Skip to content

Instantly share code, notes, and snippets.

View retrage's full-sized avatar
💭
🦄

Akira Moroo retrage

💭
🦄
View GitHub Profile
@retrage
retrage / 2048.py
Last active August 29, 2015 14:00
This script is a command-line 2048 game.
import random
import copy
import curses
table = [[0 for j in range(4)] for i in range(4)]
def init(table):
table[0][0] = random.randint(1,2)*2
table[0][2] = random.randint(1,2)*2
return table
def parse3(l):
stack = []
for i in range(len(l)):
if l[i]=='(':
stack.insert(0, i)
elif l[i]==')':
print l[stack.pop(0):i+1]
def calc(l):
ll = len(l)
@retrage
retrage / .zshrc
Created August 15, 2014 05:45
My .zshrc file.
autoload -U compinit
compinit
autoload predict-on
predict-on
bindkey -v
setopt auto_pushd
setopt correct
@retrage
retrage / .vimrc
Last active August 29, 2015 14:05
My .vimrc file.
syntax on
filetype indent plugin on
set tabstop=8 expandtab shiftwidth=4 softtabstop=4
set number
set mouse=
set nocompatible
set incsearch
set clipboard=unnamed,autoselect
"foo bar
@retrage
retrage / .updaterc.sh
Last active August 29, 2015 14:05
This gist updates my vimrc and zshrc.
#!/bin/sh
cd ~/src/83a7d8f5fd6401bd6515
echo "Updating vimrc and zshrc: \c"
git pull
cp .vimrc ~/.vimrc
cp .zshrc ~/.zshrc
# cp updaterc.sh ~/updaterc-next.sh
# chmod 764 ~/updaterc.sh
@retrage
retrage / bf.py
Last active August 29, 2015 14:08
Brainf*ck interpreter
#!/usr/bin/python
from __future__ import print_function
import sys
if len(sys.argv) > 1:
with open(sys.argv[1]) as src:
program = src.read()
else:
print("No input file.")
@retrage
retrage / CSV2TeX.py
Created November 5, 2014 14:21
An excel-style table to tex-style table script
#!/usr/bin/python
import re
import sys
def parseCSV(text,delim=','):
tokenizer = re.compile(delim+r'|\r?\n|[^'+delim+r'"\r\n][^'+delim+ \
r'\r\n]*|"(?:[^"]|"")*"')
tmp = tokenizer.findall(text)
data = []
@retrage
retrage / bfs.py
Last active August 29, 2015 14:10
Brainf*ck like stack machine interpreter
#!/usr/bin/python
from __future__ import print_function
import sys
if len(sys.argv[1]) > 1:
with open(sys.argv[1]) as src:
program = src.read()
else:
print("No input file.")
@retrage
retrage / fusecpp.h
Created January 5, 2015 14:50
C++ header for fuse3. The original was created by Gerard J. Cerchio.
/**
* @(#) fusecpp.h - allow access to fuse from C++
*
* Gerard J. Cerchio www.circlesoft.com
*
* modified for fuse3
* by retrage01@gmail.com
*
*/
@retrage
retrage / base58.py
Last active August 29, 2015 14:27
Base58 encoder/decoder
#!/usr/bin/python
alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
base = len(alphabet)
def encode_base58(input_bin):
if input_bin == 0x00:
return alphabet[0]