Skip to content

Instantly share code, notes, and snippets.

View lateefj's full-sized avatar

Lateef Jackson lateefj

View GitHub Profile
@lateefj
lateefj / syncmap.go
Last active October 18, 2019 23:26
Simple Shared Map Example In Go With Timeouts
// Example on sharing a map with multiple goroutines
package main
import (
"errors"
"fmt"
"sync"
"time"
)
@lateefj
lateefj / example.go
Last active March 10, 2016 07:19
Glow Map reduce
package main
import (
"encoding/csv"
"io"
"log"
"os"
"path/filepath"
"strconv"
"strings"
@lateefj
lateefj / Basic Usage
Last active August 29, 2015 14:21
Basic McTest Usage
req, _ := http.NewRequest("GET", "/path/to/handler", nil)
resp := NewMockTestResponse(t)
HomeHandler(resp, req)
b := "HomeHandler"
if !resp.AssertCode(http.StatusOK) {
t.Fatalf("Response StatusCode is %d asserted that it is %d", resp.StatusCode, http.StatusOK)
}
if !resp.AssertBody(b) {
t.Fatalf("Response body is %s asserted that it is %s", resp.String(), b)
}
@lateefj
lateefj / raw.nim
Created March 14, 2015 05:01
Python wrapper
import python
type
Digits = object of RootObj
#data: seq[seq[int]]
target: seq[int]
Py_Initialize()
var dsModule = PyImport_ImportModule("sklearn.datasets")
var pyTarget = PyObject_GetItem(dsModule, PyString_FromString("target"))
@lateefj
lateefj / datasets.nim
Created March 14, 2015 04:37
Dataset conversion attemp.
import nimborg/py/low_level
import nimborg/py/high_level
type
Digits = object of RootObj
data: seq[seq[int]]
target: seq[int]
let ds = pyImport("sklearn.datasets")
proc digits(): Digits =
@lateefj
lateefj / gist:7364f68724f6f377933f
Last active August 29, 2015 14:16
Simple Python import
import nimborg/py/low_level
import nimborg/py/high_level
let pystring = pyImport("string")
let pydigits = pystring.digits
var pyObj: PPyObject = pydigits
echo(PyList_Size(pyObj))
@lateefj
lateefj / name_handlers_test.go
Created January 4, 2014 02:40
Name search handler test with Gorilla mux
package names
import (
"encoding/json"
"net/http"
"testing"
"github.com/gorilla/context"
"github.com/gorilla/mux"
"github.com/lateefj/mctest"
@lateefj
lateefj / name_handlers.go
Created January 4, 2014 02:33
Name search example code.
// Handlers for doing name searching
package names
import (
"encoding/json"
"fmt"
"net/http"
"github.com/golang/glog"
@lateefj
lateefj / m_test.go
Last active December 30, 2015 18:09
MockHttp test.
package main
import (
"bytes"
"fmt"
"net/http"
"testing"
)
type MockResponse struct {