Skip to content

Instantly share code, notes, and snippets.

@aita
aita / CSV.hs
Created November 18, 2018 15:13
module CSV
( CSV
, Record
, Field
, csv
, parseCSV
, parseCSVFromFile
, parseCSVTest
, printCSV
)
[
// replace ctrl by meta
{"key":"meta+end","command":"cursorBottom","when":"textInputFocus"},
{"key":"meta+shift+end","command":"cursorBottomSelect","when":"textInputFocus"},
{"key":"meta+home","command":"cursorTop","when":"textInputFocus"},
{"key":"meta+shift+home","command":"cursorTopSelect","when":"textInputFocus"},
{"key":"meta+a","command":"editor.action.selectAll","when":"textInputFocus"},
{"key":"meta+i","command":"expandLineSelection","when":"textInputFocus"},
{"key":"meta+shift+z","command":"redo","when":"textInputFocus && !editorReadonly"},
{"key":"meta+y","command":"redo","when":"textInputFocus && !editorReadonly"},
@aita
aita / pl0.py
Last active November 24, 2018 15:52
import re
import io
import sys
from collections import namedtuple
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
import random
class TreapNode:
__slots__ = ['parent', 'value', 'priority', 'left', 'right']
def __init__(self):
self.parent = None
self.value = None
self.priority = None
def binary_search(a, x, low, high):
while low < high:
mid = (low + high) // 2
if x < a[mid]:
high = mid
else:
low = mid + 1
return low
import math
def insertion_sort(a):
for i in range(1, len(a)):
tmp = a[i]
j = i
while j > 0 and a[j - 1] > tmp:
a[j] = a[j - 1]
j -= 1
import argparse
import logging
import boto3
def main():
parser = argparse.ArgumentParser(description="ec2 private IP describer")
parser.add_argument("vpc_id", nargs="+", help="vpc ids")
args = parser.parse_args()
@aita
aita / nfa.py
Last active June 27, 2018 01:00
from collections import namedtuple
NFA = namedtuple('NFA', 'transition initial accept')
empty = "empty"
def lookup(automata, state, s):
x = [(i, empty) for i in automata.transition.get((state, empty), [])]
if not s:
@aita
aita / dfa.ml
Last active June 18, 2018 14:00
open Core
type ('a, 'b) dfa = {
alphabet: 'a list;
transition: ('b * 'a * 'b) list;
initial: 'b;
accept: 'b list;
}
let alphabet = [0; 1;]
@aita
aita / HowToSDL2WithRust.md
Last active December 17, 2023 15:25
SDL2の手引き with Rust