Skip to content

Instantly share code, notes, and snippets.

View hoangthienan's full-sized avatar

An Hoang hoangthienan

  • Ho Chi Minh City
View GitHub Profile
@hoangthienan
hoangthienan / browserdetect
Created December 8, 2012 12:12
Browser Detect
var BrowserDetect = function(){
var e=this;
var c=function(f){
for(var j=0;j<f.length;j++){
var h=f[j].string;
var g=f[j].prop;
this.versionSearchString=f[j].versionSearch||f[j].identity;
if(h){
if(h.indexOf(f[j].subString)!=-1){
return f[j].identity

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage

Vagrant Setup

This tutorial guides you through creating your first Vagrant project.

We start with a generic Ubuntu VM, and use the Chef provisioning tool to:

  • install packages for vim, git
  • create user accounts, as specified in included JSON config files
  • install specified user dotfiles (.bashrc, .vimrc, etc) from a git repository

Afterwards, we'll see how easy it is to package our newly provisioned VM

@hoangthienan
hoangthienan / wkhtmltopdf
Created July 28, 2014 06:40
Install wkhtmltopdf on Centos 6 x64
$ wget http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linux-centos6-amd64.rpm
$ rpm -ivh wkhtmltox-0.12.1_linux-centos6-amd64.rpm
$ which wkhtmltopdf
/usr/local/bin/wkhtmltopdf
@hoangthienan
hoangthienan / mongodb
Created August 5, 2014 08:59
[Mongo] Backup & Restore
--backup
[root@sm ~]# mongodump -d smprocdb -o ./mongodump
[root@sm ~]# cd mongodump
[root@sm mongodump]# tar -zcf smprocdb.tar.gz smprocdb
--restore
[root@sm mongodump]# tar -xvf smprocdb.tar.gz ./smprocdb
[root@sm mongodump]# mongorestore -d smprocdb --drop ./smprocdb
--windows
@hoangthienan
hoangthienan / elasticsearch
Last active September 10, 2018 14:42
Install ElasticSearch on CentOS 6.5
# install missing libraries (if any)
[root@sm ~]# cd ~
[root@sm ~]# sudo yum update
# get and unpack elasticsearch tar file
[root@sm ~]# wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.1.tar.gz -O elasticsearch.tar.gz
[root@sm ~]# tar -xvf elasticsearch.tar.gz
[root@sm ~]# mv elasticsearch-* elasticsearch
[root@sm ~]# sudo mv elasticsearch /usr/local/share
@hoangthienan
hoangthienan / redmine
Last active August 29, 2015 14:05
redmine
# Install Redmine on CentOS 6.5
# I don't install redmine via command : yum install redmine.
# Redmine supports Ruby 1.x so do not install ruby 2.0.
Install gem and passenger dependencies
yum -y install zlib-devel curl-devel openssl-devel httpd-devel apr-devel apr-util-devel mysql-devel libyaml-devel
Get Ruby
# Create the directory where you will store the Downloads
mkdir ~/Downloads # This can be any directory.
@hoangthienan
hoangthienan / gjslint.ini
Last active August 29, 2015 14:11
Google-Closure-Linter JetBrains PhpStorm Integration
--strict
--ignore_errors=1,2,6,110,131,233
--jsdoc
--summary
--beep
--check_html
--nomultiprocess
--debug_indentation
--time
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then