Skip to content

Instantly share code, notes, and snippets.

View geoffalday's full-sized avatar

Geoff Alday geoffalday

View GitHub Profile
@geoffalday
geoffalday / files.py
Created May 3, 2012 10:28
Get files from directory
#via http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python
import fnmatch
import os
matches = []
for root, dirnames, filenames in os.walk('src'):
for filename in fnmatch.filter(filenames, '*.c'):
matches.append(os.path.join(root, filename))
@geoffalday
geoffalday / admin.py
Created January 29, 2012 05:04
Two Methods per Alex
@app.route('/edit/<int:page_id>', methods=['GET'])
def edit(page_id):
context = "Edit"
page = Page.query.get(page_id)
title = page.title
text = page.text
return render_template('edit.html', title=title, text=text, context=context)
@app.route('/edit/<int:page_id>', methods=['POST'])
@geoffalday
geoffalday / get_sentiment.rb
Created November 1, 2011 14:09
Ruby function for accessing the Viralheat sentiment API
require 'rubygems'
require 'sentiment_analysis'
def get_sentiment(text)
sa = SentimentAnalysis::Client.new(:api_key => 'YOUR_API_KEY')
sentiment = sa.review(:text => text, :format => :json)
# The limit on the text is 360 characters.
return sentiment
end
@geoffalday
geoffalday / gist:1322089
Created October 28, 2011 11:22 — forked from trvsdnn/gist:1321710
twitter_link
def twitter_link(handle)
avatars_path = 'public/img/avatars/'
avatar = handle + '.jpg'
avatar_path = avatars_path + avatar
img_tag = "<img src='#{avatar_path.sub(/^public/, '')}' />"
# Check and see if there's already an avatar.
unless File.exists?(avatar_path)
# We don't have it. Let's try to get it from Twitter.
begin
@geoffalday
geoffalday / words.txt
Last active August 29, 2015 14:00
Words that should be used more often.
aluminium
kerfuffle
shenanigans
@geoffalday
geoffalday / geoff.txt
Created April 29, 2014 15:12
A few ways my name has been pronounced.
gee-off
geff
goff
george
jiff
joff
greg
{
"ignored_packages":
[
"Vintage"
],
"trim_trailing_white_space_on_save": true,
"tab_size": 4,
"translate_tabs_to_spaces": true,
"detect_indentation": false,
"use_tab_stops": true