Skip to content

Instantly share code, notes, and snippets.

View xsj0jsx's full-sized avatar

xsj0jsx

  • sogou inc
  • beijing,china
View GitHub Profile
#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);
#show git branch relationship
git log --graph --all --decorate
@xsj0jsx
xsj0jsx / shell_example.sh
Last active February 1, 2016 03:48
linux command usage example
#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 '{}' '+'
@xsj0jsx
xsj0jsx / 0_reuse_code.js
Created January 14, 2016 00:41
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@xsj0jsx
xsj0jsx / Lua.cc
Last active January 28, 2016 02:57 — forked from alex-ac/Lua.cc
#include <Lua.hh>
extern "C" {
#include <lualib.h>
#include <lauxlib.h>
};
using namespace util;
int Lua::call(lua_State *vm) {