-
source /usr/local/bin/virtualenvwrapper.sh -
mkvirtualenv env1 -
ls $WORKON_HOME -
lssitepackages - Switch environments with workon workon env2
-
deactive -
rmvirtualenv env2
- ar
creates static libraries.
- ldd
lists the shared libraries on which the object binary is dependent.
- nm
lists the symbols defined in the symbol table of an object file.
- objdump
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
| // A functor is any object that can be used with () in the manner of a function. | |
| // includes pointers to functions, and class objects for which the () operator (function call operator) is overloaded | |
| #include <iostream> | |
| #include <vector> | |
| #include <algorithm> | |
| using namespace std; |
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
| // avoid resource leaks when exceptions are thrown. | |
| // if an exception occurs after successful memory allocation but | |
| // before the delete statement executes, a memory leak could occur. | |
| // void memory_leak() | |
| //{ | |
| // ClassA * ptr = new ClassA; | |
| // try { | |
| // ... | |
| // } | |
| // catch(...) { |
Inspired by this article. Neat tricks for speeding up integer computations.
Note: cin.sync_with_stdio(false); disables synchronous IO and gives you a performance boost.
If used, you should only use cin for reading input
(don't use both cin and scanf when sync is disabled, for example)
or you will get unexpected results.
x = x << 1; // x = x * 2
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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| import Queue | |
| """ | |
| Problem:(from http://weibo.com/lirenchen) | |
| 从图左边入口处的2011进去,在迷宫里转悠,最后变成2012从右边出来。可以在迷宫里转圈, |
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
| /* | |
| * Reference: | |
| * http://www.quora.com/Computer-Programming/What-are-some-cool-bit-manipulation-tricks-hacks | |
| * http://www.catonmat.net/blog/low-level-bit-hacks-you-absolutely-must-know/ | |
| */ | |
| #include <iostream> | |
| #include <string.h> | |
| using namespace std; |
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
| # define variable, use using $() | |
| # -g add debug information to the executable file | |
| # -Wall turns on most, but not all, compiler warnings | |
| # using Emacs and M-x replace-string RET string RET newstring RET | |
| # to replace xx to your file name. | |
| # Use google's testing framework | |
| GTEST_DIR = ../gtest | |
| # Where to find user code. | |
| USER_DIR = ../gtest_sample |
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
| # define variable, use using $() | |
| # -g add debug information to the executable file | |
| # -Wall turns on most, but not all, compiler warnings | |
| CC = g++ | |
| CFLAGS = -g -Wall | |
| file: file.o | |
| $(CC) $(CFLAGS) -o file file.o | |
| file.o: file.cpp |
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
| #!/usr/bin/env python | |
| #coding=utf8 | |
| import urllib | |
| import urllib2 | |
| import cookielib | |
| import base64 | |
| import re | |
| import json | |
| import hashlib | |
| import os |