Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cep21's full-sized avatar

Jack Lindamood cep21

View GitHub Profile

Keybase proof

I hereby claim:

  • I am cep21 on github.
  • I am cep21 (https://keybase.io/cep21) on keybase.
  • I have a public key ASAwNIEREtDh3M0e-0fmJBK5AlukNaSfZzfs3spchpbB2Qo

To claim this, I am signing this object:

@cep21
cep21 / ship.go
Last active May 28, 2019 17:53
Abstracted space ship
type Ship2 struct {
GameKillable
PhysicalObject
}
type PhysicalObject struct {
LocX float64
LocY float64
Size float64
}
@cep21
cep21 / space.go
Last active May 28, 2019 17:53
Original spaceship
type Ship struct {
Health int
LocX float64
LocY float64
Size float64
}
func (s *Ship) Heal(amnt int) {
if s.Health >= 0 {
s.Health += amnt
@cep21
cep21 / main_test.go
Created June 12, 2018 00:23
workaround
package main
import (
"sync"
"testing"
)
func TestAppend(t *testing.T) {
x := make([]string, 0, 6)
x = append(x, "start")
@cep21
cep21 / main_test.go
Created June 11, 2018 18:22
A -race failing test
package main
import (
"testing"
"sync"
)
func TestAppend(t *testing.T) {
x := make([]string, 0, 6)
@cep21
cep21 / main_test.go
Last active June 24, 2022 02:41
Example test
package main
import (
"sync"
"testing"
)
func TestAppend(t *testing.T) {
x := []string{"start"}
@cep21
cep21 / integration_test.go
Created January 26, 2018 19:40
Example integration test
package trace_110
import (
"testing"
"sync"
"fmt"
"time"
"net/http"
)
@cep21
cep21 / a.go
Last active August 29, 2017 22:42
Two file imports
// From package A
package a
type T int64
type S struct{}
func (s *S) TypedFunction() T {
return T(0)
}
type I interface {
Func()
}
type I2 interface {
Another()
}
type I3 interface {
Func()
Another()
}
@cep21
cep21 / cache_library.go
Last active July 25, 2017 22:26
example cache library
type ObjectCache {}
func (r *ObjectCache) Cached(ctx context.Context, key string, callback func() (interface{}, error), storeIntoPtr interface{}) error {
// Check cache for object, if it exists, get it from cache, otherwise call callback, store to cache, and put result
// into storeIntoPtr pointer
}
func (app * Application) UserCode(ctx context.Context) (*UserProfile, error) {
var ret *UserProfile
err := app.Cache.Cached(ctx, "user:" + userID, func() (interface{}, error) {