Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View johtso's full-sized avatar
🤖

Johannes johtso

🤖
View GitHub Profile
class MultiLoader(object):
def __init__(self):
self.d = {}
def load(self, values):
for k, v in zip(self.keys, values):
if k:
self.d[k] = self.process(k, v)
def process(self, key, value):
@johtso
johtso / load_object.py
Created December 10, 2011 13:53
load_object monkeypatch
def load_object(path):
"""Load an object given its absolute object path, and return it.
object can be a class, function, variable o instance.
path ie: 'scrapy.contrib.downloadermiddelware.redirect.RedirectMiddleware'
"""
# monkeypatch
if not isinstance(path, basestring):
return path
@johtso
johtso / pygcurse_skeleton.py
Created December 1, 2011 18:10
Ascii Games with Pygame and Pygcurse
import sys
import pygcurse
import pygame
from pygame.locals import *
WINWIDTH = 40
WINHEIGHT = 50
FPS = 40
@johtso
johtso / jQueryBookmarklet.coffee
Created July 7, 2011 21:33
Load jQuery/jQuery UI dependencies
loadDependencies = (callback) ->
requirements = {jq: '1.6.1', jqui: '1.8.7'}
getScript = (url, next) ->
script = document.createElement('script')
script.src = url
head = document.documentElement.childNodes[0]
script.onload = script.onreadystatechange = onScriptLoad script, next
head.appendChild script
@johtso
johtso / okv-via-yql.coffee
Created June 12, 2011 00:31
Interact with OpenKeyval via YQL
###
Putting trust in Yahoo rather than OpenKeyval.
Probably not useful, just did it to see if it was possible.
###
okvGet = (key, callback) ->
yql_query = "select * from html where url='https://secure.openkeyval.org/#{key}' and xpath='/html/body/p/text()'"
$.ajax
url: 'https://query.yahooapis.com/v1/public/yql',
// This is a test
getdirentries64(0x6, 0x7FD7728E2A00, 0x1000) = 1192 0
close_nocancel(0x6) = 0 0
fstat64(0x5, 0x7FFF50CE06D0, 0x1000) = 0 0
fstat64(0x5, 0x7FFF50CE0720, 0x1000) = 0 0
open_nocancel("/Users/human/.virtualenvs/main/lib/python2.7/site-packages/salt/renderers/mako.pyc\0", 0x0, 0x1B6) = 6 0
fstat64(0x6, 0x7FFF50CE04F8, 0x1B6) = 0 0
read_nocancel(0x6, "\003\363\r\nK\2012Tc\0", 0x1000) = 1282 0
fstat64(0x6, 0x7FFF50CE0608, 0x1000) = 0 0
read_nocancel(0x6, "\n .hostmask: IPv4Address('0.0.0.31')\n .broadcast: IPv4Address('1.2.3.31')\n .netmask: IPv4Address('255.255.255.224')\n .prefixlen: 27\n\n i\377\0", 0x1000) = 0 0
close_nocancel(0x6) = 0 0

Keybase proof

I hereby claim:

  • I am johtso on github.
  • I am johtso (https://keybase.io/johtso) on keybase.
  • I have a public key whose fingerprint is 480D 27DC 20A4 E61E F849 037C 581B 992E 7F19 4964

To claim this, I am signing this object: