Skip to content

Instantly share code, notes, and snippets.

Avatar

Endre Simo esimov

View GitHub Profile
@esimov
esimov / perlin.js
Created Oct 6, 2014
Perlin noise implementation in Javascript
View perlin.js
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 / mandelbrot.go
Last active Jul 25, 2019
ASCII mandelbrot set generator
View mandelbrot.go
package main
import (
"fmt"
"github.com/shiena/ansicolor"
"os"
"sync"
)
const (
@esimov
esimov / caire_batch.go
Created Jul 2, 2019
Resize multiple images with Caire.
View caire_batch.go
package main
import (
"fmt"
"log"
"math/rand"
"os"
"runtime"
"strconv"
"time"
@esimov
esimov / factorial.go
Last active Apr 24, 2019
Factorial calculation in Go lang using three different methods: first traditionally, second with closure and third using memoization. The last method is the fastest between the three.
View factorial.go
package main
import (
"fmt"
"time"
)
const LIM = 41
var facts [LIM]uint64
@esimov
esimov / fact_goroutine.go
Last active Jan 8, 2019
Example of parallel factorial computation in Go lang using go routines.
View fact_goroutine.go
package main
import (
"math/rand"
"fmt"
)
const (
N int = 128
)
@esimov
esimov / prime_goroutine.go
Last active Sep 26, 2018
Filter prime numbers in Go lang concurently using goroutines
View prime_goroutine.go
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 / sublime_build.json
Last active Oct 5, 2017
Sublime Build System for TypeScript
View sublime_build.json
//for Windows
{
"cmd": ["tsc","$file"],
"file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
"selector": "source.ts",
"windows": {
"cmd": ["tsc.cmd", "$file"]
}
}
@esimov
esimov / simplexnoise.js
Created Oct 6, 2014
Simplex noise implementation in Javascript
View simplexnoise.js
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_haml_to_html.json
Last active Mar 4, 2017
Sublime build for HAML->HTML automatic conversion
View sublime_haml_to_html.json
{
"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 / mouseposition.js
Last active Apr 22, 2016
Get mouse position relative to canvas in JS
View mouseposition.js
BitmapData.prototype.getContext = function() {
return this.context;
};
BitmapData.prototype.getCanvas = function() {
return this.canvas;
};
BitmapData.prototype.getCanvasPos = function(el) {
var canvas = document.getElementById(el) || this.getCanvas();