Skip to content

Instantly share code, notes, and snippets.

View groveriffic's full-sized avatar

Sam Ehlers groveriffic

View GitHub Profile
@groveriffic
groveriffic / sum_monoid.go
Last active October 15, 2015 20:22
Demonstrates a trivial sum monoid in Go.
package main
import (
"fmt"
"log"
)
// Sum monoid
var identity int = 0
var mappend = func(a, b int) int {
package main
import (
"fmt"
"log"
)
// Product monoid
var identity int = 1
var mappend = func(a, b int) int {
package main
import (
"fmt"
"log"
)
// A monoid that combines sum and count to calculate an average
type average struct {
sum int
package main
import (
"fmt"
"log"
)
// String Concatenation Monoid
var identity string = ""
var mappend = func(a, b string) string {
package main
import (
"fmt"
"log"
)
type point struct {
x int
y int
@groveriffic
groveriffic / affine_edit.elm
Last active December 4, 2015 23:00
Edit affine transformations with mouse and keyboard in Elm
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
import Mouse
import Keyboard
import Char
import Signal
import Transform2D
import Time
@groveriffic
groveriffic / unit_circle.html
Created March 16, 2017 19:02
Using the stock web stack to refresh my understanding of Trigonometry
<html>
<head>
<title>Trigonometry in the Unit Circle</title>
<style>
circle, line {
fill: none;
stroke: black;
stroke-width: 0.01;
}
@groveriffic
groveriffic / curl_syntax.py
Created October 1, 2018 16:26
Prints out a command line curl from the same inputs your would have used with requests
def curl_syntax(url, params=[], headers=[]):
print(url, params, headers)
from urllib.parse import urlencode
print('curl \\')
print(' --verbose \\')
for k in sorted(headers.keys()):
v = headers[k]
print(' --header "{}: {}" \\'.format(k, v))
params_array = []
for k in sorted(params.keys()):