Skip to content

Instantly share code, notes, and snippets.

View windhooked's full-sized avatar

H windhooked

View GitHub Profile
job "fail-service" {
datacenters = ["public-services"]
type = "service"
group "fail-service" {
count = 1
task "fail-service" {
driver = "docker"
@anti1869
anti1869 / nested_struct_join.go
Created August 4, 2018 19:27
Join two structs on foreign key relation with jmoiron/sqlx (nested json object from struct)
/*
Note: I have db.MapperFunc(FromCamelCaseToUnderScore)
This will make nested json like this
{
"likes": [
{
"chat_id": 155636374,
"created": "2018-08-04T10:52:36.360217Z",
@owulveryck
owulveryck / README.md
Last active August 1, 2021 17:06
Simple linear regression with plot in go with gonum

Very simple linear regression

curl -s //www.lauradhamilton.com/data_files/cricket_chirps_versus_temperature.txt | go run main.go > output.svg
2018/06/13 19:57:59 3.3057614388773593*x+24.966014428303183
@niklas-ourmachinery
niklas-ourmachinery / identifying-controls-in-an-imgui.md
Last active January 24, 2023 06:09
Identifying controls in an IMGUI

Identifying controls in an IMGUI

In an IMGUI we need a way to identify which control is active or hot. For example, when we press a key, which text box does the text go to.

Possible options:

  1. Sequential number (Unity)

Each control drawn gets a sequentially increasing number.

@mrichman
mrichman / main.go
Last active December 28, 2021 08:20
AWS Lambda function in Go to resize an image uploaded to S3. Uses https://github.com/apex/apex
package main
import (
"bytes"
"image/jpeg"
"log"
"path"
"strings"
apex "github.com/apex/go-apex"
@tboerger
tboerger / gist:4840e1b5464fc26fbb165b168be23345
Created February 17, 2017 09:37
Golang LDAP search and authentication
package main
import (
"fmt"
"strings"
"gopkg.in/ldap.v2"
)
const (
ldapServer = "ad.example.com:389"
@wallyqs
wallyqs / Docker Compose + NATS example
Last active February 18, 2024 22:27
NATS Docker blog post/HTTP Server
FROM golang:1.6.2
COPY . /go
RUN go get github.com/nats-io/nats
RUN go build api-server.go
EXPOSE 8080
ENTRYPOINT ["/go/api-server"]
import (
log "github.com/sirupsen/logrus"
"github.com/jinzhu/gorm"
)
type GormLogger struct {}
func (*GormLogger) Print(v ...interface{}) {
if v[0] == "sql" {
log.WithFields(log.Fields{"module": "gorm", "type": "sql"}).Print(v[3])
@limingjie
limingjie / 256 colors.md
Last active April 24, 2024 22:15
256 colors in putty, tmux/screen and vim

#256 colors in putty, tmux/screen and vim There is a detailed answer on stackoverflow. If you are looking for a short one, here it is.

  • putty

    Set Connection -> Data -> Terminal-type string to xterm-256color

  • tmux

Add this line to ~/.tmux.conf

@zmanian
zmanian / keyping.go
Last active March 19, 2024 11:04
Key Pinning in #Golang
package main
import (
"bytes"
"crypto/sha256"
"crypto/tls"
"crypto/x509"
"log"
"net"
"net/http"