Skip to content

Instantly share code, notes, and snippets.

@andersonsp
Last active October 13, 2016 21:50
Show Gist options
  • Save andersonsp/08c85cbc48c8c878d06b to your computer and use it in GitHub Desktop.
Save andersonsp/08c85cbc48c8c878d06b to your computer and use it in GitHub Desktop.
Shell snippets
## copy all *.example files usable files
for ex in config/*.yml.example(:t:r) do
[[ -a config/${ex} ]] || cp config/${ex}.example config/${ex}
done
# it updates _just_ one gem and uses the specified Gemfile
BUNDLE_GEMFILE=Gemfile.other bundle update --source awesome_gem
# do a loop task with a progressbar
events=4000;
word="####################################################################################################";
for ((i = 1; i <= $events; i++)) do
pct=`echo "a = $i/$events*100; scale=0; a/1+1" | bc -l`;
printf "%3d [%*s] %4d\n" $pct -100.100 $word[1,$pct] $i;
# some expensive task here
sleep 0.5;
done
# load environment variables from .env and run a command
env $(cat .env | xargs) rails
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment