Skip to content

Instantly share code, notes, and snippets.

View yegle's full-sized avatar

Yuchen Ying yegle

  • Google
  • San Francisco Bay Area
View GitHub Profile
@yegle
yegle / runme.sh
Last active November 30, 2015 00:15
document problem in beancount
#!/usr/bin/env bash
echo "Because gist doesn't support directory"
dir=$(dirname "$0")
mkdir -p "$dir/stmts/Assets/US/BoA"
touch "$dir/stmts/Assets/US/BoA/2015-01-31.statement"
@yegle
yegle / bash-read-variable
Created December 11, 2012 05:18
bash read varaible
#!/bin/bash
# FAIL!
echo a| read i
echo $i
# WORKS
read i <<<$(echo a)
echo $i
@yegle
yegle / gist:4098405
Created November 17, 2012 18:12
python itertools
from itertools import product
import string
print(list(product(string.lowercase[:13],repeat=2)))
[('a', 'a'), ('a', 'b'), ('a', 'c'), ('a', 'd'), ('a', 'e'), ('a', 'f'), ('a', 'g'), ('a', 'h'), ('a', 'i'), ('a', 'j'), ('a', 'k'), ('a', 'l'), ('a', 'm'), ('b', 'a'), ('b', 'b'), ('b', 'c'), ('b', 'd'), ('b', 'e'), ('b', 'f'), ('b', 'g'), ('b', 'h'), ('b', 'i'), ('b', 'j'), ('b', 'k'), ('b', 'l'), ('b', 'm'), ('c', 'a'), ('c', 'b'), ('c', 'c'), ('c', 'd'), ('c', 'e'), ('c', 'f'), ('c', 'g'), ('c', 'h'), ('c', 'i'), ('c', 'j'), ('c', 'k'), ('c', 'l'), ('c', 'm'), ('d', 'a'), ('d', 'b'), ('d', 'c'), ('d', 'd'), ('d', 'e'), ('d', 'f'), ('d', 'g'), ('d', 'h'), ('d', 'i'), ('d', 'j'), ('d', 'k'), ('d', 'l'), ('d', 'm'), ('e', 'a'), ('e', 'b'), ('e', 'c'), ('e', 'd'), ('e', 'e'), ('e', 'f'), ('e', 'g'), ('e', 'h'), ('e', 'i'), ('e', 'j'), ('e', 'k'), ('e', 'l'), ('e', 'm'), ('f', 'a'), ('f', 'b'), ('f', 'c'), ('f', 'd'), ('f', 'e'), ('f', 'f'), ('f', 'g'), ('f', 'h'), ('f', 'i'), ('f', 'j'), ('f', 'k'), ('f', 'l'),
@yegle
yegle / mkdir.sh
Created October 7, 2015 04:24
Create a directory that cannot be deleted in OS X
mkdir -p confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14B---/confdir-14
@yegle
yegle / list_reference_copy.py
Last active August 29, 2015 14:12
Create reference slice to a list in Python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
class MyList(list):
def __init__(self, raw_list, start=None, stop=None):
self.raw_list = raw_list
self.start = start or 0
self.stop = stop or len(raw_list)-1
@yegle
yegle / appengine_config.py
Last active August 29, 2015 14:12
Use VirtualEnv to manage dependencies on GAE project
import os
from google.appengine.ext import vendor
"""
1. Create a virtualenv directory at the root of your project, name it "venv"
2. Install packages needed in your project
3. Freeze it and save the package list into requirements.txt file, add it to
version control
4. Exclude "venv" directory from version control
5. Save the content of this file as "appengine_config.py", and put it at the
@yegle
yegle / opt.py
Created July 3, 2014 16:19
USCIS OPT application status query
#!/usr/bin/env python
# vim: set fileencoding=utf-8 ts=4 sw=4 tw=79 :
from __future__ import (unicode_literals, absolute_import,
division, print_function)
import requests
from lxml import etree
from io import StringIO