Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / disable_DS_Store.sh
Created September 29, 2012 09:16
Prevent .DS_Store file creation
#
$ > defaults write com.apple.desktopservices DSDontWriteNetworkStores true
@yenliangl
yenliangl / combine_multiple_pdf_files.sh
Created September 29, 2012 09:15
Combine multiple pdf files by pdftk
# combine several pdf files
pdftk file1.pdf file2.pdf file3.pdf cat output newfile.pdf
# combine files
pdftk *.pdf cat output newfile.pdf
@yenliangl
yenliangl / make_file_visible.sh
Created September 29, 2012 09:11
Make file invisible/visible in MacOSX Finder
# invisible
setfile -a V afile.txt
# visible
setfile -a v afile.txt
@yenliangl
yenliangl / flash.sh
Created September 29, 2012 09:09
flash recovery image
fastboot flash recovery image_to_flash.img
@yenliangl
yenliangl / tee.csh
Created September 28, 2012 07:25
Use tee to save output of one command pipe and also to standard output
command |& tee output.ext