Skip to content

Instantly share code, notes, and snippets.

console.log('hoge');
Promise.resolve()
.then(function() {
return new Promise(function(resolve) {
setTimeout(function() {
resolve('fuga');
}, 1000);
});
})
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.26.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.26.0/mapbox-gl.css' rel='stylesheet' />
<link href='https://www.mapbox.com/base/latest/base.css' rel='stylesheet' />
<style>
<?php
class ReadLineIterator implements Iterator {
private $fp;
private $currentId = 0;
private $current = null;
public function __construct($fp) {
$this->fp = $fp;
<!DOCTYPE html>
<html>
<head lang="ja">
<meta charset="UTF-8">
<style>
body {
margin: 0;
overflow: hidden;
}
#images {
@haiiro-shimeji
haiiro-shimeji / gpg.conf
Last active December 28, 2015 23:18
edit file encrypted by gnupg
#in .gnupg/gpg.conf
group mykeys = [recipient1] [recipient2] ...
module Hoge (
fuga
) where
filter' :: (a -> Bool) -> [a] -> [a]
filter' _ [] = []
filter' p (x:xs) = (if p x then (x:) else id) $ filter' p xs
chain :: (Integral a) => a -> [a]
chain 1 = [1]
@haiiro-shimeji
haiiro-shimeji / gist:6212507
Last active December 20, 2015 23:29
Illegal Invocation in Google Chrome
TestCase("hoge", {
'test for native method': function() {
var f = console.log;
//f("hoge"); //Illegal Invocation
f.bind(console)("hoge");
},
//Native method では Illegal Invocation Error と表示されるが、
//理屈は通常オブジェクトの場合と同じ
'test': function() {
var obj = {
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>
<body>
<form id="form">
Select file to add to database: <input type="file" name="file">
<button type="submit">put into db</button>
#include <stdio.h>
int main(int argc, char** argv) {
//関数定義の前に関数利用のコードがあるとコンパイルエラー.
hoge();
}
void hoge() {
puts("hoge");
}
@haiiro-shimeji
haiiro-shimeji / test.js
Last active December 20, 2015 17:49
usage of sinon.js
TestCase("usage.sinon", {
'test mock for constructor': sinon.test(function() {
var obj = {
hoge: function(id) {
this.id = id
}
};
this.mock(obj)