Skip to content

Instantly share code, notes, and snippets.

View bentranter's full-sized avatar

Ben Tranter bentranter

View GitHub Profile
@bentranter
bentranter / gotta_go_fast.go
Created September 3, 2015 18:47
Scrape every course at LU in less than 3 seconds
// Gotta go fast
package main
import (
"fmt"
"net/http"
"time"
"github.com/bentranter/chalk"
"github.com/yhat/scrape"
@bentranter
bentranter / pointers.c
Last active October 4, 2015 20:32
Pointers in Go: Just like C 😊
#include <stdio.h>
int byVal(int i) {
i = 0;
return i;
}
int byRef(int *i) {
*i = 0;
return *i;
@bentranter
bentranter / rest_api_design_notes.md
Created October 20, 2016 18:07
Notes about REST API Design from StormPath's Latest Webinar

Stormpath Presentation

They focus on security and high availability. Free for devs.

  • Latency caching?

What're the things you can use to make your life easier?

HATEOAS - Hypermedia As The Engine Of Application State. The API and all info is self-contained in the data sent to and from the server - no out-of band info. Basically, you shuldn't need to go elseqhere or look up docs.

@bentranter
bentranter / uuid_v4.js
Last active September 1, 2021 11:09
Spec Compliant UUIDv4 Generator using the Web Crypto API
// uuid returns an RFC 4122 compliant universally unique
// identifier using the crypto API
function uuid() {
// get sixteen unsigned 8 bit random values
var u = window
.crypto
.getRandomValues(new Uint8Array(16));
// set the version bit to v4
@bentranter
bentranter / four_letter_word_list.txt
Created April 11, 2019 20:21
List of all four letter words in the Unix dictionary at /usr/share/dict/words
AANI
AARU
ABAC
ABAS
ABBA
ABBY
ABED
ABEL
ABET
ABEY
@bentranter
bentranter / race_test.go
Created December 18, 2019 17:45
An attempt to recreate the race condition in godo.
package race_test
import (
"context"
"fmt"
"log"
"math/rand"
"os"
"sync"
"testing"
@bentranter
bentranter / fillstruct_test.go
Created July 27, 2022 17:17
Fill a struct in Go using reflection
package fillstruct
import (
"reflect"
"testing"
)
// FillStruct fills a struct with a string value as an example of how to use
// reflection to accomplish this.
func FillStruct(v interface{}) {