Skip to content

Instantly share code, notes, and snippets.

tampham tamphh

Block or report user

Report or block tamphh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tamphh
tamphh / git_fzf.sh
Last active Jul 24, 2019 — forked from junegunn/gist:f4fca918e937e6bf5bad
Browsing git commit history with fzf
View git_fzf.sh
# git log show with fzf
#
# https://gist.github.com/tamphh/3c9a4aa07ef21232624bacb4b3f3c580/edit
# https://asciinema.org/a/257939
#
# git log show with fzf
gli() {
# param validation
View gitcheats.txt
# shortform git commands
alias g='git'
# get a list of all commit messages for a repo
git log --pretty=format:'%s'
# pull all git repos to current version
find . -name .git -type d -execdir git pull -v
# pull all git repos to currenrt version
@tamphh
tamphh / file_preview
Last active Jul 9, 2019
Bash script to preview files with bat for fzf
View file_preview
#!/bin/bash
file="$1"
[[ $(file --mime "$file") =~ binary ]] &&
echo "$file" is a binary file ||
(bat --style=numbers --color=always "$file" ||
highlight -O ansi -l "$file" ||
coderay "$file" ||
rougify "$file" ||
cat "$file") 2> /dev/null | head -500
@tamphh
tamphh / input_source
Created Jul 4, 2019
Bash script to get input source (keyboard name) fo OS X
View input_source
#!/bin/bash
input_name=$(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources | egrep -w 'KeyboardLayout Name' | sed -E 's/^.+ = \"?([^\"]+)\"?;$/\1/')
if [[ -z "$input_name" ]]; then
echo "V.N"
elif [[ -n "$input_name" ]]; then
echo "U.S"
fi
@tamphh
tamphh / test_fcm.rb
Created Mar 4, 2019
Ruby script to send POST HTTPS request sample
View test_fcm.rb
# source: http://www.rubyinside.com/nethttp-cheat-sheet-2940.html
# FCM ref: https://medium.com/@cdmunoz/working-easily-with-fcm-push-notifications-in-android-e1804c80f74
# How to run in terminal: ruby test_fcm.rb
require 'net/https'
require 'uri'
require 'json'
uri = URI.parse('https://fcm.googleapis.com/fcm/send')
device_token = 'FCM_device_token'
header = {
@tamphh
tamphh / pre-commit
Last active Jan 14, 2019
git hook(ruby script) for Rails project to avoid unwanted specific files, keywords (debugger, binding.pry,...) to be commited.
View pre-commit
#!/usr/bin/env ruby
# How to use?
# - Save this file as .git/hooks/pre-commit in your project .git folder
# - Execute:
# chmod +x .git/hooks/pre-commit
#
# If you want to skip the hook just add the --no-verify flag:
# git commit --no-verify
@tamphh
tamphh / pre-commit
Last active Sep 9, 2018
git hook(bash script) for Rails project to avoid unwanted specific files, keywords (debugger, binding.pry,...) to be commited.
View pre-commit
#!/bin/bash
# How to use?
# - Save this file as .git/hooks/pre-commit in your project .git folder
# - Execute:
# chmod +x .git/hooks/pre-commit
#
# If you want to skip the hook just add the --no-verify flag:
# git commit --no-verify
@tamphh
tamphh / .tmux.conf
Created Jun 21, 2018
tmux customization
View .tmux.conf
#change prefix from C-b to C-a
unbind C-b
set -g prefix C-a
#theme
set -g default-terminal "tmux-256color"
set-option -ga terminal-overrides ",xterm-256color:Tc"
#-------------------------------------------------------#
##STATUS LINE/MESSAGES AT BOTTOM
You can’t perform that action at this time.