Skip to content

Instantly share code, notes, and snippets.

View val314159's full-sized avatar

val314159 val314159

View GitHub Profile
import requests
r=requests.get('https://127.0.0.1:8332',verify=False,data='{"jsonrpc":"1.0","id":"%s","method":"getinfo","params":[]}' % str(uuid1()),auth=('bitcoinrpc','password9'))
print r.content
import os
from staching import Stache
class Stache2(Stache):
def add_template_file(s, name,prefix):
s.add_template(name, ''.join(open(prefix+name).xreadlines()))
def load_templates(s, prefix):
[ s.add_template_file(fn,prefix) for fn in os.listdir(prefix) ]
if __name__=='__main__':
'''
small util lib for cors handling (in bottle)
'''
def add_headers(response):
'''
call this to slap the proper CORS headers into any dict-like object
'''
#allow_methods = ', '.join(['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'OPTIONS'])
allow_methods = ', '.join(['GET', 'HEAD', 'POST', 'OPTIONS'])
allow_headers = ', '.join(['Origin', 'X-Requested-With', 'Content-Type',
@val314159
val314159 / i.sh
Last active August 29, 2015 14:06
i.sh
cat > env.sh <<"""
""";. env.sh
@val314159
val314159 / install.sh
Last active August 29, 2015 14:06
authsvr.py
PYTHONPATH=`pwd`
export PYTHONPATH
git clone https://github.com/FedericoCeratto/bottle-cork.git
git clone https://gist.github.com/d448af5cc4111bc5de2d.git
ln -s d448af5cc4111bc5de2d/cors.py
cp -r bottle-cork/examples authsvr
cp -r authsvr/example_conf authsvr/conf.auth
if [ -e v ]; then ( echo "exists, skipping" ) else ( virtualenv .v ) fi
cat >env.sh<<EOF
source .v/bin/activate
@val314159
val314159 / env.sh
Last active August 29, 2015 14:06
qsvr.py
source .v/bin/activate
run_qsvr () { python -u qsvr.py; }
run () { python -u qsvr.py; }
launch_qsvr () { python -u qsvr.py 1>LOG 2>&1 &}
launch () { python -u qsvr.py 1>LOG 2>&1 &}
unlaunch () { killall -9 python; }
cln () { rm -fr .? *.pyc *~ 2>/dev/null; }
$*
@val314159
val314159 / install.sh
Last active August 29, 2015 14:06
meta installer
rm -f eenv.sh
# qsvr
git clone https://gist.github.com/067edcf3039ad202c5d8.git
sh 067edcf3039ad202c5d8/install.sh
cp env.sh 067edcf3039ad202c5d8
echo source 067edcf3039ad202c5d8/env.sh >>eenv.sh
# authsvr
git clone https://gist.github.com/48217eca901c2afb29a4.git
@val314159
val314159 / websse.py
Last active August 29, 2015 14:06 — forked from werediver/websse.py
"""
Simple demonstration of how to implement Server-sent events (SSE) in Python
using Bottle micro web-framework.
SSE require asynchronous request handling, but it's tricky with WSGI. One way
to achieve that is to use gevent library as shown here.
Usage: just start the script and open http://localhost:8080/ in your browser.
Based on:
@val314159
val314159 / level_db.py
Last active August 29, 2015 14:07
db driver for leveldb
from leveldb import LevelDB as _LevelDB
def _DB(_=[]): return (_ or _.append(_LevelDB('.db')) or 1) and _[0]
def ZAP(): list(DLT(k) for k,v in RNG([]))
def DLT(k): _DB().Delete(':'.join(k))
def GET(k): return json.loads(_DB().Get(':'.join(k)))
def PUT(k,v): _DB().Put(':'.join(k),json.dumps(v))
def RNGP(pfx=''):return (((k.split(':'),json.loads(v)) for k,v in
_DB().RangeIter(pfx,pfx+'~~~')))
def RNG(k=[]): return RNGP(':'.join(k))
def DLT1P(del_pfx): return ( DLT( k ) for k,v in RNG(del_pfx) )
@val314159
val314159 / index.htm
Last active August 29, 2015 14:08 — forked from bennadel/index.htm
<!doctype html>
<html ng-app="Demo" ng-controller="DemoController">
<head>
<meta charset="utf-8" />
<title>
Using Controllers With ngRepeat In AngularJS
</title>
<style type="text/css">