Giter Club home page Giter Club logo

taoup's Issues

Fake news: Electrical engineer's motto? Possibly missing: Resistor color codes.

So I was doing some research into this particular message, and I have a few concerns:

taoup/taoup

Line 1307 in 40f7a68

puts white{ bold{ "Motto of the Electrical Engineer" } } + white{ ": Working hardware is a lot like an erect penis; it stays up as long as you don't fuck with it." }

  1. Is this fake news?

I couldn't find any groups of electrical engineers that advertised this as their motto. From what I understand, this isn't actually a motto at all, but just a really mediocre old joke from list servs.

  1. Are we not doing enough?

Engineering has plenty of inappropriate acronyms and jokes. Should we add resistor color codes as well? I can prepare a pr for that if you like.

  1. Is the motto even reasonable?

Are you supposed to consult your doctor if your computer works for longer than four hours? Asking for a friend.

./taoup-fortune

Hi

./taoup-fortune triggers an error on Mac OSX with ZSH

sort: invalid option -- R
Try `sort --help' for more information.

Release numbers mismatch?

Hi, thanks again for this great software! 🎉

I noticed that the latest Release is about taoup-1.1.21, but the versioned tag is v1.21 - which should be the correct number? I found this while packaging the update for Nixpkgs...

Taoup runs slow

I like to run taoup at shell startup.

But after a pass of cleanup/optimization, I ended up removing it, after noticing it takes a big chunk of my shell's startup time:

[ronj@t ~]$ time taoup-fortune
< Law of Communications: The inevitable result of improved and enlarged communications between different levels in a hierarchy is a vastly increased area of misunderstanding. >

real    0m0,305s
user    0m0,237s
sys     0m0,119s

For me on a recent laptop with ruby 2.6.3p62, it takes between 0.2 and 0.4s, which is a noticeable delay, especially given the small task it accomplishes.

  1. Does the number match your experience?
  2. Any suggestions to speed this up with the current Ruby implementation? (I know Python is quite fast to boot, but I don't know Ruby at all, is its boot time a big part of taoup's execution time?)
  3. Would a pure POSIX shell rewrite make sense?

Anyway, thanks for the collection and frequent additions 🙂.


EDIT workaround: why always calling ruby at each call when you can simply dumping the fortunes to a static cache and shuffle that:

After git clone,

./taoup | grep -v '^---' > taoup.txt

Then taoup-fortune can be as simple as a call to unix shuf:

#!/usr/bin/env sh
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
shuf -n 1 "$dir/taoup.txt"

Add a flag for different colors

Can we help out users of non-dark terminals by adding a flag to use different colors? I wanna read but it hurts my eyes to do so:D

shuf never used in taoup-fortune

when i checked whether shuf was installed on my machine with type shuf or which shuf, both of them confirmed that shuf is /usr/bin/shuf.

but as this log below showed what i observed as i executed bash -x taoup-fortune 2>&1, the program seemed to assume that shuf was unavailable.

++ dirname taoup-fortune
+ dir=.
++ which md5sum
+ '[' /usr/bin/md5sum ']'
++ md5sum ./taoup
++ cut -d ' ' -f1
+ MD5SUM=260d2085d6fdc421c1faf9505dcf2898
+ cachefile=./.taoup-fortune.cache.260d2085d6fdc421c1faf9505dcf2898
+ '[' '!' -r ./.taoup-fortune.cache.260d2085d6fdc421c1faf9505dcf2898 ']'
++ which cowsay
+ '[' /usr/bin/cowsay ']'
++ shuf -e
+ '[' ']'
++ echo test
++ sort -R
+ '[' test ']'
+ cat ./.taoup-fortune.cache.260d2085d6fdc421c1faf9505dcf2898
+ grep -v '^---'
+ sort -R
+ head -n 1
+ cowsay -f eyes -n
+ head -n 2
+ tail -n 1
< �[37mBetween Plan 9 and Erlang we missed a bus somewhere.�[0m�[30m�[1m - @jacquesm�[0m�[0m >
+ echo ''
+ cowsay -f eyes
+ tail -n 10
+ sed 's/^/�[0;32;40m/'
�[0;32;40m     \
�[0;32;40m                                   .::!!!!!!!:.
�[0;32;40m  .!!!!!:.                        .:!!!!!!!!!!!!
�[0;32;40m  ~~~~!!!!!!.                 .:!!!!!!!!!UWWW$$$ 
�[0;32;40m      :$$NWX!!:           .:!!!!!!XUWW$$$$$$$$$P 
�[0;32;40m      $$$$$##WX!:      .<!!!!UW$$$$"  $$$$$$$$# 
�[0;32;40m      $$$$$  $$$UX   :!!UW$$$$$$$$$   4$$$$$* 
�[0;32;40m      ^$$$B  $$$$\     $$$$$$$$$$$$   d$$R" 
�[0;32;40m        "*$bd$$$$      '*$$$$$$$$$$$o+#" 
�[0;32;40m             """"          """"""" 
+ echo '�(B�[m'
�(B�[m

apparently the test for shuf's functionality in the program is by testing whether shuf -e 2>/dev/null doesn't return a null string, which it would as no strings or files were passed into the command.

even if the test was to verify whether -e was a valid option for the machine's shuf, that would be redundant as -e was implemented in the first public version of shuf, per the git history of the program in coreutils.

a solution could be to adapt the test for cowsay's existence to shuf, such as which shuf 2>/dev/null.

License clarification

Hi, thanks for this excellent piece of software! 🎉

I just want to ask for clarification WRT GPL3 licensing - is this going to use GPL3 only, or GPL3 or any later version? I ask because I'm packaging this for Nix, see NixOS/nixpkgs#136751, and even when checking the taoup script itself I didn't find the recommended notice to guide me to knowing under what GPL3 license this software is under.

Thanks in advance!

requires gem install

gem install ansi

You can puts this in a bundle file or have the taoup check for it's existence and install it

begin
  gem "ansi"
rescue Gem::LoadError
  `gem install ansi`
end

Encoding flag needed?

Hi,

as far as I can tell, a comment indicating that the script is in utf-8 is needed:
$ ruby --version
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
$ ./taoup > /dev/null
./taoup:313: invalid multibyte char (US-ASCII)
./taoup:313: invalid multibyte char (US-ASCII)
./taoup:313: syntax error, unexpected $end, expecting '}'
...d{ " - Douglas Hofstadter, 'Gödel, Escher, Bach: An Eternal...
...
$ git diff
diff --git a/taoup b/taoup
index 4b20c0d..ac3cdc0 100755
--- a/taoup
+++ b/taoup
@@ -1,4 +1,5 @@
#!/usr/bin/ruby
+# encoding: utf-8

require 'ansi/code'

$ ./taoup > /dev/null

(No error output)

FYI, my locale settings:

$ locale
LANG=en_GB.UTF-8
LANGUAGE=
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

There's no way to output just 1 random categorized quote

So I wrote a bash function (or is it awk, really?) to do so:

just_one_taoup() {
  # ChatGPT4 wrote 99% of this. I preserved the conversation with it about it: https://gist.github.com/pmarreck/339fb955a74caed692b439038c9c1c9d
  needs taoup please install taoup: https://github.com/globalcitizen/taoup && \
  taoup | awk -v seed=`date +%N` 'BEGIN{srand(seed)} /^-{3,}/{header=$0; next} !/^$/{lines[count++]=$0; headers[count-1]=header} END{randIndex=int(rand()*count); print headers[randIndex]; print lines[randIndex]}'
}

(my needs dependency-check function, for anyone curious:)

needs() {
  local bin=$1;
  shift;
  command -v $bin > /dev/null 2>&1 || {
    echo "I require $bin but it's not installed or in PATH; $*" 1>&2;
    return 1
  }
}

It would be nice if this was built-in, though. Instead of outputting immediately with puts, you could assemble all the quote data into an array (including headers), count the number of quotes (excluding headers), pick a random number between 0 and (that count - 1), find that quote through iteration (skipping headers but noting the last one seen), and then output the last header seen and the quote.

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.