Skip to content

Instantly share code, notes, and snippets.

@santiaago
santiaago / cache.go
Last active June 24, 2023 18:24
Learning HTTP caching in Go
package main
import (
"bytes"
"flag"
"image"
"image/color"
"image/draw"
"image/jpeg"
"log"
@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 / 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 / Program.cs
Created August 13, 2018 11:05
Simple C# NATS example
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using NATS.Client;
namespace worker
{
class Program
{
@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 / 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
"contributes": {
"commands": [
{
"command": "extension.sayHello",
"title": "Hello World"
}
]
},
@santiaago
santiaago / main.go
Created February 10, 2015 19:20
Testing HTTP caching in Go
package main
import (
"bytes"
"flag"
"image"
"image/color"
"image/draw"
"image/jpeg"
"log"
@santiaago
santiaago / chessboard.go
Created January 11, 2015 16:33
Building a chessboard image in go
package main
import (
"image"
"image/color"
"image/jpeg"
"log"
"os"
)
@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)
}