Skip to content

Instantly share code, notes, and snippets.

View phoorichet's full-sized avatar

Lock Phoorichet phoorichet

View GitHub Profile
<!DOCTYPE html>
<meta charset="utf-8">
Hello, world!
<p>Test Gist</p>
<!DOCTYPE html>
<meta charset="utf-8">
<style>
/* CSS goes here. */
.subunit { fill: #dcd; }
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>

TopoJSON files converted from shapfiles. It consists of 3 administrative levels ranging from 0 to 2, which are country, provinces, districts respectively.

@phoorichet
phoorichet / README.md
Last active August 29, 2015 14:03
A map of provinces in Thailand

A map of Thailand built using D3 library. It shows the border of all the provinces.

@phoorichet
phoorichet / README.md
Created July 9, 2014 06:31
A map of Thailand built on D3 library

A map of Thailand displayed by ampher.

package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func producer(total int) chan *http.Request {
queue := make(chan *http.Request)
func producer(total int) chan *http.Request {
queue := make(chan *http.Request)
// make sure that this the for-loop is run using goroutine
// otherwiser, it will block
go func() {
for i := 0; i < total; i++ {
// ignore error assuming that the request valid
req, _ := http.NewRequest("GET", "http://localhost:9000", nil)
queue <- req
}
func consumer(queue chan *http.Request, id int) {
// create http client
client := &http.Client{}
// consumer runs forever until the queue is closed
for {
select {
case req, ok := <-queue:
if !ok {
// not ok means queue is closed
// ...
func main() {
// create fixed size queue
queue := producer(1000)
// create consumers to consume work in the queue
consumerCount := 10
for i := 0; i < consumerCount; i++ {
go consumer(queue, i)
}
package main
import (
"fmt"
"io/ioutil"
"net/http"
"sync"
)
func producer(total int) chan *http.Request {