Skip to content

Instantly share code, notes, and snippets.

View iporsut's full-sized avatar
🏠
Working from home

Weerasak Chongnguluam iporsut

🏠
Working from home
View GitHub Profile
package main
import (
"errors"
"fmt"
)
func Div(a, b float32) (result float32, err error) {
if b == 0 {
err = errors.New("Cannot divide by zero.")
@iporsut
iporsut / gist:c1e5e62ad1d5411b7bf6
Created March 2, 2015 15:07
Goroutine SecondCounter and FiveSecondCounter Channel Sync
package main
import (
"fmt"
"time"
)
var oneDone chan bool = make(chan bool)
var fiveDone chan bool = make(chan bool)
@iporsut
iporsut / gist:c161e3d75b60c05af927
Created March 2, 2015 15:01
Goroutine SecondCounter Channel Sync
package main
import (
"fmt"
"time"
)
var done chan bool = make(chan bool)
func SecondCounter() {
@iporsut
iporsut / gist:57894820d97c4cd0c0c4
Created March 2, 2015 14:44
Goroutine SecondCounter
package main
import (
"fmt"
"time"
)
func SecondCounter() {
for i := 1; i <= 20; i++ {
time.Sleep(1 * time.Second)
package main
import (
"fmt"
"time"
)
func SecondCounter() {
for i := 1; i <= 20; i++ {
time.Sleep(1 * time.Second)
" Start Pathogen for vim-gocode plugin
execute pathogen#infect()
Helptags
filetype plugin indent on
syntax on
set number
" Neocomplete Enable
"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
@iporsut
iporsut / log.go
Created December 14, 2014 13:28
Spike Logger Go
package main
import "fmt"
type Logger interface {
log(message string)
}
type DefaultLogger struct {
}
@iporsut
iporsut / gocat.go
Last active August 29, 2015 14:11
Gocat With Golang Manage Error
package main
import (
"io"
"log"
"os"
)
type MyFile struct {
*os.File
@iporsut
iporsut / gist:3ed3cc10cafc4c020557
Created October 22, 2014 06:06
Jasmine 1.3 mostRecentCall
it("should call SaveOrder when click save", function() {
spyOn(service, "SaveOrder");
var expectedArgument = {
id: "1",
items: [
"item1",
"item2",
"item3"
]
@iporsut
iporsut / gist:d3175fd341c70a257077
Created October 21, 2014 15:16
AcceptingAuthorizerFake Go
type AcceptingAuthorizerFake struct {
}
func (fake *AcceptingAuthorizerFake) Authorize(username, password string) (bool, error) {
return (username == "Bob"), nil
}