Skip to content

Instantly share code, notes, and snippets.

@santiaago
santiaago / file1.txt
Last active January 2, 2021 07:47
Python script to insert lines in multiple files following a pattern
a > b
a = foo(c)
b = 2
b = foo(b)
foo
bar
foobar
b = foo(v)

use re.escape("lol") to escape strings use re.search(pattern, string) to search for a match use importlib.reload(module) to reload in python 3.4

@santiaago
santiaago / lab_graphsearch.js
Created May 12, 2014 13:05
lab graph search d3.js
//---------------------------------------------------------------------------
// variables
//---------------------------------------------------------------------------
var width = 512; // bl.ocks.org viewport width
var height = 512; // bl.ocks.org viewport height
var cellwidth = 32;//128; // cellWidth
var cellheight = 32;//128; // cellHeight
var mode = false // toggle mode on mousedown/mouseup
@santiaago
santiaago / sortByDate.go
Last active November 23, 2022 18:43
Sorting an array of dates in Go
package main
import "fmt"
import "time"
import "sort"
func main() {
fmt.Println("Sorting an array of time")
const shortForm = "Jan/02/2006"
t1, _ := time.Parse(shortForm, "Feb/02/2014")
@santiaago
santiaago / CopyToPointerStructure.go
Last active December 11, 2020 12:21
json Marshal omitempty examples
package main
import (
"encoding/json"
"fmt"
"reflect"
)
type T1 struct {
Field1 string