Skip to content

Instantly share code, notes, and snippets.

@yenliangl
yenliangl / gist:4123824
Created November 21, 2012 08:36
Improving performance of ifstream in C++
std::ifstream file("test.txt", std::ios::in | std::ios::end);
std::size_t fileSize = file.tellg();
std::vector<char> buffer(fileSize);
file.seekg(0, std::ios::beg);
file.read(buffer.data(), fileSize);
@yenliangl
yenliangl / gist:4124014
Created November 21, 2012 09:43
Read file by ifstream
#include <fstream>
#include <sstream>
#include <vector>
int main()
{
std::ifstream file("Plop");
if (file)
{
/*
@yenliangl
yenliangl / iterate_number.bash
Created May 5, 2013 16:51
Iterate over a range of numbers in bash
for n in {1..30}; do wget -c http://meanrat.com/media/30days/day$n.pdf; done
@yenliangl
yenliangl / bindkey.tcsh
Created November 6, 2013 02:45
Bind terminal keys in tcsh
if ($?tcsh && $?prompt) then
bindkey "\e[1~" beginning-of-line # Home
bindkey "\e[7~" beginning-of-line # Home rxvt
bindkey "\e[2~" overwrite-mode # Ins
bindkey "\e[3~" delete-char # Delete
bindkey "\e[4~" end-of-line # End
bindkey "\e[8~" end-of-line # End rxvt
endif
@yenliangl
yenliangl / http_get.sh
Created February 12, 2014 16:48
Send HTTP GET request to a WEB server through wget
wget -S -O - http://this/is/a/url
@yenliangl
yenliangl / create_mavericks_install_falsh_drive.sh
Created February 15, 2014 17:15
Create install flash drive for MacOSX Mavericks
sudo /Applications/Install\ OS\ X\ Mavericks.app/Contents/Resources/createinstallmedia --volume /Volumes/Untitled --applicationpath /Applications/Install\ OS\ X\ Mavericks.app --nointeraction
package your_package;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
@yenliangl
yenliangl / gist:4d42e4a18369ae5b71a4
Created January 10, 2015 08:22
How to use repo to smart switch different branch
Use repo to intitalize different branches
$ mkdir /repos/aosp-1.6_r1
$ cd /repos/aosp-1.6_r1
$ repo init -b android-1.6_r1 -u https://android.googlesource.com/platform/manifest --reference=/repos/aosp-main
$ repo sync
Switch to another branch
$ mkdir /repos/aosp-1.6_r2
@yenliangl
yenliangl / gist:2dca5efbaa3a065a88b8
Created March 12, 2015 03:45
Reverse page order of PDF using PDFTK
# Assume in.pdf has 100 pages
pdftk in.pdf cat 100-1 output out.pdf