This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # When you are working on your macbook sitting in cafe and you have to go pee, | |
| # you need some way to guard you machine. | |
| # | |
| # Start this script, remove any earphones, and go do the job. | |
| # The assumption is the thief will close the lid of the laptop before taking it away. | |
| # This script detects the closing of the lid and plays some loud audio that will | |
| # likely distract the thief and/or grab attention of nearby people, making the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x <- 1:50 | |
| case_when( | |
| x %% 35 == 0 ~ "fizz buzz", | |
| x %% 5 == 0 ~ "fizz", | |
| x %% 7 == 0 ~ "buzz", | |
| TRUE ~ as.character(x) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BookGen | |
| URL = 'http://betterexplained.com/calculus/lesson-' | |
| EBOOK = 'calculus_better_explained.epub' | |
| def gen_book | |
| gen_original | |
| gen_edited | |
| gen_epub | |
| gen_kindle | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl ipinfo.io |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://superuser.com/questions/556029/how-do-i-convert-a-video-to-gif-using-ffmpeg-with-reasonable-quality | |
| # http://blog.pkh.me/p/21-high-quality-gif-with-ffmpeg.html | |
| m2g() { | |
| movie=$1 | |
| filters="fps=15,scale=$2:-1:flags=lanczos" | |
| palette="/tmp/palette.png" | |
| dtop="/Users/blah/Desktop" | |
| ffmpeg -v warning -i $movie -vf "$filters,palettegen" -y $palette | |
| ffmpeg -v warning -i $movie -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y "$dtop/$movie.gif" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '.source.gfm': | |
| 'Email item': | |
| 'prefix': 'email' | |
| 'body': '### $1. [$2][$3]\n_<strong>$4</strong>_\n\n$5\n\n[$3]:$6\n\n***\n$7' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # get multiple quantmod returns | |
| require(quantmod) | |
| require(PerformanceAnalytics) | |
| symbols <- c("CNSAX", "FAHDX", "VUSTX", "VFISX", "PREMX") | |
| getSymbols(symbols, from='1900-01-01') | |
| prices <- list() | |
| for(symbol in symbols) { | |
| prices[[symbol]] <- Ad(get(symbol)) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://allthingsr.blogspot.com.au/2012/10/pull-yahoo-finance-key-statistics.html | |
| metrics <- yahooQF(c('Price/Sales', 'P/E Ratio', 'Market Capitalization')) | |
| tickers <- c('FB', 'TWTR') | |
| q <- getQuote(paste(tickers, sep='', collapse=';'),what=metrics) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://www.smashingmagazine.com/2015/06/25/efficient-image-resizing-with-imagemagick/ | |
| resizeimage() { | |
| # smartresize inputfile.png 300 outputdir/ | |
| # smartresize inputfile image_size outputdir | |
| mogrify -path $3 -filter Triangle -define filter:support=2 -thumbnail $2 -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 82 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB $1 | |
| } |