Skip to content

Instantly share code, notes, and snippets.

@millerdrew
Created July 25, 2018 10:07
Show Gist options
  • Save millerdrew/c75265f5ba097781017719b5011eea09 to your computer and use it in GitHub Desktop.
Save millerdrew/c75265f5ba097781017719b5011eea09 to your computer and use it in GitHub Desktop.
#For Japanese Studies
#Get Japanese definition from jisho.org. Uses a ruby script, jishourl, to build the url and
#make sure it's encoded properly. After that curl pulls down the data and pipes it into
#nokogiri for parsing.
function jdef() {
curl -s "$(jishourl $1)" | nokogiri -e 'puts $_.at_css("span.meaning-meaning").text'
}
#Adds a new word and definition to the Firebase Realtime Database via a cloud function
alias nw='function _nw() {
def=$(jdef $1);
echo $1;
echo $def;
curl -G "https://us-central1-japanese-vocab-2d5af.cloudfunctions.net/addVocab" --data-urlencode "word=$1" --data-urlencode "meaning=$def"
};
_nw'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment