Comments (6)
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.
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.
Added shuf
.
from taoup.
@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 OK here's an idea. The existing
taoup-fortune
script runsmd5sum
ormd5
(as available; the latter being normal on OSX) on thetaoup
file. A filename is generated,.taoup.cache.<hash>
. If the file does not exist, it is generated by storing the output oftaoup
. 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.
@globalcitizen cool! Thanks for listening!
from taoup.
Related Issues (9)
- Encoding flag needed? HOT 1
- ./taoup-fortune HOT 6
- requires gem install HOT 1
- License clarification HOT 5
- Implementing mac build over Homebrew HOT 2
- There's no way to output just 1 random categorized quote HOT 4
- Add a flag for different colors HOT 4
- Fake news: Electrical engineer's motto? Possibly missing: Resistor color codes. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from taoup.