Skip to content

Instantly share code, notes, and snippets.

View andyleejordan's full-sized avatar

Andy Jordan andyleejordan

View GitHub Profile
@SimDing
SimDing / as_gwf.ts
Last active December 22, 2023 03:54
Baldurs Gate 3 - Great Weapon Fighting and Savage Attacker Calculations
// DSL for producing distributions of dice rolls
type Cont<T> = (state: T) => void;
const rollDie = <T, U>(faces: number, state: T, cont: (faces: number, state: T, next: Cont<U>) => void, next: Cont<U>) => {
for (let i = 1; i <= faces; i++) {
//console.log(state, 'rolled', i);
cont(i, { ...state }, next);
}
};
@ClintLiddick
ClintLiddick / External_GTest.cmake
Last active April 26, 2024 14:18
CMake ExternalProject_Add for Google Mock (gmock) and Google Test (gtest) Libraries
find_package(Threads REQUIRED)
ExternalProject_Add(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
UPDATE_COMMAND ""
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON)
@sstelfox
sstelfox / arp_inspector.rb
Last active August 29, 2015 14:13
Playing around with manual packet inspection using ruby and pcaprub
#!/usr/bin/env ruby
require 'ipaddr'
require 'pcaprub'
require 'strscan'
# https://en.wikipedia.org/wiki/EtherType
ETHER_TYPE = {
0x0800 => :ipv4,
0x0806 => :arp,
@XVilka
XVilka / TrueColour.md
Last active October 29, 2024 09:43
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

@rgbkrk
rgbkrk / hubdecrypt.sh
Last active April 6, 2022 02:55
Encrypt a (short) file using someone's public key from github
#!/usr/bin/env bash
# HubCrypt
# ========
#
# Decrypt a file encrypted using hubencrypt (ok, it's just openssl + rsautl +
# your SSH keys). It needs the private key that matches your last public key
# listed at github.com/<user>.keys
#
# sets the proxy cache path location, max size 2g
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=STATIC:100m inactive=24h max_size=2g;
# transfers the `Host` header to the backend
proxy_set_header Host $host;
# uses the defined STATIC cache zone
proxy_cache STATIC;
# cache 200 10 minutes, 404 1 minute, others status codes not cached
@cbsmith
cbsmith / random_selection.cpp
Last active August 9, 2022 12:29
Hopefully serves as a reference implementation on how to do random selection of an element from a container.
// -*- compile-command: "clang++ -ggdb -o random_selection -std=c++0x -stdlib=libc++ random_selection.cpp" -*-
//Reference implementation for doing random number selection from a container.
//Kept for posterity and because I made a surprising number of subtle mistakes on my first attempt.
#include <random>
#include <iterator>
template <typename RandomGenerator = std::default_random_engine>
struct random_selector
{
//On most platforms, you probably want to use std::random_device("/dev/urandom")()
@datagrok
datagrok / git-branch-simplify.md
Last active April 16, 2024 17:26
How to simplify the graph produced by git log --graph

Ideas for improvements to git log --graph

I will maybe someday get around to dusting off my C and making these changes myself unless someone else does it first.

Make the graph for --topo-order less wiggly

Imagine a long-running development branch periodically merges from master. The git log --graph --all --topo-order is not as simple as it could be, as of git version 1.7.10.4.

It doesn't seem like a big deal in this example, but when you're trying to follow the history trails in ASCII and you've got several different branches displayed at once, it gets difficult quickly.

@agnoster
agnoster / README.md
Last active September 25, 2024 09:27
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark