This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Assuming a schema similar to the Cassandra wiki quick start (http://wiki.apache.org/cassandra/GettingStarted): | |
* CREATE TABLE mykeyspace.users ( | |
* user_id int PRIMARY KEY, | |
* fname text, | |
* lname text, | |
* user_id int | |
* ) | |
* | |
* RETURNs THIS: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is a work in progress!! | |
###################################################### | |
# I'm on a CentOS dev VM provided by my company # | |
###################################################### | |
#uname -a | |
#Linux ------- 2.6.18-128.el5 ----- x86_64 x86_64 x86_64 GNU/Linux | |
# OR | |
#cat /proc/version | |
#Linux version 2.6.18-128.el5 (mockbuild@builder10.centos.org) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-44)) ---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
RatcliffObserhelp distance | |
SEE tokenizer | |
[NIST Ratcliff/Obershelp pattern recognition](https://xlinux.nist.gov/dads/HTML/ratcliffObershelp.html): | |
Compute the similarity of two strings as the number of matching characters divided by the total number of characters in the two strings. | |
Matching characters are those in the longest common subsequence plus, recursively, matching characters in the unmatched region on either side of the longest common subsequence. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Luhn trait | |
pub trait Luhn { | |
fn luhn(self) -> bool; | |
} | |
impl Luhn for String { | |
fn luhn(self) -> bool { | |
let s = remove_whitespace(&self); | |
let d = Digits::digits(s); | |
if d.len() < 16 { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools | |
dbl2nd(da::Array{Int64,1}) = for i in 1:2:(length(da)) | |
da[i] *= 2 | |
end | |
mod9(da::Array{Int64,1}) = for i in 1:2:length(da) | |
if da[i] > 9 | |
da[i] -= 9 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gobike | |
/* | |
Example JSON: | |
{ | |
"HTTPStatus":200, | |
"TimeLocal":"2013-11-29T18:43:59.674946633-07:00", | |
"TimeUTC":"2013-11-30T01:43:59.674946695Z", | |
"URL":{ | |
"Scheme":"", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gobike | |
import ( | |
"errors" | |
"fmt" | |
"github.com/benbjohnson/megajson/scanner" | |
"io" | |
) | |
type MStatusJSONDecoder struct { |
NewerOlder