Skip to content

Instantly share code, notes, and snippets.

View minodisk's full-sized avatar

Daisuke Mino minodisk

  • Knowledge Work
  • Tokyo, Japan
  • 07:36 (UTC +09:00)
  • X @minodisk
View GitHub Profile
target.parentNode.insertBefore element, target.nextSibling
@minodisk
minodisk / http.coffee
Created April 18, 2012 08:14
Ajax in CoffeeScript
exports.http =
get: (options, callback)->
options.method = 'get'
@request options, callback
post: (options, callback)->
options.method = 'post'
@request options, callback
@minodisk
minodisk / makefile.coffee
Created March 29, 2012 17:19
ディレクトリを監視して CoffeeScript をコンパイル
###
makefile.coffee v0.1.3
###
fs = require 'fs'
path = require 'path'
{spawn} = require 'child_process'
coffee = require 'coffee-script'
{parser, uglify} = require 'uglify-js'
{Relay} = require 'relay'
@minodisk
minodisk / facebook.js
Created March 18, 2012 00:42
How to dynamically initialize social button.
FB.XFBML.parse();
@minodisk
minodisk / cast.js
Created March 11, 2012 00:17
How to use ColorJS
RGB(new HSV(0, 1, 1));
HSV(new RGB(255, 0, 0));
@minodisk
minodisk / loading.coffee
Created December 15, 2011 17:04
ローディングの未圧縮ソース達
NUMBERS = [
'zero'
'one'
'two'
'three'
'four'
'five'
'six'
'seven'
'eight'
@minodisk
minodisk / forinstring.js
Created October 18, 2011 20:07
`for in String` runs without throwing Error
var _keys = function(obj){
//if(Object.keys) return Object.keys(obj);
var keys = [];
for(var k in obj){
if(obj.hasOwnProperty(k)) keys.push(k);
}
return keys;
};
_keys('foo'); // [0, 1, 2]
@minodisk
minodisk / myjson.js
Created October 18, 2011 12:35
native JSON がミリ秒を無視しないかの判定
my.JSON = (function () {
if (window.JSON && window.JSON.stringify([new Date()]).charAt(21) === '.') {
return window.JSON;
}
var JSON = {};
// implementation
return JSON;
})();
@minodisk
minodisk / supportstouch.coffee
Created October 17, 2011 10:36
マルチタッチデバイス判定
supportsTouch = document.createTouch?
@minodisk
minodisk / escapeAsUnicode.js
Created September 28, 2011 06:34
Escape as unicode
function escapeAsUnicode (text) {
var unicode = '';
for (var i = 0, len = text.length, code; i < len; ++i) {
code = text.charCodeAt(i).toString(16);
while (code.length < 4) {
code = '0' + code;
}
unicode += '\\\u' + code;
}
return unicode;