Skip to content

Instantly share code, notes, and snippets.

@miguelmota
miguelmota / logrus_hooks.go
Last active September 7, 2021 07:27
Golang Logrus show filename and line number
package logger
import (
"fmt"
"path"
"runtime"
"github.com/sirupsen/logrus"
)
@rivo
rivo / postgres.go
Last active August 6, 2023 22:39
A demo Go application (a PostgreSQL database browser) highlighting the use of the rivo/tview package. See https://github.com/rivo/tview/wiki/Postgres
package main
import (
"database/sql"
"fmt"
"net/url"
"os"
"reflect"
"regexp"
"strconv"
@BretFisher
BretFisher / docker-compose.yml
Created November 10, 2017 18:13
Docker Compose local development with wildcard DNS for multi-domain development
version: '3'
# vcap.me is a wildcard domain that resolves to localhost
# in case you need to pass URL's around from browser to
# containers this could help you get around localhost problem
services:
# use www.vcap.me to access web containter from host
# use api.vcap.me to access api container from host
proxy:
@CraigChilds94
CraigChilds94 / color.go
Last active January 27, 2024 15:39
Hex to RGB conversion in Go
package main
import (
"fmt"
"strconv"
)
type Hex string
type RGB struct {
@eduncan911
eduncan911 / go-build-all
Last active April 11, 2024 07:14
Go Cross-Compile Script
#!/bin/bash
#
# GoLang cross-compile snippet for Go 1.6+ based loosely on Dave Chaney's cross-compile script:
# http://dave.cheney.net/2012/09/08/an-introduction-to-cross-compilation-with-go
#
# To use:
#
# $ cd ~/path-to/my-awesome-project
# $ go-build-all
#
@jayjanssen
jayjanssen / gist:8e74bc4c5bdefc880ffd
Last active March 16, 2023 02:21
Golang MySQL connection with multiple IPs and connection timeouts
package main
import (
"database/sql"
"fmt"
"github.com/go-sql-driver/mysql"
"log"
"net/http"
"strings"
"time"
@msubel
msubel / uuid_v4_excel_formula.txt
Created July 14, 2015 12:37
An Excel Fromula to generate a UUID v4
=LOWER(CONCATENATE(DEC2HEX(RANDBETWEEN(0;POWER(16;8));8);"-";DEC2HEX(RANDBETWEEN(0;POWER(16;4));4);"-";"4";DEC2HEX(RANDBETWEEN(0;POWER(16;3));3);"-";DEC2HEX(RANDBETWEEN(8;11));DEC2HEX(RANDBETWEEN(0;POWER(16;3));3);"-";DEC2HEX(RANDBETWEEN(0;POWER(16;8));8);DEC2HEX(RANDBETWEEN(0;POWER(16;4));4)))
@raineorshine
raineorshine / _chrome-ext-auth-identity.md
Last active November 10, 2023 23:57
How to set up user authentication for a Chrome Extension using the Chrome Identity API

How to set up user authentication for a Chrome Extension using the Chrome Identity API

  1. Create a private key file, from which you can create the manifest key and Application ID, as detailed here: https://stackoverflow.com/questions/23873623/obtaining-chrome-extension-id-for-development
  2. Add the manifest key to "key" in manifest.json
  3. Create a new project in Google Developer Console https://console.developers.google.com/project
  4. Go to "APIs & auth > Credentials" and create new client id for a Chrome Application using the Application ID generated in step 3.
  5. Copy the Client ID to oauth2.client_id in the manifest.json

Deprecated?

@Yawning
Yawning / orhttp_example.go
Created April 29, 2015 14:41
How to dispatch HTTP requests via Tor in Go.
// To the extent possible under law, the Yawning Angel has waived all copyright
// and related or neighboring rights to orhttp_example, using the creative
// commons "cc0" public domain dedication. See LICENSE or
// <http://creativecommons.org/publicdomain/zero/1.0/> for full details.
package main
import (
// Things needed by the actual interface.
"golang.org/x/net/proxy"