This file contains hidden or 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
alias cb="cd /base" # I use /base for various things. You can ignore this line. | |
alias edal="vim ~/.aliases" # To edit aliases. | |
alias gitc="git commit -m" | |
alias gita="git add ." | |
# Colored 'ls' from bash. | |
if [ -x /usr/bin/dircolors ]; then | |
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" |
This file contains hidden or 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
function cd { | |
builtin cd $1 | |
ls | |
} | |
alias cb="cd /base" | |
# Docker | |
function dntr { | |
docker exec -ti $1 bash |
This file contains hidden or 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
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) |
This file contains hidden or 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
func (bq *BOHeap) Pop() int { | |
// Pop for Brodal-Okasaki Heap. | |
// Root node is the return value. | |
// If the root happens to have a subqueue, merge those nodes using ordinary binomial heap procedure. | |
// Among the children of root, elect a new minimum node. | |
// Merge the children of the new root according to skew binomial pop procedure. | |
// Pop for skew binomial: | |
// Remove the minimum root | |
// Partition the gone roots children into 2 groups: Those with rank 0 and those with rank >0 |
This file contains hidden or 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
func (bon* BONode) partition() ([]*BONode, []*BONode) { | |
// Partition a node, yielding her rank 0 children and rank >0 children. | |
// This should take O(logn) time, because every node except the root has at most 2 children, which one of those children has rank 0. | |
nodestack := make([]*BONode, 10) // this is to be used as stack | |
nodestack = appendList(nodestack, bon.children_head) | |
zeros := make([]*BONode, 10) | |
nonzeros := make([]*BONode, 10) |
This file contains hidden or 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
# Copy and paste this code to your .bashrc and relog to your terminal | |
function dntr { | |
docker exec -ti $1 bash | |
} | |
function dstry { | |
docker stop -t 0 $1 | |
docker rm $1 | |
} |
This file contains hidden or 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
docker ps -a | awk '{print $1}' | grep ^[0-9a-f] | xargs docker rm |
This file contains hidden or 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
# This code fails because you cannot change a dictionary's size during iteration. | |
bar = {1: "a", | |
2: None, | |
3: "c" | |
} | |
for key, value in bar.iteritems(): | |
if value is None: | |
bar.pop(key) |
This file contains hidden or 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 argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--argument_one", help="This argument does nothing") | |
parser.add_argument("--argument_two", help="This argument is even more useless than other one.") | |
parsed = parser.parse_args() # By default, this uses sys.argv. | |
# This means the arguments doesnt have to be coming from CLI. |
This file contains hidden or 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
func Test_read3(t *testing.T) { | |
var bstr ByteStream | |
bstr.length = 3 | |
bstr.data = []byte { 0xdd, 0xaf, 0xaf } | |
readcnt, rb := bstr.read(3) | |
if readcnt != 3 { | |
t.Errorf("Readcnt; Expected 3, got %d", readcnt) |