Skip to content

Instantly share code, notes, and snippets.

@lleo
lleo / example_slice_args.go
Last active February 8, 2016 00:27
slice limit & args array
package main
import "fmt"
func showArgs(args ...int) {
fmt.Println(args)
}
func main() {
//n := []byte{0, 1, 2, 3, 4} //odd
@lleo
lleo / concurrency-10.go
Created January 29, 2016 22:34
My Solutions / answers to tour.golang.org Jan 29, 2016
//Exercise: Web Crawler http://tour.golang.org/concurrency/10
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
@lleo
lleo / git_log.md
Created January 8, 2016 05:14 — forked from olivierlacan/git_log.md
My git log custom output aliases
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
git config --global alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit --all"
git config --global alias.mylog "log --pretty=format:'%h %s [%an]' --graph"

To check that they've been added correctly, first run git config --list. You should see something like this in the midst of all your other configuration:

alias.hist=log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
@lleo
lleo / co-generator-ex1.js
Last active August 29, 2015 13:58
Example use of ES6 generator with 'co' and 'thunkify' modules to read four files in in parallel.
#!/usr/bin/env node --harmony-generators
var fs = require('fs')
, thunkify = require('thunkify')
, co = require('co')
, readFile = thunkify(fs.readFile)
, fns = ["file0.txt", "file1.txt"
, "file2.txt", "file3.txt"]
co(function*(){
@lleo
lleo / co-generator-ex0.js
Last active January 31, 2016 15:10
Example use of ES6 generator with 'co' and 'thunkify' modules to read four files in series.
#!/usr/bin/env node --harmony-generators
var fs = require('fs')
, thunkify = require('thunkify')
, co = require('co')
, readFile = thunkify(fs.readFile)
, fns = ["file0.txt", "file1.txt"
, "file2.txt", "file3.txt"]
co(function*(){
var contents = '', i
@lleo
lleo / html5-video-streamer.js
Last active September 2, 2020 13:42
This is an enhancement to Gist#1993068 https://gist.github.com/paolorossi/1993068 . I found what was needed to demonstrate a functioning video stream was a HTML file with a <video> tag pointing to the streamer.
#!/usr/bin/env node
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
* Modified from https://gist.github.com/paolorossi/1993068
*/
var http = require('http')
, fs = require('fs')
, util = require('util')
@lleo
lleo / fiber_ring.rb
Created July 27, 2011 05:43
Improved Fiber benchmark based on gist: 824294
#!/usr/bin/env ruby
require 'fiber'
require 'benchmark'
DEBUG=false
class FiberRing
attr_reader :id
def initialize(id)