Skip to content

Instantly share code, notes, and snippets.

@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 / sublime_sass_to_css.json
Last active October 11, 2015 18:08
Sublime build for SASS->CSS automatic conversion
{
"cmd": ["sass", "--update", "$file:${file_path}/${file_base_name}.css"],
"selector": "source.sass",
"line_regex": "Line ([0-9]+):",
"osx":
{
"path": "/usr/local/bin:$PATH"
},
@esimov
esimov / interface.ts
Last active October 11, 2015 22:48
Interface implementation in Typescript
interface Package {
person: {
firstName?:string;
lastName?:string;
age:number;
action: string;
};
status: {
married?:bool;
@esimov
esimov / mouseposition.js
Last active November 14, 2022 13:40
Get mouse position relative to canvas in 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();
@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 / collision_check.as
Last active December 10, 2015 00:38
2d grid collision check
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.utils.getTimer;
[SWF (backgroundColor = 0xffffff, width = 1090, height = 800)]
public class BallCollisionGrid extends Sprite {
private var _grids:Array;
@esimov
esimov / factorial.go
Last active June 11, 2023 21:19
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.
package main
import (
"fmt"
"time"
)
const LIM = 41
var facts [LIM]uint64
@esimov
esimov / bubblesort.go
Last active August 29, 2015 13:58
Bubblesort in Golang
package main
import (
"fmt"
)
func BubbleSort(arr[] int)[]int {
for i:=1; i< len(arr); i++ {
for j:=0; j < len(arr)-i; j++ {
if (arr[j] > arr[j+1]) {
@esimov
esimov / bubblesort.go
Last active August 29, 2015 13:58
Sorting inverted maps in Go lang using Bubblesort sorting algorithm
package main
import (
"fmt"
)
var (
values = map[string]int{
"alpha": 34, "bravo": 56, "charlie": 23,
"delta": 87, "echo": 56, "foxtrot": 12, "golf": 34, "hotel": 16,
@esimov
esimov / fact_goroutine.go
Last active August 7, 2022 00:20
Example of parallel factorial computation in Go lang using go routines.
package main
import (
"math/rand"
"fmt"
)
const (
N int = 128
)