Skip to content

Instantly share code, notes, and snippets.

View YusukeHirao's full-sized avatar

Yusuke Hirao YusukeHirao

View GitHub Profile
@YusukeHirao
YusukeHirao / file0.coffee
Created July 19, 2013 15:33
hashchangeイベントとscrollYの不思議な挙動 ref: http://qiita.com/YusukeHirao/items/b6848644e8c1fa95254c
$ ->
$input = $('input')
$('button').on 'click', ->
$input.val window.pageYOffset # => 現在のscrollY
$(window).on 'hashchange', ->
$input.val window.pageYOffset # => hashchangeする前のscrollYが返される
window.scrollTo 0, 0
@YusukeHirao
YusukeHirao / file0.js
Last active December 20, 2015 02:59
結果の順番を保証して、且つ『並列』でAjax通信を行う方法 ref: http://qiita.com/YusukeHirao/items/bca14c5f2fe4026fd4d7
var request = [
{ url: 'hoge00.json', params: { hoge: 123, huga: 456 } },
{ url: 'hoge01.json', params: { hoge: 246, huga: 912 } },
{ url: 'hoge02.json', params: { hoge: 369, huga: 1368 } },
{ url: 'hoge03.json', params: { hoge: 492, huga: 1824 } },
{ url: 'hoge04.json', params: { hoge: 615, huga: 2280 } }
];
var results = [];
var doneCount = 0;
@YusukeHirao
YusukeHirao / file0.coffee
Created August 8, 2013 09:28
インスタンスプロパティを作るときの注意 ref: http://qiita.com/YusukeHirao/items/79ac90e07968e7301c43
# ダメなパターン
class Foo
array: []
object: {}
foo = new Foo
foo2 = new Foo
foo.array.push 'オラァ'
interface ICustomEvent {
type:string;
data:Object;
timeStamp:number;
defaultPrevented:boolean;
}
class CustomEvent implements ICustomEvent {
data:Object;
timeStamp:number;
@YusukeHirao
YusukeHirao / file0.js
Created August 15, 2013 17:32
配列の中の最大値を取得する(NaN, null対応) ref: http://qiita.com/YusukeHirao/items/7b56ea73c86b4032a849
Math.max.apply(null, [-100, 0, 3.14, 0xFF, 1000]); // => 1000
// ※ Mathの関数のコンテキスト(applyやcallの第一引数)はなんでもいいらしい
@YusukeHirao
YusukeHirao / file0.js
Created August 15, 2013 17:57
配列の中の最大値を取得する(NaN, null対応) ref: http://qiita.com/YusukeHirao/items/15d1e3b6d91faa40ba59
Math.max.apply(null, [-100, 0, 3.14, 0xFF, 1000]); // => 1000
// ※ Mathの関数のコンテキスト(applyやcallの第一引数)はなんでもいいらしい
@YusukeHirao
YusukeHirao / file0.js
Created August 16, 2013 06:40
配列の中の最大値を取得する(NaN, null対応) ref: http://qiita.com/YusukeHirao/items/e848f5de40beaa52e002
Math.max.apply(null, [-100, 0, 3.14, 0xFF, 1000]); // => 1000
// ※ Mathの関数のコンテキスト(applyやcallの第一引数)はなんでもいいらしい
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<?php $bcBaser->title() ?>
<meta name="description" content="<?php echo $bcBaser->getDescription() ?>">
<meta name="keywords" content="<?php echo $bcBaser->getKeywords() ?>">
</head>
@YusukeHirao
YusukeHirao / Define
Created August 28, 2013 11:13
文字まとめ for JS(正規表現) ref: http://qiita.com/YusukeHirao/items/099ab93bdbf47f0d7a02
// [ !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]
var SIGN_CHARS = '\\u0020-\\u002F\\u003A-\\u0041\\u005B-\\u0061\\u007B-\\u007E';
// 半角数字
var DIGIT_CHARS = '0-9';
// 半角英字
var ALPHA_CHARS = 'A-Za-z';
// [ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~]
@YusukeHirao
YusukeHirao / JAVA
Created September 5, 2013 08:49
HTML5 time要素のフォーマット ref: http://qiita.com/YusukeHirao/items/6140a58a1dd1d5d60a7c
new SimpleDateFormat("yyyy-MM-dd HH:mm");