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
l = [1, 1, 2, 2, 3]
distinct_result = list()
map(lambda x: not x in distinct_result and distinct_result.append(x), l)
print(distinct_result)
#[1, 2, 3]
distinct_result = list(set(l))
print(distinct_result)
#[1, 2, 3]
// 1つの場合
function preloader() {
heavyImage = new Image();
heavyImage.src = "sample.jpg";
}
// 複数ある場合
function preloader() {
// counter
var i = 0;
# 整数を割り算すると、デフォルトで小数点以下が切り捨てになる
12 / 26
#0
float(12) / 26
#0.46153846153846156
12 * 1.0 / 26
#0.46153846153846156
var Item = (function () {
function Item(price) {
this.price = price;
}
Item.prototype.showPrice = function () {
alert(this.price);
};
return Item;
})();
var i = new Item(200);
function Item() {
this.initialize.apply(this, arguments);
}
Item.prototype = {
initialize: function(price) {
this.price = price;
},
showPrice: function() {
alert(this.price);
}
@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>";
var obj = {
"uri": "http://example.com/",
"title": "title",
"author": "hogenishi",
"x": 20,
"y": 65,
"width": 200,
"height": 150,
"version": 0.1.1
};
&: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)));
}
unko = setTimeout ->
console.log("ok")
, 1000
@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