Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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_primes.go
Created February 1, 2016 10:39
Concurrent Prime Sieve using goroutines
package main
import (
"fmt"
)
func main() {
prime := primes()
for {
@esimov
esimov / resource_poller.go
Created February 2, 2016 13:56
Resource poller using goroutines
package main
import (
"fmt"
"log"
"net/http"
"time"
)
const (