This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mv node_modules node_modules_old && npm install | |
var fs = require('fs') | |
var path = require('path') | |
var node_modules = path.join(__dirname, 'node_modules') | |
var node_modules_old = path.join(__dirname, 'node_modules_old') | |
fs.readdir(node_modules, function(err, files) { | |
files.forEach(function(dir) { | |
if (dir.charAt(0) === '.') return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('underscore') | |
var util = require('util') | |
function validate(request) { | |
var errors = [] | |
var values = {} | |
var obj = {} | |
function validator(param) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = function(f) { | |
var pro = {} | |
var chain = [] | |
var end = null | |
function next() { | |
var f = chain.shift() | |
if (!f) { | |
end.apply(null, arguments) | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// put this in your AppDelegate | |
- (void)changeRootViewController:(UIViewController*)viewController { | |
if (!self.window.rootViewController) { | |
self.window.rootViewController = viewController; | |
return; | |
} | |
UIView *snapShot = [self.window snapshotViewAfterScreenUpdates:YES]; | |
[viewController.view addSubview:snapShot]; | |
self.window.rootViewController = viewController; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Backbeam.addRealTimeConnectionListener(new RealTimeConnectionListener() { | |
@Override | |
public void realTimeConnecting() { | |
System.out.println("connecting..."); | |
} | |
@Override | |
public void realTimeConnected() { | |
System.out.println("connected"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs') | |
var path = require('path') | |
var vm = require('vm') | |
var util = require('util') | |
String.prototype.endsWith = function(suffix) { | |
return this.indexOf(suffix, this.length - suffix.length) !== -1; | |
} | |
var basedir = path.join(__dirname, 'less_files')+path.sep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface UIView (ActivityIndicator) | |
- (void)showActivityIndicator; | |
- (void)showActivityIndicatorWithStyle:(UIActivityIndicatorViewStyle)style; | |
- (void)hideActivityIndicator; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{name: 'Afghanistan', code: 'AF'}, | |
{name: 'Åland Islands', code: 'AX'}, | |
{name: 'Albania', code: 'AL'}, | |
{name: 'Algeria', code: 'DZ'}, | |
{name: 'American Samoa', code: 'AS'}, | |
{name: 'Andorra', code: 'AD'}, | |
{name: 'Angola', code: 'AO'}, | |
{name: 'Anguilla', code: 'AI'}, | |
{name: 'Antarctica', code: 'AQ'}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>tldr leaks memory?</h1> | |
<!-- Start recording with Chrome Dev Tools using the "Timeline" section. Click 'start' and see the memory usage --> | |
<!-- pushState() does not work with local files, so you can save this file as 'index.html', | |
start a static Python web server with `python -m SimpleHTTPServer` in the same directory and open http://localhost:8000/ --> | |
<button onclick="start()">Start!</button> | |
<script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Q = require('q') | |
var async = require('async') | |
function dumbQ(value) { | |
var deferred = Q.defer() | |
setTimeout(function() { | |
deferred.resolve(value) | |
}, 200) | |
return deferred.promise | |
} |