Skip to content

Instantly share code, notes, and snippets.

View jaredfolkins's full-sized avatar
🧂
💡

Jared Folkins jaredfolkins

🧂
💡
View GitHub Profile
func ShowCris(fname string, lname string) (string, error) {
res, err := DoSomethingAmazing(fname,lname)
if err != nil {
Panic(err)
}
return res, nil
}
@jaredfolkins
jaredfolkins / setup_test.go
Last active August 29, 2015 14:16
TestMain() Pattern
// Because TestMain() is an init method and should (in most cases) only be called once, one must wrap it to extend the functionality
//
// 1. This code should exist in a setup_test.go (descriptive name) file
// 2. Setup/Teardown methods along with variables/connections/assets for specific tests should be written inside of the specific test file
// Example Filename: some_random_test.go
// Setup Method: someRandomTestSetup()
// Teardown Method: someRandomTestTeardown()
// 3. The Setup/Teardown methods are added to the global testMainSetup()/testMainTeardown() to centralize and organize your test suite
package proj
➜ h2demo git:(master) go run -race h2demo.go
2015/03/31 08:53:07 Listening on https://localhost:4430/
2015/03/31 08:53:11 Ignoring frame: [FrameHeader GOAWAY len=8]
==================
WARNING: DATA RACE
Write by goroutine 15:
bytes.(*Buffer).Truncate()
/usr/local/Cellar/go/1.4.2/libexec/src/bytes/buffer.go:62 +0x3b
bytes.(*Buffer).Reset()
/usr/local/Cellar/go/1.4.2/libexec/src/bytes/buffer.go:75 +0x3e
@jaredfolkins
jaredfolkins / gist:778d40cf52b0927c7c69
Last active August 29, 2015 14:19
Using gorename to refactor the gorethink rethinkdb driver.
gorename -from '"github.com/dancannon/gorethink".Db' -to DB -v
gorename -from '"github.com/dancannon/gorethink".DbCreate' -to DBCreate -v
gorename -from '"github.com/dancannon/gorethink".DbDrop' -to DBDrop -v
gorename -from '"github.com/dancannon/gorethink".RqlCompileError' -to ErrRQLCompile -v
gorename -from '"github.com/dancannon/gorethink".RqlRuntimeError' -to ErrRQLRuntime -v
gorename -from '"github.com/dancannon/gorethink".RqlClientError' -to ErrRQLClient -v
gorename -from '"github.com/dancannon/gorethink".RqlDriverError' -to ErrRQLDriver -v
gorename -from '"github.com/dancannon/gorethink".RqlConnectionError' -to ErrRQLConnection -v
@jaredfolkins
jaredfolkins / Lidar_walkthrough.md
Created September 25, 2015 00:03 — forked from YKCzoli/Lidar_walkthrough.md
Lidar_walkthrough

Processing LiDAR to extract building heights

Walk through

Detailed walk through of building extraction using postgis

First lets pull a data layer from of openstreetmap. You can do this any which way you’d like, as there are a variety of methods for pulling openstreetmap data from their database. Check the [wiki] (http://wiki.openstreetmap.org/wiki/Downloading_data) for a comprehensive list. My favourite method thus far is pulling the data straight into QGIS using the open layers plugin. For those who may want to explore this method, check [this tutorial] (http://www.qgistutorials.com/en/docs/downloading_osm_data.html). For building extraction you only need building footprints, and include the building tags. Not all polygons are of type building in OSM, so we can download all the polygons, and then filter the layer for only polygons tagged as buildings.

LiDAR data was pulled from USGS via the Earth Explorer site. [Here] (http://earthobservatory.nasa.gov/blogs/ele

A few examples will help to clarify these operations. Let's begin by creating two arrays:
operating_systems = ["Fedora", "SuSE", "RHEL", "Windows", "MacOS"]
linux_systems = ["RHEL", "SuSE", "PCLinuxOS", "Ubuntu", "Fedora"]
Now, we can create a union of the two arrays:
operating_systems | linux_systems
=> ["Fedora", "SuSE", "RHEL", "Windows", "MacOS", "PCLinuxOS", "Ubuntu"]
describe "#create_nokogiri_object" do
it "if supplied document is not a nokogiri object" do
document = DeschutesDocument.new('<html>')
document.nokogiri_document.should be_a_kind_of(Nokogiri)
end
end
Failure/Error: document.nokogiri_document.should be_a_kind_of(Nokogiri)
expected #<Nokogiri::HTML::Document:0x8041d478 name="document" children=[#<Nokogiri::XML::DTD:0x80a01a24 name="html">, #<Nokogiri::XML::Element:0x80b02a2c name="html">]> to be a kind of Nokogiri
def save_deed_and_related_documents(deed)
unless deed.make_reference.nil?
deed.make_reference.each do | reference |
puts reference
end
end
end
def save_deed_and_related_documents(deed)
unless deed.make_reference.nil?
deed.make_reference.each do | reference |
reference.each do | record |
puts record
end
end
end
end