Giter Club home page Giter Club logo

Comments (6)

globalcitizen avatar globalcitizen commented on May 26, 2024 1

Yes, it's not fast. However, it's not a problem for me. Your approach is a good one. If you would like to contribute an optimized portable shell script with this approach and create a pull request I can assign you credit in the git history.

from taoup.

globalcitizen avatar globalcitizen commented on May 26, 2024 1

Implemented. You can rm .taoup-fortune.* in your script after updating to remove old files. Automatic cache regeneration will occur regardless, you will have one more harmless cachefile per update unless explicitly cleared. I don't like implementing automatic rm ${anything} in bash, for safety.

Update also removes OSX portable random sort unless required, which should save some further execution time.

from taoup.

globalcitizen avatar globalcitizen commented on May 26, 2024 1

Added shuf.

from taoup.

globalcitizen avatar globalcitizen commented on May 26, 2024

@ronjouch OK here's an idea. The existing taoup-fortune script runs md5sum or md5 (as available; the latter being normal on OSX) on the taoup file. A filename is generated, .taoup.cache.<hash>. If the file does not exist, it is generated by storing the output of taoup. The file is then read as if it is the output of the program.

from taoup.

ronjouch avatar ronjouch commented on May 26, 2024

@ronjouch OK here's an idea. The existing taoup-fortune script runs md5sum or md5 (as available; the latter being normal on OSX) on the taoup file. A filename is generated, .taoup.cache.<hash>. If the file does not exist, it is generated by storing the output of taoup. The file is then read as if it is the output of the program.

@globalcitizen that would work, but I already have tooling around updating git repos (such as taoup) and post-actions, so for my current "on-the-side" solution is even better for me, as it happens only once every repo update. Here's what it looks like:

# update taoup to latest master. post-update:cache it
git-update master 'https://github.com/globalcitizen/taoup.git' /opt/taoup "./taoup | grep -v '^---' > taoup.txt"

One nit regarding your solution: one file per hash would lead to polluting the folder with tons of .taoup.cache.<hash> files. It seems more reasonable to output hash to a file (.taoup.cache), and contents to another file (taoup.md5sum). Then the script can compare md5 to cat .taoup.md5sum, and overwrite .taoup.cache if necessary.

from taoup.

ronjouch avatar ronjouch commented on May 26, 2024

@globalcitizen cool! Thanks for listening! 🙂

from taoup.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.