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
trongthanh / gist:799860
Created January 28, 2011 05:05
convert video to mp4 format
# convert to MP4 video
ffmpeg -i output.mov -s 1280x720 -b 2000k -ab 128k -vcodec libxvid -acodec libmp3lame -sws_flags +bitexact final.mp4
@trongthanh
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
trongthanh / gist:954886
Created May 4, 2011 07:43
Create Flash context menu
public function createContextMenu(versionString: String): void {
if (!contextMenu) contextMenu = new ContextMenu();
contextMenu.hideBuiltInItems();
var versionMenu: ContextMenuItem = new ContextMenuItem("v." + versionString, false, false);
contextMenu.customItems = [versionMenu];
}
@trongthanh
trongthanh / gist:1196596
Created September 6, 2011 04:37
Emulate slow Internet connection speed on localhost with netem (Ubuntu)
#Refer: http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delaying_only_some_traffic
#Refer: http://www.bomisofmab.com/blog/?p=100
#Refer: http://drija.com/linux/41983/simulating-a-low-bandwidth-high-latency-network-connection-on-linux/
#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
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 - http://catchvar.com/threejs-game-transforming-isometric-screen-co
var
projector = new THREE.Projector(),
p3D = new THREE.Vector3(25, 15, 9),
p2D;
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
trongthanh / clear_svn.sh
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
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 ../zipfile.zip master
@trongthanh
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
trongthanh / gist:2258994
Created March 31, 2012 03:34
Convert dash-separated properites to camel case ones
# Using vim
:%s/-\(.\)/\U\1/g
# Explain: Search for pattern -(.) and turn uppercase the first group \U\1
@trongthanh
trongthanh / dabblet.css
Created April 17, 2012 05:19
Realistic CSS3 Waterfall
/**
* Realistic CSS3 Waterfall
* Author: Thanh Tran
* License: MIT
* Tutorial: http://blog.int3ractive.com/2012/04/tutorial-realistic-waterfall-with-css3.html
* Image courtesy: http://wolffanticy.webs.com/waterfallcavepack.htm
*/
/* Container with the static waterfall background image */
.waterfall {