Skip to content

Instantly share code, notes, and snippets.

@ewalk153
ewalk153 / mbox.go
Created August 18, 2014 22:19
parse MBOX file format for attachments
package main
import (
"bufio"
"bytes"
"encoding/base64"
"fmt"
"io"
"io/ioutil"
// "log"
@ewalk153
ewalk153 / mini-bot.go
Last active December 28, 2025 22:52
Mini-bot is a mini hipchat bot that listens in a given room, and runs actions based on user interactions
package main
import (
"errors"
"fmt"
api "github.com/andybons/hipchat"
"github.com/daneharrigan/hipchat"
"github.com/joho/godotenv"
"os"
"strings"
@ewalk153
ewalk153 / fast_pg_restore.sh
Created July 24, 2014 21:06
Faster restore of postgres backup by ignoring certain data
pg_restore -l cr2.dump > db.list
# edit db.list
pg_restore --verbose --clean --no-acl --no-owner -h {HOST} -U {USER} -d {DATABASE} -L db.list cr2.dump
package main
import (
"bytes"
"fmt"
"github.com/gorilla/sessions"
"html/template"
"net/http"
"strconv"
)
@ewalk153
ewalk153 / mailhook.go
Created April 29, 2014 15:38
Record requests and display results, in memory
package main
import (
"fmt"
"net/http"
"os"
"strings"
)
//History of recent posts
@ewalk153
ewalk153 / pointer_only.go
Created April 18, 2014 13:17
Demonstrate that the SetYAML method only works with pointer Fields
package main
import (
"fmt"
"gopkg.in/yaml.v1"
"time"
)
type timeUnMarsh struct {
time.Time
cat | ruby -e "STDIN.readlines.select{|l|l[/memory_total/]}.map{|l| l.split(/\s+/)}.map{|l| puts \"#{l[2][/T[\d+:]+/][1..-1]} #{l[9][/([\d.]+)MB/][0..-3]}\"}"
@ewalk153
ewalk153 / upgrade_postgres.bash
Created January 3, 2014 03:32
upgrade heroku postgres from crane to yanari
# this can be done anytime
heroku addons:add heroku-postgresql:standard-yanari --app nav-chronos; heroku pg:wait
# about 3m30s
heroku maintenance:on
heroku ps:scale worker=0
heroku pgbackups:capture --expire
# less than 20 min
@ewalk153
ewalk153 / xml.go
Created December 25, 2013 17:56
go example for using XML
package main
import (
"encoding/xml"
"fmt"
"log"
)
type Reading struct {
RType string `xml:"r_type,attr"`
@ewalk153
ewalk153 / Guardfile
Last active January 1, 2016 01:29
Go guard file. Slightly more advanced version.
require 'guard'
require 'guard/plugin'
class Guard::Mygo < Guard::Plugin
def run_all
system 'go test ./...'
end
def run_on_changes(paths)
paths.each do |file|