Skip to content

Instantly share code, notes, and snippets.

View piyonishi's full-sized avatar
On target

Yusuke Nakanishi piyonishi

On target
View GitHub Profile
@piyonishi
piyonishi / closure.js
Created May 19, 2015 15:16
クロージャ
function newCounter() {
var i = 0;
return function() {
i = i + 1;
return i;
}
}
var c1 = newCounter();
var c2 = newCounter();
console.log(c1()); // 1
// 命令形
var total = 0,
num = 0,
ave,
i;
for (i = 1; i <= 10; i++) {
total += i;
num++;
}
@piyonishi
piyonishi / open_browser.sh
Created September 22, 2014 04:59
ブラウザ起動
open -a Firefox
open -a Safari
open -a Google\ Chrome
@piyonishi
piyonishi / git_branch_delete.sh
Last active August 29, 2015 14:06
git branchの削除
git branch -a
git branch -d branch-name
or
git branch -D branch-name
git push origin :branch-name
unko = setTimeout ->
console.log("ok")
, 1000
&:after{
content:'';
display: block;
@include position(absolute, null null 0px 0px);
width: 100%;
height: 60px;
@include background(linear-gradient(rgba(#fff,0), rgba(#fff,1)));
}
var obj = {
"uri": "http://example.com/",
"title": "title",
"author": "hogenishi",
"x": 20,
"y": 65,
"width": 200,
"height": 150,
"version": 0.1.1
};
@piyonishi
piyonishi / delegate_event.js
Last active December 29, 2015 07:19
イベントの委譲
var list = document.getElementById("list");
list.addEventListener("click", function(e) {
if (e.target.tagName == "LI") {
e.target.style.color = "#f00";
return false;
}
}, false);
list.innerHTML = "<li>test</li>";
function Item() {
this.initialize.apply(this, arguments);
}
Item.prototype = {
initialize: function(price) {
this.price = price;
},
showPrice: function() {
alert(this.price);
}
var Item = (function () {
function Item(price) {
this.price = price;
}
Item.prototype.showPrice = function () {
alert(this.price);
};
return Item;
})();
var i = new Item(200);