Skip to content

Instantly share code, notes, and snippets.

@danielbraun
Last active April 17, 2020 16:08
Show Gist options
  • Save danielbraun/e1534ce5da56894c4fce15a16016059b to your computer and use it in GitHub Desktop.
Save danielbraun/e1534ce5da56894c4fce15a16016059b to your computer and use it in GitHub Desktop.
My magic makefile to make everything happen
all:
%.min.js: %.js
uglifyjs < $< > $@
%.xml: %.edn
edn2xml < $< > $@
%.bundle.js: %.js
browserify $< > $@
%.tab: %.mysql.sql
mysql --defaults-extra-file=my.cnf < $< > $@
%.xml: %.html
xsltproc --html $*.xsl $< -o $@
%.txt: %.pdf
pdftotext - - < $< > $@
%.info.txt: %.pdf
pdfinfo $< > $@
%.pdf: %.svg
cairosvg $< -o $@
%.out: %.curl
curl -K $< > $@
%.dividends.csv:
curl "https://query1.finance.yahoo.com/v7/finance/download/$(shell basename $*)?period1=0&period2=$(shell date +%s)&interval=1d&events=div" > $@
%.sorted.csv: %.csv
csvsort < $< > $@
%/stocks.nyse.min.json:
curl 'https://www.nyse.com/api/quotes/filter' \
-XPOST \
-H 'Content-Type: application/json' \
--data-binary '{"instrumentType":"EQUITY","pageNumber":1,"maxResultsPerPage":100000}' > $@
%/dividends: %/stock_symbols.nyse.csv.tail
mkdir -p $@
cat $< | xargs printf "$@/%s.dividends.sorted.csv\n" | xargs $(MAKE)
%/stock_symbols.nyse.csv: %/stocks.nyse.csv
cat $< | csvcut -c symbolTicker > $@
%.tail: %
tail -n +2 < $< > $@
%.csv: %.json
json2csv < $< > $@
%.table.txt: %.csv
csvlook $@ > $@
%.json: %.min.json
jq < $< > $@
%.min.json: %.csv
csvjson < $< > $@
%.out.edn: %.edn
%.xml: %.php
php < $< > $@
%.svg: %.csv
gnuplot -e "set key autotitle columnhead; set datafile separator ','; set terminal svg enhanced mouse jsdir 'http://gnuplot.sourceforge.net/demo_svg_5.2'; plot '$<';" > $@
http://gnuplot.sourceforge.net/demo_svg_5.2/gnuplot_svg.js
%.instagram.jpg:
curl -L "https://www.instagram.com/p/$(shell basename $*)/media?size=l" > $@
# Sign in doesn't work
%.album.html:
printf "<iframe \
src='https://embed.music.apple.com/us/album/$(shell basename $*)' \
height='100%%' \
frameborder='0' \
allow='autoplay *; encrypted-media *;' \
sandbox='allow-forms allow-popups allow-same-origin allow-scripts allow-storage-access-by-user-activation allow-top-navigation-by-user-activation' \
width='100%%' \
></iframe>" > $@
yad2/rentals/%.json:
@mkdir -p `dirname $@`
@res="$(shell curl 'https://www.yad2.co.il/api/pre-load/getFeedIndex/realestate/rent?page=$*' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/$*.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15' \
-f \
-L \
-s \
-w %{url_effective} \
-o $@)" \
; file --mime $@ | grep "text/html" \
&& echo "Error: Verification required" \
&& rm $@ && open $$res\
&& exit 1 \
|| exit 0
domains/%:
mkdir -p $(shell dirname $@)
whois $* > $@
nslookup $* >> $@
server:
shell2http -cgi / 'export FILE=.`echo $$REQUEST_URI | sed "s/?.*//"` && make -s $$FILE && cat $$FILE'
.PHONY: %/dividends *.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment