Skip to content

Instantly share code, notes, and snippets.

View seanhagen's full-sized avatar
:shipit:
coding

Sean Hagen seanhagen

:shipit:
coding
View GitHub Profile
@seanhagen
seanhagen / hay-collisions.txt
Last active September 2, 2022 02:20
Collisions when encoding to Pig Latin when using 'way', 'hay', and 'yay' as the suffix for words starting with a vowel.
airbrusheshay | airbrushes hairbrushes
airbrushhay | airbrush hairbrush
airierhay | airier hairier
arkhay | ark hark
armedhay | armed harmed
arminghay | arming harming
armlesslyhay | armlessly harmlessly
arrowinghay | arrowing harrowing
ashinghay | ashing hashing
earhay | ear hear
@seanhagen
seanhagen / main.go
Created September 1, 2022 23:53
Simple web scraper to get a list of English words
package main
import (
"fmt"
"io"
"net/http"
"os"
"github.com/PuerkitoBio/goquery"
)
@seanhagen
seanhagen / anonymous-gist.go
Created July 15, 2022 17:50
Example io.Pipe
func main() {
r, w := io.Pipe()
ctx := context.Background()
ctx, cancel := context.WithTimeout(ctx, time.Second*10)
defer cancel()
wg := sync.WaitGroup{}
wg.Add(2)
@seanhagen
seanhagen / config.el
Last active February 18, 2022 22:57
Example Org Config
(setq straight-use-package-by-default t
user-emacs-directory "~/test/emacs"
straight-base-dir "~/test"
package-user-dir "~/test/elpa")
(defvar bootstrap-version)
(let ((bootstrap-file (expand-file-name "~/test/straight/repos/straight.el/bootstrap.el"))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
@seanhagen
seanhagen / example_query_usage.go
Created February 5, 2022 01:59
An example of how you can have both squirrel-crafted queries & hand-crafted queries in the same codebase
type result struct {
ID string `db:"id"`
Name string `db:"name"`
Title sql.NullString `db:"title"`
}
func queryWithSqurrel(ctx context.Context, id string) (*Result, error) {
q := sq.Select("t.id,t.name,t.title").
From("the_table t").
Column("b.other as phone").
@seanhagen
seanhagen / camera.cs
Created March 2, 2021 19:33
Native Camera
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
public class CameraScript : MonoBehaviour {
// Start is called before the first frame
void Start() {
NativeCamera.RequestPermission();
@seanhagen
seanhagen / aoc2019-18-1.go
Created December 20, 2019 02:35
Some code that's not working right
// this is the node thing for getting from the start position to the last key
type path struct {
name string
node *tile
steps int
parent *path
children []path
keysFound []string
@seanhagen
seanhagen / go-config.el
Created June 24, 2019 19:21
Emacs LSP & yasnippet config
;;; go-config.el --- Summary
;;; Commentary:
;;; Code:
(setenv "GOPATH" "/home/sean/Code/Go")
(use-package go-mode
:ensure t
:defer t
:mode "\\.go\\'"
@seanhagen
seanhagen / base.go
Created August 27, 2019 21:01
Interface/API Design Question
package email
import (
"context"
)
// Version 1
// Sender is an interface to hide the fact we're using a 3rd party library
type Sender interface {
@seanhagen
seanhagen / grpc-middleware.go
Created April 4, 2019 00:28
Honeycomb Go GRPC Middleware
// HoneycombUnary returns an interceptor that adds Honeycomb metrics to any incoming unary requests.
func HoneycombUnary() grpc.UnaryServerInterceptor {
return func(ctx context.Context, r interface{}, i *grpc.UnaryServerInfo, h grpc.UnaryHandler) (interface{}, error) {
ctx, t, s := setupTrace(ctx, r, i.FullMethod, "unary")
defer t.Send()
o, err := h(ctx, r)
result := "success"
if err != nil {