Skip to content

Instantly share code, notes, and snippets.

Avatar

Jinhwan Choi jinhwanlazy

View GitHub Profile
@jinhwanlazy
jinhwanlazy / filter_algospot.py
Last active Aug 29, 2015
filter problems solved with python but not by me from algospot.com
View filter_algospot.py
import requests
from bs4 import BeautifulSoup as bs
from itertools import chain, filterfalse
langs = {'python': ['(py)', '(pypy)', '(py3)'],
'ruby': ['(rb)']}
def get_pids(maxpage=17):
@jinhwanlazy
jinhwanlazy / SMQT.py
Created Mar 15, 2016
Successive Mean Quantization Transtform. Straightforward recursive implementation.
View SMQT.py
def SMQT(data, level):
ret = [0] * len(data)
def MQU(idx, depth):
if depth == 0 or not idx:
return
mean = sum(data[i] for i in idx) / len(idx)
D0, D1 = [], []
for i in idx:
(D0 if data[i] <= mean else D1).append(i)
@jinhwanlazy
jinhwanlazy / keyboard.jscad
Last active Aug 10, 2016
3d printable mechanical keyboard, powered by openascad. still work in progress.
View keyboard.jscad
layout = [
["","","","","","","","","","","","","","",""],
[{w:1.5},"","","","","","","","","","","","","",{w:1.5},""],
[{w:1.75},"","","","","","","","","","","","",{w:2.25},""],
[{w:2.25},"","","","","","","","","","","",{w:1.75},"",""],
[{x:1.5},"",{w:1.5},"",{w:6},"",{w:1.5},"",""]
];
split_pos = [
[5, 4.5, 4.75, 4.25, 4.75],
@jinhwanlazy
jinhwanlazy / tmux-ambiguous-width-cjk.patch
Created Sep 17, 2016 — forked from waltarix/tmux-do-not-combine-utf8.patch
tmux: Fix a problems with displaying Ambiguous-width, Japanese Dakuten and Handakuten signs.
View tmux-ambiguous-width-cjk.patch
diff --git a/utf8.c b/utf8.c
index ad99edc..0d803d3 100644
--- a/utf8.c
+++ b/utf8.c
@@ -343,7 +343,200 @@ static struct utf8_width_entry utf8_width_table[] = {
{ 0xe0100, 0xe01ef, 0, NULL, NULL },
{ 0x100000, 0x10fffd, 0, NULL, NULL },
};
+
+/* Sorted, generated by 'uniset +WIDTH-A +WIDTH-F +WIDTH-W -cat=Me -cat=Mn -cat=Cf c'
@jinhwanlazy
jinhwanlazy / gist:e80e934445d4a2e4a95552b2f2efce5a
Created Dec 26, 2016
입력모드에서 빠져나올 때 입력기를 자동으로 영어로 바꿈.
View gist:e80e934445d4a2e4a95552b2f2efce5a
" auto reset input method
function! g:SetImeToEnglish()
let s:current_input_method = system("ibus engine")
if s:current_input_method !~ "xkb:us::eng"
let s:ret = system("ibus engine xkb:us::eng")
endif
endfunction
let s:ibus_version = system("ibus version")
if s:ibus_version =~ "IBus 1.5"
@jinhwanlazy
jinhwanlazy / race_plot.py
Last active Feb 15, 2017
typeracer data plotter
View race_plot.py
"""
Plots race TypeRacer history.
Make sure you have permission to read the file
usage:
$ python3 race_plot.py race_data.csv [day, week, month or year]
"""
import sys
import matplotlib.pyplot as plt
import pandas as pd
@jinhwanlazy
jinhwanlazy / spiral_gcode.py
Created Feb 24, 2017
The very basic spiral toolpath generator
View spiral_gcode.py
from mecode import GMatrix
import numpy as np
e = 0.00001
inch = 25.4
unit = 19.05
feedrate = 200
tool_diameter = 1
overlap = 0.5
View gist:681e579e01aa2663b2920e3e4456f26f
BUILDDIR = build
SRCDIR = src
OPENSCAD:=$(shell type -p openscad || echo /Applications/OpenSCAD.app/Contents/MacOS/OpenSCAD)
VPATH = $(SRCDIR):$(BUILDDIR)
STL_TARGETS = $(patsubst $(SRCDIR)/%.scad,$(BUILDDIR)/%.stl,$(wildcard $(SRCDIR)/*.scad))
.PHONY: all clean
View race_plot_scatter.py
import sys
import matplotlib.pyplot as plt
import pandas as pd
from matplotlib import cm
from datetime import datetime, timezone, timedelta
plt.style.use('ggplot')
ticks_format = {
'day': '%b, %-d',
'week': '%b, %-d',
'month': '%b',
@jinhwanlazy
jinhwanlazy / bos_profit.py
Last active Sep 6, 2017
Boscoin rewards calculator
View bos_profit.py
"""
Calculates expected number of rewards by operating a BOScoin node.
Note that this is speculation, since we don't know how many frozen units/nodes
will be until genesis. Also note that this script is not applying increasing
number of total supply. However, roughly saying, rewards will not be changed
while every node operators, frozen coin holders try to reinvest all their rewards.
Becasue rewards are distributed by shares.
"""
class RewardCalculator:
def __init__(self, initial_rewards, decrease_rate, decrease_cycle, end):