This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -f /etc/ssl/ca-bundle.pem ] | |
then | |
mv /etc/ssl/ca-bundle.pem /etc/ssl/ca-bundle.pem.old | |
fi | |
find /etc/ssl/certs -maxdepth 1 -type f -exec cat {} \; >> /etc/ssl/ca-bundle.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"on_save": [{ | |
"cmd": "gs9o_run_many", "args": { | |
"commands":[ | |
["clear"], | |
["sh", "if [ -f onsave.sh ]; then ./onsave.sh; else gofmt -s -w ./ && go build . errors && go test -i && go test && go vet && golint ; fi"] | |
], | |
"focus_view": false | |
} | |
}], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I'm forever forgetting to adjust the time zone on my camera when taking pictures on vacation | |
// this uses the linux exiftool to adjust the timezone -8 hours for all images in a directory | |
exiftool "-DateTimeOriginal-=0:0:0 8:0:0" * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package enum_example | |
import ( | |
"bytes" | |
"encoding/json" | |
) | |
// TaskState represents the state of task, moving through Created, Running then Finished or Errorred | |
type TaskState int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"reflect" | |
) | |
/* | |
This is an example of a channel that can receive any data type, e.g. different struct types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package string_test | |
import "testing" | |
func Benchmark_StringNotEqual(b *testing.B) { | |
z := "" | |
i := 0 | |
for i:= 0; i<b.N; i++ { | |
if z != "" { | |
i++ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// This example shows how to extend a struct for marshalling, e.g. to Json to allow private fields | |
// to be exposed or for adding additonal fields that are populated at runtime. | |
import ( | |
"encoding/json" | |
"fmt" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package middleware | |
import ( | |
"net/http" | |
"os" | |
"path" | |
"strings" | |
) | |
// FSHandler404 provides the function signature for passing to the FileServerWith404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CustomTime provides an example of how to declare a new time Type with a custom formatter. | |
// Note that time.Time methods are not available, if needed you can add and cast like the String method does | |
// Otherwise, only use in the json struct at marshal/unmarshal time. | |
type CustomTime time.Time | |
const ctLayout = "2006-01-02 15:04:05 Z07:00" | |
// UnmarshalJSON Parses the json string in the custom format | |
func (ct *CustomTime) UnmarshalJSON(b []byte) (err error) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// change the channel size to the number of concurrent tasks you'd like | |
var throttle = make(chan struct{}, 1) | |
func DoStuff() { | |
// block until we can add to throttle channel | |
throttle <- struct{}{} | |
defer func() { | |
<-throttle // remove from channel when we are done | |
}() | |
// do your funky stuff |
OlderNewer