Skip to content

Instantly share code, notes, and snippets.

@maiah
maiah / main.go
Last active April 7, 2016 05:41
Syncing and Cancellable gophers
package main
import (
"errors"
"sync"
"time"
)
func main() {
sm := NewSyncedMessage("abc")
@maiah
maiah / pokemon.js
Last active December 10, 2015 01:22
Pokemon evolution with Javascript streams
'use strict';
const f = require('from');
const t = require('through');
const pokemons = f(['charmander', 'bulbasaur', 'squirtle']);
const evolve = t((pokemon) => {
'use strict';
let evolvedPokemon = pokemon;
defmodule P2 do
def num_to_list(mx) do
if mx > 1 do
Enum.reduce(1..mx, fn (x, acc) -> "#{acc},#{x}" end)
else
"#{mx}"
end
end
defmodule P2 do
def num_to_list(mx) when mx > 1 do
num_to_list(mx, mx - 1)
end
def num_to_list(mx) do
"#{mx}"
end
@maiah
maiah / main.go
Last active October 26, 2015 08:14
Beautiful Streaming Filter, Map, and Collect using Channel Struct-wrapper
package main
import (
"fmt"
"strconv"
)
type Power struct {
up int
}
@maiah
maiah / main.go
Last active October 20, 2015 23:50
Reader wrapper to have functional programming style of reading io (no mutables)
package main
import (
"fmt"
"io"
"os"
)
func main() {
f, err := os.Open("./temp")
@maiah
maiah / main.go
Created October 19, 2015 07:45
Streaming Reduce, Map, and Collect in Go
package main
import (
"fmt"
"strconv"
)
type Power struct {
up int
}
@maiah
maiah / main.go
Last active October 19, 2015 01:39
Something like Reduce, Map, and Collect in Go
package main
import (
"fmt"
"strconv"
)
type Power struct {
up int
}
@maiah
maiah / immutable_collection.go
Created October 2, 2015 09:03
Copy Method for Immutable slices and maps
package main
import "fmt"
type nums []int
func (n nums) copy() []int {
dest := make(nums, len(n))
copy(dest, n)
return dest
@maiah
maiah / .vimrc
Last active July 14, 2016 10:13
Sample .vimrc config
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required