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
| system.use("info.webtoolkit.Base64"); | |
| var username = "admin"; | |
| var password = "password"; | |
| var auth = "Basic " + Base64.encode(username + ":"+ password); | |
| checkAuth = function() { | |
| if (!this.request.headers.hasOwnProperty('Authorization') || (this.request.headers.hasOwnProperty('Authorization') && (auth != this.request.headers['Authorization']))) { | |
| this.response.headers['WWW-Authenticate'] = 'Basic realm="SmartAPI"'; | |
| this.response.code = 401; | |
| this.response.body = "Not Authorized\n"; |
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 sys = require("sys") | |
| var http = require("http"); | |
| var twitter = http.createClient(80, "search.twitter.com"); | |
| var count = 10 | |
| for (var i = 1; i <= count; i++) { | |
| var request = twitter.request("GET", "/search.json?q=crockfordfact+OR+crockfordfacts&rpp=100&page=" + i, {"host": "search.twitter.com"}); | |
| request.addListener('response', function(response) { |
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 ($, window, undefined) { | |
| var m = document.createElement('i'), | |
| m_style = m.style, | |
| // TODO support other browsers easings - based on Safari's easing options and ported to Emile easing. | |
| stanardEasing = { | |
| 'ease-in-out' : function(pos){if((pos/=0.5)<1){return 0.5*Math.pow(pos,4);}return -0.5*((pos-=2)*Math.pow(pos,3)-2);}, | |
| 'ease-in' : function(pos){return Math.pow(pos,4);}, | |
| 'ease-out' : function(pos){return Math.pow(pos,0.25);}, | |
| 'linear': function (i) {return i;} |
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 foo = { | |
| toString: function () { | |
| return 5; | |
| }, | |
| valueOf: function () { | |
| return "foo"; | |
| } | |
| }; | |
| alert(foo.toString() + 1); // 6 (bad!) | |
| alert(foo + 1); // "foo1" (no good!) |
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 people = new Lawnchair({adaptor:'dom'}); |
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
| // In the .h file ….. | |
| #import | |
| #import “PhoneGapCommand.h” | |
| @interface FlurryAPI : PhoneGapCommand { | |
| } | |
| - (void)doit:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; | |
| @end | |
| // in the .m file |
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 test = (function({ arguments:[] }){ | |
| console.log(arguments[0]); | |
| }); | |
| test('fffffffffu'); |
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
| alert.call.call.call.call.call.apply(function (a) {return a}, [1,2]) // 2 |
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
| // this is just a really silly way of saying this | |
| Function.prototype.call.apply(function (a) {return a}, [1,2]) | |
| // 2 | |
| // if this still seems weird to you. Consider this: | |
| function logThisAndArgs(){ console.log(this, arguments); } | |
| Function.prototype.call.apply(logThisAndArgs, [{'some':'object'},1,2,3,4]) | |
| // logs -> Object { some="object"} [1, 2, 3, 4] |
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 up() { | |
| git add . | |
| git commit -m $1 | |
| git push origin master | |
| } |