Skip to content

Instantly share code, notes, and snippets.

Avatar
:shipit:
coding

Sean Hagen seanhagen

:shipit:
coding
View GitHub Profile
@seanhagen
seanhagen / hay-collisions.txt
Last active Sep 2, 2022
Collisions when encoding to Pig Latin when using 'way', 'hay', and 'yay' as the suffix for words starting with a vowel.
View hay-collisions.txt
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 Sep 1, 2022
Simple web scraper to get a list of English words
View main.go
package main
import (
"fmt"
"io"
"net/http"
"os"
"github.com/PuerkitoBio/goquery"
)
View anonymous-gist.go
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 Feb 18, 2022
Example Org Config
View config.el
(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 Feb 5, 2022
An example of how you can have both squirrel-crafted queries & hand-crafted queries in the same codebase
View example_query_usage.go
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").
View camera.cs
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 Dec 20, 2019
Some code that's not working right
View aoc2019-18-1.go
// 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 / base.go
Created Aug 27, 2019
Interface/API Design Question
View base.go
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 / go-config.el
Created Jun 24, 2019
Emacs LSP & yasnippet config
View go-config.el
;;; go-config.el --- Summary
;;; Commentary:
;;; Code:
(setenv "GOPATH" "/home/sean/Code/Go")
(use-package go-mode
:ensure t
:defer t
:mode "\\.go\\'"
@seanhagen
seanhagen / grpc-middleware.go
Created Apr 4, 2019
Honeycomb Go GRPC Middleware
View grpc-middleware.go
// 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 {