Skip to content

Instantly share code, notes, and snippets.

View oxbambooxo's full-sized avatar

Ben oxbambooxo

View GitHub Profile
@ading2210
ading2210 / ollama-limiter.sh
Created January 21, 2025 03:23
A bash script to limit ollama download speeds
#!/bin/bash
#see https://github.com/ollama/ollama/issues/2006 for why this is needed
set -e
run_nethogs() {
local pid="$1"
nethogs -t -d 0 -P "$pid" | grep --line-buffered "ollama"
}
@maratori
maratori / .golangci.yml
Last active April 18, 2025 13:05
Golden config for golangci-lint
# This file is licensed under the terms of the MIT license https://opensource.org/license/mit
# Copyright (c) 2021-2025 Marat Reymers
## Golden config for golangci-lint v2.1.2
#
# 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 it to suit your needs.
# If this config helps you, please consider keeping a link to this file (see the next comment).
@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 April 5, 2025 21:07
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 July 25, 2024 03:38
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 March 31, 2025 10:12
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