Skip to content

Instantly share code, notes, and snippets.

View st98's full-sized avatar

st98 st98

View GitHub Profile
@st98
st98 / arrow.js
Last active August 29, 2015 14:13
アロー関数。挙動を確かめたかった。
typeof (()=>{})(); // => 'undefined'
typeof (()=>({}))(); // => 'object'
/**/
(()=>this)(); // => Window
(()=>this).call(1); // => 1
(()=>((()=>this)())).call(1); // => Window
@st98
st98 / box-sizing-1.html
Last active August 29, 2015 14:13
box-sizing の挙動を確かめたかった。
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>box-sizing-1</title>
<style>
* {
margin: 0;
padding: 0;
font-family: Consolas;
@st98
st98 / face.ml
Last active August 29, 2015 14:13
OCaml 入門。顔文字。
('A';) (*´ω`*)
@st98
st98 / l5.ml
Last active April 21, 2019 17:03
OCaml 入門。Lesson 5。http://try.ocamlpro.com/
(* Step 4 *)
let xy =
let x = 'x' and y = 'y' in x :: [y]
let ab =
let a = 'a' and b = 'B' in a :: [Char.lowercase b]
let up = Char.uppercase in
let big_xy = List.map up xy and
big_ab = List.map up ab in
@st98
st98 / o.ml
Created January 10, 2015 22:21
OCaml 入門。
let (+) = ( * ) in Printf.printf "%B" (3 * 5 = 15);
@st98
st98 / a.ml
Last active August 29, 2015 14:13
OCaml 入門。
print_int (( * ) ((+) 1 2) ((+) 2 3));;
@st98
st98 / replacer.coffee
Last active August 29, 2015 14:13
不思議な JSON.stringify の第 2 引数。
# 参考: ネイティブ JSON を使う
# (https://developer.mozilla.org/ja/docs/Using_native_JSON#replacer_.E3.83.91.E3.83.A9.E3.83.A1.E3.83.BC.E3.82.BF)
obj =
a: 12
b: 'hoge'
c: true
d: undefined
e: 'fuga'
f: [12, 'piyo', true]
@st98
st98 / ip.js
Last active August 29, 2015 14:13
IP アドレスがなんか、こう。
// f(2130706433) === '127.0.0.1';
function f(n) {
return [
(n & 0xff << 24) >> 24,
(n & 0xff << 16) >> 16,
(n & 0xff << 8) >> 8,
n & 0xff
].map(String).join('.');
}
@st98
st98 / bf2js.coffee
Last active August 29, 2015 14:13
Brainf*ck を JavaScript に変換するヤツ。
parse = (prog) ->
prog = prog.replace /[^><\[\],.+-]/g, ''
if prog.length is 0
return []
c = 0
result = (prog.match /([+]+|[-]+|[>]+|[<]+|.)/g).map (m) ->
if m[0] is '['
c++
@st98
st98 / composition.ml
Last active August 29, 2015 14:13
OCaml 入門。
3 |> fun x -> x * 2 |> succ;; (* => 7 *)
succ @@ (fun x -> x * 2) @@ 3;; (* => 7 *)