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 / gobike_handler_megajson.go
Last active December 29, 2015 18:59
Handler for trying to get megajson to work with HTTP
/*
Trying to use megajson with http.Get(url) but getting Decoding errors.
Have tried with various json responses using various structs.
Decoder errors at various indices (depending on json and structs I'm using):
==========Some Decoding Errors===============
2013/11/29 18:27:23 decoding error: Unexpected comma at 112: ,; expected colon // common for NewMStatusJSONDecoder(resp.Body)
2013/11/29 18:29:14 decoding error: Unexpected null at 153: ; expected '{' or string
2013/11/29 18:39:01 decoding error: Unexpected number at 9: 1.1; expected '{'
@jbowles
jbowles / mstatus_decoder.go
Created November 30, 2013 02:21
Generated code from megajson on MStatus struct
package gobike
import (
"errors"
"fmt"
"github.com/benbjohnson/megajson/scanner"
"io"
)
type MStatusJSONDecoder struct {
@jbowles
jbowles / mstatus.go
Last active December 29, 2015 18:59
gobike MStatus struct using with megajson experiment
package gobike
/*
Example JSON:
{
"HTTPStatus":200,
"TimeLocal":"2013-11-29T18:43:59.674946633-07:00",
"TimeUTC":"2013-11-30T01:43:59.674946695Z",
"URL":{
"Scheme":"",
# Too lazy to make a pull request and too impatient to wait,
# Just tuck 1.2 into the devel version
## First,
## $brew unlink go
## $vim /usr/local/Library/Formula/go.rb
## around line 20 under the `devel' block edit the following
devel do
#url 'https://go.googlecode.com/files/go1.2rc5.src.tar.gz'
#version '1.2rc5'
@jbowles
jbowles / gist:9946328
Created April 3, 2014 00:51
keybase.md
### Keybase proof
I hereby claim:
* I am jbowles on github.
* I am jbowles (https://keybase.io/jbowles) on keybase.
* I have a public key whose fingerprint is 18A2 A842 FEB6 3E60 3CB3 AC80 3A7B 98D5 D2AA FE72
To claim this, I am signing this object:
defmodule WordCounter do
def count(sent) do
sent |> normalize |> find_words |> count_unique |> Enum.sort()
end
def find_words(sent) do
Regex.scan(~r/\w+/, sent)
end

I can only rebind a variable that is explicitly declared as mutable; cool.

fn main() {
    let mut x: int = 5;
    x = 10i;
    println!("value of x: {}", x); // -> 10
}
// Using the Unicode Names package: http://www.rust-ci.org/huonw/unicode_names/doc/unicode_names/#cargo-enabled
//require macros...
// in Cargo.toml looks like this:
// [dependencies.unicode_names_macros]
// git = "https://github.com/huonw/unicode_names"
#![feature(phase)]
#[phase(plugin)] extern crate unicode_names_macros;
@jbowles
jbowles / fibonacci_two_ways.ex
Created December 3, 2014 16:00
tail call optimizations through pattern matching in elixir
defmodule Mather do
def numbers(x,y) do
f = fn
x,y when x>0 -> x + y
x,y -> x*y
end
IO.puts f.(x,y)
end
# A tail call optimized fibonacci.
@jbowles
jbowles / cz_ue_world_data_enrollment.fsx
Last active December 10, 2017 15:29
From the fslabbasic template get world bank data (updated version of the fslab.org getting started example)
#load "../packages/FsLab/FsLab.fsx"
(* My Environment
visual studio code 2017 Version 1.18.1
mono --version ‹2.4.1›
Mono JIT compiler version 5.4.1.7 (2017-06/e66d9abbb27 Wed Oct 25 12:10:41 EDT 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: normal
SIGSEGV: altstack