Skip to content

Instantly share code, notes, and snippets.

View val314159's full-sized avatar

val314159 val314159

View GitHub Profile
@fxsjy
fxsjy / SimpleAuthServer.py
Created April 26, 2013 06:23
SimpleAuthServer: A SimpleHTTPServer with authentication
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):
@cowboy
cowboy / HEY-YOU.md
Last active April 9, 2024 15:54
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
@jwreagor
jwreagor / EmacsKeyBinding.dict
Created March 20, 2014 18:41
Global Emacs Key Bindings for OS X
{
/* 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
@jcgregorio
jcgregorio / How_to_use.html
Last active July 17, 2023 14:44
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/.
<!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>
@werediver
werediver / websse.py
Last active June 1, 2023 14:17
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.
"""
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:
@stonehippo
stonehippo / docker_x11_gui_osx.md
Last active December 6, 2021 00:21
Getting X11 GUI applications to work on OS X with Docker

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\"
@neilisaac
neilisaac / .screenrc
Created July 7, 2011 01:23
GNU screenrc with status bar at the bottom
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
@tmc
tmc / gist:787105
Created January 19, 2011 23:29
gevent nonblocking stdin
import os
import sys
import fcntl
import gevent
from gevent.socket import wait_read
def print_every(s, repeat=1):
print s
if repeat:
@val314159
val314159 / Docker.makefile
Created September 1, 2016 22:43
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
######################################## ######################################
@val314159
val314159 / yottaauthapp.py
Last active September 30, 2015 23:43
Yotta Authorization App
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 = [ '{}' ]