Skip to content

Instantly share code, notes, and snippets.

View kumikoda's full-sized avatar
🧎‍♂️
Summoning AI God

Anson Chu kumikoda

🧎‍♂️
Summoning AI God
View GitHub Profile
@kumikoda
kumikoda / fibonacci.go
Last active August 29, 2015 14:13
Golang tutorial function closures
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
a,b := 0,1
return func() int {
a,b = b, a+b
@kumikoda
kumikoda / string-method.go
Last active August 29, 2015 14:14
Methods
package main
import "fmt"
type IPAddr [4]byte
// TODO: Add a "String() string" method to IPAddr.
func (ip IPAddr) String() string {
return fmt.Sprintf("%v.%v.%v.%v", ip[0], ip[1], ip[2], ip[3])
}
@kumikoda
kumikoda / error.go
Last active August 29, 2015 14:14
Golang tutorial sqrt function with error
package main
import (
"fmt"
"math"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
better manager positive
fierce leader inspire find things cool (go)
communication, responsiveness, on call awesomeness
interaction with other teams
----------
@kumikoda
kumikoda / ro13.go
Created February 8, 2015 01:33
goland tutorial rot13 reader
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@kumikoda
kumikoda / pssh.md
Created February 13, 2015 20:12
pssh cheatsheet

pssh -t 0 -o output -h hosts "echo hello world"

// -t : timeout, 0 for no timeout // -o : name of folder to write output // -h : file with hostnames, one per line

// put the following in your ssh config so you won't be prompted StrictHostKeyChecking no

@kumikoda
kumikoda / npm-outdated.sh
Created February 20, 2015 21:52
check yo dependencies outdated
npm outdated --depth=0
@kumikoda
kumikoda / work.go
Last active August 29, 2015 14:26
Using go routines and channels to do some work
package main
import (
"fmt"
"sync"
"time"
)
func main() {
@kumikoda
kumikoda / fifo.py
Created June 9, 2017 00:18
fifo queue in python
class Fifo:
def __init__(self, size):
self.size = size
self.count = 0
self.q = [None] * size
self.head = 0
self.tail = 0
def push(self, elm):
print self.count
@kumikoda
kumikoda / game-of-life.py
Created June 9, 2017 00:19
game of life in python
from sets import Set
class Game:
def __init__(self, state):
self.state = state
def next(self):
new_state = Set()
for cell in state: