Skip to content

Instantly share code, notes, and snippets.

View richadams8's full-sized avatar

Rich Adams richadams8

  • Jive Communications
  • Lindon, UT
View GitHub Profile
@richadams8
richadams8 / smarterjimlist.sh
Created June 8, 2015 19:56
Better at searching for instances with given keywords
jlist () {
GREP_COMMAND="jim instance list "
for arg in $@; do
GREP_COMMAND=${GREP_COMMAND}"| grep $arg "
done;
echo $GREP_COMMAND
eval "$GREP_COMMAND"
}
@richadams8
richadams8 / cleangitbranches.sh
Created June 8, 2015 18:40
Clean out all git branches other than master
git branch | grep -v master | xargs git branch -d
@richadams8
richadams8 / checkstaticedge.sh
Last active August 29, 2015 14:22
Script for checking static-edge status
# Credit where credit is due to Nathaniel Landau for the sweet little bash hacks (http://natelandau.com/bash-scripting-utilities/)
bold=$(tput bold)
underline=$(tput sgr 0 1)
reset=$(tput sgr0)
purple=$(tput setaf 5)
red=$(tput setaf 1)
green=$(tput setaf 2)
tan=$(tput setaf 3)
@richadams8
richadams8 / convert_md_link_to_anchor_regex
Last active August 29, 2015 14:22
Convert markdown links to html anchors regex
@richadams8
richadams8 / WaterPercolation.java
Created May 1, 2015 15:43
Water Percolation Algorithm
package com.radams.play;
import org.junit.Test;
/**
* @author Rich Adams
*/
public class WaterPercolation
{
public boolean percolate(int[][] grid)
@richadams8
richadams8 / total_posix_offests.sql
Created April 28, 2015 21:02
PostgreSQL function for getting total posix hours or minutes
CREATE OR REPLACE FUNCTION posix_hours(val TIMESTAMPTZ) RETURNS INTEGER AS $$
BEGIN
RETURN (EXTRACT(EPOCH FROM (val - TIMESTAMPTZ '1970-01-01 00:00:00+00')) /
EXTRACT(EPOCH FROM INTERVAL '1 hour'))::INT;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION posix_minutes(val TIMESTAMPTZ) RETURNS INTEGER AS $$
BEGIN
RETURN (EXTRACT(EPOCH FROM (val - TIMESTAMPTZ '1970-01-01 00:00:00+00')) /
@richadams8
richadams8 / deathtoall.sh
Last active August 29, 2015 14:19
Rebuild all jinst instances
rebuildall(){
jim instance list | grep "$1" | cut -c 1-10 | xargs -I '{}' jim instance rebuild '{}';
}
@richadams8
richadams8 / workspaceclone.sh
Created February 27, 2015 23:14
Short bash function for cloning a directory with the workspace
workspaceclone () { jazz cog workspace switch -p ./$(basename $1) $1 ; }
@richadams8
richadams8 / .bash_profile
Last active August 29, 2015 14:14
.bash_profile 4/28/2015
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management