Skip to content

Instantly share code, notes, and snippets.

@keturn
keturn / run-pyrasite.md
Created June 30, 2015 04:38
pyrasite in 2015
@keturn
keturn / napkin-includes.diff
Created November 11, 2009 20:03
sleeptracker patch
diff -ur napkin-0.0/lib/hypnodata.cc napkin-patched/lib/hypnodata.cc
--- napkin-0.0/lib/hypnodata.cc 2008-04-04 15:10:03.000000000 -0700
+++ napkin-patched/lib/hypnodata.cc 2009-11-11 10:52:46.000000000 -0800
@@ -1,3 +1,6 @@
+#include <cstdlib>
+#include <cstdio>
+#include <cstring>
#include <napkin/exception.h>
#include <napkin/util.h>
#include <napkin/types.h>
@keturn
keturn / associate.py
Created January 28, 2010 08:44
openid/contrib/associate.py
#!/usr/bin/env python
"""Make an OpenID Assocition request against an endpoint
and print the results."""
from datetime import datetime
import sys
from openid.store.memstore import MemoryStore
from openid.consumer import consumer
from openid.consumer.discover import OpenIDServiceEndpoint
@keturn
keturn / crash-app.js
Created January 29, 2010 03:27
expression-crash
/* This was one of my attempts to figure out deferred responses.
It crashes the whole server with a message like this:
[object Object].emitSuccess (node.js:283:15)
[object Object].<anonymous> (node.js:695:21)
[object Object].emitSuccess (node.js:283:15)
node.js:552:29
node.js:1027:1
node.js:1031:1
@keturn
keturn / myOpenID-delegation
Created March 11, 2010 02:27
yahoo openid delegation fail
at http://openidenabled.com/python-openid/trunk/examples/consumer/finish/:
openid <http://specs.openid.net/auth/2.0>
mode = id_res
identity = http://keturn.myopenid.com/
claimed_id = http://keturn.net/
assoc_handle = {HMAC-SHA1}{4b9852bd}{CDlRdQ==}
op_endpoint = http://www.myopenid.com/server
response_nonce = 2010-03-11T02:32:02ZUpcemj
return_to = http://openidenabled.com/python-openid/trunk/examples/consumer/finish/?janrain_nonce=2010-03-11T02%3A27%3A41ZbQoFal
sig = dJMjI3wsbpnhvgfCIl2J2dBCaNY=
from django.db import models
class Top(models.Model):
_counter = 0
def __init__(self, arg):
Top._counter += 1
print "Top(%s)#__init__(<%x>, %s) called %d times" % (
self.__class__.__name__, id(self), arg, Top._counter)
@keturn
keturn / binding_methods.py
Created April 15, 2010 06:29
method or function? why explicit self
class A(object):
# method
def foo(self, x):
print self, x
# function -- defined after A is closed.
def bar(self, y):
print self, y
A.bar = bar
@keturn
keturn / selenium-ajax.py
Created July 8, 2010 23:38
getAjaxResult for python selenium
def getAjaxResult(self, func, *args):
sel = self.selenium
self.js('''\
ajaxSeleniumResult = (function (func, args) {
var result = [], funcArgs;
function storeSeleniumResult() {
result.push(window.jQuery.makeArray(arguments));
}
// assume function's last argument is a callback
args.push(storeSeleniumResult);
@keturn
keturn / closure-compiler
Created August 4, 2010 23:47
convenience wrapper for closure-compiler/compiler.jar
#!/bin/bash
java -jar ~/src/closure-compiler/compiler.jar ${@/#/--js }
@keturn
keturn / ngplans.htm
Created April 8, 2011 19:04
trying to use angular
<!doctype html>
<html xmlns:ng="http://angularjs.org">
<head>
<title>all plans</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="icon" href="/s/plans/images/plans-icon.png?68f34ebf0f" />
<link rel="stylesheet" href="/s/jquery-ui-css/jquery-ui-1.8.9.css?9f6e6ea563" type="text/css" charset="utf-8"/>
<link rel="stylesheet" href="/s/jquery-ui-css/jquery-ui-1.8.9.custom.css?7ea76fa98c" type="text/css" charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="/s/plans/css/plans.css?9fbd065898">
<link rel="stylesheet" type="text/css" href="/s/plans/css/datatables.css?396b174e7a" />