Skip to content

Instantly share code, notes, and snippets.

View webdevwilson's full-sized avatar

Kerry Wilson webdevwilson

View GitHub Profile
func SayHello() (interface{}, error) {
msg := os.Getenv("MSG")
return fmt.Sprintf("Hello from %s", msg), nil
}
func (h *httpHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// strip the path prefix
uri := req.URL.Path[len(h.pathPrefix):]
var data interface{}
var err error
if uri == "/" {
http.Redirect(w, req, fmt.Sprintf("%s/hello", h.pathPrefix), 302)
return
/**
* List the subdirectories in a directory
* @param p the path to the directory
*/
function *listDirectories(p: string) {
return new Promise((resolve, reject) => {
fs.readdir(p, (err, files) => {
files.forEach(f => {
fs.stat(f, (err, stats) => {
if(stats.isDirectory())
# Stores vault profile in .aws-vault-profile and provides useful
# commands to use them
#
# aws-vault-get - echo the profile for this directory, searches parent directories
# aws-vault-set <profile> - set the profile for the current directory
# ave <command> - execute a command with the current aws profile
# avl - login to the AWS console with the current profile
# avr - rotate your keys
AWS_VAULT_PROFILE_FILE=".aws-vault-profile"

Keybase proof

I hereby claim:

  • I am webdevwilson on github.
  • I am webdevwilson (https://keybase.io/webdevwilson) on keybase.
  • I have a public key ASCQOw3sBm8okN0t_Nj-LcZdXMcDAd-ZGJHubJTgBSZdcgo

To claim this, I am signing this object:

@webdevwilson
webdevwilson / mysql_copy.sh
Last active May 1, 2017 16:31
Migrate databases to a different host
#!/bin/bash -e
# Set permissions: `chmod 755 ./mysql_copy.sh`
# Run: `./mysql_copy.sh <databasename>`
######### CONFIGURE HERE ######################################################
# insert your source database credentials
SRC_DB_HOST=localhost
SRC_DB_USER=root
#!/bin/bash
javac -d bin $(find ./src/* | grep .java)
dir=$(pwd)
cd bin
java edu/gatech/cs6310/projectOne/ProjectOne -i ../resources/medium/student_demand_600.csv
if [ $? -eq 1 ]; then
echo "Relative directory failed."
exit 1
fi
@webdevwilson
webdevwilson / main
Created October 29, 2014 16:15
Dual ssl auth in go
# copied from https://groups.google.com/forum/#!topic/golang-nuts/dEfqPOSccIc
package main
import(
"crypto/rand"
"crypto/tls"
"io/ioutil"
"log"
"net"
@webdevwilson
webdevwilson / .profile
Last active December 26, 2015 10:49
Overload cd to garbage collect git
# overload cd to gc git when entering a directory
cd () {
builtin cd "$@"
if [ -d ".git" ]; then
(git gc --quiet &)
fi
}
@webdevwilson
webdevwilson / State.java
Created March 29, 2013 16:38
Enum containing states with abbreviations
import java.util.HashMap;
import java.util.Map;
public enum State {
ALABAMA("Alabama", "AL"), ALASKA("Alaska", "AK"), AMERICAN_SAMOA("American Samoa", "AS"), ARIZONA("Arizona", "AZ"), ARKANSAS(
"Arkansas", "AR"), CALIFORNIA("California", "CA"), COLORADO("Colorado", "CO"), CONNECTICUT("Connecticut", "CT"), DELAWARE(
"Delaware", "DE"), DISTRICT_OF_COLUMBIA("District of Columbia", "DC"), FEDERATED_STATES_OF_MICRONESIA(
"Federated States of Micronesia", "FM"), FLORIDA("Florida", "FL"), GEORGIA("Georgia", "GA"), GUAM("Guam", "GU"), HAWAII(
"Hawaii", "HI"), IDAHO("Idaho", "ID"), ILLINOIS("Illinois", "IL"), INDIANA("Indiana", "IN"), IOWA("Iowa", "IA"), KANSAS(