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 = function Foo() { | |
var someValue = 1; | |
this.noSuchMethodHandler(id, args) { | |
if (id == "increment") { | |
return someValue++; | |
} | |
} | |
}; | |
Foo.prototype.exec = function(id,args) { |
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
// courtesy https://twitter.com/tomdevdiary/status/8946331934 | |
("foo" + + "bar") === "fooNaN" // true |
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
// using node 1.90 | |
var sys = require('sys'), http = require('http'); | |
var crockfordator = http.createClient(80, 'crockfordfacts.com'); | |
var req = crockfordator.request('GET', '/', | |
{ | |
'accept':'application/json', | |
'host':'crockfordfacts.com' | |
} | |
); |
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 writeData = function (filename, data, callback) { | |
var writeOutData = function () { | |
var fw = new FileWriter(); | |
fw.oncomplete = callback; | |
fw.onerror = function () { | |
alert("Failed to save update"); | |
} | |
fw.writeAsText("myDir/" + filename, data); | |
} | |
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
/***** | |
To authorize on Twitter API through xAuth, you need HMAC-SHA1 | |
I'm using the following lib for that: | |
http://jssha.sourceforge.net | |
Make sure you have sha.js included! | |
<script src="http://jssha.sourceforge.net/sha.js"></script> | |
Also, you need to email [email protected] to get xAuth access | |
I cannot do that for you - see http://dev.twitter.com/pages/xauth | |
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/ruby | |
# usage: ruby convert.rb icon.jpg png | |
require 'rubygems' | |
require 'image_science' | |
if ARGV.length == 2 | |
source_file = ARGV.first | |
target_extension = ARGV.last | |
target_file = source_file.sub /[\w\d]+$/, target_extension | |
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
// insert this into your AppDelegate.m file | |
// this will fire an "appActive" event on the webview every time the app is launched | |
// whether through fast-app switching or a cold launch | |
- (void)applicationDidBecomeActive:(UIApplication *)application { | |
// delay of 1ms ensures code will be executed in new stack trace | |
// that way, event listener can't block applicationDidBecomeActive | |
// and crash the app | |
NSString *fireActiveEvent = @"window.setTimeout(function() { \n" | |
"var appActive = document.createEvent('Events'); \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
// private method | |
// Wraps the HTML in a TAG, Tag is optional | |
// If the html starts with a Tag, it will wrap the context in that tag. | |
// doesn't ACTUALLY work | |
function wrap(xhtml, tag) { | |
// new approach | |
// createDocumentFragment | |
var docFrag = document.createDocumentFragment(), | |
dummy, | |
wrapTag; |
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
(higgins={bot:function(){return Math.random()>0.5?"it's just JavaScript":"Dojo already did it"}}).bot() |
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
document.addEventListener('click', function (evt) { | |
if (typeof evt.target.ontouchend == 'function') { | |
evt.target.ontouchend.call(evt.target, evt); | |
} | |
}, false); |
OlderNewer