Skip to content

Instantly share code, notes, and snippets.

Ian Schenck ianschenck

Block or report user

Report or block ianschenck

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ianschenck
ianschenck / dhcp
Created Aug 3, 2016
Captive Portal on TP-Link TL-WA7210N using CHAOS CALMER (15.05.1, r48532), Files under /etc/config/
View dhcp
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option filterwin2k '0'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option local '/lan/'
option domain 'lan'
option expandhosts '1'
View example.py
import interface
class IFoo(interface.Interface):
def foo(self):
"""foo this object."""
class IBar(interface.Interface):
@ianschenck
ianschenck / run.py
Last active Aug 29, 2015
Run twisted wsgi like an old-school, socket sharing fcgi subprocess
View run.py
# Many very old fcgi containers had a trick probably inherited from old
# inetd, where a socket is syscall dup2'd onto fd 0 of a subprocess.
# The parent creates and binds the socket while the children then just
# listen on it.
#
# Something to note is that supervisord provides this facility with its
# [fcgi-program] configuration section. The benefit here is simple inet
# or fcgi style graceful restarts. Anyhow, here is how you grab a
# socket that is fd 0 and start your twisted wsgi container on it. The
# wsgi application here is `application`.
@ianschenck
ianschenck / new_app.py
Last active Jan 25, 2020
Run your flask app under twisted wsgi, ALWAYS.
View new_app.py
if __name__ == "__main__":
reactor_args = {}
def run_twisted_wsgi():
from twisted.internet import reactor
from twisted.web.server import Site
from twisted.web.wsgi import WSGIResource
resource = WSGIResource(reactor, reactor.getThreadPool(), app)
site = Site(resource)
View pool.py
class Pool(object):
def __init__(self, factory, size, finalizer=None):
self._factory = factory
self._finalizer = finalizer or lambda x: None
self._pool = list()
self._pool_sema = threading.Semaphore()
for _ in range(size):
self.put(self._factory())
View stamp_version_ldflags
go install path/to/main -ldflags "-X path/to/main.commit $(git rev-parse HEAD)"
View go-misc.el
(defun go-build ()
"Build a go package"
(interactive)
(compile "go build"))
(defun go-test ()
"Test a go packages"
(interactive)
(compile "go test -v"))
(defun go-vet ()
"Vet a go package"
@ianschenck
ianschenck / gist:7238329
Last active Dec 27, 2015
Mesos/Marathon/Docker on 12.04 with 3.8+ kernel.
View gist:7238329
#!/bin/bash
set -o errexit -o nounset -o pipefail
function -h {
cat <<USAGE
USAGE: mesos-docker-setup
Installs tools for running Docker under Mesos with Marathon.
USAGE
}; function --help { -h ;}
@ianschenck
ianschenck / fabfile.py
Created Aug 2, 2013
Fabric file to setup ceph quicky.
View fabfile.py
"""
Deploy Ceph.
"""
import base64
import ConfigParser
import os
import StringIO
import struct
import time
You can’t perform that action at this time.