Skip to content

Instantly share code, notes, and snippets.

View st98's full-sized avatar

st98 st98

View GitHub Profile
@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 / a.ml
Last active August 29, 2015 14:13
OCaml 入門。
print_int (( * ) ((+) 1 2) ((+) 2 3));;
@st98
st98 / o.ml
Created January 10, 2015 22:21
OCaml 入門。
let (+) = ( * ) in Printf.printf "%B" (3 * 5 = 15);
@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 / face.ml
Last active August 29, 2015 14:13
OCaml 入門。顔文字。
('A';) (*´ω`*)
@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 / arrow.js
Last active August 29, 2015 14:13
アロー関数。挙動を確かめたかった。
typeof (()=>{})(); // => 'undefined'
typeof (()=>({}))(); // => 'object'
/**/
(()=>this)(); // => Window
(()=>this).call(1); // => 1
(()=>((()=>this)())).call(1); // => Window
<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="style.css">
<title>index.html</title>
</head>
<body>
<h1>index.html</h1>
@st98
st98 / regexp.js
Last active August 29, 2015 14:13
/[\s\S]+/
/.+/.test('\n'); // => false
/[\s\S]+/.test('\n'); // => true
'/*hoge\n*/fuga*/'.replace(/\/\*[\s\S]*?\*\//g, ''); // => 'fuga*/'
document.body.innerHTML = document.body.innerHTML.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\n{2,}/g, '\n\n');
@st98
st98 / r.c
Last active August 29, 2015 14:13
./r 1 2:10
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[]) {
char *s;
int i, n;
for (i = 1; i < argc; i++) {
n = (strchr(argv[i], ':')) ? strtol(s + 1, (char**) NULL, 10) : 32;
srand(strtol(argv[i], (char**) NULL, 10));
for (;n--;) {