Skip to content

Instantly share code, notes, and snippets.

View davidhq's full-sized avatar
🎯
Focusing

davidhq

🎯
Focusing
View GitHub Profile
# git helpers - davidhq
function git_repo {
local root=$(git rev-parse --show-toplevel || echo ".")
local cwd=`pwd`
cd $root
local origin=$(git remote -v | grep origin | grep push | sed 's/origin//g' | sed 's/[email protected]://g' | sed 's/https:\/\/github.com\///g' | sed 's/.git (push)//g' | xargs)
cd $cwd
eval "$1=$origin"
}
@davidhq
davidhq / loc.sh
Last active March 18, 2016 22:56
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
function loc {
if [ -z "$1" ] || [ "$1" == "all" ]; then
loc js "$2"
loc jsx "$2"
@davidhq
davidhq / key.go
Last active March 17, 2016 22:23
package main
// "Fork" Geth
// add:
// func DecryptKeyFromFile(keysDirPath string, keyAddr common.Address, auth string) (keyBytes []byte, keyId []byte, err error) {
// return decryptKeyFromFile(keysDirPath, keyAddr, auth)
// }
// to crypto/key_store_passphrase.go
import (
module My.Data.List where
data List a = Cons a (List a) | Nil
instance showList :: (Show a) => Show (List a) where
show (Cons x xs) = (show x) ++ " : " ++ show xs
show Nil = "Nil"
@davidhq
davidhq / space.sh
Last active September 28, 2015 11:14
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
alias root="sudo -i"
# utility function
function current_usage {
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Usage:
# m → mix help
# m a → mix archive
# m h → mix hex
# m a.b → mix archive.build
# m d.co → mix deps.compile
# m p.n → mix phoenix.new
@davidhq
davidhq / grab.sh
Last active September 11, 2015 22:44
# Example:
#
# $ find . | grep core_ext
# ./config/initializers/core_ext.rb
# ./spec/lib/core_ext_spec.rb
#
# $ grab 2
# ./spec/lib/core_ext_spec.rb ===> (also copied on clipboard)
#
# Without arguments the default is to grab the first line
# swiss knife
function c {
local dir
dir=`pwd`
if [ -z "$1" ]; then
cd - > /dev/null
else
if [ -d "$1" ]; then
cd "$1"
elif [ -f "$1" ]; then
@davidhq
davidhq / rspec.bash
Created March 26, 2015 21:36
RSpec++
function rspec {
command rspec $@
if [ $? -ne 0 ]; then
afplay ~/Misc/dumb.mp3 -v 0.3
fi
}
@davidhq
davidhq / cd_projects.sh
Last active August 29, 2015 14:17
cd_projects
# p proj -> cd ~/Projects/project
# works best (fastest) if your projects are lower-case and you refer to them as such
# if not, then for best performance (no lag) you have to call "p Proj" (if ~/Projects/Project exists)
function p {
cd ~/Projects
local match
if [ -n "$1" ]; then
local min_size=1000
# first try only directories that start exactly with our input
for d in $1*/ ; do