Skip to content

Instantly share code, notes, and snippets.

@reusee
reusee / gist:93bc025719ec4ed8fbb9
Created November 20, 2014 02:10
markdown fix
src = '''\
Chapter 1
foo
- figure 1.1
bar
Section 1.1
- figure 1.2
- figure 1.3
baz
Section 1.2
@reusee
reusee / foo.py
Last active August 29, 2015 14:13
def ispower(a,b): #a==b^i ?
while a>1:
if a%b==0:a/=b
else:return False
return True
def beal(max_base, max_power):
bases, powers, table, pow = initial_data(max_base, max_power)
for x in bases:
flag2=flag3=False # for 2^m+3^n=z^r x=2^i or x=3^i ?
~> ccg -f github.com/reusee/cowmap -t Key=string,Value=string -r Map=StrStrMap,New=NewStrStrMap
import "sync"
type StrStrMap struct {
v atomic.Value
l sync.Mutex
}
func NewStrStrMap(m map[string]string) *StrStrMap {
ret := new(StrStrMap)
require 'weakref'
$debug = false
SPACE = [' ', "\t"]
NEWLINE = ["\r", "\n"]
QUOTE = {
'"' => '"',
"'" => "'",
'{' => '}',
'(' => ')',
@reusee
reusee / gist:1323259
Created October 28, 2011 19:35
graph-like structure in redis
class Isred(Redis):
def node(self, serial = None):
return Node(self, serial)
class Node(dict):
def __init__(self, r, serial = None):
self.redis = r
self.serial = str(serial) if serial else r.incr('serial')
def __getitem__(self, key):
@reusee
reusee / gist:1325724
Created October 30, 2011 09:05
reus vimrc reusee@gmail.com
colo evening
syntax on
filetype plugin on
set autochdir
set autoindent
set cursorline
set dir=~/.vimdir
set expandtab
set fileencoding=utf-8
@reusee
reusee / gist:1348701
Created November 8, 2011 18:47
lua object emulator
local yield = coroutine.yield
local create = coroutine.create
local status = coroutine.status
local resume = coroutine.resume
local setmetatable = setmetatable
local next = next
local pop = table.remove
local insert = table.insert
local type = type
local pairs = pairs
@reusee
reusee / gist:1384816
Created November 22, 2011 03:33
collins cobuild 6th xml file formatter
# coding: utf8
import re
class Formatter(dict):
def __init__(self, input_file):
dict.__init__(self)
xml_source = open(input_file, 'r')
for line in xml_source.xreadlines():
line = line.strip()
@reusee
reusee / kindle.cls.tex
Created November 23, 2011 04:23
documentclass for kindle 3
\ProvidesClass{kindle}
\LoadClass{book}
\usepackage[margin=0mm,top=1mm,bottom=1mm,papersize={90mm,120mm}]{geometry}
\usepackage{xltxtra}
\usepackage{fontspec}
\setmainfont{LiHei Pro}
\pagestyle{empty}
\sloppy
\XeTeXlinebreaklocale "zh"
@reusee
reusee / gist:1397703
Created November 27, 2011 15:34
timer wheel
#include <iostream>
#include <list>
using std::list;
using std::string;
using std::cout;
using std::endl;
#define ROOT_BITS 8
#define REST_BITS 8
#define REST_NUM 3