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
tm() { | |
[[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" | |
if [ $1 ]; then | |
tmux $change -t "$1" 2>/dev/null || (tmux new-session -d -s $1 && tmux $change -t "$1"); return | |
fi | |
session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0) && tmux $change -t "$session" || echo "No sessions found." | |
} |
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
# required | |
# ------------- | |
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh | |
export FZF_DEFAULT_COMMAND='fd -t f' | |
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" | |
export FZF_ALT_C_COMMAND='fd -t d' | |
export FZF_COMPLETION_TRIGGER='' | |
bindkey '^T' fzf-completion | |
bindkey '^I' $fzf_default_completion |
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
__author__ = "Shihang Zhang" | |
__status__ = "Prototype" | |
class TrieNode(object): | |
""" Trie Node Class | |
@attrs: | |
children: a dictionary contains all children nodes | |
count: an integer indicates the number of occurence of current word |
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
class SimpleGraph(object): | |
def __init__(self, edges, weights=None): | |
self._edges = edges | |
self._weights = weights | |
def neighbors(self, id): | |
return self._edges[id] | |
def cost(self, start, end): |
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
class HashTable(object): | |
def __init__(self, size=100): | |
self._size=size | |
self._table=[[] for i in range(self._size)] | |
def get(self, key): | |
hash = self._hash(key) | |
bucket = self._table[hash] | |
for x in bucket: |