Skip to content

Instantly share code, notes, and snippets.

View hrkd's full-sized avatar
🎯
Focusing

hrkd

🎯
Focusing
View GitHub Profile
@hrkd
hrkd / centering.css
Created May 2, 2013 10:16
拾いモノ
.centering {
position: absolute;
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script data-main="js/app" src="./js/require.js"></script>
</head>
<body>
</body>
</html>
require([
"somefile"
],function(){
//init function
});
@hrkd
hrkd / scss_for_loop.sass
Last active December 17, 2015 08:48
sassのループがすげべんり。
$ary : "a", "b", "c"
@for $i from 1 through length($ary)
$selecter : "id_"+nth($ary, $i)
div.#{$selecter}
@hrkd
hrkd / prototype.js
Created May 15, 2013 10:12
ちょっとずつ育てる。
Object.prototype.getId = function(id){
return document.getElementById(id);
};
Object.prototype.getTag = function(tag){
return document.getElementsByTagName(tag);
};
Object.prototype.addChild=function(tag){
this.appendChild(document.createElement(tag));
return this.childNodes;
};
@hrkd
hrkd / getParm.js
Last active December 17, 2015 09:58
GETパラメータ取得
location.__proto__.getParm = (function(){
if(this.search){
var query = [];
var tmpQ = [];
query = location.search.replace("?","").split("&");
for(var i=0;i<query.length;i++){
tmpQ[query[i].split("=")[0]] = query[i].split("=")[1];
}
return tmpQ ? tmpQ : undefined;
@hrkd
hrkd / add_removeEvent.js
Created May 16, 2013 10:21
イベントの登録・解除をjQueryぽく。
Object.prototype.addEvent=function(type,func){
var tmpFnc = func;
eval("var "+type.split(".")[1]+"=tmpFnc");
this.addEventListener(type.split(".")[0], eval(type.split(".")[1]), false);
};
Object.prototype.removeEvent=function(type){
this.removeEventListener(type.split(".")[0], eval("this."+type.split(".")[1]), false);
};
//target.addEvent("click.name",function(){});
@hrkd
hrkd / sprite.sass
Last active December 17, 2015 10:39
sprite使い方
@import "compass/utilities/sprites";
/*setting*/
//$nav-layout:smart
$nav-spacing: 10px
/*init*/
@import "nav/*.png"
/*usage*/
require.config({
baseUrl:"js",
paths:{}
});
require(
//import module
[
"src/a",
"src/b",
@hrkd
hrkd / if.js
Created May 30, 2013 09:56
三項演算子
a = (a>b)? b : c ;