Skip to content

Instantly share code, notes, and snippets.

View matthewhughes's full-sized avatar

Matthew Hughes matthewhughes

View GitHub Profile
@matthewhughes
matthewhughes / MillisDelay.c
Created July 30, 2015 14:16
Millis Delay Example
const int ledPin = 13;
int ledState = LOW;
long previousTime = 0;
long interval = 1000;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop()
import pyhk
def newCard():
pass
if __name__ = '__main__':
hotkey = pyhk.pyhk()
hotkey.addHotKey(['ctrl', 's'], newCard)
hot.start()

Keybase proof

I hereby claim:

  • I am matthewhughes on github.
  • I am matthewhughes (https://keybase.io/matthewhughes) on keybase.
  • I have a public key whose fingerprint is EE2F 19EC E213 27AA C0CC EDEF F97A 1E5B C138 8764

To claim this, I am signing this object:

@matthewhughes
matthewhughes / Plurk Scraper 3
Created July 8, 2013 10:55
Plurk Scraper 3
def search_plurk(argument):
plurks = plurk.callAPI('/APP/PlurkSearch/search', {'query' : argument})
rows = []
for p in plurks["plurks"]:
row = OrderedDict()
row['Plurk_ID'] = p["plurk_id"]
row['Owner_ID'] = p["owner_id"]
row['Verb'] = p["qualifier"]
row['Content'] = p["content"]
rows.append(row)
@matthewhughes
matthewhughes / Plurk Scraper 2
Created July 8, 2013 10:52
Plurk Scraper 2
def main():
try:
if len(sys.argv) != 2:
raise InvalidArgumentError("Please supply a single argument. An example would be 'kittens'")
else:
search_plurk(argument)
except Exception, e:
scraperwiki.status('error', type(e).__name__)
print json.dumps({
@matthewhughes
matthewhughes / Plurk Scraper 1
Created July 8, 2013 10:48
First part of plurk scraper
from plurk_oauth.PlurkAPI import PlurkAPI
from collections import OrderedDict
import traceback
import scraperwiki
import sys
import json
api_key = "REDACTED"
api_secret = "REDACTED"
def submit_to_scraperwiki(identity, title, latitude, longitude, url):
result = {"id" : identity, "title" : title, "latitude" : latitude, "longitude" : longitude, "url" : url}
scraperwiki.sqlite.save(UNIQUE_KEYS, result, 'kittens')
def main():
favs = flickr.walk(tags="kittens", extras="geo")
for photo in favs:
if photo.get('latitude') != '0':
title = photo.get('title')
latitude = float(photo.get('latitude'))
longitude = float(photo.get('longitude'))
url = shorturl.url(photo.get('id'))
identity = photo.get('id')
submit_to_scraperwiki(identity, title, latitude, longitude, url)
if __name__ == '__main__':
main()
from flickrapi import FlickrAPI, shorturl
import scraperwiki
API_KEY = "REDACTED"
flickr = FlickrAPI(API_KEY)