Skip to content

Instantly share code, notes, and snippets.

View trongthanh's full-sized avatar
Keep calm and code on

Thanh Tran trongthanh

Keep calm and code on
View GitHub Profile
trongthanh / gist:799860
Created January 28, 2011 05:05
convert video to mp4 format
# convert to MP4 video
ffmpeg -i -s 1280x720 -b 2000k -ab 128k -vcodec libxvid -acodec libmp3lame -sws_flags +bitexact final.mp4
trongthanh / gist:819927
Created February 10, 2011 04:05
Log my computer IP to a file shared on Ubuntu One
# log my computer IP to a file shared on Ubuntu One
/sbin/ifconfig $1 | grep "inet addr" | gawk -F: '{print $2}' | gawk '{print $1}' > "/home/thanh/Ubuntu One/office_ip"
trongthanh / gist:954886
Created May 4, 2011 07:43
Create Flash context menu
public function createContextMenu(versionString: String): void {
if (!contextMenu) contextMenu = new ContextMenu();
var versionMenu: ContextMenuItem = new ContextMenuItem("v." + versionString, false, false);
contextMenu.customItems = [versionMenu];
trongthanh / gist:1196596
Created September 6, 2011 04:37
Emulate slow Internet connection speed on localhost with netem (Ubuntu)
#Setup the rate control and delay
sudo tc qdisc add dev lo root handle 1: htb default 12
sudo tc class add dev lo parent 1:1 classid 1:12 htb rate 56kbps ceil 128kbps
sudo tc qdisc add dev lo parent 1:12 netem delay 200ms
#Remove the rate control/delay
sudo tc qdisc del dev lo root
trongthanh / perspectiveProject.js
Created October 18, 2011 04:35 — forked from jsermeno/perspectiveProject.js
Three.js Transform 3D coordinates to screen coordinates and back in perspective projection -
projector = new THREE.Projector(),
p3D = new THREE.Vector3(25, 15, 9),
p2D = projector.projectVector(p3D, camera);
p3D = projector.unprojectVector(p2D, camera);
//need extra steps to convert p2D to window's coordinates
p2D.x = (p2D.x + 1)/2 * window.innerWidth;
trongthanh /
Created October 18, 2011 06:16
Search for .svn folders and remove them. (Remove all subversion metadata folders)
$ find . -name '.svn' -exec rm -R -f '{}' \;
trongthanh / gist:1823062
Created February 14, 2012 03:09
export a git revision
# Can use a short revision id (3ec090f) in place of master to export a specific revision
git archive --format zip --output ../ master
trongthanh / gist:2048765
Created March 16, 2012 06:21
Git commands to pull remote and merge with current branch
# save current changes (if any) to stash
git stash save
# pull remote changes to local
git pull origin
# apply stash and try auto merge
git stash pop
# OR
git stash apply
trongthanh / gist:2258994
Created March 31, 2012 03:34
Convert dash-separated properites to camel case ones
# Using vim
# Explain: Search for pattern -(.) and turn uppercase the first group \U\1
trongthanh / dabblet.css
Created April 17, 2012 05:19
Realistic CSS3 Waterfall
* Realistic CSS3 Waterfall
* Author: Thanh Tran
* License: MIT
* Tutorial:
* Image courtesy:
/* Container with the static waterfall background image */
.waterfall {