Skip to content

Instantly share code, notes, and snippets.


Yuchen Ying yegle

  • Google
  • San Francisco Bay Area
View GitHub Profile
yegle /
Created Jan 5, 2012
Bash Shell启动方式与RC脚本

Bash Shell启动方式与rc脚本


根据启动Bash Shell的方式不同,对Shell有两种分类方式



yegle /
Created Nov 2, 2012
REST API based on Django ORM and
class API(
class DjangoAPI(API):
model = None
def __init__(self):
self.qs = self.model.objects
self.exclude = []
yegle / gist:4098405
Created Nov 17, 2012
python itertools
View gist:4098405
from itertools import product
import string
[('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 / bash-read-variable
Created Dec 11, 2012
bash read varaible
View bash-read-variable
echo a| read i
echo $i
read i <<<$(echo a)
echo $i
yegle /
Last active Nov 7, 2020
How Linux kernel handles the send system call

This is a brief introduction about how Linux kernel handles the send system call.

This study is based on kernel version 3.7.2, which is the latest stable kernel when writing this study.

How system call is defined

In the latest kernel, the system call is defined using the SYSCALL_DEFINEx macro, in which x is the number of arguments. For example, in order to find the definition of asmlinkage long sys_sendto(int, void __user *, size_t, unsigned, struct sockaddr __user *, int);, you need to grep for SYSCALL_DEFINE6 because it has 6 arguments.

The definition of the system call send can be found at net/socket.c.

yegle /
Created Jan 21, 2013
How to use Django's get_readonly_fields
def get_readonly_fields(self, request, obj=None):
if obj and obj.is_processed:
return ('csv_file',) + self.readonly_fields
return self.readonly_fields
yegle /
Created Jul 3, 2014
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
yegle /
Last active Aug 29, 2015
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 "", and put it at the
yegle /
Last active Aug 29, 2015
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 /
Created Oct 7, 2015
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
You can’t perform that action at this time.