Skip to content

Instantly share code, notes, and snippets.

function f(){
console.log(this)
}
// window scope
f()
// object scope
var o = {
'f':f
@asmedrano
asmedrano / csvwrite.go
Created February 24, 2014 19:37
csv write in go.
package main
import(
//"fmt"
"encoding/csv"
"os"
)
func main(){
@asmedrano
asmedrano / rediswriter.go
Last active August 29, 2015 13:57
Fun with Go interfaces. In this case using io.Writer
package main
import (
"fmt"
"io"
"os"
"time"
"path/filepath"
"github.com/garyburd/redigo/redis"
)
@asmedrano
asmedrano / splitfile.go
Created March 11, 2014 03:15
Split a file into several files of given bytesize. Try not to leave orphaned rows.
package main
import (
"fmt"
"os"
"bytes"
"errors"
"sync"
"path/filepath"
"strconv"
@asmedrano
asmedrano / Fun with named pipes
Last active August 29, 2015 13:57
Fun with Named Pipes
Shell 1 // this will create a named pipe @ /tmp/gfifo and read from the pipe 4eva
> ./gopipe
2014/03/12 20:53:35 Created Pipe
Shell 2
> echo "ASD" > /tmp/gfifo
Shell 1 // prints bytes
> [65 83 68]
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`
package main
import "fmt"
import "encoding/json"
type My struct {
Name string
}
@asmedrano
asmedrano / gist:2466271
Created April 22, 2012 19:17
New Twitter Bootstrap row every Nth item.
{%for item in items%}
{% if forloop.first or forloop.counter0|divisibleby:3 %}
<div class = "row">
{%endif%}
{# We need to add a new Bootstrap row every after every third item item#}
<div class = "span4">
<h3><a href ="">{{title}}</a></h3>
<span>Posted on {{created_on}} </span>
</div>
@asmedrano
asmedrano / acs2010_sumlev.py
Created April 26, 2012 19:49
ACS2010 Census Summary Levels as a Dict
"""
Summary Level Definitions
Defined as:
SUMLEV: (Geographies, Hierarchy(when avail))
"""
SUMLEV = {
'010':('United States', 'United States'),
'020':('Region'),
'030':('Division'),
'040':('State','State'),
// a simple addition function
function add_these(num1, num2){
$result = $num1 + $num2;
return $result;
}