Skip to content

Instantly share code, notes, and snippets.

working on it...

josh bowles jbowles

working on it...
View GitHub Profile
jbowles / lev_part_three.go
Created Jun 29, 2013
Part three of Levenshtein distance
View lev_part_three.go
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 {
min := int(^uint(0) >> 1)
for _, i := range a {
if i < min {
jbowles / lev_part_two.go
Last active Dec 19, 2015
Part two of Levenshtein Distance
View lev_part_two.go
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 / lev_part_one.go
Last active Dec 19, 2015
Part one of Levenshtein distance
View lev_part_one.go
package main
import "fmt"
// 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 / state_jacket.go
Created Mar 23, 2013
First pass at porting Sate Jacket to Go
View state_jacket.go
//package state_gacket // soft 'g', like state_dʒacket
package main
import (
type Metadata struct {
EntryLength int
jbowles / random_normal.js
Last active Dec 15, 2015
Random numbers from a normal distribution
View random_normal.js
/*jslint node:true*/
"use strict";
function normal_random(mean, variance) {
if (mean === undefined) {
mean = 0.0;
if (variance === undefined) {
variance = 1.0;
jbowles / stream_classifier.js
Last active Dec 14, 2015
Playing around with node
View stream_classifier.js
/*jshint node:true*/
"use strict";
var http = require('http'),
fs = require('fs'),
natural = require('natural'),
classifier = new natural.BayesClassifier();
// flatten an array
jbowles / example_nlp_with_treat.rb
Created Feb 22, 2013
A quick look at what can be done with treat
View example_nlp_with_treat.rb
require 'treat'
include Treat::Core::DSL
doc1 = document('')
doc2 = document('')
[d1,d2].apply(:chunk, :segment, :tokenize)
#Check it!
jbowles /
Created Nov 23, 2012
Horizon TFSG Step, Formula, Hub First Draft
;; Clojure Step
(declare step check-valid base-complete check-user)
(defn one-of [coll]
(if (seq coll)
[(rand-nth coll)]))
(defn step[] (concat (check-valid) (base-complete) (check-user)))
(defn check-valid[] (one-of [0 1]))
jbowles /
Created Nov 23, 2012
Horizon Transactional Grammar First Draft
(def simple-grammar
  {:hub [:node-unique-accept :node-unique-check :node-unique-persist]
   :node-unique-accept [:ParseUrl :ParseParams :AcceptBool]
   :node-unique-check [:FormatRead :FormatCheckBool]
   :node-unique-persist [:SaveOrUpdate :PersistBool]
   :ParseUrl #{"http, www,, /blog/seo-glossary-url-definitions/" "http, jbowles," "http, www,, /~mckeeman/cs48/mxcom/doc, FiniteAutomata.pdf" "https, www,, categories/state_machines.html"}
   :ParseParams #{"program address city state zip" "fname lname school program address city state zip" "fname lname school state zip" "fname lname city state zip"}
   :AcceptBool #{"0" "1"} ;;[] (one-of [0 1])
   :FormatRead #{"UTF8" "other stuff"}
jbowles /
Created Nov 23, 2012
Horizon Transaction First Draft

The :hub is the transaction and/or application (more on this later). Each :node is wrapper around a Hero Formula responsible for passing the non-boolean values to the :hub, but it also returns a boolean. Each camel-cased line inside the :node parentheses is a Hero :formula and the values in quotes are the return values of a Formula's :step. Formula.step is the only thing responsible for changing state.

The following is in Clojure but it should be interpretable from a Ruby perspective; it's the relations that matter here not the syntax.

[:hub ;; begin transaction
 ( ;; begin set of Nodes
You can’t perform that action at this time.