Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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

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 / 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)
@santiaago
santiaago / randInInterval.go
Last active August 27, 2017 16:01
Random number in a given interval
// computes a random number in the specified interval centered in zero.
func randInInterval(min int, max int) float64 {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
size := float64(max - min)
return r.Float64()*size + float64(min)
}
@santiaago
santiaago / pieChartData.csv
Last active August 29, 2015 14:11
piechart
sentiment population
positive 50
negative 20
neutral 30
@santiaago
santiaago / barchart.html
Created December 11, 2014 00:09
bar chart
<!DOCTYPE html>
<meta charset="utf-8">
<title>Bar Chart with Negative Values</title>
<style>
.bar.positive {
fill: #B9E397;
}
.bar.negative {
@santiaago
santiaago / main.go
Last active March 18, 2023 07:57
Playing with images
package main
import (
"bytes"
"encoding/base64"
"flag"
"html/template"
"image"
"image/color"
"image/draw"
@santiaago
santiaago / driftme.ps1
Last active August 29, 2015 14:13
drift me
param([String]$server="yourservername",
[String]$sqlServerVersion="sql2014",
[String]$dbToDrift="yourdbtodrift",
[String]$tableToDrift="yourtabletodrift")
$previousLocation = Get-Location
Import-Module "sqlps" -DisableNameChecking
SQLSERVER:
$directory = "\sql\{0}\{1}\databases\{2}" -f $server, $sqlServerVersion, $dbToDrift