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
from xml.dom.minidom import parseString | |
def findCentroidGivenKML(location): | |
#Read KML file as a string | |
file = open(location) | |
data = file.read() | |
file.close() | |
#Parse that string into a DOM | |
dom = parseString(data) |
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
<Placemark> | |
<name>Tag #58 - White Brothers Auto Parts</name> | |
<description><![CDATA[]]></description> | |
<styleUrl>#style29</styleUrl> | |
<Point> | |
<coordinates>-84.357826,33.754772,0.000000</coordinates> | |
</Point> | |
</Placemark> |
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
#Read KML file as a string | |
file = open(location) | |
data = file.read() | |
file.close() |
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
private string urlencode(string input_url) | |
{ | |
StringBuilder b = new StringBuilder(100); | |
foreach (char c in input_url) | |
{ | |
b.Append(replace(c)); | |
} | |
return b.ToString(); | |
} |
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
n = 100 | |
for i in range(8): | |
print((n>>i)%2) |
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 main | |
import "net/http" | |
import "fmt" | |
import "time" | |
type http_req struct { | |
req_time time.Duration | |
url string | |
status string |
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
cagocs:examples christopheragocs$ go run shared_memory.go | |
I am a very global string.I have been to LondonI have been to France | |
I am a very global string.I have been to London | |
I am a very global string.I have been to LondonI have been to France | |
cagocs:examples christopheragocs$ go run -race shared_memory.go | |
================== | |
WARNING: DATA RACE | |
Write by goroutine 4: | |
main.writeToSomeString() | |
/Users/christopheragocs/personal/golangIntro/examples/shared_memory.go:26 +0x38 |
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
(defmacro time-limited | |
"Use this macro to cause a function to time out after a little while" | |
[seconds & body] | |
`(let [f# (future ~@body)] | |
(try | |
(.get f# ~seconds java.util.concurrent.TimeUnit/SECONDS) | |
(catch java.util.concurrent.TimeoutException x# | |
(do (future-cancel f#) | |
(throw x#))) | |
(catch Exception e# |
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
import random | |
#Orientation and doIntersect mostly copied wholesale from here: | |
# http://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/ | |
# with some modifications because I can safely ignore their special cases. | |
def orientation(p, q, r): | |
val = (q[1] - p[1]) * (r[0] - q[0]) - (q[0] - p[0]) * (r[1] - q[1]) | |
if val == 0: | |
return val #colinear |
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 main | |
func main() { | |
stringChannel = make(chan string) | |
go sendToZMQ(stringChannel) | |
stringChannel <- "Hello there" | |
stringChannel <- "How are you" | |
stringChannel <- "shopBot.explode(Now)" | |
} |
OlderNewer