Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View brydavis's full-sized avatar

Bryan Davis brydavis

View GitHub Profile
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
var dataset = [
{
"Year":2003,
"Quarter":"Q1",
"OperatingCashFlow":3410,
"Revenue":1475,
"Operating Income":4,
"QEndDate":"3/31/2003",
"StockClose":14.14
},
<div id="sparklines"></div>
<style>
path {
stroke-width: 2;
fill: none;
}
path.wind { stroke: red; }
path.power { stroke: steelblue; }
package main
import "fmt"
import "math"
var pow = math.Pow
var sqrt = math.Sqrt
func main() {
x1, y1 := 0, 0
@brydavis
brydavis / decision.go
Last active March 16, 2016 22:43
Simple Decision Tree
package main
import (
"bytes"
"encoding/csv"
// "encoding/json"
"fmt"
"io/ioutil"
"strings"
)
@brydavis
brydavis / shannon.go
Last active March 16, 2016 23:10
Shannon's entropy measure of dataset heterogeneity
package main
import (
"fmt"
"math"
)
func main() {
// set of probabilities
@brydavis
brydavis / go.go
Last active March 20, 2016 16:28
package main
import "fmt"
func main() {
s := make(chan int)
X(s)
fmt.Println(<-s)
}
package main
import (
"bufio"
"database/sql"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"log"
package main
import "regexp"
func CleanQuery(q string) string {
r1 := regexp.MustCompile(`\s+`)
r2 := regexp.MustCompile(`--[^\n]*\n`)
q = r2.ReplaceAllString(q, "")
return r1.ReplaceAllString(q, " ")
}
// heavily borrowed from Rosetta Code example
package main
import "fmt"
type row map[string]interface{}
var (
tableA = []row{
row{"name": "Jonah", "age": 27},