Skip to content

Instantly share code, notes, and snippets.

View oxbambooxo's full-sized avatar

Ben oxbambooxo

View GitHub Profile
@maratori
maratori / .golangci.yml
Last active July 17, 2024 23:45
Golden config for golangci-lint
# This code is licensed under the terms of the MIT license https://opensource.org/license/mit
# Copyright (c) 2021 Marat Reymers
## Golden config for golangci-lint v1.59.1
#
# This is the best config for golangci-lint based on my experience and opinion.
# It is very strict, but not extremely strict.
# Feel free to adapt and change it for your needs.
run:
@chuangzhu
chuangzhu / draw_exponential_func.py
Last active April 8, 2020 03:04
Draw a __NEGATIVE BASED__ exponential function diagram using `matplotlib.mplot3d`.
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
SIZE = 10 # How big you'd like to draw
fig = plt.figure()
# OR USING `ax = fig.add_subplot(1, 1, 1, projection='3d')`
ax = Axes3D(fig)
@thomaswieland
thomaswieland / gist:3cac92843896040b11c4635f7bf61cfb
Created February 17, 2018 13:56
Python: IMAP IDLE with imaplib2
import imaplib2, time
from threading import *
# This is the threading object that does all the waiting on
# the event
class Idler(object):
def __init__(self, conn):
self.thread = Thread(target=self.idle)
self.M = conn
self.event = Event()
@asukakenji
asukakenji / 0-go-os-arch.md
Last active July 18, 2024 06:42
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.17.1 darwin/amd64.

GOOS Values

GOOS Out of the Box
aix
android
@subfuzion
subfuzion / dep.md
Last active June 14, 2023 15:46
Concise guide to golang/dep

Overview

This gist is based on the information available at golang/dep, only slightly more terse and annotated with a few notes and links primarily for my own personal benefit. It's public in case this information is helpful to anyone else as well.

I initially advocated Glide for my team and then, more recently, vndr. I've also taken the approach of exerting direct control over what goes into vendor/ in my Dockerfiles, and also work from isolated GOPATH environments on my system per project to ensure that dependencies are explicitly found under vendor/.

At the end of the day, vendoring (and committing vendor/) is about being in control of your dependencies and being able to achieve reproducible builds. While you can achieve this manually, things that are nice to have in a vendoring tool include:

@dim
dim / atomutex_test.go
Created February 28, 2017 16:49
Benchmark: sync.RWMutex vs atomic.Value
/*
Benchmark_RWMutex-4 100000000 18.1 ns/op
Benchmark_Atomic-4 200000000 8.01 ns/op
Benchmark_RWMutex_parallel-4 30000000 46.7 ns/op
Benchmark_Atomic_parallel-4 1000000000 2.61 ns/op
*/
package main
@BretFisher
BretFisher / docker-for-mac.md
Last active July 9, 2024 11:29
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@oxbambooxo
oxbambooxo / libuv_cat.c
Last active March 30, 2017 13:52
"cat" in libuv without global variables
#include <stdlib.h>
#include <unistd.h>
#include <uv.h>
typedef struct req_bundle_s {
uv_loop_t *loop;
uv_fs_t *read_req;
uv_fs_t *writ_req;
@lilydjwg
lilydjwg / dns-ipv6-reply
Created April 17, 2016 13:37
Answer AAAA DNS queries on behalf of a DNS server
#!/usr/bin/env python3
import socket
import struct
import traceback
import subprocess
import time
import signal
import dnslib
@vigevenoj
vigevenoj / Instructions for building manually without packaging
Last active April 23, 2021 14:25
Building mosquitto on centos 6 with websocket support
sudo yum install wget mercurial cmake openssl-devel c-ares-devel libuuid-devel
wget https://github.com/warmcat/libwebsockets/archive/v2.1.0.tar.gz
tar xf v2.1.0.tar.gz
cd libwebsockets-2.1.0
mkdir build; cd build
cmake .. -DLIB_SUFFIX=64
sudo make install
echo "/usr/local/lib64" | sudo tee -a /etc/ld.so.conf.d/libwebsockets.conf
sudo ldconfig
ldconfig -p | grep libwebsockets