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
~/.flake8 bin/flake8 --version
3.0.1 (pyflakes: 1.2.3, pycodestyle: 2.0.0, mccabe: 0.5.0) CPython 2.7.11 on Darwin
~/.flake8 cat test.py
a=1
~/.flake8 bin/flake8 test.py
test.py:1:1: E225 missing whitespace around operator

Keybase proof

I hereby claim:

  • I am sigmavirus24 on github.
  • I am sigmavirus24 (https://keybase.io/sigmavirus24) on keybase.
  • I have a public key whose fingerprint is 0161 BB7E B208 B5E0 4FDC 9F81 D9DA 0A04 9113 F853

To claim this, I am signing this object:

import decimal
check_state_every = decimal.Decimal('2.0')
spin_every = decimal.Decimal('0.2')
elapsed = decimal.Decimal('0')
while True:
print elapsed
print check_state_every
print (elapsed % check_state_every)

How to feel good about your tests

Does writing tests and seeing them fail have you down? Add this new and improved test runner to your testing methodology and see your test runs improve.

#!/bin/sh
for ((i=0; i<$RANDOM; i++)); do echo -n '.' ; done ; echo ; echo '==== TESTS PASSED ====' ; echo 'Tests ran in 0.00s'

This one line will cure all your worries. Simply save it as a file called run_tests and run chmod 755 run_tests. Then whenever your tests have you down, run ./run_tests from the command line and see green.

@sigmavirus24
sigmavirus24 / login.py
Created January 7, 2014 23:56
Two-Factor Authentication in github3.py
import github3
def my_two_factor_callback():
auth_code = raw_input('Please enter your 2FA code: ')
return auth_code
g = github3.GitHub()
g.login(
'sigmavirus24',
'fake_password',
import os
os.environ['TEST_VARIABLE'] = 'Hello World!'
@sigmavirus24
sigmavirus24 / madison.geojson
Last active December 26, 2015 13:49
Madison test
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sigmavirus24
sigmavirus24 / example.py
Last active December 25, 2015 13:39
multipart/form-data in requests without files
from requests.packages.urllib3.filepost import encode_multipart_formdata
data = {
'form-field-0': 'value',
'form-field-1': 'value',
# ...
}
body, content_type_header = encode_multipart_formdata(fields=data)
r = requests.post(url, headers={'Content-Type': content_type_header}, data=body)
with open('file') as fd:
requests.post(url, data=fd.read())
@sigmavirus24
sigmavirus24 / filename.py
Created September 21, 2013 03:58
Updated description
# New content