Skip to content

Instantly share code, notes, and snippets.

@owent
owent / test_backtrace.cpp
Last active June 4, 2022 02:14
test_backtrace
/**
* traceback for cpp
*
* Created on: 2018-01-27
* Author: owent
*
* Released under the MIT license
*
* @note Required flag -rdynamic or addr2line to get the function name when using gcc/clang in unix like system
* @note Using addr2line -Cfpe <exe_path> [func_addr...] for more detail when using gcc/clang
@jsmouret
jsmouret / struct.go
Last active June 20, 2024 11:15
Convert map[string]interface{} to a google.protobuf.Struct
package pb
import (
"fmt"
"reflect"
st "github.com/golang/protobuf/ptypes/struct"
)
// ToStruct converts a map[string]interface{} to a ptypes.Struct
@ijin82
ijin82 / http-proxy-auth.go
Last active May 14, 2024 09:21
Simple HTTP proxy with authorization on golang
package main
import (
"github.com/elazarl/goproxy"
"github.com/elazarl/goproxy/ext/auth"
"log"
"net/http"
"flag"
)
@Poil
Poil / gist:dac77d2966491818dd898910754cc6da
Last active May 10, 2022 06:28
Confluence - User Macro - Floating or Fixed Table of Content, with auto hide option
## Macro title: toc-right
## Macro has a body: N
##
## Developed by: Benjamin DUPUIS
## Date created: 05/08/2011
## Date Updated: 30/11/2016
## Installed by: Benjamin DUPUIS
## @param Maxlvl:title=MaxLvl|type=int|required=true|desc=Max Level|default=5
## @param Float:title=Float|type=boolean|required=true|desc=Float/Fixed Position|default=true
## @param Hidable:title=Hidable|type=boolean|required=true|desc=Hidable (Float menu only)|default=true
@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"
@jgfrancisco
jgfrancisco / compress.go
Last active November 4, 2021 13:15
compress protobuf
package main
import (
"bytes"
"compress/flate"
"compress/gzip"
"compress/zlib"
"errors"
"fmt"
"io/ioutil"
@adamveld12
adamveld12 / comments.md
Last active July 19, 2024 12:40
Go Code Review Comments

Go Code Review Comments

This page collects common comments made during reviews of Go code, so that a single detailed explanation can be referred to by shorthands. This is a laundry list of common mistakes, not a style guide.

You can view this as a supplement to http://golang.org/doc/effective_go.html.

Please discuss changes before editing this page, even minor ones. Many people have opinions and this is not the place for edit wars.

@myusuf3
myusuf3 / delete_git_submodule.md
Created November 3, 2014 17:36
How effectively delete a git submodule.

To remove a submodule you need to:

  • Delete the relevant section from the .gitmodules file.
  • Stage the .gitmodules changes git add .gitmodules
  • Delete the relevant section from .git/config.
  • Run git rm --cached path_to_submodule (no trailing slash).
  • Run rm -rf .git/modules/path_to_submodule (no trailing slash).
  • Commit git commit -m "Removed submodule "
  • Delete the now untracked submodule files rm -rf path_to_submodule
@bcoe
bcoe / json.lua
Created April 18, 2014 07:25
Atomic update of JSON in Redis
# atomic update of a key using LUA.
EVAL "local t1 = cjson.decode(redis.call('get', ARGV[1])); local t2 = cjson.decode(ARGV[2]); for k,v in pairs(t2) do t1[k] = v end; redis.call('set', ARGV[1], cjson.encode(t1))" 0 "foo" '{"bar": 3}'
local id = ARGV[1]
local t1 = cjson.decode(redis.call('get', id)
local t2 = cjson.decode(ARGV[2])
# merge the new hash with the prior hash.
for k,v in pairs(t2) do t1[k] = v end
redis.call('set', id, cjson.encode(t1))