Skip to content

Instantly share code, notes, and snippets.

View maxbeutel's full-sized avatar

Max maxbeutel

View GitHub Profile
series = [
10,
57,
33,
21,
19,
20,
18,
17,
24,
alias gis='git status'
alias gaa='git add -A'
alias gdc='git diff --cached --color=always'
alias gdd='git diff --color=always'
alias gll='git log --color=always'
alias gpr='git pull --rebase'
# Show or count differences between branches.
# Usage to compare current branch against master: gbdl origin/master..
alias gbcl="git rev-list --pretty=\"%h - %an, %ad : %s\""
alias gbcc="git rev-list --count"
// walkEvents walks an event list applying a hook function.
// This is intended to be parallelized. Apply only when the
// computation has no dependency on the order in which commits
// are processed.
// Source: http://esr.ibiblio.org/?p=8607#comment-2365265
func walkEvents(events []Event, hook func(int, Event)) {
if control.flagOptions["serial"] {
for i, e := range events {
hook(i, e)
}
<!DOCTYPE html>
<html><head>
<script type="text/javascript">
// https://github.com/mhwombat/grid/wiki/Triangular-tiles
function rectTriGrid(r, c) {
var res = [];
for (var y = 0; y <= 2*r-1; y++) {
for(var x = xMin(y); x <= xMax(c, y); x++) {
package main
import (
"bufio"
"encoding/json"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
package main
import (
"fmt"
"math"
)
// Cumulative distribution function for the standard normal distribution
// Percentage of data that lies within the standard distribution
func cdfNorm(x float64) float64 {
@maxbeutel
maxbeutel / convert.go
Last active December 27, 2017 06:48
utility for type conversions
package convert
/*
Usage, assuming o is a map[string]interface{}
errs := []error{}
errs = append(errs, c.AsString(c.FromUntypedMap(o, "nr")).Assign(&tmp.OrderId))
errs = append(errs, c.AsString(c.FromUntypedMap(o, "status")).Assign(&tmp.Status))
errs = append(errs, c.AsTime(c.FromUntypedMap(o, "date")).Assign(&tmp.Date))
@maxbeutel
maxbeutel / connected-components.go
Created December 12, 2017 03:39
Rough draft of how to implement connected component labelling using disjoint sets
package main
import (
"fmt"
"image"
_ "image/png"
"log"
"os"
)
require(igraph)
require(expm)
G <- graph.tree(n=7,children=2)
V(G)$name <- LETTERS[1:length(V(G))]
co <- layout.reingold.tilford(G, params=list(root=1))
plot(G, layout=co)
@maxbeutel
maxbeutel / plotrent.r
Last active July 5, 2017 03:02
plot rent
#install.packages('ggplot2', dep = TRUE, repos = "http://cran.us.r-project.org")
library(ggplot2)
df <- read.csv("/Users/max/Desktop/sant-ritz-rental-0516-to-0517.csv")
z <- df[df$NoOfBedroom==1,]
z$LeaseCommencementDate <- as.Date(paste("01-", z$LeaseCommencementDate, sep = ""), format = "%d-%b-%Y")
mean(z$MonthlyGrossRent)