Skip to content

Instantly share code, notes, and snippets.

@thinkjson
thinkjson / sprintly.py
Created November 2, 2012 17:01
Open sprint.ly tickets from Python
import urllib2
import base64
from urllib import urlencode
SPRINTLY_USERNAME = ''
SPRINTLY_API_KEY = ''
SPRINTLY_PROJECT = ''
class Sprintly():
@thinkjson
thinkjson / gist:4005033
Created November 2, 2012 23:35
AccessTokenRefreshError stack trace
File "data_api/bigquery.py", line 33, in authenticate
self.service = build('bigquery', 'v2', http=self.http)
File "oauth2client/util.py", line 120, in positional_wrapper
return wrapped(*args, **kwargs)
File "apiclient/discovery.py", line 193, in build
resp, content = http.request(requested_url)
File "oauth2client/util.py", line 120, in positional_wrapper
return wrapped(*args, **kwargs)
File "oauth2client/client.py", line 405, in new_request
self._refresh(request_orig)
@thinkjson
thinkjson / time_dimension.py
Created December 6, 2012 20:22
Generate time dimension table
"""
Invocation: python time_dimension.py [start_date] [end_date]
"""
from datetime import datetime, timedelta
import sys
start_date = datetime.strptime(sys.argv[1], '%Y-%m-%d')
end_date = datetime.strptime(sys.argv[2], '%Y-%m-%d')
@thinkjson
thinkjson / gist:4659461
Created January 28, 2013 21:52
Unicode in Python
Last login: Mon Jan 28 12:42:42 on ttys002
Mark-Cahill:~ mark.cahill$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> a = u'B\u2056blia'
>>> a
u'B\u2056blia'
>>> print a
B⁖blia
import requests # `pip install requests`; DO IT!
import time
import sys
class ComfortSweet:
LAST_ATTEMPT = 0
def main(self):
@thinkjson
thinkjson / gist:5105273
Created March 7, 2013 03:03
Pasta with meat sauce
This is one of our favorites, takes very little time to prepare, and is very easy. Who doesn't like a good meat sauce, right?
1 large can tomato sauce
1 large can crushed tomatoes
1 small can tomato paste
1 onion, diced
1/4 cup red wine
1 tablespoon minced garlic
1lb ground turkey
1lb pasta
@thinkjson
thinkjson / countries.csv
Last active December 14, 2015 21:29
countries
AD AND Andorra
AE ARE United arab emirates
AF AFG Afghanistan
AG ATG Antigua and barbuda
AI AIA Anguilla
AL ALB Albania
AM ARM Armenia
AN ANT Netherlands Antilles
AO AGO Angola
AQ ATA Antarctica
import requests # `pip install requests`; DO IT!
import time
import sys
class ComfortSweet:
LAST_ATTEMPT = 0
def main(self):
@thinkjson
thinkjson / instance_running.py
Last active December 17, 2015 15:59
Notify when instance is running
import sys
import subprocess
import requests
import time
""" Notify when instance is running
Invocation:
python instance_running.py [hostname]
"""
@thinkjson
thinkjson / bible-tweet-bookmarklet
Last active December 22, 2015 19:09
Create a new bookmark with the content below as the url to attempt to autolink Bible references in Tweets
javascript:$('.tweet-text').each(function(i, item) { $(this).html($(this).html().replace(/(\w+) \d+\:\d+/g, '<a href="https://www.bible.com/search?q=$&">$&</a>')); });