Skip to content

Instantly share code, notes, and snippets.

View JeffreyBPetersen's full-sized avatar

Jeff Petersen JeffreyBPetersen

View GitHub Profile
@JeffreyBPetersen
JeffreyBPetersen / raindots.html
Last active November 29, 2016 11:17
raindots
<!doctype html>
<html>
<head>
<style>
body {
align-items: center;
background-color: black;
color: white;
display: flex;
height: 100vh;
@JeffreyBPetersen
JeffreyBPetersen / main.go
Created October 31, 2016 22:19
BoltDB example
package main
import (
"fmt"
"log"
"github.com/boltdb/bolt"
)
func main(){
fmt.Println("hi there")
@JeffreyBPetersen
JeffreyBPetersen / po.go
Created October 7, 2016 21:46
quickest possible go webserver?
package main
import "net/http"
func main() {
http.ListenAndServe(":80", http.FileServer(http.Dir(".")))
}
<html>
<head></head>
<body style="display:flex;justify-content:center;">
<pre style="font-family:sans-serif;line-height:150%;max-width:64em;white-space:pre-wrap;">
Interviewer: Today we have Elon Musk. Elon, thank you for joining us.
Elon: Thanks for having me.
Interviewer: So, we want to spend the time today talking about your view of the future and what people should work on. To start off, could you tell us, you famously said, when you were younger, there were five problems that you thought were most important for you to work on. If you were 22 today, what would the five problems that you would think about working on be?
@JeffreyBPetersen
JeffreyBPetersen / main.go
Created September 13, 2016 00:04
Pick a single value out of a multiple return in golang.
package main
import (
"fmt"
"io/ioutil"
)
func door(number int) func(...interface{}) interface{} {
return func(doors ...interface{}) interface{} {
return doors[number]
@JeffreyBPetersen
JeffreyBPetersen / post.md
Last active August 22, 2016 01:46
In response to "What will drastically change the world in the next 5 years?"

What will drastically change the world in the next 5 years? - reddit post

Cryptoeconomics

It's a very weird, small, young, and cross-disciplinary field, of which the most widely known example is Bitcoin. It's what happens when you intersect economics/game-theory with computer science.

Nowadays you can already do some incredibly weird stuff like write programs that implement all the core logic of a business including finances, yet don't depend on anyone in particular to keep them running. That's doable using Ethereum.

Still, for the most part things haven't yet progressed past parlor tricks that on the surface resemble digital Rube Goldberg machines for sending money across the room. I'd credit this to a few reasons:

@JeffreyBPetersen
JeffreyBPetersen / pubsub.js
Created August 19, 2016 07:28
Simple publisher/subscriber design pattern in javascript.
function PubSub(){
this.channels = {};
this.channelBySubscription = {};
this.nextSubscriptionID = 0;
};
PubSub.prototype.pub = function(channel, publication){
let currentChannel = this.channels[channel];
for(let subscriptionID in currentChannel){
currentChannel[subscriptionID](publication);
@JeffreyBPetersen
JeffreyBPetersen / clock.js
Created August 17, 2016 01:34
A rudimentary binary clock sonification
let config = {
ticksPerSecond: 2.4,
volume: 0.02
};
let rawNote = steps => 440 * Math.pow(Math.pow(2, 1/12), steps);
let sqr = (time, freq) => Math.floor(time * freq % 2) * 2 - 1;
let sin = (time, freq) => Math.sin(time * freq * Math.PI * 2);
@JeffreyBPetersen
JeffreyBPetersen / index.html
Last active August 15, 2016 06:36
What I like to start with for making a new webpage.
<!doctype html>
<html>
<head>
<link href='index.css' rel='stylesheet'></link>
<script src='index.js' defer></script>
</head>
<body>
hello
</body>
</html>
@JeffreyBPetersen
JeffreyBPetersen / noip.css
Last active August 11, 2016 02:24
I named this "noip" for no particular reason.
body {
align-items: center;
display: flex;
justify-content: center;
margin: 0;
min-height: 100vh;
}
#noip {
background-color: #000;