Skip to content

Instantly share code, notes, and snippets.

View diamondburned's full-sized avatar

Diamond diamondburned

View GitHub Profile
@cdown
cdown / gist:1163649
Last active April 14, 2025 22:42
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@ryochack
ryochack / 20140316-205912.go
Created March 16, 2014 13:28
golang reflection: interface of array
package main
import (
"fmt"
"reflect"
)
func dump_interface_array(args interface{}) {
val := reflect.ValueOf(args)
fmt.Println(val.Kind())
@zchee
zchee / cgo.md
Last active April 17, 2025 04:57
cgo convert list

See also, http://libraryofalexandria.io/cgo/

Using Go cgo

cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.

So, Here collect materials.

@Brainiarc7
Brainiarc7 / VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
Last active March 12, 2025 14:42
This gist contains instructions on setting up FFmpeg and Libav to use VAAPI-based hardware accelerated encoding (on supported platforms) for H.264 (and H.265 on supported hardware) video formats.

Using VAAPI's hardware accelerated video encoding on Linux with Intel's hardware on FFmpeg and libav

Hello, brethren :-)

As it turns out, the current version of FFmpeg (version 3.1 released earlier today) and libav (master branch) supports full H.264 and HEVC encode in VAAPI on supported hardware that works reliably well to be termed "production-ready".

@phemmer
phemmer / defer.sh
Last active December 20, 2024 15:15
bash defer function - just like go's defer()
function _run_deferred() {
local _depth="$BASHPID.${#FUNCNAME[@]}"
[[ "$_depth" != "$_deferred_depth" ]] && return
local opt=$-
set +e
for (( i=${#_deferred[@]} - 1; i >= 0; i-- )); do
eval "${_deferred[i]}"
done
[[ "$opt" == *e* ]] && set -e
}
@rumblefrog
rumblefrog / channelsorter.go
Created February 18, 2019 08:04
Sort Discord channels (category, text, voice) in an one dimension array
package channelsorter
import (
"sort"
"github.com/rumblefrog/discordgo"
)
type ChannelGeneric struct {
Underlying *discordgo.Channel
@superloach
superloach / README.md
Last active January 1, 2021 05:12
dismock gateway testing

this is a very basic example that swaps the ws connection in dismock for one that allows mocking events. it then tests this by sending a status update and comparing results.

everything (hello, ready, event parsing) is done manually right now, but the general idea is that we can mock all the gateway events, both incoming and outgoing.