Instantly share code, notes, and snippets.

View es6-classes.js
class Dispatcher {
register(listener) {
this.listener = listener;
}
dispatch(action) {
if (this.listener) {
this.listener(action);
}
View tag-helpers.js
var hbs = require('express-hbs'),
api = require('core/server/api'),
_ = require('lodash'),
async = require('express-hbs/lib/async'), // To redefine `registerAsyncHelper`
registerAsyncHelper;
// Redefine `registerAsyncHelper` from `express-hbs`
registerAsyncHelper = function (name, fn) {
hbs.handlebars.registerHelper(name, function (context, options) {
// Pass `[context, options]` as arg instead of `context` only
View main.js
module.exports = function (Handlebars) {
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
View swm-helper
# List all installed Apple Developer certificates
security find-certificate -a -c "Developer" login.keychain | grep '"labl"' | cut -d'"' -f4
# List installed .mobileprovision files
ls ~/Library/MobileDevice/Provisioning\ Profiles/
# Get plist from a .mobileprovision file
openssl smime -inform der -verify -noverify -in $mobileprovision_file
View pre-receive
#!/bin/sh
REPO_DIRNAME=$PWD
REPO_BASENAME=$(basename $REPO_DIRNAME)
REPO_BASENAME=${REPO_BASENAME%.git}
if [ $REPO_BASENAME = "gitolite-admin" ]; then
View a.php
$a = function () {
echo 'x';
};
$a();
View vkontakte.js
goog.provide('VKontakte');
goog.require('goog.crypt.Md5');
VKontakte = function (user_id, app_id, app_secret) {
this.user_id_ = user_id;
this.app_id_ = app_id;
this.app_secret_ = app_secret;
};
View client.m
- (void)connect {
NSHost *host = [NSHost hostWithName:@"example.com"];
// iStream and oStream are instance variables
[NSStream getStreamsToHost:host port:2000 inputStream:&iStream
outputStream:&oStream];
[iStream retain];
[oStream retain];
[iStream setDelegate:self];
[oStream setDelegate:self];
View api-controller.js
function ApiController() {
Controller.call(this);
}
ApiController.prototype = Object.create(Controller.prototype);
ApiController.prototype.error = function (status, message) {
this.render(status, { 'error': message });
};
View IndexController.js
var darkside = require('darkside');
var IndexController = function () {
darkside.base(this, darkside.ViewController);
};
util.inherits(IndexController, darkside.ViewController);