Skip to content

Instantly share code, notes, and snippets.

Avatar

val314159 val314159

View GitHub Profile
View Docker.makefile
NAME=vvm
all: clean build rund ;
clean: ; rm -f Dockerfile ; docker rm -f $(NAME) ; true
build: Dockerfile ; docker build --tag $(NAME) . && rm Dockerfile
runi: ; docker run -it --name $(NAME) $(NAME)
rund: ; docker run -d --name $(NAME) $(NAME)
exec: ; docker exec -it $(NAME) /bin/bash -c "TERM=$(TERM) exec bash"
ps: ; docker ps
Dockerfile: Makefile ; echo "$$DOCKERFILE" >Dockerfile
######################################## ######################################
@stonehippo
stonehippo / docker_x11_gui_osx.md
Last active Oct 11, 2020
Getting X11 GUI applications to work on OS X with Docker
View docker_x11_gui_osx.md

Getting X11 GUI applications to work on OS X with Docker

$ brew install socat
$ brew cask install xquartz <--- assuming you don't already have XQuartz installed some other way
$ open -a XQuartz <--- start an XQuartz session

$ socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"
@val314159
val314159 / yottaauthapp.py
Last active Sep 30, 2015
Yotta Authorization App
View yottaauthapp.py
class YoctoAuthApp(object):
def __init__(self, auth_obj={}):
_.auth_obj = auth_obj
def __call__(self, env, start):
def rstart(resp):
start(resp, [('Content-Type', 'application/json'),
('Access-Control-Allow-Origin', '*'), ])
try:
data = self.auth_obj
ret = [ '{}' ]
@val314159
val314159 / yottapubsub.py
Last active Sep 30, 2015
Yotta Pub-Sub
View yottapubsub.py
#!/usr/bin/env python
class YottaPubSub(object):
def __init__(_): _.sessions, _.channels = {}, {}
def add(_,sid,fun): _.sessions[sid] = fun ; _.sub( sid, [] )
def pop(_,sid): _.sessions.pop( sid ) ; _.channels.pop( sid )
def sub(_,sid,channels): _.channels[sid] = ["*",sid] + channels
def pub(_,sid,channel,msg):
for key,func in _.sessions.iteritems():
if key!=sid and channel in _.channels[key]:
func( sid, channel, msg )
View test_gist.py
print "this is a gist meant to test python API calls for comments"
@jcgregorio
jcgregorio / How_to_use.html
Last active May 9, 2021
HTML Templating using the HTML <template> element and exactly 100 lines of JS. A cleaned up version of this code is now available at https://github.com/jcgregorio/stamp/.
View How_to_use.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="templating.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<template id=t>
@val314159
val314159 / level_db.py
Last active Aug 29, 2015
db driver for leveldb
View level_db.py
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) )
View env.sh
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; }
$*
View cors.py
'''
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',
@cheapRoc
cheapRoc / EmacsKeyBinding.dict
Created Mar 20, 2014
Global Emacs Key Bindings for OS X
View EmacsKeyBinding.dict
{
/* Keybindings for emacs emulation. Compiled by Jacob Rus.
*
* This is a pretty good set, especially considering that many emacs bindings
* such as C-o, C-a, C-e, C-k, C-y, C-v, C-f, C-b, C-p, C-n, C-t, and
* perhaps a few more, are already built into the system.
*
* BEWARE:
* This file uses the Option key as a meta key. This has the side-effect
* of overriding Mac OS keybindings for the option key, which generally