This file contains 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 emoji = { | |
binary_store: {}, | |
convert: function(str, raw) { | |
var ret = [], img; | |
for (var i = 0, c; c = str.charCodeAt(i); i++) { | |
if ( | |
0xE63E <= c && c <= 0xE6A5 || | |
0xE6AC <= c && c <= 0xE6AE || | |
0xE6B1 <= c && c <= 0xE6B3 || |
This file contains 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
try | |
do shell script "open \"http://radiko.jp/player/player.html#TBS\"" | |
on error errorText | |
display dialog errorText | |
end try |
This file contains 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
Number.prototype.drop = function(digit) { | |
var n = Math.pow(10, digit || 0); | |
var ret = this * n; | |
ret = Math.floor(ret); | |
return (ret / n).toFixed(digit); | |
}; |
This file contains 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
// ==UserScript== | |
// @name Gresemonkey localStorage Test | |
// @namespace http://codefairy.org/ns/userscripts | |
// @include * | |
// ==/UserScript== | |
GM_log(typeof unsafeWindow.localStorage); // object | |
GM_log(unsafeWindow.localStorage.num = Number(unsafeWindow.localStorage.num || 0) + 1); // OK! | |
GM_log(typeof window.localStorage); // object |
This file contains 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
// prototype.js breakes native JSON | |
if (String.prototype.evalJSON && Object.toJSON) | |
window.JSON = { | |
parse: function(str) { return str.evalJSON(); }, | |
stringify: function(obj) { return Object.toJSON(obj); } | |
}; |
This file contains 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 formatTumblrDate(date) { | |
var y = date.getFullYear(); | |
var m = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][date.getMonth()]; | |
var d = date.getDate(); | |
d = d+(['st', 'nd', 'rd', 'th'][(/(1?\d)$/.exec(d))[1] - 1] || 'th'); | |
var h = date.getHours(); | |
var ampm = ['am', 'pm'][Number(h >= 12)]; | |
h = h % 12; | |
var min = date.getMinutes(); | |
if (min < 10) min = '0'+min; |
This file contains 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 shortcut = { | |
keys: [], | |
setup: function() { | |
document.addEventListener('keypress', this.keypress, false); | |
return this; | |
}, | |
bind: function(key, handler) { | |
this.keys[key] = handler; |
This file contains 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 greasemonkey = (typeof unsafeWindow != 'undefined'); | |
if (greasemonkey) | |
Foo.setup(); // use @resource | |
else { | |
// referred to jQuery | |
var head = document.getElementsByTagName('head')[0]; | |
var script = document.createElement('script'); | |
script.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'; |
This file contains 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
Array.prototype.flatten = function() { | |
return this.join().split(','); | |
}; |
This file contains 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 monochrome(src) { | |
var d = new Deferred; | |
var img = new Image; | |
img.src = src; // must same domain | |
img.onload = function() { | |
var w = img.width; | |
var h = img.height; | |
var _canvas = $('<canvas width="'+w+'" height="'+h+'" class="photo">'); | |
var _context = _canvas[0].getContext('2d'); |