Skip to content

Instantly share code, notes, and snippets.

@kols
kols / Doppelgänger
Created May 21, 2011 12:30
关于『Doppelgänger』
(游戏 Persona 2)片头文字引用自海涅的诗『Der Doppelgänger』远山一行译的日文版
静けき夜 巷は眠る
この家に 我が恋人はかつて住み居たり
彼の人は この街すでに去りませど
そが家は いまもここに残りたり
一人の男そこに立ち 高きを見やり
手は大いなる苦悩と闘うと見ゆ
@kols
kols / LICENSE.txt
Created September 28, 2011 15:30 — forked from p01/LICENSE.txt
Sudoku Solver in 140bytes
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mathieu 'p01' Henri <http://www.p01.org/releases/>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@kols
kols / play_flash.rb
Created October 16, 2011 11:00
Play the flash video loading in your browser using a movie player
#!/usr/bin/env ruby
# Play the flash video loading in your browser using a movie player
PLAYER = 'mplayer -zoom' # your favorite player
def get_flash_file_path
pat = %r(^.*?(\d+).*?(\d+).*$)
`lsof /tmp | grep Flash` =~ pat
pid, fd = $~[1], $~[2]
"/proc/#{pid}/fd/#{fd}"
@kols
kols / conv_hexstr.rb
Created June 26, 2012 18:22
Convert hex string to ruby string
#!/usr/bin/env ruby
def convert_hexstr(str, start=0, index=nil)
index ||= str.length
hexstr = str[start, index]
ar = []
hexstr.scan(/\\x../).each do |s|
ar << s.gsub('\\', '0').to_i(16)
end
ar.empty? ? str : ar.pack('C*').force_encoding('utf-8')
@kols
kols / django_ext.py
Created September 14, 2012 06:37
ipython django extension
"""If we're working with a Django project, set up the environment
"""
import os
def load_ipython_extension(ipython):
try:
import django
except ImportError:
return
@kols
kols / compress.py
Created December 11, 2012 04:20
Compress and upload image using PIL and fabric
import argparse
import os
import sys
from PIL import Image
OUTPUT_DIR = 'output'
OUTPUT_SIZE = (3000, 1500)
@kols
kols / distance.py
Last active December 14, 2015 18:49
Distance calculation
import math
EARTH_RADIUS = 6378137. # in meters
def calculate_distance(lat1, lng1, lat2, lng2):
if not all((lat1, lng1, lat2, lng2)):
return
a = math.radians(lat1) - math.radians(lat2)
@kols
kols / ejabberd.plist
Last active December 16, 2015 05:09
launchd.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyL
ist-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
@kols
kols / index.coffee
Created July 11, 2013 15:08
upyun node.js lib concept
request = require "request"
url = require 'url'
fs = require 'fs'
path = require 'path'
crypto = require 'crypto'
UPYUN_API_HOSTS =
AUTO: "v0.api.upyun.com"
TELECOM: "v1.api.upyun.com"
NETCOM: "v2.api.upyun.com"
@kols
kols / master.vim
Created January 30, 2014 16:35 — forked from gmccreight/master.vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)