Skip to content

Instantly share code, notes, and snippets.

View sighmin's full-sized avatar
💛
grateful

Simon van Dyk sighmin

💛
grateful
View GitHub Profile
@sighmin
sighmin / README.md
Last active July 11, 2017 15:03
Traffic widget and job for dashing dashboard framework.

Description

Simple Dashing widget and job to display driving times of a route. Uses TomTom for free traffic information.

We at platform45 use it to display our driving times home so we know when to leave work to get home to our loved ones in time.

##Dependencies

Uses json, uri and net/http net/https libraries.

@sighmin
sighmin / GP Finance Decision Tree
Created May 29, 2013 09:01
A Decision Tree evolved using genetic programming to buy/short a stock of the S&P500 companies assuming an empty portfolio. Fitness f() is the revenue generated using this tree on historical stock data at quarterly intervals, in 2010. Thanks google for the easy access to this data.
f() = 17.90104616080656
└── EarningsPerShareChange < 89.677
├── GrossMargin09 > 62.198
│ ├── ReturnOnEquity09 < 9.4697
│ │ ├── GrossMargin09 > 62.198
│ │ │ ├── ReturnOnEquity09 < 9.4697
│ │ │ │ ├── GrossMargin09 > 66.274
│ │ │ │ │ ├── ReturnOnEquity09 < 42.481
│ │ │ │ │ │ ├── GrossMargin10 > 46.027
│ │ │ │ │ │ │ ├── BUY
@sighmin
sighmin / Loops and Functions Go Tour Exercise
Last active August 21, 2019 18:39
Go tour sqrt VS newton's method: http://tour.golang.org
package main
import (
"fmt"
"math"
)
func Newt(x float64) float64 {
if x == 0 { return 0 }
z := 1.0
@sighmin
sighmin / Slices Go Tour Exercise
Last active September 29, 2018 08:38
Go tour "Pic" method: http://tour.golang.org
package main
import (
"fmt"
"code.google.com/p/go-tour/pic"
)
// Return a matrix of uint8's to be drawn
func Pic(dx, dy int) [][]uint8 {
@sighmin
sighmin / Maps Go Tour Exercise
Created February 23, 2014 17:27
Go tour "WordCount" method: http://tour.golang.org
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
tokens := strings.Fields(s)
hashmap := make(map[string] int)
@sighmin
sighmin / Closure Go Tour Exercise
Last active August 29, 2015 13:56
Go tour "Fibonacci closure factory" method: http://tour.golang.org
package main
import "fmt"
// Fibonacci closure factory
func fibonacci() func() int {
previous := 0
current := 1
return func() int {
package main
import (
"fmt"
"math/cmplx"
)
func Cbrt(x complex128) complex128 {
result := complex128(x)
for i := 0; i < 100; i++ { // To ensure high precision
@sighmin
sighmin / Go hello world http server
Created April 14, 2015 05:53
Go hello world http server
package main
import (
"fmt"
"log"
"net/http"
)
type Hello struct{}
@sighmin
sighmin / Go multiple http handlers example
Created April 14, 2015 06:25
Go multiple http handlers example
package main
import (
"fmt"
"log"
"net/http"
)
type String string
type Struct struct {
@sighmin
sighmin / checklist.rb
Created June 4, 2015 14:17
Fiddling with the shockingly documented AREL library to produce a join using an aggregate SQL function (max) in the hopes I'd be able to chain it. ALAS! Only after 2 hours did I realize this ain't gonna works yo.
class Checklist < ActiveRecord::Base
scope :current, -> {
c = Arel::Table.new(:checklists, as: 'c')
r = Arel::Table.new(:checklists, as: 'r')
sql = c.project(Arel.star)
.join(r.project(r[:version_id], r[:version_no].maximum.as('vno'))
.group(r[:version_id]).as('r'))
.on(r[:version_id].eq(c[:version_id])
.and(r[:vno].eq(c[:version_no])))
find_by_sql(sql)