Skip to content

Instantly share code, notes, and snippets.

View diamondburned's full-sized avatar

Diamond diamondburned

View GitHub Profile
@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.

@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
@phemmer
phemmer / defer.sh
Last active August 6, 2025 10:42
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
}
@Killeroid
Killeroid / gpg-import-and-export-instructions.md
Created October 18, 2017 11:51
How to export and import gpg keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Gotten from the RedHat GPG migration manual

Backup the public and secret keyrings and trust database

## Export all public keys

gpg -a --export >mypubkeys.asc

@Brainiarc7
Brainiarc7 / VAAPI-hwaccel-encode-Linux-Ffmpeg&Libav-setup.md
Last active September 8, 2025 00:27
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".

@zchee
zchee / cgo.md
Last active June 20, 2025 08:51
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.

@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())
@cdown
cdown / gist:1163649
Last active July 7, 2025 00:58
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