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
| defaults write -g ApplePressAndHoldEnabled -bool false |
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 request = require('request') | |
| var url = 'http://picasaweb.google.com' | |
| + '/data/feed/api/user/102873175118305865375/' | |
| + 'albumid/5646665615382099025' | |
| + '?alt=json' | |
| request.get(url, function(err, res, body) { | |
| var gplus = JSON.parse(body) | |
| var len = gplus.feed.entry.length |
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
| #!/usr/bin/env node | |
| var http = require('http') | |
| // Google Plus Photos API | |
| // Sample data from Felipe Apostol's Street Photography album | |
| // userId is 102873175118305865375 | |
| // albumId is 5646665615382099025 | |
| var options = { |
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 obj = { | |
| name: 'flip', | |
| printMe: function() { | |
| // solution: pass this as closure | |
| var self = this | |
| console.log('1. ' + this.name) | |
| var x = (function() { | |
| // console.log('2. ' + this.name) | |
| console.log('2. ' + self.name) | |
| var y = (function() { |
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 arr = [1, 2, 3, 4, 5, 6, 7] | |
| , results = [] | |
| , len = arr.length | |
| ;(function iterator(i) { | |
| if (i >= len) { | |
| callback(null, results) | |
| } else { | |
| async_work(function(err, res) { | |
| if (err) { |
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 mongo = require('mongodb') | |
| var Server = mongo.Server | |
| , Db = mongo.Db | |
| , BSON = mongo.BSONPure | |
| var server = new Server('localhost', 27017, {auto_reconnect: true}) | |
| , db = new Db('dbName', server) | |
| db.open(function(err, db) { |
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
| (function(){ | |
| var traverse = function(util, searchTerm, options) { | |
| var options = options || {}; | |
| var obj = options.obj || window; | |
| var path = options.path || ((obj==window) ? "window" : ""); | |
| var props = Object.keys(obj); | |
| props.forEach(function(prop) { | |
| if ((tests[util] || util)(searchTerm, obj, prop)){ | |
| console.log([path, ".", prop].join(""), "->",["(", typeof obj[prop], ")"].join(""), obj[prop]); | |
| } |
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 toType = function(obj) { | |
| return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() | |
| } | |
| toType({a: 4}); //"object" | |
| toType([1, 2, 3]); //"array" | |
| (function() {console.log(toType(arguments))})(); //arguments | |
| toType(new ReferenceError); //"error" | |
| toType(new Date); //"date" | |
| toType(/a-z/); //"regexp" |
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 trutheyTester = function(expr) { | |
| return expr ? "truthey" : "falsey"; | |
| } | |
| trutheyTester({}); //truthey (an object is always true) | |
| trutheyTester(false); //falsey | |
| trutheyTester(new Boolean(false)); //truthey (an object!) | |
| trutheyTester(""); //falsey |
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 myObject = { name : 'flipjs' } | |
| console.log('Start observing...') | |
| Object.observe(myObject, function(changes) { | |
| changes.forEach(function(change) { | |
| console.log(change.name | |
| + " was " | |
| + change.type | |
| + " and is now " |