Skip to content

Instantly share code, notes, and snippets.

@waynemoore
waynemoore / humanised_time_to_date.js
Last active January 1, 2016 14:39
Change GitHub humanised times to actual relative dates
$('time').each(function(i, time) { var $time = $(time); $time.removeClass('js-relative-date'); $time.text($time.attr('title')); })
@waynemoore
waynemoore / month_day_range.py
Created July 27, 2011 11:01
Get first and last day of a particular month using python-dateutil.
import datetime
# requires python-dateutil (http://labix.org/python-dateutil)
from dateutil.relativedelta import relativedelta
def get_month_day_range(date):
"""
For a date 'date' returns the start and end date for the month of 'date'.
Month with 31 days:
@waynemoore
waynemoore / transpose.py
Created July 26, 2011 09:35
Transpose a matrix in Python
def transpose(matrix):
num_rows = len(matrix)
num_cols = len(matrix[0])
t_matrix = [[None for _ in range(num_rows)] for _ in range(num_cols)]
for y in range(num_rows):
for x in range(num_cols):
t_matrix[x][y] = matrix[y][x]
return t_matrix
@waynemoore
waynemoore / tweepy_get_user_status.py
Created October 27, 2010 17:17
How to query a user's status using tweepy.
import tweepy
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token_key, access_token_secret)
api = tweepy.API(auth)
user = api.get_user('twitter')
print user.status.text