This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Test 1: raw EventTarget'); | |
const et = new EventTarget(); | |
// add handler of 'foo' event | |
et.addEventListener('foo', (e)=> { | |
console.log('foo event emitted:', e.detail); | |
}); | |
// dispatch 'foo' event | |
et.dispatchEvent(new CustomEvent('foo', { detail: 123 })); | |
console.log('Test 2: subclass of EventTarget'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* perm(arr, prefix=[]){ | |
if (arr.length <= 1){ | |
yield [...prefix, ...arr]; | |
return; | |
} | |
for (const [i, x] of arr.entries()) { | |
const arr2 = [...arr.slice(0, i), ...arr.slice(i+1)]; | |
yield* perm(arr2, [...prefix, x]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env node | |
'use strict'; | |
const fs = require('fs'); | |
const path = require('path'); | |
const crypto = require('crypto'); | |
const child_process = require('child_process'); | |
// parse args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
CHAP= | |
ALLFLAG=0 | |
while getopts ac: OPT | |
do | |
case $OPT in | |
a) ALLFLAG=1;; | |
c) CHAP=$OPTARG;; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(()=>{ | |
const svg = document.querySelector('svg'); | |
const svg2 = cl(svg); | |
const gs = svg2.querySelectorAll('g'); | |
for (let i=0; i < gs.length; i++){ | |
const g = gs[i]; | |
const cl = g.getAttribute('class'); | |
if (cl){ | |
const c = g.getAttribute('class').split(' '); | |
if (c.some(x=>/__states$/.test(x))){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const PORT = 8080; | |
const net = require('net'); | |
const srv = net.createServer(sock=>{ | |
console.log('New connection'); | |
sock.on('data', buf=>{ | |
console.log('---------- data start ----------'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Rank = Int | |
data Jobname = Human | Diviner | Werewolf Rank deriving (Eq,Show) | |
data State=State Jobname Bool deriving (Show) | |
type Plid=String | |
type Pattern = (Plid,State) | |
-- 配列を一つ抜く | |
cutoff :: Int -> [a] -> (Maybe a,[a]) | |
cutoff _ [] = (Nothing,[]) | |
cutoff n list = case (splitAt n list) of (mae, []) -> (Nothing,mae) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Rank = Int | |
data Jobname = Human | Diviner | Werewolf Rank deriving (Eq,Show) | |
data State=State Jobname Bool deriving (Show) | |
type Plid=String | |
type Pattern = (Plid,State) | |
-- 配列を一つ抜く | |
cutoff :: Int -> [a] -> (Maybe a,[a]) | |
cutoff _ [] = (Nothing,[]) | |
cutoff n list = case (splitAt n list) of (mae, []) -> (Nothing,mae) |
NewerOlder