Skip to content

Instantly share code, notes, and snippets.

View jbowles's full-sized avatar
💭
working on it...

josh bowles jbowles

💭
working on it...
View GitHub Profile
@jbowles
jbowles / stream_classifier.js
Last active December 14, 2015 03:28
Playing around with node
/*jshint node:true*/
"use strict";
// SEND REQUEST TO CLASSIFY TEXT
var http = require('http'),
fs = require('fs'),
natural = require('natural'),
classifier = new natural.BayesClassifier();
// flatten an array
@jbowles
jbowles / random_normal.js
Last active December 15, 2015 05:19
Random numbers from a normal distribution
/*jslint node:true*/
"use strict";
function normal_random(mean, variance) {
if (mean === undefined) {
mean = 0.0;
}
if (variance === undefined) {
variance = 1.0;
}
@jbowles
jbowles / state_jacket.go
Created March 23, 2013 15:13
First pass at porting Sate Jacket to Go
//package state_gacket // soft 'g', like state_dʒacket
package main
import (
"fmt"
"reflect"
)
/*
type Metadata struct {
EntryLength int
@jbowles
jbowles / lev_part_one.go
Last active December 19, 2015 01:28
Part one of Levenshtein distance
package main
import "fmt"
// http://en.wikipedia.org/wiki/Levenshtein_distance
// FIRST PART: define vector/cell for the dynamic programming table based on string lengths
func PartOneLevenshtein(s1, s2 string) {
m := len(s1)
n := len(s2)
@jbowles
jbowles / lev_part_two.go
Last active December 19, 2015 01:28
Part two of Levenshtein Distance
package main
import "fmt"
// PART TWO: step through each string character and vector/cell of dynamic programming table to determine difference.
//// This handles the case where both characters are an exact match, and only the "no-change" condition is used.
func LevenshteinTwo(s1, s2 string) {
m := len(s1)
n := len(s2)
width := n - 1
@jbowles
jbowles / lev_part_three.go
Created June 29, 2013 12:53
Part three of Levenshtein distance
package main
import "fmt"
// PART THREE: if characters are not the same, we step through a comparison against each character to
//// determine DELETION, INSERTION, SUBSTITUTION and get the minimum of the three values.
func MinInt(a ...int) int {
min := int(^uint(0) >> 1)
for _, i := range a {
if i < min {
@jbowles
jbowles / lev_part_four.go
Created June 29, 2013 22:08
Part four of Levenshtein Distance
package main
import "fmt"
// PART FOUR: in which we get the min value for delete, insert, substitute and set value in Vector, return significant Vector value.
func MinInt(a ...int) int {
min := int(^uint(0) >> 1)
for _, i := range a {
if i < min {
min = i
@jbowles
jbowles / simple_transport_example.go
Created July 27, 2013 15:50
simple web crawler using simple_transport
package main
import (
"fmt"
"net/http"
"time"
"io/ioutil"
"github.com/pkulak/simpletransport/simpletransport"
)
var lotso_urls = []string{
package main
import (
"bufio"
"fmt"
"os"
"time"
)
const numWorkers = 3
@jbowles
jbowles / hello_function.go
Last active December 23, 2015 07:49
Playing with function passing in golang
package main
import "fmt"
type HelloList struct {
people []string
}
func NewHelloList(names []string) *HelloList {
return &HelloList{people: names}