Skip to content

Instantly share code, notes, and snippets.

View mettledrum's full-sized avatar

Andrew Hoyle mettledrum

View GitHub Profile
@mettledrum
mettledrum / main.go
Last active December 15, 2017 16:42
go aws sdk -> s3rver docker; just morphed the README.md example a lil' bit
package main
import (
"context"
"encoding/json"
"flag"
"fmt"
"log"
"os"
"time"
@mettledrum
mettledrum / main.go
Last active November 27, 2017 23:51
workers that run until error
package main
import (
"errors"
"fmt"
"sync"
"time"
)
// what the consumer does
@mettledrum
mettledrum / main.go
Created November 22, 2017 23:03
hard workin go routines
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
)
@mettledrum
mettledrum / fiddle.response.json
Last active April 28, 2016 16:44
beer json response
{
"who": "mettledrum",
"age": 31,
"fav_beers":
[
{
"name": "hot pepper",
"abv": 5.2,
"is_good": false
},
@mettledrum
mettledrum / agreement.html
Created May 30, 2015 16:13
wkhtmltopdf usage for PDF rendering
<h1>{{.Stuff}} is really neato!</h2>
@mettledrum
mettledrum / PDFify.go
Created May 25, 2015 21:33
use suffix to PDF-ify any ol' endpoint
package main
import (
"fmt"
"log"
"net/http"
"github.com/gorilla/context"
"github.com/gorilla/mux"
"github.com/terryh/gopdf"
@mettledrum
mettledrum / gist:a6107e0de98140b42222
Last active April 24, 2018 06:25
example of using pprof
package main
import (
"runtime/pprof"
"fmt"
"net/http"
"os"
"time"
)
@mettledrum
mettledrum / _comment_forest.html.erb
Last active August 29, 2015 14:05
_partials for recursively displaying nested comments for a posting
<% @comments.each do |comment_hash| %>
<%= render 'comment_tree', comment_hash: comment_hash %>
<% end %>
# mixes in logic to make a model understand how to fetch its relationships
# based on the item_id/item_item_type field combination
module VariadicItem
extend ActiveSupport::Concern
included do
belongs_to :item_type
end
# get the item associated with the current polymorphic record into which this module has been mixed
@mettledrum
mettledrum / numbers_to_English.rb
Last active August 29, 2015 14:01
Just a simple class to convert integers LT | 1 quadrillion | into their American English equivalent.
# Andrew Hoyle
# converts a +/- integer to its American English equivalent
# includes basic exceptions
# PRE: less than | 1 quintillion | and +/- integer
# allows only numbers, commas, and '+' or '-' in idx[0]
# POST: American English translation of number
class Worder
# AM. ENGLISH