Skip to content

Instantly share code, notes, and snippets.

View garrettwilkin's full-sized avatar

Garrett Wilkin garrettwilkin

View GitHub Profile
@garrettwilkin
garrettwilkin / gist:3642279
Created September 5, 2012 18:39
What the scope?
I want to use a function so that i dont have to write the same logic over and over again in my calls to the find function on my MongoDb collections.
Here's the function I want, but notice that it contains 'self.res'. That's cause i just ripped it out of my find(...) call (below). Previously, when this was just an annoymous function, self.res is the HTTP response that we're building.
So how to i access self.res in my callback, if I use a named function, instead of an anonymous function in my find?
function findHandler(err, docs) {
if (!err) {
// Return Success & JSON Content-type
var length = docs.length;
@garrettwilkin
garrettwilkin / gist:3642610
Created September 5, 2012 19:00 — forked from Southern/gist:3642328
What the scope?
function findHandler(err, docs) {
if (!err) {
// Return Success & JSON Content-type
var length = docs.length;
writeMeta(self.res,200,url,length);
// Process results from Mongo
docs.forEach(function(e,i,a) {
//console.log(e,i,a);
@garrettwilkin
garrettwilkin / TileMill.log
Created September 9, 2012 00:39
TileMill crash on startup
gw@airy ~/Code> vim /Users/gw/Library/Logs/TileMill.log
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
@garrettwilkin
garrettwilkin / gist:3724263
Created September 14, 2012 19:46
Attempting to add new mapping to piratespeak.dictiony "up","aloft"
When I execute this URL in my browser:
http://query.yahooapis.com/v1/public/yql?q=insert%20into%20piratespeak.dictionary%20(english_term%2C%20pirate_term)%20values%20(%22up%22%2C%20%22aloft%22)%3B&format=json&env=store%3A%2F%2Fkid666.com%2Fpiratespeak&callback=cbfunc
I get this response:
cbfunc({"query":{"count":1,"created":"2012-09-14T19:42:19Z","lang":"en-US","results":{"result":"Ahoy mate! Ye doth added ye Pirate term \"aloft\" for yonder English term \"up\""}}});
It looks good, but if i go back to the console and get the URL to list everything in piratespeak.dictionary,
@garrettwilkin
garrettwilkin / gist:3729265
Created September 15, 2012 18:46
Krispin node douche error
/Users/gw/Code/douche/lib/douche/wsdl.js:48
var name = operation_tag['@']['name'];
^
TypeError: Cannot read property 'name' of undefined
at WSDL._read_xml (/Users/gw/Code/douche/lib/douche/wsdl.js:50:34)
at WSDL.parse (/Users/gw/Code/douche/lib/douche/wsdl.js:21:10)
at IncomingMessage.WSDL._get (/Users/gw/Code/douche/lib/douche/wsdl.js:108:7)
at IncomingMessage.EventEmitter.emit (events.js:115:20)
at IncomingMessage._emitEnd (http.js:366:10)
at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
@garrettwilkin
garrettwilkin / Output.txt
Created October 5, 2012 15:08
Java double experiments.
gw@airy ~/> java Reps
a: 1.0
b: 0.35
c: 0.65
d: 0.35
e: 0.035
f: 0.034999999999999996
g: 0.06999999999999999
@garrettwilkin
garrettwilkin / build.xml
Created December 12, 2012 21:44
Trying to create a source jar for use with Netbeans, so that it can intellisense me to the implementation of various functions. I've tried to add sources so many ways, and failed everytime. I thought that this jar of java files would do the trick. I was wrong. Check out the source-jar target.
<project name="comFidessaUstpPairsDialogUtil" default="main" basedir=".">
<property environment="env"/>
<property name="srcDir" value="${basedir}/src"/>
<property name="bldDir" value="${basedir}/build"/>
<property name="jarDir" value="${env.CASE}/regional/classes"/>
<path id="case.jar">
<pathelement path="${classpath}"/>
"{
u'priority': 6,
u'eta': u'2015-11-25T15: 27: 25.112018-05: 00',
u'request': {
u'args': u'[]',
u'time_start': None,
u'name': u'offline_processor.tasks.session_timer',
u'delivery_info': {
u'priority': None,
u'redelivered': False,
@garrettwilkin
garrettwilkin / HTML
Last active December 14, 2015 20:48
Wordpress header CSS styling
<div id="page" class="hfeed site">
<header id="masthead" class="site-header" role="banner">
<nav role="navigation" class="site-navigation main-navigation">
<h1 class="assistive-text">Menu</h1>
<div class="assistive-text skip-link"><a href="#content" title="Skip to content">Skip to content</a></div>
<div class="menu"><ul><li class="current_page_item"><a href="http://mainecivichackday.com/" title="Home">Home</a></li><li class="page_item page-item-1"><a href="http://mainecivichackday.com/about/">About</a></li><li class="page_item page-item-20"><a href="http://mainecivichackday.com/participate/">Participate</a></li><li class="page_item page-item-24"><a href="http://mainecivichackday.com/solve/">Solve</a></li><li class="page_item page-item-9"><a href="http://mainecivichackday.com/contact/">Contact</a></li></ul></div>
</nav><!-- .site-navigation .main-navigation -->
<hgroup>
<h1 class="site-title"><a href="http://mainecivichackday.com/" title="Maine Civic Hack Day" rel="home">Maine Civic Hack
this._commsAjax("pagedQuery",
data,
$.proxy(function(data) {
if (data.errorCode != 0) {
delete this._activeSess[sessionId];
queryObj.error(data.errorText, data.errorCode);
}
}, this)