This is now an actual repo:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import fcntl | |
import gevent | |
from gevent.socket import wait_read | |
def print_every(s, repeat=1): | |
print s | |
if repeat: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defscrollback 1024 | |
startup_message off | |
hardstatus on | |
hardstatus alwayslastline | |
hardstatus string "%{.1099} %-w%{.bg}%n %t%{-}%+w %=%H %c:%s " | |
#bind c screen 1 | |
#bind 0 select 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import BaseHTTPServer | |
from SimpleHTTPServer import SimpleHTTPRequestHandler | |
import sys | |
import base64 | |
key = "" | |
class AuthHandler(SimpleHTTPRequestHandler): | |
''' Main class to present webpages and authentication. ''' | |
def do_HEAD(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
/* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | |
$* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
OlderNewer