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
| #include <string> | |
| #include <fstream> | |
| #include <streambuf> | |
| std::ifstream t("file.txt"); | |
| std::string str; | |
| t.seekg(0, std::ios::end); | |
| str.reserve(t.tellg()); | |
| t.seekg(0, std::ios::beg); |
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
| #show git branch relationship | |
| git log --graph --all --decorate |
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
| #handle filename include space and '\n' | |
| find ~ -iname '*.jpg' -print0 | xargs --null ls -l | |
| # cat gzipped file content | |
| zcat foo.txt.gz | less | |
| # or | |
| zless foo.txt.gz | |
| # only extract some specific file | |
| tar xf archive.tar pathname | |
| # use find to archive files, note the use of '+' | |
| find playground -name 'file-A' -exec tar rf playground.tar '{}' '+' |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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
| #include <Lua.hh> | |
| extern "C" { | |
| #include <lualib.h> | |
| #include <lauxlib.h> | |
| }; | |
| using namespace util; | |
| int Lua::call(lua_State *vm) { |