Skip to content

Instantly share code, notes, and snippets.

@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 / sublime_haml_to_html.json
Last active March 4, 2017 00:52
Sublime build for HAML->HTML automatic conversion
{
"cmd": ["haml"],
"working_dir": "${file_path:${folder}}",
"selector": "source.haml",
"file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
"windows":
{
"cmd": ["haml", "--trace", "$file", "${file_base_name}.html"],
"shell": "true"
@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 / sublime_build.json
Last active October 5, 2017 11:13
Sublime Build System for TypeScript
//for Windows
{
"cmd": ["tsc","$file"],
"file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
"selector": "source.ts",
"windows": {
"cmd": ["tsc.cmd", "$file"]
}
}
@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
}
@esimov
esimov / caire_batch.go
Created July 2, 2019 09:55
Resize multiple images with Caire.
package main
import (
"fmt"
"log"
"math/rand"
"os"
"runtime"
"strconv"
"time"
@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 (
<html>
<head>
<meta charset="utf-8" />
<script src="js/wasm_exec.js"></script>
<script type="text/javascript">
function fetchAndInstantiate(url, importObject) {
return fetch(url).then(response =>
response.arrayBuffer()
).then(bytes =>
WebAssembly.instantiate(bytes, importObject)
ifeq ($(OS),Windows_NT)
BROWSER = start
else
UNAME := $(shell uname -s)
ifeq ($(UNAME), Linux)
BROWSER = xdg-open
endif
ifeq ($(UNAME), Darwin)
BROWSER = open
endif
// +build js,wasm
package main
import (
"fmt"
"github.com/esimov/pigo/wasm/canvas"
)