Skip to content

Instantly share code, notes, and snippets.

@donato
donato / aws-swap.sh
Created July 7, 2017 20:33
Switching between aws environments often?
# Given files ~/dev.s3cfg and ~/prd.s3cfg
# $swap dev
# $swap prd
function swap {
echo "Setting aws key + secret for s3cmd and aws-cli to $1 ENV"
rm -f ~/.s3cfg
cp ~/$1.s3cfg ~/.s3cfg
rm -rf ~/.aws/
cp -r ~/$1.aws ~/.aws/
}
@donato
donato / jwenv.sh
Last active October 27, 2017 20:32
Set JW Environment variables
# !/bin/bash
# This has two assumptions
# 1. Virtual environment set up in ~/venv/{project-name}
# 2. Configuration for configuration set up in ~/salt/{project-name}
# Given the name of the project as parameter
# $jwenv mini-batch
function project_name {
if [ -z $1 ];
then
@donato
donato / alias-gre.sh
Last active August 18, 2016 16:19
Alias to list the 5 most recently edited git branches
# Alias to list the 5 most recently edited git branches
alias gre="git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:red)%(objectname:short)%(color:reset);%(color:yellow)%(refname:short)%(color:reset);(%(color:green)%(committerdate:relative)%(color:reset));%(authorname);%(contents:subject)' | column -t -s ';' | tail -5"
## Example output
# d1d3373 bugfix/graph-segments (3 days ago) Donato Borrello Parameterize graph_segments values
# d1d3373 task/ordering (3 days ago) Donato Borrello Parameterize graph_segments values
# 3138812 bugfix/group-validate (3 days ago) Donato Borrello Bugfix to validation for group in charts
# 4bda519 task/accuracy-checker (19 hours ago) Donato Borrello Add script to wrap accuracy checker
@donato
donato / channel-push-test.js
Created May 4, 2016 15:38
Example performance test for CSP Channels
/*
This is a simplified excerpt of a performance test used for channel throughput.
It reads from a file into an inputChannel, and pushes it's data through two other channels.
You can tune the test by how many bytes are sent at a time, and how long to wait between sending more data.
usage
$node channel-push-test.js my_video.mp4
*/
@donato
donato / github-clean.js
Created October 9, 2015 15:47
Delete merged and closed branches from github which don't have recent activity
function deleteBefore(days) {
var ONE_DAY = 1000 * 60 * 60 * 24;
$('.branch-summary:not(.is-deleted)').each(function () {
var $this = $(this);
var datetime = new Date($this.find('time').attr('datetime')).getTime();
var today = (new Date().getTime());
var filter = today - (ONE_DAY * days);