Skip to content

Instantly share code, notes, and snippets.

@jeffdyke
jeffdyke / ssh_through_bastion_host.go
Last active June 26, 2025 23:52
Go - SSH Through Bastion Host
// I created this to attach to https://stackoverflow.com/questions/60046598/ssh-through-bastion-host
package main
import (
"flag"
"fmt"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ssh/agent"
"log"
@coolreader18
coolreader18 / segfault.py
Last active August 12, 2025 17:18
CPython segfault in 5 lines of code
class E(BaseException):
def __new__(cls, *args, **kwargs):
return cls
def a(): yield
a().throw(E)
@mcpower
mcpower / aoc-tips.md
Last active August 7, 2025 14:57
Tips for getting on the Advent of Code leaderboard

Hi, I'm mcpower. I've done Advent of Code seriously for two years now in Python, placing 9th in 2018 and 12th in 2017. This year, I'm taking a break from aiming for the leaderboard - while it's fun and all, it is a bit stressful at times (the good kind of stress, though!). As such, I'd like to share a few tips for anyone wanting to aim for the leaderboard.

This is everything that worked for me. Your mileage may vary, though - don't take this as gospel, see what works for you.

Go fast

Go fast.

@filimonov
filimonov / gist:c37a31d30692b78fddec1fd439c1f7eb
Last active April 5, 2024 06:52
perl stack trace from gdb (also from coredump)
define perl_stack
set $end=my_perl->Icurstackinfo->si_cxix
set $i=0
while ($i<$end)
printf "%d:%s\n", my_perl->Icurstackinfo->si_cxstack[$i].cx_u.cx_blk.blku_oldcop->cop_line, my_perl->Icurstackinfo->si_cxstack[$i].cx_u.cx_blk.blku_oldcop->cop_file
set $i=$i+1
end
printf "%d:%s\n",my_perl->Icurcop->cop_line, my_perl->Icurcop->cop_file
end
@pkhuong
pkhuong / div-by-mul.lisp
Last active September 7, 2019 08:51
Quick runtime div-by-mul constants
(defstruct div-by-mul-constants
;; Implement truncated integer by `divisor` with a fixed point
;; approximation.
(divisor 0 :type sb-ext:word
:read-only t)
;; The reciprocal is roughly multipler / 2^(W + shift),
;; where W is the word width.
(multiplier 0 :type sb-ext:word
:read-only t)
(shift 0 :type sb-ext:word
@andy-thomason
andy-thomason / Genomics_A_Programmers_Guide.md
Created May 14, 2019 13:32
Genomics a programmers introduction

Genomics - A programmer's guide.

Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.

https://www.genomicsplc.com

@kekru
kekru / 01nginx-tls-sni.md
Last active August 17, 2025 18:13
nginx TLS SNI routing, based on subdomain pattern

Nginx TLS SNI routing, based on subdomain pattern

Nginx can be configured to route to a backend, based on the server's domain name, which is included in the SSL/TLS handshake (Server Name Indication, SNI).
This works for http upstream servers, but also for other protocols, that can be secured with TLS.

prerequisites

  • at least nginx 1.15.9 to use variables in ssl_certificate and ssl_certificate_key.
  • check nginx -V for the following:
    ...
    TLS SNI support enabled
@munificent
munificent / generate.c
Last active August 29, 2025 13:51
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@shaneutt
shaneutt / LICENSE
Last active May 26, 2025 15:18
Golang: Demonstrate creating a CA Certificate, and Creating and Signing Certs with the CA
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@mtds
mtds / lvn.md
Last active August 14, 2025 10:17
Linux Virtual Networking

Virtual Networking on Linux

In the Linux Kernel, support for networking hardware and the methods to interact with these devices is standardized by the socket API:

                +----------------+
                |   Socket API   |
                +-------+--------+
                        |
User space              |