Skip to content

Instantly share code, notes, and snippets.

View beeekind's full-sized avatar

Benjamin Jones beeekind

View GitHub Profile
package json2go
import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"sort"
"strings"
"text/template"
@beeekind
beeekind / main.go
Last active December 2, 2020 19:35
Simple intuitive way to scrape single page applications in golang
package main
import (
"fmt"
"context"
"github.com/PuerkitoBio/goquery"
"github.com/chromedp/cdproto/dom"
"github.com/chromedp/chromedp"
)
@beeekind
beeekind / yamlexample.yaml
Created January 19, 2018 18:34
Better yaml
---
'200':
message: foo
creator: bar
@beeekind
beeekind / sandwichcodes.yaml
Created January 19, 2018 18:30
YAML all the things
---
statuscodes:
- code: '404'
message: No Sandwich Found
creator: rnelson0
- code: '410'
message: Sandwich Gone
creator: Breynolds
- code: '403'
message: Sandwich Locked
@beeekind
beeekind / extractor.go
Created October 18, 2017 20:42
data structures
package profile_extractor
import "time"
type Profile struct {
Name string
ProfileURL string
CurrentJobTitle string
CurrentCompany string
CurrentLocation string
package twelvefactor_ping
import (
"github.com/b3ntly/twelvefactor_ping/ping"
"net/http"
"os"
"log"
"fmt"
)
@beeekind
beeekind / pipeline.go
Created April 25, 2017 18:25
Asynchronous rate-limiting
package main
import (
"sync/atomic"
"time"
"fmt"
)
var (
counter int32 = 0
@beeekind
beeekind / interpreter.js
Created February 11, 2016 08:04
AngularJS service which takes a raw csv file via the HTML5 file api and returns an array of contact objects. Agnostic to ordering of the csv, and providing hard coded aliases for key words such as firstName which might also be called first_name in the csv.
angular.module('handstack').service("InterpreterService", function(){
this.getContactsFromRawCSV = function(file, callback){
/**
* Take CSV in a format similar to:
*
* '
* firstName,lastName,phone,email
* ben,jones,1234,b@b.com
* jessica,lee,2345,j@j.com
* '
@beeekind
beeekind / index.js
Created September 25, 2015 18:01
Example of using async module to setup before hook eloquently for mocha.js tests
"use strict";
var expect = require("expect.js");
var async = require("async");
var superagent = require("superagent");
var api = require("../lib/api");
var serverFactory = require("./helpers/server").init;
var Orm = require("@bjones6/hs-models");
var databaseSettings = { // this is running unexposed on localhost don't get excited
@beeekind
beeekind / createUser.js
Created September 24, 2015 16:50
Example of a express JS helper function with multiple asynchronous actions that must be completed in a certain order
"use strict";
/** @module CreateUser */
var models = require("../wrapper").getSingleton();
var async = require("async");
var password = require("password-hash-and-salt");
/**
* Create a user with a variable number of fields and a salted/hashed password, all users should