Skip to content

Instantly share code, notes, and snippets.

View val314159's full-sized avatar

val314159 val314159

View GitHub Profile
@val314159
val314159 / test_gist.py
Created March 23, 2015 21:26
test gist
print "this is a gist meant to test python API calls for comments"
@val314159
val314159 / test_twitter.py
Last active August 29, 2015 14:17
test_twitter.py
#!/usr/bin/env python
requirements_txt'''
oauth==1.0.1
oauthlib==0.7.2
requests==2.6.0
requests-oauthlib==0.4.2
'''
import os,sys,json,requests
#import twitter
from pprint import pprint
@val314159
val314159 / utils57.py
Created March 30, 2015 18:29
Utilities 57
import os
class untrue(object):
"""
new type of object to comunicate untruth
"""
def __nonzero__(_): return False
pass
def force(thunk):
"""
if you pass this a thunk, it will evaluate it and eat the errors.
@val314159
val314159 / ssl_patch.py
Created April 17, 2015 15:53
SSL Patch to make ssl work with popular packages again
# Re-add sslwrap to Python 2.7.9
import inspect
__ssl__ = __import__('ssl')
try:
_ssl = __ssl__._ssl
except AttributeError:
_ssl = __ssl__._ssl2
pass
@val314159
val314159 / jobq.py
Created May 12, 2015 16:42
gevent job queue
import traceback as tb, gevent
from concurrent.futures import Future
in_flight = [0]
in_flight_max = 100
Q = []
def spawn_query(fn,future,*a,**kw):
def wrapper():
try:
@val314159
val314159 / Dockerfile
Last active August 29, 2015 14:21
raml-python dockerfile
#!/usr/bin/env docker build -f
FROM ubuntu
MAINTAINER Joel Ward <jmward@gmail.com>
RUN apt-get -y -qq install python wget git
RUN cd /opt && \
wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz && \
tar -xvf node-v0.10.28-linux-x64.tar.gz && \
mv node-v0.10.28-linux-x64 node && \
cd /usr/local/bin && \
ln -s /opt/node/bin/* . && \
alias ll='ls -la'
alias run='dock run'
alias build='dock build .'
alias build2='dock build2'
# OSX (Darwin) only
if [ "`uname`" == "Darwin" ]; then
$(boot2docker shellinit 2>/dev/null)
fi
@val314159
val314159 / iyaml.py
Last active August 29, 2015 14:21
iYAML: yaml + include
"""
pip install pyaml
--
import sys,yaml
yaml.load(open(sys.argv[1]))
"""
import os.path,yaml
from yaml import *
root = os.path.curdir
def include(loader, node):
@val314159
val314159 / jj3.py
Last active August 29, 2015 14:21
jj3
import sys,jinja2,yamli
def main( tmpl_text, data_text ):
data = yamli.load( data_text )
tmpl = jinja2.Template( tmpl_text ).
f_out.write( tmpl.render( ** data ) )
if __name__=='__main__': main( *sys.argv )
@val314159
val314159 / test_login.py
Created June 17, 2015 16:42
test_login.py
#!/usr/bin/env python
import os, sys, requests
Hostname = sys.argv[1]
Username = sys.argv[2]
Password = sys.argv[3]
AppToken = 'U3dlcUFOQWdFVkVoVWt1cGVjcmVrYXN0ZXFhVGVXckFTV2E1dXN3MzpXMnZBV3JlY2hhUHJlZGFoVVJhZ1VYYWZyQW5hbWVqdQ=='