This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#long file extension usually means it's a text | |
SELF="$(cd ${0%/*} && echo $PWD/${0##*/})" | |
if [[ $1 == "-o" ]]; then | |
a="$HOME/.association" | |
text="vim -u /usr/share/vim/vim73/macros/less.vim" | |
default="xdg-open" | |
elif [[ $1 == "-e" ]]; then | |
a="$HOME/.associationedit" | |
text="vim" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2 | |
#usage: scriptname file1 file2 ... | |
import sys | |
import re | |
def toarray(a): | |
entrystart = re.compile('[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} \[[^\s]*@[^\s]*\]') | |
a2 = [] | |
for line in a: | |
match = entrystart.match(line) | |
if match is not None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A = Import["pebble.txt", "Table"]; | |
A = Select[A, | |
Function[x, | |
If[x[[1]] == x[[7]] | |
&& x[[3]] == Floor[Log[2, x[[1]]]] | |
&& x[[2]] < 2^(Floor[Log[2, x[[1]]]] + 1) | |
, True, | |
False | |
]]]; | |
B = Table[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function latex2html($text){ | |
$s[] = '/\\\\begin{theorem}\\[(.*?)\\]\\s/'; | |
$r[] = '<blockquote class="theorem"><strong>Theorem ($1)</strong> '; | |
$s[] = '/\\\\begin{lemma}\\[(.*?)\\]\\s/'; | |
$r[] = '<blockquote class="theorem"><strong>Lemma ($1)</strong> '; | |
$s[] = '/\\\\begin{problem}\\[(.*?)\\]\\s/'; | |
$r[] = '<blockquote class="problem"><strong>Problem ($1)</strong> '; | |
$s[] = '/\\\\begin{corollary}\\[(.*?)\\]\\s/'; | |
$r[] = '<blockquote class="theorem"><strong>Corollary ($1)</strong> '; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default (Int, Integer, Rational, Double) | |
if' :: Bool -> a -> a -> a | |
if' True x _ = x | |
if' False _ y = y | |
isBraidIdentity x n = | |
[1..n] == concat (map (braidReduce x) [[y] | y <- [1..n]]) | |
braidReduce = flip (foldr homomorphism) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Tree | |
import Data.List | |
import Debug.Trace | |
import Maybe | |
--the last int is the amount of argument | |
data Label = Command String | |
| Constant String | |
| Declaration | |
deriving Show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.List | |
binaryArray n = a [] n | |
a list 0 = [list] | |
a list n = (a (0:list) (n-1))++(a (1:list) (n-1)) | |
f list = map (fx list) [1..length list] | |
fx list j = 1 + (length (takeWhile ((/=) (maximum result)) result)) | |
where result = map (sum . (take j) . (flip drop list)) [0..(length list)-j] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import commands | |
import time | |
f = '~/.freetalk/history/mgcclx@gmail.com/SESSION' | |
s = commands.getoutput('cat ' + f + ' | tail --lines 1 | cut -c 21-') | |
s = s.replace('[','<fc=#ffffff>',1) | |
s = s.replace(']',':</fc>',1) | |
s = s.replace('@gmail.com','',1) | |
s = s.rstrip() | |
u = unicode(s, "utf-8") | |
print u[0:100].encode("utf-8") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Word Problem for B_3 | |
--Input a word, 1 = generator \sigma_1, 2 = generator \sigma 2, -1 and -2 are their inverse respectively. | |
--Return true if it's trivial, else return false | |
isTrivialBraid3 list = | |
(remainword == []) && (pdelta+delta == 0) | |
where (remainword, pdelta) = positiveDelta' word [] 0 | |
(word,delta) = negativeDelta' list [] 0 | |
positiveDelta' before after delta | |
| (suffix == [1,2,1] || suffix == [2,1,2]) = positiveDelta' before (drop 3 after) (delta + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
public class Counter { | |
public HashMap<String, Integer> counters; | |
Counter(){ | |
//initialize counters | |
counters = new HashMap<String, Integer>(); | |
newCounter("part"); |