Skip to content

Instantly share code, notes, and snippets.

@harlow
harlow / golang_job_queue.md
Last active April 24, 2024 10:21
Job queues in Golang
@harlow
harlow / get_set.go
Created August 4, 2014 04:31
Get and set values of a Struct using reflection in Go Lang
type MyStruct struct {
N int
}
n := MyStruct{ 1 }
// get
immutable := reflect.ValueOf(n)
val := immutable.FieldByName("N").Int()
fmt.Printf("N=%d\n", val) // prints 1
@harlow
harlow / user.rb
Last active November 16, 2023 15:13
Extract a validator in Rails. Zip code validation.
# app/models/user.rb
class User < ActiveRecord::Base
validates :zip_code, presence: true, zip_code: true
end
@harlow
harlow / worker-pool.go
Last active November 3, 2022 19:52
Worker pool to control concurrency and collect results
package main
import (
"fmt"
"sync"
"time"
)
const concurrency = 3
@harlow
harlow / cache.go
Created August 24, 2016 18:23
Golang cache map
package cache
import (
"crypto/sha256"
"encoding/json"
"fmt"
"os"
"sync"
"time"
)
@harlow
harlow / first-name-synonyms.csv
Last active January 19, 2022 18:05
First name synonyms for Elasticsearch synonym filter
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 4 columns, instead of 5. in line 1.
aaron,erin,ron,ronnie
abel,ab,abe,eb,ebbie
abiel,ab
abigail,abby,gail,gail,nabby
abner,ab
abraham,ab,abe
abram,ab
adaline,ada,addy,delia,dell,lena
adelaide,addy,adele,dell,della,heidi
adeline,ada,addy,delia,dell,lena
@harlow
harlow / lambda.tf
Created June 6, 2020 20:45
Terraform for Lambda func that reads Kinesis and writes to DynamoDB
# AWS
provider "aws" {
region = "us-west-2"
profile = "myAWSProfile"
}
# IAM
## IAM Role
resource "aws_iam_role" "iam_for_lambda" {
@harlow
harlow / README.md
Last active April 7, 2021 04:51
Nashville Hot Chicken

Nashville Hot Chicken

Prework

Salt and pepper brine the Chicken pieces for 24 hrs

Breading Station

Combine the following until the egg streaks are gone

@harlow
harlow / adams-heroku-values.md
Created December 11, 2020 22:14 — forked from adamwiggins/adams-heroku-values.md
My Heroku values

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@harlow
harlow / streams_to_firehose.go
Last active December 28, 2019 18:58
Golang lambda function to send Streams data to Firehose
package main
import (
"github.com/apex/go-apex"
"github.com/apex/go-apex/kinesis"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/firehose"
)