Skip to content

Instantly share code, notes, and snippets.

View chritchens's full-sized avatar

Christian Nyumbayire chritchens

View GitHub Profile
@chritchens
chritchens / primes.hs
Created August 15, 2013 17:18
An Haskell solution to the third Euler project problem.
-- find the biggest prime factor of 600851475143
problem3 = do
print "Find the biggest prime factor of 600851475143"
print(maxPrimeFactor 600851475143)
maxPrimeFactor :: Int -> Int
maxPrimeFactor n = take 1 (primeFactors n)
primeFactors :: Int -> [Int]
@chritchens
chritchens / simple-elasticgo.go
Created August 14, 2013 14:24
Just a simple example on using elastigo, a Go driver for Elasticsearch. It's also an occasion to play with the encode/json package. In this case the docs are Couchbase documents indexed by Elasticsearch through the official river plugin. The type of the docs, `couchbaseDocuments`, is automatically set by the plugin. Plugin page: http://www.couch…
package main
import "fmt"
import "log"
import "encoding/json"
import "time"
import "github.com/mattbaird/elastigo/api"
import "github.com/mattbaird/elastigo/core"
type Person struct {
@chritchens
chritchens / go-couchbase-views.go
Last active December 21, 2015 01:58
An example of using go-couchbase, a Go driver for Couchbase, for views.
package main
import "fmt"
import "log"
import "github.com/couchbaselabs/go-couchbase"
/* the view is a JavaScript map function that returns a list of key-value rows. Each row has a birthday as key and the document id as value. To obtain the entire doc, just replace `meta.id` with `doc`.
function (doc, meta) {
if(doc.birthday) {
@chritchens
chritchens / go-couchbase-docs.go
Created August 14, 2013 14:11
An example of use of go-couchbase, a go driver for the NoSQL database Couchbase
package main
import "fmt"
import "log"
import "time"
import "github.com/couchbaselabs/go-couchbase"
type Person struct {
Name string `json:name`
Surname string `json:surname`