Skip to content

Instantly share code, notes, and snippets.

Avatar

Kosuke Okumura kokumura

View GitHub Profile
@kokumura
kokumura / jupyter-headers.py
Created Nov 18, 2016
Jupyter notebook の最初のセルによく書くやつ
View jupyter-headers.py
%matplotlib inline
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (10, 6)
import pandas as pd
import numpy as np
View .screenrc
escape ^Tx
bind n eval 'next'
bind p eval 'prev'
defscrollback 10000
# enable 256 color
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# don't resize terminal width when re-attached.
@kokumura
kokumura / command_not_found.zsh
Last active Apr 26, 2017
command_not_found
View command_not_found.zsh
# add following line to end of your ~/.zshrc file and type "hoge" on command line
command_not_found_handler(){echo 44CAIOOAgOOAgOOAgCDjgIDjgIAg44CA77y/77y/77y/XwrjgIDjgIDjgIDjgIDjgIAg77yPIO+8vOOAgOOAgO+8j++8vOOAgO+9t+++mO+9rwog44CA44CA44CA44CA77yP44CA77yI44O877yJIOOAgO+8iOODvO+8ie+8vOOAgOOAgOOAgOOAgO+8nOOAjHt944CNCuOAgOOAgOOAgOOAgO+8j+OAgOOAgOKMkiDvvIhfX+S6ul9f77yJICDijJIgCuOAgOOAgOOAgOOAgHzjgIDjgIAg44CA44CA44CAfHLilKwtfOOAgOOAgOOAgHwK44CA44CA44CA44CAIO+8vOOAgOOAgOOAgOOAgCBg44O84oCZwrTjgIDjgIAg77yPCuOAgOOAgOOAgOOAgOODjuOAgOOAgOOAgOOAgOOAgOOAgOOAgOOAgOOAgOOAgO+8vArjgIAg77yPwrTjgIDjgIDjgIDjgIDjgIDjgIDjgIDjgIDjgIDjgIDjgIDjgIDjg70K44CAfOOAgOOAgOOAgOOAgO+9jOOAgOOAgOOAgOOAgOOAgOOAgOOAgOOAgOOAgOOAgO+8vArjgIDjg73jgIDjgIDjgIAgLeS4gOKAneKAneKAneKAnX5+772AYOKAmeOAgOOAgOOAgC3kuIDigJ3igJ3igJ3igJnjg7wt772kLgrjgIDjgIDjg70g77y/77y/77y/77y/KOKMkiko4oySKeKMkinjgIAp44CA44CAKOKMku+8vyjijJIp4oySKeKMkikpCgrjgIDjgIDjgIDjgIAg44CA44CA44CAIOOAgO+8v++8v++8v18K44CA44CA44CA44CA44CA44CA44CAIO+8j1/jg44g44CA44O9772kX++8vArjgIDvvpDjgIDvvpDjg
View fillram.c
#include <stdlib.h>
#include <unistd.h>
void main(){
while(malloc(100*1024*1024));
while(1)sleep(60);
}
View tty-exec.py
#!/usr/bin/env python
import subprocess, pty, os, sys
def _safe_read(m):
try:
return os.fdopen(m,"r").read()
except IOError:
return ''
sout_m, sout_s = pty.openpty()
@kokumura
kokumura / sqlite-ex.py
Created Apr 22, 2016
SQLiteにPythonでUDFを追加するやつ
View sqlite-ex.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sqlite3
import numpy as np
class Median:
def __init__(self):
self.values = []
def step(self, value):
self.values.append(value)
View serialize_sparse_matricies.py
# -*- coding: utf-8 -*-
import scipy.sparse as sps
import numpy as np
from StringIO import StringIO
def _np_savez(compressed=False, *args, **kwds):
sio = StringIO()
if compressed:
np.savez_compressed(sio, *args, **kwds)
else:
@kokumura
kokumura / gist:76455b2511e18ce9237a
Created Feb 10, 2016
テンションが上がるワンライナー
View gist:76455b2511e18ce9237a
ls | perl -pe 's/([aiueo])/\1\1\1/ig;s/$/!!!/'
@kokumura
kokumura / xljj.py
Last active Mar 18, 2021
xlsxファイルの各セルにjinja2テンプレートを適用するやつ
View xljj.py
#!/usr/bin/env python
# -*- coding:utf8 -*-
import optparse
import sys
from contextlib import closing
import yaml
import jinja2
from openpyxl import load_workbook
@kokumura
kokumura / jj2.py
Last active Dec 3, 2015
Command line Jinja2 renderer
View jj2.py
#!/usr/bin/env python
# -*- coding:utf8 -*-
import sys, optparse
import jinja2
def main(args, params):
encoding = params.encoding
tpl = jinja2.Template(sys.stdin.read().decode(encoding))
param = dict()
ex_args = list()