Skip to content

Instantly share code, notes, and snippets.

@pbyrne
pbyrne / daredevil.markdown
Created June 5, 2015 00:03
Notes for Daredevil episode of Some Fine TV
@pbyrne
pbyrne / gist:bd4e811123be0803f9e7
Last active February 25, 2016 20:41
A recent gnarly bit of Bash I built up over a few minutes until it did what I needed. I was specifically looking to see which, if any, jobs posted to our job board weren't working, since someone reported that they'd clicked a link and it took them to a broken page, but neglected to tell me which posting it was.
# oneliner
for link in $(curl https://dribbble.com/jobs.rss | grep link | cut -d'>' -f2 | cut -d'<' -f1); do echo $link; curl -I --location $link | grep -E '(Location|HTTP)' | cut -d' ' -f2; echo "--------------------"; done
# expanded
for link in $(curl https://dribbble.com/jobs.rss | grep link | cut -d'>' -f2 | cut -d'<' -f1); # cut the URL out of "<link>http://example.com</link>" from our jobs RSS feed
do echo $link # print it
curl -I --location $link | grep -E '(Location|HTTP)' | cut -d' ' -f2 # get the URL, follow any redirects, and print out each redirect and the ending HTTP status code
echo "--------------------"
done

Bash

ar1=(1); ar2=(1); [ $ar1 = $ar2 ] && echo true || echo false
true

Python