Skip to content

Instantly share code, notes, and snippets.

@hmason
hmason / fetch_locu_data.py
Last active July 29, 2023 19:21
A quick script to fetch data from the locu api by query and zip code.
import sys
import os
import json
import csv
import time
import pickle
import requests
API_KEY = [YOUR API KEY GOES HERE]
@hmason
hmason / gist:4254104
Created December 10, 2012 22:57
whois spam?
$ whois facebook.com
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
FACEBOOK.COM.ZZZZZ.GET.LAID.AT.WWW.SWINGINGCOMMUNITY.COM
FACEBOOK.COM.MORE.INFO.AT.WWW.BEYONDWHOIS.COM
@hmason
hmason / test.sh
Created August 21, 2012 22:01
Did you know that bash will reload a script *while it is executing*?!
#!/bin/bash
function addnext {
NUM=$1
sleep 1
echo HI $NUM
NUM=$(expr $NUM + 1)
echo addnext $NUM >> $0
}
import sys, os
import json
if __name__ == '__main__':
f = open("formatted_tweets.json")
data = f.read()
f.close()
tweets = json.loads(data)
import sys, os
import urllib, urllib2
import json
def main(query, api_key):
h = urllib.urlopen("http://api.nytimes.com/svc/search/v1/article?%s" % (urllib.urlencode({'api-key': api_key, 'query': query})))
return json.loads(h.read())
if __name__ == '__main__':
print main("title:data","f7b4a1749764aec0364b215c354e3a0f:18:25759498")
curl 'http://api.nytimes.com/svc/search/v1/article?query=justin%20beiber&api-key=f7b4a1749764aec0364b215c354e3a0f:18:25759498'
Bitly tech talk 4/22/2010
On 4/22 we held a bit.ly tech talk on 'Command Line Fu', where we invited talented hackers to come share their best moves. Please correct my notes and add your fu here!
# @jehiah
# in place file regex replacement
perl -pi -e 's/this/that/g' filename_pattern
# print the last column of a file ($NF stands for 'Number of Fields' or more commonly Last Field).
Bitly tech talk 4/22/2010
On 4/22 we held a bit.ly tech talk on 'Command Line Fu', where we invited talented hackers to come share their best moves. Please correct my notes and add your fu here!
# jehiah
# in place file regex replacement
perl -pi -e 's/this/that/g' filename_pattern
# print the last column