Skip to content

Instantly share code, notes, and snippets.

@kurgm
kurgm / array-methods-by-reduce.md
Last active May 6, 2024 16:59
配列のメソッドをreduceとreduceRightで再現する

map メソッドを reduce メソッドで再現する

const array = [1, 2, 3];
const doubled = array.map((element) => element * 2);

const doubledByReduce = array.reduce(
  (acc, element, i) => {
    acc[i] = element * 2;
    return acc;
@kurgm
kurgm / 20221120-typescript-getter.md
Created November 19, 2022 15:40
TypeScriptでgetterに型をつける

問題

以下の makeGetter 関数に型をつけることを考える。

const makeGetter = (obj) => {
  return (key) => obj[key];
};

ただし、makeGetter が返す関数の型は、 obj の型に応じてオーバーロードされた状態になっていてほしい。つまり

type Author = {
#!/usr/bin/env python3
# usage : ./count_by_pattern.py path/to/dump_newest_only.txt < template.txt
import argparse
import os.path
import re
import sys
import time
from typing import NamedTuple, Optional, Pattern, Sequence, TextIO, Union

使い方

(ぼくはこう使っているという話ですが)

コンテストごとにディレクトリを用意する。

contest-5/
+- python.py   <- 自分が書いたコード
+- c.c         <- 自分が書いたコード
@kurgm
kurgm / 0000000000000000-writeup.md
Last active May 6, 2019 22:00
Writeup for 0000000000000000 in TSG CTF

Writeup for 0000000000000000 in TSG CTF

Problem

I took a photo at university on a sunny day~~

天気がいい日に大学で写真を撮ったよ

(with a JPEG file, attached to this writeup as problem.jpg)

@kurgm
kurgm / gwv_result.json
Last active May 10, 2024 17:15
GlyphWiki validation result data
This file has been truncated, but you can view the full file.
{"lastModified":1715360411.0,"result":{"corner":{"00":[["cbeta-31026",[5,"1:12:13:129:69:129:177"],[4,"1:2:2:128:69:174:69"]],["cdp-8747-var-002",[7,"1:12:0:122:86:122:184"],[5,"1:0:2:117:86:156:86"]],["cdp-8851-01-var-003",[3,"1:12:413:34:33:34:174"],[0,"1:2:2:33:34:91:34"]],["dkw-32463",[3,"7:12:7:46:63:46:112:46:163:19:189"],[4,"1:2:0:50:63:182:63"]],["hokke-00712",[1,"1:12:32:26:28:26:141"],[4,"1:32:32:24:28:53:28"]],["hokke-00713",[1,"1:12:32:26:27:26:140"],[4,"1:32:32:25:27:49:27"]],["hokke-00721",[4,"1:12:0:94:21:94:79"],[0,"1:2:2:89:21:165:21"]],["hokke-10953",[7,"1:12:0:93:37:93:66"],[8,"1:0:2:94:37:155:37"]],["hokke-10953",[20,"1:12:0:135:78:135:162"],[21,"1:0:2:136:78:178:78"]],["hokke-14322",[22,"1:12:0:60:141:60:167"],[23,"1:0:2:58:141:140:141"]],["hokke-17356",[1,"1:12:0:59:111:59:145"],[3,"1:0:2:58:111:135:111"]],["hokke-17436",[0,"1:12:32:108:27:108:173"],[1,"1:0:2:107:27:161:27"]],["hokke-17632",[4,"1:12:0:73:65:73:91"],[5,"1:0:2:71:65:110:65"]],["hokke-24634",[0,"6:12:7:85:21:84:44:84:59:75:
@kurgm
kurgm / 0_juggle.md
Created December 30, 2018 05:38
Solution for 35C3 CTF juggle
$ ./as.py < solution.s > solution.xml
$ nc 35.246.237.11 1 < solution.xml
Reading input document from stdin...
<?xml version="1.0" encoding="UTF-8"?><all><flag>35C3_The_chef_gives_you_his_compliments</flag></all>
@kurgm
kurgm / 3.unreadable.ts
Created September 1, 2017 03:12
TSG第3回コードゴルフ大会-Unreadable
// See also: https://github.com/hakatashi/esolang-battle/wiki/%E7%AC%AC3%E5%9B%9E%E3%82%B3%E3%83%BC%E3%83%89%E3%82%B4%E3%83%AB%E3%83%95%E5%A4%A7%E4%BC%9A-WriteUp
// I/O
const vars: { [key: number]: number } = {};
let outbuf = "";
function output(c: number) {
outbuf += String.fromCharCode(c);
}
let inbuf = "";
let inbufidx = 0;
function input() {
@kurgm
kurgm / gwhentaigana.woff
Last active August 4, 2017 06:35
GlyphWiki変体仮名グリフのテストページ
@kurgm
kurgm / cardinal.py
Last active June 8, 2019 08:23 — forked from lynn/cardinal.py
Cardinal esolang interpreter
#!/usr/bin/env python3
# usage:
# python3 cardinal.py code.cardinal < input.txt
# to show program execution, pass -d and a time delta:
# python3 cardinal.py -d 0.1 code.cardinal < input.txt
import sys
import time