This file contains hidden or 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
| // Example on sharing a map with multiple goroutines | |
| package main | |
| import ( | |
| "errors" | |
| "fmt" | |
| "sync" | |
| "time" | |
| ) |
This file contains hidden or 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 main | |
| import ( | |
| "encoding/csv" | |
| "io" | |
| "log" | |
| "os" | |
| "path/filepath" | |
| "strconv" | |
| "strings" |
This file contains hidden or 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
| 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) | |
| } |
This file contains hidden or 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
| 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")) |
This file contains hidden or 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
| 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 = |
This file contains hidden or 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
| 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)) |
This file contains hidden or 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 names | |
| import ( | |
| "encoding/json" | |
| "net/http" | |
| "testing" | |
| "github.com/gorilla/context" | |
| "github.com/gorilla/mux" | |
| "github.com/lateefj/mctest" |
This file contains hidden or 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
| // Handlers for doing name searching | |
| package names | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "net/http" | |
| "github.com/golang/glog" |
This file contains hidden or 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 main | |
| import ( | |
| "bytes" | |
| "fmt" | |
| "net/http" | |
| "testing" | |
| ) | |
| type MockResponse struct { |