Skip to content

Instantly share code, notes, and snippets.

View sigmavirus24's full-sized avatar
🌴
Taking a break from F/OSS indefinitely

Ian Stapleton Cordasco sigmavirus24

🌴
Taking a break from F/OSS indefinitely
View GitHub Profile
@sigmavirus24
sigmavirus24 / gcd.py
Created May 9, 2012 19:12
Studying Fun
def gcd(a, b):
if a < b:
(a, b) = b, a
print euclidean_algorithm(a, b)
def euclidean_algorithm(a, b):
r = a % b
if r:
return euclidean_algorithm(b, r)
return b
@sigmavirus24
sigmavirus24 / example.py
Created July 16, 2012 15:51
Example for #python
from requests import session
class requires_auth(object):
def __init__(self, func):
self.func = func
def __call__(self, *args, **kwargs):
return self.func(*args, **kwargs)
@sigmavirus24
sigmavirus24 / example.py
Created July 16, 2012 16:07
Example for #python
from requests import session
def requires_auth(method):
def wrapper(self, *args, **kwargs):
# check for auth params
if hasattr(self, 'auth_information'):
return method(self, *args, **kwargs)
else:
raise AuthRequiredException
@sigmavirus24
sigmavirus24 / argv_pt1.py
Created July 21, 2012 17:26
Example for ninjax1 (DO NOT UPDATE FURTHER. USED TO TEST GITHUB3.PY)
#!/usr/bin/env python
import sys
' '.join(sys.argv)
@sigmavirus24
sigmavirus24 / test.py
Created August 22, 2012 15:11
Test for kennethreitz/requests#804
from requests import Session
class Test(Session):
def __init__(self):
super(Test, self).__init__(params={'alt': 'json'})
self.get_url = 'http://httpbin.org/get'
t = Test()
r1 = t.get(t.get_url)
bar
@sigmavirus24
sigmavirus24 / gist:3623733
Created September 4, 2012 17:20
Testing github3.py edit
bar
@sigmavirus24
sigmavirus24 / pr.md
Created September 13, 2012 14:52 — forked from kennethreitz/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

class A:
def __init__(self):
self._x = 1
class B(A):
def __init__(self):
self._y = 2
@sigmavirus24
sigmavirus24 / recipe.py
Created October 1, 2012 19:23
List of places to replace list functions with iter functions
github3/api.py:45:def list_gists(username=None):
github3/api.py:55:def list_followers(username):
github3/api.py:64:def list_following(username):
github3/api.py:72:def list_repo_issues(owner, repository, filter='', state='', l
abels='',
github3/api.py:82:def list_orgs(username):
github3/api.py:90:def list_repos(login, type='', sort='', direction=''):
github3/api.py:118:def list_events():
github3/github.py:318: def list_authorizations(self):