Skip to content

Instantly share code, notes, and snippets.

View jonmorehouse's full-sized avatar
💻
founder at nuon.co

Jon Morehouse jonmorehouse

💻
founder at nuon.co
View GitHub Profile
@jonmorehouse
jonmorehouse / strings.sh
Created January 14, 2014 07:33
String manipulation using bash
# extract whats in front of extension in bash script
# name = "jon.coffee"
# echo "${name %%coffee}"
# http://tldp.org/LDP/abs/html/string-manipulation.html
# using the % / # string modifiers
# name = JonMorehouse
# remove up to the element
# remove element and print after
@jonmorehouse
jonmorehouse / vimrc
Created January 15, 2014 19:09
UUID generator for vim. Inputs a uuid to copy buffer
fu! GenerateUUID()
python << EOF
import uuid
import vim
# output a uuid to the vim variable for insertion below
vim.command("let generatedUUID = \"%s\"" % str(uuid.uuid4()))
EOF
@jonmorehouse
jonmorehouse / vimrc
Last active August 29, 2015 13:55
Go test runner for vim editor
fu! GoTestPackage()
let command = "go test ."
call CleanShell(command)
endfunction
fu! GoTestFile()
package main
import (
"os"
)
func main() {
path := "test.txt"
@jonmorehouse
jonmorehouse / tar.go
Created February 17, 2014 22:29
Quick golang script for creating a gzipped tarball
package main
import (
"os"
"archive/tar"
"log"
"io"
"compress/gzip"
)
@jonmorehouse
jonmorehouse / ec2.sh
Last active August 29, 2015 13:56
EC2 one liners for setting up / breaking down machines
#!/usr/local/bin/bash
# create an ec2-instance and grab the instance id
instance_id=$(ec2-run-instances -g development -t t1.micro -k master $EC2_UBUNTU_AMI | grep INSTANCE | awk '{ print $2 }')
# create a tag for this instance as needed
ec2-create-tags -t Name=development $instance_id
# grab instance_id by tag
instance_id=$(ec2-describe-instances --filter "tag:Name=development" | grep INSTANCE | awk '{ print $2 }')
@jonmorehouse
jonmorehouse / alias_generator.sh
Created March 3, 2014 08:17
Alias Generator - useful for creating name-spaced aliases for project directories
#!/usr/local/bin/bash
alias_path="$1"
if [ $# -gt 1 ]
then
# if _ or "" is passed in, then we want to just pass in a blank
if [[ $2 == "_" || $2 == "" ]]
then
alias_prefix=""
else
alias_prefix="$2-"
@jonmorehouse
jonmorehouse / security-groups.sh
Last active August 29, 2015 13:57
Command line management of groups
# create a new security group
ec2-add-group -d "Group description" $groupName
# now delete a group
ec2-delete-group $groupName
# authorize rules for a group
ec2-authorize $groupName
# authorize a group to expose all tcp ports
[Unit]
Description=docker daemon
[Service]
PermissionsStartOnly=true
Type=forking
ExecStart=/usr/bin/docker -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock -d