Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Stephen 200sc

  • strongDM
  • Minneapolis, MN
View GitHub Profile
@200sc
200sc / lookupFlag.go
Created Aug 19, 2019
How to lookup a flag from os.Args in Go
View lookupFlag.go
package main
import (
"fmt"
"os"
"strings"
)
func LookupFlag(name string) (value string, found bool) {
i := 0
View yt-download.go
package main
import (
"encoding/csv"
"flag"
"fmt"
"io"
"os"
"path/filepath"
"strings"
@200sc
200sc / convert.go
Created Apr 12, 2019
Convert csvs with rows of fields to rows of objects
View convert.go
package main
import (
"encoding/csv"
"fmt"
"os"
"strconv"
)
type Record struct {
View recolor.go
package render
func Recolor(cMap[color.Color]color.Color) Modification {
return func(rgba image.Image) *image.RGBA {
bds := rgba.Bounds()
newRgba := image.NewRGBA(bds)
for x := 0; x < bds.Max.X; x++ {
for y :=0; y < bds.Max.Y; y++ {
@200sc
200sc / holes.go
Last active Oct 25, 2017
a function to get holes from a 2d boolean array
View holes.go
func GetHoles(sh Shape, w, h int) [][]intgeom.Point {
flooding := make(map[intgeom.Point]bool)
for x := 0; x < w; x++ {
for y := 0; y < h; y++ {
if !sh.At(x, y) {
flooding[intgeom.Point{x,y}] = true
}
}
View collisionDemo.go
package main
// This is a gist copy of https://github.com/200sc/collision-demo/blob/master/core.go
import (
"image/color"
"bitbucket.org/oakmoundstudio/oak"
"bitbucket.org/oakmoundstudio/oak/collision"
"bitbucket.org/oakmoundstudio/oak/entities"
View pongOak.go
package main
import (
"bitbucket.org/oakmoundstudio/plasticpiston/plastic"
"bitbucket.org/oakmoundstudio/plasticpiston/plastic/collision"
"bitbucket.org/oakmoundstudio/plasticpiston/plastic/entities"
"bitbucket.org/oakmoundstudio/plasticpiston/plastic/event"
"bitbucket.org/oakmoundstudio/plasticpiston/plastic/render"
"image/color"
"math/rand"
View flappyOak.go
package main
import (
"image/color"
"time"
"github.com/200sc/go-dist/floatrange"
"bitbucket.org/oakmoundstudio/oak"
"bitbucket.org/oakmoundstudio/oak/collision"
View LICENSE
All public gists https://gist.github.com/200sc
Copyright 2017, Patrick Stephen
MIT License, http://www.opensource.org/licenses/mit-license.php
View cross.go
package main
// Build cross-compiles packages on set of
// OS and architecture pairs.
import (
"bytes"
"flag"
"fmt"
"os"