Skip to content

Instantly share code, notes, and snippets.

View gsmcwhirter's full-sized avatar

Gregory McWhirter gsmcwhirter

View GitHub Profile
def my_decorator(klass):
old_run = klass.run
def wrapper():
def new_run(self, *args, **kwdargs):
old_run(self, *args, **kwdargs)
print "wrapped"
var qs = require("querystring"),
xml2js = require("xml2js"),
parser = new xml2js.Parser(),
config = require("../config"),
crypto = require("crypto"),
tar = require("tar"),
fs = require("fs");
var parseBody = function(body, callback) {
var decodedBody = decodeURIComponent(qs.stringify(qs.parse(body)));
Bot.prototype.initialize = function (){
//yadayada whatever else you need
this.queueWorking = false;
this.queue = [];
this.connection.on('data', function (chunk){self.onData(chunk);});
this.on('new message', function (){self.onNewMessage();});
}
import multiprocessing as mp
import sys
import time
def task(say):
time.sleep(5)
return "Hello, {0}".format(say)
def run_pool():
pool = mp.Pool()
emitter = EventEmitter()
emitter.on('something', handler_function_1);
emitter.on('something', handler_function_2);
emitter.on('something_else', handler_function_3);
# somewhere else
emitter.emit('something'); #handler_function_1 and handler_function_2 are called in order
underscore@1.2.4 /usr/local/lib/node_modules/couchtato/node_modules/nomnom/node_modules/underscore
underscore@1.2.4 /usr/local/lib/node_modules/underscore
request@2.9.3 /usr/local/lib/node_modules/couchapp/node_modules/request
semver@1.0.13 /usr/local/lib/node_modules/npm/node_modules/semver
rimraf@1.0.9 /usr/local/lib/node_modules/npm/node_modules/rimraf
npm ERR! error installing forever@0.8.1 Error: EACCES, permission denied '/usr/local/lib/node_modules/forever/README.md'
npm ERR! error rolling back forever@0.8.1 Error: EACCES, permission denied '/usr/local/lib/node_modules/forever/LICENSE'
npm ERR! Error: EACCES, permission denied '/usr/local/lib/node_modules/forever/README.md'
npm ERR! Report this *entire* log at:
npm ERR! <http://github.com/isaacs/npm/issues>
<script type="text/x-handlebars" data-template-name="blog-post">
{{view Blog.EditFormView contentBinding="content" classBinding="content.isEditing:editing-form"}}
{{view Blog.PostDisplayView contentBinding="content" classBinding="content.isEditing:editing-display"}}
{{#if showComments}}
<div id="disqus_thread"></div>
{{#view contentBinding="content" tagName="script" type="text/javascript"}}
var disqus_shortname = 'ideafreemonoid';
var disqus_identifier = '{{content.slug}}';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
<script type="text/x-handlebars" data-template-name="blog">
<div class="actions">{{view Blog.AddPostLink}}</div>
{{#collection contentBinding="Blog.postsController" tagName="ol" class="posts"}}
{{view Blog.BlogPostView contentBinding="content" classBinding="content.isDraft:blog-draft"}}
{{/collection}}
{{#if hasManyPages}}
<div class="pagination"><a href="#!blog/1">&laquo;first</a>
{{#each pagesLinkData}}
<a href="{{pageHref}}">{{page}}</a>
{{/each}}
Blog.BlogView = Ember.View.extend({
templateName: "blog"
, currentPageBinding: "Blog.postsController.currentPage"
, totalPagesBinding: "Blog.postsController.totalPages"
, hasManyPages: function (){
return this.get("totalPages") > 1;
}.property("totalPages")
, pagesLinkData: function (){
App.MyView1 = Ember.View.extend({
templateName: 'mytemplate'
});
App.MyView2 = App.MyView1.extend({});