Skip to content

Instantly share code, notes, and snippets.

View YusukeHirao's full-sized avatar

Yusuke Hirao YusukeHirao

View GitHub Profile
@YusukeHirao
YusukeHirao / 1.html
Created September 23, 2012 06:31
Pattern of HTML5
<input type="text" name="hoge" pattern="abc">
@YusukeHirao
YusukeHirao / file0.js
Created October 10, 2012 10:37
可変長引数で渡したコールバック関数を$.Deferred().pipe()で直列処理 ref: http://qiita.com/items/03364b0e82975a03dec6
$.Deferred().pipe(function () {
// なんらかの処理
// ajaxとかanimateとかdeferredとかのpromiseしたjQueryオブジェクトを返す。
// (※それらの処理がresolveされた時点で次のpipeに登録した関数が実行される)
return promised;
}).pipe(function () {
// なんらかの処理
// ajaxとかanimateとかdeferredとかのpromiseしたjQueryオブジェクトを返す。
// (※それらの処理がresolveされた時点で次のpipeに登録した関数が実行される)
return promised;
@YusukeHirao
YusukeHirao / file0.txt
Created November 19, 2012 14:54
配列を操作するjQueryのユーティリティ関数まとめ ref: http://qiita.com/items/8d1089c2bf86e7dc05ef
// ECMA5から使えるforEachメソッドとはvalueとindexの引数の順番が逆
[1, 2, 3].forEach(function (value, index, context) {
// loop
});
@YusukeHirao
YusukeHirao / file0.txt
Created November 22, 2012 05:28
UAを参照しないでブラウザを判定する方法 ref: http://qiita.com/items/2b97592826fa2d480b70
var w = window,
d = w.document,
dE = d.documentElement,
unavailableQuerySelector = isUndefined(d.querySelector),
unavailablePerformance = isUndefined(w.performance),
isIE = !isUndefined(d.uniqueID),
ltIE6 = isIE && isUndefined(dE.style.maxHeight),
ltIE7 = isIE && unavailableQuerySelector,
ltIE8 = isIE && isUndefined (d.getElementsByClassName),
ltIE9 = isIE && isUndefined(w.Worker),
@YusukeHirao
YusukeHirao / support.js
Last active December 11, 2015 12:38
ブラウザサポート
var Support = (function (w) {
var d = w.document,
dE = d.documentElement,
notIn = function (property) {
return property === void 0;
},
disavailableAddEventListener = notIn(w.addEventListener);
availablePosStyle = !notIn(dE.style.posTop);
isTouchable = !notIn(w.ontouchstart) || !!w.navigator.msPointerEnabled;
@YusukeHirao
YusukeHirao / file0.coffee
Created May 13, 2013 14:45
画像をコンテナに合わせて拡縮させる計算方法 ref: http://qiita.com/items/785e331be62f15db0fa4
# 画像の情報
imgWidth = $img.width()
imgHeight = $img.height()
imgAspectRatio = containerWidth / containerHeight
# コンテナの情報
containerWidth = $container.width()
containerHeight = $container.height()
containerAspectRatio = containerWidth / containerHeight
# 画像の拡縮率の算出
# アス比が1以上なら横長/1以下なら縦長
# nodeやenvのPATHを通しておく
PATH=/usr/local/bin:/bin:/usr/bin:$PATH
export PATH
for f in "$@"
do
dir=`dirname "$f"`
file=`basename "$f"`
name=`basename "$f" .js`
cd $dir
selector {
/* 画像パス スライス リピート の順であれば安全 */
border-image: url(hoge.png) 1 1 1 1 stretch;
/* ボーダーの太さは別に記述する */
border-width: 5px 5px 5px 5px;
}
@YusukeHirao
YusukeHirao / file0.coffee
Created May 24, 2013 07:42
Backbone.jsをCoffeeで書いた時のEventsの継承の仕方 ref: http://qiita.com/items/14050e79df746b51d28c
# model
class Hoge extends Backbone.Model
constuctor: ->
super
@set fuga: 'fuga'
# View
class HogeView extends Backbone.View
constuctor: ->
@model = new Hoge
@YusukeHirao
YusukeHirao / GistBox
Created June 18, 2013 09:00
GistBox.test
do (w = @, $ = @jQuery) ->
# GitBoxTest
$('#hoge').on 'click', ->
$(@).next('.fuga').slideToggle 200, 'linear', ->
console?.log? 'slide'