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 | |
function flask-boilerplate-tmux | |
{ | |
# https://github.com/swaroopch/flask-boilerplate | |
BASE="$HOME/code/flask-boilerplate" | |
cd $BASE | |
tmux start-server | |
tmux new-session -d -s flaskboilerplate -n model |
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
if has('python') " Assumes Python >= 2.6 | |
" Quick way to open a filename under the cursor in a new tab | |
" (or URL in a browser) | |
function! Open() | |
python <<EOF | |
import re | |
import platform | |
import 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
if has('ruby') | |
function! Heading(char) | |
ruby <<EOF | |
buffer = VIM::Buffer.current | |
new_line = VIM::evaluate("a:char") * buffer.line.length | |
buffer.append(buffer.line_number, new_line) | |
EOF | |
endfunction | |
command H1 call Heading('=') |
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/env python | |
def flatten(array): | |
out = [] | |
def real_flatten(array): | |
for item in array: | |
if isinstance(item, (list, tuple, set)): | |
real_flatten(item) | |
else: | |
out.append(item) |
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 eachnode(tree, n=0): | |
if n == len(tree): | |
raise StopIteration | |
yield tree[n] ## The method of access is specific to the data structure | |
for subnode in eachnode(tree, n+1): | |
yield subnode | |
if __name__ == '__main__': | |
tree = [10,20,30] ## Assuming array for test purposes, can be a real tree. |
NewerOlder