Skip to content

Instantly share code, notes, and snippets.

@forelabs
forelabs / aws-login.bash
Created September 25, 2019 08:30
aws login function
function aws-login() {
eval $(aws-mfa ecr get-login --no-include-email)
}
@forelabs
forelabs / genpasswd.bash
Created September 25, 2019 08:32
password generator
function genpasswd() {
local l=$1
[ "$l" == "" ] && l=32
tr -dc "!$#;,.%()A-Za-z0-9_" < /dev/urandom | head -c ${l} | xargs
}
@forelabs
forelabs / grmaster.bash
Created September 25, 2019 08:34
branch rebase master
function grmaster() {
b=$(git branch | sed -n '/\* /s///p')
git checkout master
git pull --rebase
git checkout $b
git rebase master
}
@forelabs
forelabs / .gitconfig
Created September 25, 2019 08:41
global git config
[push]
default = tracking
[branch]
autosetuprebase = always
[alias]
c = commit
u = pull --rebase
p = push
dev = checkout development
new = checkout -b
@forelabs
forelabs / .gitignore_global
Created September 25, 2019 08:42
global git ignore
.env
.npmrc
.ssh/
*.sqlite
*.log
node_modules/
@forelabs
forelabs / ar_arel_wrapper.rb
Created January 9, 2020 10:47 — forked from tokland/ar_arel_wrapper.rb
Simple wrapper over arel
require 'active_record'
require 'arel'
# Ruby-like syntax in AR conditions using the underlying Arel layer (Rails >= 3.0).
#
# What you would usually write like this:
#
# User.where(["users.created_at > ? AND users.name LIKE ?", Date.yesterday, "Mary"])
#
# can now be written like this (note those parentheses required by the operators precedences):
@forelabs
forelabs / disable_animations.js
Created August 30, 2018 08:47
[Rails] Disable css & jquery animations in Capybara tests with Chome running on Selenium
var disableAnimationStyles = '-webkit-transition: none !important;' +
'-moz-transition: none !important;' +
'-ms-transition: none !important;' +
'-o-transition: none !important;' +
'transition: none !important;' +
'transition-property: none !important;' +
'-o-transition-property: none !important;' +
'-moz-transition-property: none !important;' +
'-ms-transition-property: none !important;' +
'-webkit-transition-property: none !important;' +
@forelabs
forelabs / update-go.bash
Created September 25, 2019 08:31
go version update
function update-go() {
release=$(curl --silent https://golang.org/doc/devel/release.html | grep -Eo 'go[0-9]+(\.[0-9]+)+' | sort -V | uniq | tail -1)
os=$(uname -s | tr '[:upper:]' '[:lower:]')
arch=$(case "$(uname -m)" in i*) echo '386' ;; x*) echo 'amd64' ;; *) echo 'armv61'; esac)
curl --silent https://storage.googleapis.com/golang/$release.$os-$arch.tar.gz \
| sudo tar -vxz --strip-components 1 -C $(dirname $(dirname $(which go)))
}