Skip to content

Instantly share code, notes, and snippets.

@tamphh
tamphh / .tmux.conf
Created June 21, 2018 04:04
tmux customization
#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
@tamphh
tamphh / pre-commit
Last active January 14, 2019 04:48
git hook(ruby script) for Rails project to avoid unwanted specific files, keywords (debugger, binding.pry,...) to be commited.
#!/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 / test_fcm.rb
Created March 4, 2019 14:58
Ruby script to send POST HTTPS request sample
# 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 / input_source
Created July 4, 2019 07:31
Bash script to get input source (keyboard name) fo OS X
#!/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 / file_preview
Last active July 9, 2019 08:41
Bash script to preview files with bat for fzf
#!/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 / gitcheats.txt
Created July 18, 2019 03:08 — forked from chrismccoy/gitcheats.txt
git cheats
# 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 / values_pointers.go
Created December 22, 2020 03:21 — forked from josephspurrier/values_pointers.go
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@tamphh
tamphh / pre-commit
Last active January 19, 2021 04:25
git hook(bash script) for Rails project to avoid unwanted specific files, keywords (debugger, binding.pry,...) to be commited.
#!/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 / rust-command-line-utilities.markdown
Created November 8, 2022 14:36 — forked from sts10/rust-command-line-utilities.markdown
A curated list of command-line utilities written in Rust

A curated list of command-line utilities written in Rust

Note that I have not tried all of these personally, and cannot and do not vouch for all of the tools listed here. In most cases, the descriptions here are copied directly from their code repos. Some may have been abandoned. Investigate before installing/using.

The ones I use regularly include: bat, dust, exa, fd, hyperfine, miniserve, ripgrep, just, zoxide and cargo-wipe.

  • atuin: "Magical shell history"
  • bandwhich: Terminal bandwidth utilization tool
  • bat: A replacement for cat that provides syntax highlighting and other features.
  • bottom: Yet another cross-platform graphical process/system monitor.
@tamphh
tamphh / git_fzf.sh
Last active March 30, 2024 20:32 — forked from junegunn/gist:f4fca918e937e6bf5bad
Browsing git commit history with fzf
# 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