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
// 何かDOM操作する(この時点ではまだ描画されない) | |
$('#status').text('処理を開始します'); | |
// setTimeoutを使ってDOM描画を待つ | |
setTimeout(function() { | |
// 1ミリ秒後に開始する重い処理 | |
}, 1); |
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 cache = {}; | |
var regex = /\\u[0-9a-f]{4}|\&(\w+|\#([0-9]+|x[0-9a-f]+))\;/g; | |
var ignore = /[\x00-\x20\>\<\&\"\']/; | |
var func = function (match) { | |
var ret = cache[match]; | |
if (! ret) { | |
var head = match.charAt(0); | |
if (head == "&") { | |
var p = document.createElement("p"); | |
p.innerHTML = match; |
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 seq = 0; | |
var Foo = function () { | |
this.seq = ++ seq; | |
}; | |
var Bar = function () { | |
this.fooB = new Foo(); | |
}; | |
Bar.prototype = { | |
fooA: new Foo(), // shared | |
get fooC() { |
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 walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT); | |
var buf = []; | |
while(walker.nextNode()) { | |
var src = walker.currentNode; | |
if (! src) continue; | |
var text = src.data; | |
if (! text.length) continue; | |
text = text.replace(/[\s\r\n\t]+/g, ''); | |
if (text.length < 1) continue; | |
if (! src.parentNode) continue; |
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
const en_US = { | |
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], | |
shortDays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], | |
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], | |
shortMonths: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], | |
AM: "AM", | |
PM: "PM", | |
}; | |
const literal = { |
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
/**** | |
NSLog(@"%@", [self languageNameForLanguageCode:@"fr" inLanguageCode:@"en"]); // French | |
NSLog(@"%@", [self languageNameForLanguageCode:@"ja" inLanguageCode:@"fr"]); // japonais | |
NSLog(@"%@", [self languageNameForLanguageCode:@"en" inLanguageCode:@"ja"]); // 英語 | |
****/ | |
- (NSString*)languageNameForLanguageCode:(NSString*)targetLang inLanguageCode:(NSString*)displayLang | |
{ | |
CFLocaleRef displayLocale = CFLocaleCreate(kCFAllocatorDefault, (CFStringRef)displayLang); | |
CFStringRef displayName = CFLocaleCopyDisplayNameForPropertyValue(displayLocale, kCFLocaleLanguageCode, (CFStringRef)targetLang); |
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
/** | |
* @param {array} array - Array of strings. ex. ["aaa", "bb.cc", "(ddd)"] | |
* @returns {Number} - RegExp object escaped and joined. ex. /aaa|bb\.cc|\(ddd\)/ | |
*/ | |
function array_to_regexp(array, opt) { | |
var re = array.sort(function(a, b) { | |
return b.length - a.length; | |
}).map(function(str) { | |
return str.replace(/\W/g, function(match) { |
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
/** カタカナをひらがなに変換する関数 | |
* @param {String} src - カタカナ | |
* @returns {String} - ひらがな | |
*/ | |
function katakanaToHiragana(src) { | |
return src.replace(/[\u30a1-\u30f6]/g, function(match) { | |
var chr = match.charCodeAt(0) - 0x60; | |
return String.fromCharCode(chr); | |
}); |
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
<!-- JavaScript SDK の非同期読み込み。Facebook のみ App Id が必要 --> | |
<script src="http://platform.twitter.com/widgets.js" async></script> | |
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1&appId=123456789012345" async></script> | |
<script src="http://apis.google.com/js/plusone.js" async></script> | |
<script src="http://platform.linkedin.com/in.js" async></script> |
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
/*! s3mirror.js */ | |
var knox = require("knox"); | |
var http = require("http"); | |
var opts = { | |
source: 'http://www.example.com/title.png', | |
knox: { | |
endpoint: 's3-ap-northeast-1.amazonaws.com', // tokyo region | |
key: '<api-key-here>', |
OlderNewer