Skip to content

Instantly share code, notes, and snippets.

@esimov
esimov / mandelbrot.go
Last active July 25, 2019 15:37
ASCII mandelbrot set generator
package main
import (
"fmt"
"github.com/shiena/ansicolor"
"os"
"sync"
)
const (
@esimov
esimov / xkcd.go
Created February 25, 2016 19:36
Simple Go program to download xkcd images to local disk
package main
import (
"fmt"
"net/http"
"encoding/json"
"strconv"
"os"
"log"
"io"
)
@esimov
esimov / resource_poller.go
Created February 2, 2016 13:56
Resource poller using goroutines
package main
import (
"fmt"
"log"
"net/http"
"time"
)
const (
@esimov
esimov / goroutine_primes.go
Created February 1, 2016 10:39
Concurrent Prime Sieve using goroutines
package main
import (
"fmt"
)
func main() {
prime := primes()
for {
@esimov
esimov / goroutine_ping_pong.go
Last active January 29, 2016 13:50
Ping-pong goroutine pattern
package main
import (
"time"
"fmt"
)
func main() {
var ball int
ch := make(chan int)
@esimov
esimov / goroutine_timer.go
Last active January 29, 2016 13:51
Timer goroutine pattern
package main
import (
"fmt"
"time"
)
func main() {
for i := 0; i < 10; i++ {
ch := timer(1 * time.Second)
@esimov
esimov / goroutine_iterator.go
Created January 14, 2016 15:32
Goroutines iterator using WaitGroup
package main
import (
"fmt"
"sync"
"time"
)
func main() {
var ch chan int
@esimov
esimov / simplexnoise.js
Created October 6, 2014 08:47
Simplex noise implementation in Javascript
var NOISE = NOISE || { };
NOISE.Simplex = (function() {
var iOctaves = 1,
fPersistence = 0.5,
fResult, fFreq, fPers,
aOctFreq, // frequency per octave
aOctPers, // persistance per octave
fPersMax; // 1 / max persistence
@esimov
esimov / perlin.js
Created October 6, 2014 08:37
Perlin noise implementation in Javascript
var NOISE = NOISE || { };
NOISE.Perlin = (function() {
var iOctaves = 1,
fPersistence = 0.2,
fResult, fFreq, fPers,
aOctFreq, // frequency per octave
aOctPers, // persistance per octave
fPersMax; // 1 / max persistence
@esimov
esimov / prime_goroutine.go
Last active September 26, 2018 02:55
Filter prime numbers in Go lang concurently using goroutines
package main
import "fmt"
// Generate the input values passing through the go channel pipe
func generate(ch chan int) {
go func() {
for i := 2; ; i++ {
ch <- i
}