Skip to content

Instantly share code, notes, and snippets.

@utgwkk
utgwkk / build-vim.sh
Created July 23, 2017 01:43
Vim install script
#!/bin/sh
set -e
PREFIX=/usr/local
SRC=$PREFIX/src
VIMDIR=$SRC/vim
PROC=`nproc`
CONFIGURE_OPTIONS="--prefix=$PREFIX --with-features=huge --enable-fail-if-missing \
--enable-perlinterp --enable-pythoninterp --enable-python3interp --enable-luainterp --enable-terminal"
/home/utgw/reimuchan/vendor/bundle/ruby/2.3.0/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:202: [BUG] Segmentation fault at 0x00000000000000
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0007 p:---- s:0033 e:000032 CFUNC :release_machine
c:0006 p:0038 s:0030 e:000029 RESCUE /home/utgw/reimuchan/vendor/bundle/ruby/2.3.0/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:202
c:0005 p:0432 s:0027 e:000026 METHOD /home/utgw/reimuchan/vendor/bundle/ruby/2.3.0/gems/eventmachine-1.0.9.1/lib/eventmachine.rb:226
c:0004 p:0074 s:0020 E:000228 METHOD /home/utgw/reimuchan/vendor/bundle/ruby/2.3.0/gems/tweetstream-2.6.1/lib/tweetstream/client.rb:403
c:0003 p:0039 s:0014 e:000013 METHOD /home/utgw/reimuchan/vendor/bundle/ruby/2.3.0/gems/tweetstream-2.6.1/lib/tweetstream/client.rb:143
c:0002 p:0465 s:0008 E:000ed0 EVAL reimuchan.rb:177 [FINISH]
@utgwkk
utgwkk / nowplaying_itunes.py
Last active March 26, 2017 08:55
Tweet #nowplaying of iTunes on Windows. Install pywin32 from https://sourceforge.net/projects/pywin32/ before using.
# coding: utf-8
import win32com.client
import webbrowser
from urllib.parse import quote
def get_itunes_client():
return win32com.client.Dispatch("iTunes.Application")
@utgwkk
utgwkk / next_premium_friday.py
Created February 26, 2017 06:09
今日または指定された日を起点とした次のプレミアムフライデーの日付を取得する
from datetime import date, timedelta
def next_premium_friday(offset=None):
if offset is None:
offset = date.today()
if offset.month == 12:
end_of_month = date(offset.year + 1, 1, 1) - date.resolution
else:
@utgwkk
utgwkk / tripcode.py
Created February 25, 2017 11:34
Generate tripcode
# coding: shift-jis
import re
import string
from crypt import crypt
from base64 import b64encode
from hashlib import sha1
def generate_trip(tripstr):
'''
@utgwkk
utgwkk / thdic2skk.py
Last active November 28, 2018 08:23
http://9lab.jp/works/dic/th-dic.php の Google 日本語入力向けの東方Project IME辞書をSKK用の辞書に変換するスクリプト
#!/usr/bin/python
# coding: utf-8
# http://9lab.jp/works/dic/th-dic.php の Google 日本語入力向けの東方Project IME辞書を
# SKK用の辞書に変換するスクリプト
# Usage:
# python thdic2skk.py < thdic-r6-0-総合.txt > SKK-JISYO.touhou.utf8
from __future__ import print_function
import sys
@utgwkk
utgwkk / buttonpuzzle.cpp
Created December 17, 2016 12:07
ボタンを押すとそのボタンと周囲4近傍のボタンの ON/OFF が反転して,全てのボタンを ON にすればクリアのあのゲームを解くやつ
#include <iostream>
#include <queue>
#include <vector>
#include <array>
#include <map>
#include <bitset>
#include <utility>
#include <algorithm>
const int inf = 1e9;
using state = std::pair<int, int>;
@utgwkk
utgwkk / app.py
Last active December 2, 2016 03:27
import sys
from wsgiref.simple_server import make_server
def not_found(env):
request_path = env['PATH_INFO']
status = '404 Not Found'
headers = [('Content-Type', 'text/plain; charset=utf-8')]
body = 'Not Found: {}'.format(request_path)
% cat .zsh_history | cut -d";" -f2 | cut -d" " -f1 | sort | uniq -c | sort -nr | head -20
420 git
299 vim
223 ls
198 cd
165 cat
154 python
141 sudo
129 rm
106 wget
@utgwkk
utgwkk / dig.py
Created November 4, 2016 08:22
dig implementation in Python
def dig(dic, *keys):
keys = list(keys)
if isinstance(keys[0], list):
return dig(dic, *keys[0])
if isinstance(dic, dict) and keys[0] in dic or \
isinstance(dic, list) and keys[0] < len(dic):
if len(keys) == 1:
return dic[keys[0]]
return dig(dic[keys[0]], *keys[1:])
return None