Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
| ### Testing if the client is a mobile or a desktop. | |
| ### The selection is based on the usual UA strings for desktop browsers. | |
| ## Testing a user agent using a method that reverts the logic of the | |
| ## UA detection. Inspired by notnotmobile.appspot.com. | |
| map $http_user_agent $is_desktop { | |
| default 0; | |
| ~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule | |
| ~*spider|crawl|slurp|bot 1; # bots | |
| ~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
| from sqlalchemy.ext.compiler import compiles | |
| from sqlalchemy.sql.expression import Insert | |
| @compiles(Insert) | |
| def append_string(insert, compiler, **kw): | |
| s = compiler.visit_insert(insert, **kw) | |
| if 'append_string' in insert.kwargs: | |
| return s + " " + insert.kwargs['append_string'] | |
| return s |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
GitHub's compare view is available at:
https://github.com/$USER/$REPO/compare/$REV_A...$REV_B
Naturally, $USER and $REPO are the owner (user/organization) and repository names, respectively.
$REV{A,B} are the two sides of the compare view; they can either be a ref in $USER's repository, i.e. the name of a branch, tag or a commit SHA, or it can be a ref in $OWNER's fork of the repository by using the format $OWNER:$REF.
You can get a diff or patch for the result of the compare view by appending .diff or .patch to the URL, respectively.
| # delete local tag '12345' | |
| git tag -d 12345 | |
| # delete remote tag '12345' (eg, GitHub version too) | |
| git push origin :refs/tags/12345 | |
| # alternative approach | |
| git push --delete origin tagName | |
| git tag -d tagName |
| 阿爸 a1'ba4 18137 | |
| 阿昌族 a1'chang1'zu2 50849 | |
| 阿斗 a1'dou3 42632 | |
| 阿飞 a1'fei1 48603 | |
| 阿富汗 a1'fu4'han4 3461 | |
| 阿訇 a1'hong1 34432 | |
| 阿拉伯数字 a1'la1'bo2'shu4'zi4 35937 | |
| 阿拉伯语 a1'la1'bo2'yu3 30476 | |
| 阿妈 a1'ma1 16220 |
| def copy_row(model, row, ignored_columns=[]): | |
| copy = model() | |
| for col in row.__table__.columns: | |
| if col.name not in ignored_columns: | |
| try: | |
| copy.__setattr__(col.name, getattr(row, col.name)) | |
| except Exception as e: | |
| print e | |
| continue |
| git config --global https.proxy http://127.0.0.1:1080 | |
| git config --global https.proxy https://127.0.0.1:1080 | |
| git config --global --unset http.proxy | |
| git config --global --unset https.proxy | |
| npm config delete proxy |
| # Detect operating system in Makefile. | |
| # Author: He Tao | |
| # Date: 2015-05-30 | |
| OSFLAG := | |
| ifeq ($(OS),Windows_NT) | |
| OSFLAG += -D WIN32 | |
| ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) | |
| OSFLAG += -D AMD64 | |
| endif |