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:2779392
Last active April 24, 2024 23:46
How to move a folder from one repo to another and keep its commit history
# source: http://st-on-it.blogspot.com/2010/01/how-to-move-folders-between-git.html
# First of all you need to have a clean clone of the source repository so we didn't screw the things up.
git clone git://server.com/my-repo1.git
# After that you need to do some preparations on the source repository, nuking all the entries except the folder you need to move. Use the following command
git filter-branch --subdirectory-filter your_dir -- -- all
# This will nuke all the other entries and their history, creating a clean git repository that contains only data and history from the directory you need. If you need to move several folders, you have to collect them in a single directory using the git mv command.
@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 / mojave.xml
Last active January 26, 2023 19:04
macOS Mojave dynamic background re-implement as GTK+ background slideshow. Background images are changed to reflect the time of the day.
<!-- Instructions:
- Download and unzip Mojave dynamic background here: https://files.rb.gd/mojave_dynamic.zip
- Rename the extracted folder as "mojave-background" (Excuse the trouble but I renamed it on my machine and already use that path in the XML file)
- Save this xml file next to the Mojave background files
- Fix the path to the background images below (better using absolute path)
- Lastly, either:
+ GNOME: Use gnome-tweaks tool to select this XML as wallpaper (as default wallpaper settings won't let you choose wallpaper from custom path)
+ MATE: Go to background setting (in Appearance) > Choose +Add... > make sure **All files** filter is selected at the bottom right > Then choose mojave.xml
-->
<background>
@trongthanh
trongthanh / marco-compton.conf
Last active March 21, 2022 10:06 — forked from vemacs/compton.conf
Sensible marco-compton.conf for Ubuntu MATE 18.10 (and fix shadow at Ulauncher search panel)
# For Ubuntu MATE, save this config file at ~/.config/marco-compton.conf
#################################
#
# Backend
#
#################################
# Backend to use: "xrender" or "glx".
# GLX backend is typically much faster but depends on a sane driver.
@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 {
@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 / apply-pantheon-terminal-color.sh
Created October 18, 2018 03:39
Apply custom color theme for Pantheon Terminal ver 5.3+
#!/bin/bash
# Apply custom color theme for Pantheon Terminal ver 5.3+
# 1) preview and choose a color theme from http://mayccoll.github.io/Gogh/
# 2) open the equivalent bash file containing the color values at https://github.com/Mayccoll/Gogh/tree/master/themes
# 3) concatenate all 16 colors at the top with colon ":", then replace it at the palette variable below
# 4) replace color for foreground, background, and cursor; choose whether your theme is light or dark
# 5) sudo apt-get install dconf-tools
# 6) execute this script
@trongthanh
trongthanh / initialize.sh
Last active May 17, 2020 10:41
Ubuntu Node Server Setup
#!/bin/bash
# NOTE: The commands here only applicable for Ubuntu 16.04 Xenial, do not use it for other distros
# Update server to latest packages
sudo apt update && sudo apt upgrade -y
# Install nginx and git
sudo apt install -y nginx git
@trongthanh
trongthanh / pygment-ocean.css
Created January 8, 2019 17:01
Ocean theme for Pygment / Rouge syntax highlighter
// stylelint-disable
.highlight pre { color:#cdd3de; background-color: #142026; }
.highlight .hll { background-color: #142026; }
.highlight .c { color: #65737e; font-style: italic; } /* Comment */
.highlight .err { color: #ec5f67; background-color: #1e0010 } /* Error */
.highlight .k { color: #c594c5 } /* Keyword */
.highlight .l { color: #f99157 } /* Literal */
.highlight .n { color: #f07178 } /* Name */
.highlight .o { color: #5fb3b3 } /* Operator */
.highlight .p { color: #6699cc } /* Punctuation */
@trongthanh
trongthanh / fetch-data.js
Created October 19, 2016 06:26
Intro to GraphQL
/**
* Client-side GraphQL data fetch example with HTML5 Fetch API
*
* @param {String} url URL to the GraphQL endpoint
* @param {String} query The GraphQL query
* @return {Promise} the request resolving promise object
*/
function fetchData(url = 'http://localhost:3000/graphql', query = '{ hello }') { //eslint-disable-line no-unused-vars
let requiredHeaders = new Headers({
'Content-Type': 'application/json',