Skip to content

Instantly share code, notes, and snippets.

View buithehoa's full-sized avatar
🐢
Moving slowly ...

Bùi Thế Hòa buithehoa

🐢
Moving slowly ...
View GitHub Profile
@buithehoa
buithehoa / diff-against-a-commit.sh
Last active January 20, 2021 10:48
Diff Against the Previous Commit
git show $COMMIT
# OR
git diff HEAD^ HEAD
# OR
git diff --cached <file_name>
@buithehoa
buithehoa / rename-a-branch.sh
Last active August 29, 2015 14:01
Rename a Branch
git branch -m <old_branch> <new_branch>
@buithehoa
buithehoa / column-edit-mode-in-vim
Last active August 29, 2015 14:01
Column Edit Mode in vim
+ Ctrl + V to go into column mode
+ Select the columns and rows where you want to enter your text
+ Shift + i to go into insert mode in column mode
+ Type in the text you want to enter. Dont be discouraged by the fact that only the first row is changed.
+ Esc to apply your change (or alternately Ctrl+C)
http://pivotallabs.com/column-edit-mode-in-vi/
@buithehoa
buithehoa / make-head-the-same-as-origin-master.sh
Last active August 29, 2015 14:01
Make HEAD the Same as origin/master
$ git reset --hard origin/master
@buithehoa
buithehoa / jquery-document-ready.js
Created January 7, 2015 03:43
JQuery document ready
$(document).ready(function() {
// put all your jQuery goodness in here.
});
// OR
$(function() {
// put all your jQuery goodness in here.
});
@buithehoa
buithehoa / find-texts.sh
Created January 15, 2015 13:39
Find texts in specified files with find
find . -name "*.ext" -type f -exec grep -i "text" {} +
@buithehoa
buithehoa / deploy-and-run-migrations-with-capistrano.sh
Created February 2, 2015 05:59
Deploy and run migrations with Capistrano
# Deploy and run migrations
$ cap <environment> deploy:migrations
# Run migrations
$ cap <environment> deploy:migrate
@buithehoa
buithehoa / git-show-all-remote-branches.sh
Created February 24, 2015 04:10
git: Show all remote braches
$ git remote show origin
@buithehoa
buithehoa / sanitize-a-ruby-string-to-be-used-as-a-file-name.rb
Created March 5, 2015 09:31
Sanitize a Ruby string to be used as a file name
def friendly_filename(filename)
filename.gsub(/[^\w\s_-]+/, '')
.gsub(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
.gsub(/\s+/, '_')
end
@buithehoa
buithehoa / git-revert-a-file-to-a-specific-commit.sh
Created April 14, 2015 05:43
Git: Revert a file to a specific commit
git checkout <commit> <path/to/file>