Skip to content

Instantly share code, notes, and snippets.

View sivy's full-sized avatar

Steve Ivy sivy

View GitHub Profile
SomeObject.prototype.do_thing = function () {
var lib = require('somelib');
// this == the object I assume
libdo_thing().on('success', function(err, results){
// what is the value of "this" here?
});
};
sivy@vps-1110680-1854:~/tmp/npm$ node ./cli.js install npm
npm info it worked if it ends with ok
npm info using npm@0.2.13-3
npm info using node@v0.3.2
npm info fetch http://registry.npmjs.org/npm/-/npm-0.2.13-3.tgz
npm info calculating sha1 /tmp/npm-1293736903023/1293736903774-0.33817205764353275/tmp.tgz
npm info shasum a3588e2815e04d12e5115a69fa6f1cf598bcb4aa
npm ERR! Failed creating the tarball.
npm ERR! This is very rare. Perhaps the 'gzip' or 'tar' configs
npm ERR! are set improperly?
var script = document.createElement( 'script' );
script.type = 'text/javascript';
script.id = 'my_script';
script.src = '/path/to/script.js';
$('body').prepend(script); // doesn't show up in DOM (firebug)
$('body').append(script); // doesn't show up in DOM either (firebug)
$('#my_script').get(0); // undefined
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>append/prepend test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
</head>
@sivy
sivy / update_gh_wiki.pl
Created February 8, 2011 21:07
How I update my github wiki
#!/usr/bin/env perl
###
# I have a github wiki wired up to my Notational Velocity file system data store
# It's an amusink little gizmo
#
my $USER='steve';
my $status= `cd /Users/$USER/Library/Application\\ Support/Notational\\ Data/; /usr/local/git/bin/git status`;
if ($status =~ /modified|untracked\ files\ present|deleted/) {
(wr)tt:[~]> ./test.js
test
/Users/steve/test.js:12
throw err;
^
TypeError: Bad file descriptor argument
at Socket.sendto (dgram.js:259:25)
at dgram.js:246:14
at dgram.js:40:5
[Fri Mar 11 09:11:03 2011] [error] typepadapp.admin DEBUG saved TEST SUBSCRIPTION (47): <Subscription: TEST SUBSCRIPTION>
[Fri Mar 11 09:11:03 2011] [error] typepadapp.admin DEBUG Current no. of subscriptions post obj save: 5
[Fri Mar 11 09:11:03 2011] [error] typepadapp.admin DEBUG ======
[Fri Mar 11 09:11:03 2011] [error] sub for verify_token jofkjagzy9O4G4ilVnby: <Subscription: TEST SUBSCRIPTION>
...snip...
[Fri Mar 11 09:11:03 2011] [error] typepadapp.views.feedsub DEBUG subscribe request from typepad - challenge: 7EqlwnDo27jg verify_token: jofkjagzy9O4G4ilVnby
[Fri Mar 11 09:11:03 2011] [error] typepadapp.views.feedsub DEBUG Current no. of subscriptions in subscribe: 4
[Fri Mar 11 09:11:03 2011] [error] typepadapp.admin ERROR 400 Bad Request requesting _CreateExternalFeedSubscriptionResponse https://api.typepad.com.convdemo.dev.sixapart.com/applications/6p014bd196b7d1033d/create-external-feed-subscription.json: http://yellowsubmarine.app.saymedia.com/feedsub/callback/4
@sivy
sivy / jsonp_decorator.py
Created March 16, 2011 03:16
a jsonp view decorator for Django
def jsonp(f):
"""Wrap a json response in a callback, and set the mimetype (Content-Type) header accordingly
(will wrap in text/javascript if there is a callback). If the "callback" or "jsonp" paramters
are provided, will wrap the json output in callback({thejson})
Usage:
@jsonp
def my_json_view(request):
d = { 'key': 'value' }
from functools import wraps
def recordstats(stat_prefix=None):
"""Record that this function was called, with duration
Usage:
@recordstats('stats_prefix')
def my_view(request):
return HTTPResponse(the_content)