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
fn $fib($n) { | |
if $n <= 1 { | |
return 1; | |
} | |
return $fib($n - 1) + $fib($n - 2); | |
} | |
for [$_, $n] in 0..10 { | |
$print($fib($n)); | |
} |
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 | |
# Usage: bash tri-img.sh src1.png src2.png src3.png tgt.png | |
set -e | |
DIR=$(mktemp -d -t '') | |
convert "$1" -resize 240x240 "$DIR"/1.png | |
convert "$2" -resize 118x118 "$DIR"/2.png | |
convert "$3" -resize 118x118 "$DIR"/3.png |
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 | |
# We have a command that we want to run (`yes` in this example) and pipe its | |
# output. | |
yes | sed 's/y/n/' | |
# However, we also want to add a command to run if our primary command fails. | |
# But if we add it in sequence, it is instead applied to the command our output | |
# is piped to. In this example, `echo 'bad'` will not be executed if `sed` | |
# succeeds, and `sed` will succeed even if `yes` is killed. |
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
<html> | |
<head> | |
<script type="text/javascript"> | |
var hiraganaDict = { | |
'a': 'あ', | |
'i': 'い', | |
'u': 'う', | |
'e': 'え', | |
'o': 'お', | |
'k': { |
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
def cartesian_tree(xs, tree=None): | |
if len(xs) == 0: | |
return tree | |
x = xs[0] | |
if tree == None or x < tree.value: | |
t = BinaryTree(x, tree, None) | |
else: | |
t = BinaryTree(tree.value, tree.left, cartesian_tree([x], tree.right)) |
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 | |
tar cfvj $1.`date +%Y%m%d%H%M%s`.tar.bz2 $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
len_num = map(int, raw_input().split()) | |
word = raw_input() | |
trie = {} | |
EOW = -1 | |
def add(trie, word): | |
global EOW |
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 string | |
_ = raw_input() | |
xs = [int(x) for x in raw_input().split(' ')] | |
outp = [] | |
while len(xs) > 0: | |
m = max(xs) | |
i = xs.index(m) | |
last = len(xs) - 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 string | |
_ = raw_input() | |
vals = [int(x) for x in raw_input().split(" ")] | |
outp = [] | |
left = 0 | |
right = sum(vals) | |
for i in xrange(0, len(vals)): | |
if i > 0: | |
left += vals[i - 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
# Adapted from 'http://mmb.pcb.ub.es/~carlesfe/unix/tricks.txt' | |
ps axuf | grep -v grep | grep "$@" -i --color=auto |
NewerOlder