Skip to content

Instantly share code, notes, and snippets.

@moyix
moyix / killbutmakeitlooklikeanaccident.sh
Created February 5, 2022 22:51
Script to inject an exit(0) syscall into a running process. NB: only x86_64 for now!
#!/bin/bash
gdb -p "$1" -batch -ex 'set {short}$rip = 0x050f' -ex 'set $rax=231' -ex 'set $rdi=0' -ex 'cont'
@skaslev
skaslev / inj2.lean
Created November 27, 2019 13:00 — forked from leodemoura/inj2.lean
open eq
inductive I (F : Type₁ → Prop) : Type₁ :=
mk : I F
axiom InjI : ∀ {x y}, I x = I y → x = y
definition P (x : Type₁) : Prop := ∃ a, I a = x ∧ (a x → false).
definition p := I P
@rjhansen
rjhansen / keyservers.md
Last active October 26, 2024 22:16
SKS Keyserver Network Under Attack

SKS Keyserver Network Under Attack

This work is released under a Creative Commons Attribution-NoDerivatives 4.0 International License.

Terminological Note

"OpenPGP" refers to the OpenPGP protocol, in much the same way that HTML refers to the protocol that specifies how to write a web page. "GnuPG", "SequoiaPGP", "OpenPGP.js", and others are implementations of the OpenPGP protocol in the same way that Mozilla Firefox, Google Chromium, and Microsoft Edge refer to software packages that process HTML data.

Who am I?

@alaingalvan
alaingalvan / sobol.cpp
Last active June 4, 2020 06:14
Sobol Quasi-Random Sequence Generation by Dr. John Burkardt. Forked to not use cout errors, use less dimensions (saving code size)
/**
* Sobol Noise Generation
* GNU LGPL license
* By Dr. John Burkardt (Virginia Tech)
* https://gist.github.com/alaingalvan/af92ddbaf3bb01f5ef29bc431bd37891
*/
//returns the position of the high 1 bit base 2 in an integer n
int getHighBit1(int n)
{
@alaingalvan
alaingalvan / halton.cpp
Last active December 5, 2020 03:28
Ray Tracing Gem's Halton State code, by Electronic Arts, Colin Barré-Brisebois et al. Errata corrected by Alain Galvan.
// Ray Tracing Gems Chapter 25
// Code provided by Electronic Arts
// Colin Barré-Brisebois, Henrik Halén, Graham Wihlidal, Andrew Lauritzen,
// Jasper Bekkers, Tomasz Stachowiak, and Johan Andersson
// Errata corrected by Alain Galvan
struct HaltonState
{
unsigned dimension;
@dpiponi
dpiponi / test.lhs
Last active August 26, 2018 10:47
Invert infinite upper triangular matrix
> scale :: Num a => a -> [a] -> [a]
> scale a bs = map (a *) bs
Invert an infinite upper triangular matrix with 1 on diagonal
[
[1, b₀₁, b₀₂, b₀₃, …],
[1, b₁₂, b₁₃, …],
[1, b₂₃, …],
]
@mbinna
mbinna / effective_modern_cmake.md
Last active November 13, 2024 23:24
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@danoneata
danoneata / Sudoku.hs
Last active August 20, 2022 01:27
Applicative-based Sudoku solver
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Control.Applicative
import Data.Char
import Data.List (intersperse)
import Data.Monoid hiding (All, Any)
import Data.Foldable hiding (all, any)
import Prelude hiding (all, any)
@chrisdone
chrisdone / FieldTH.hs
Last active February 13, 2017 22:17
$(lens 'foo) -- handy one-off lens maker for record fields
{-# LANGUAGE TemplateHaskell #-}
-- | For when you have a record that doesn't have lenses derived for
-- it and you need a lens, just use @$(lens 'thefield)@ and away you go.
module Control.Lens.FieldTH where
import Language.Haskell.TH
lens :: Name -> Q Exp
lens name = do
[|\f r ->
fmap
$(lamE
@pervognsen
pervognsen / hopf.txt
Last active February 17, 2017 09:44
This note is in response to this article, particularly the final section on three degrees of freedom:
http://marc-b-reynolds.github.io/distribution/2017/01/27/UniformRot.html
It notes that "Marsaglia hand-wavingly presented a method for the 4D sphere". I hope to give some insight
into how this method may be obtained and how it relates to some relatively commonplace mathematical ideas.
The unit quaternions may be embedded in C^2 as pairs of complex numbers (z1, z2) satisfying |z1|^2 + |z2|^2 = 1.
If we write z1 and z2 in polar coordinates as z1 = r1 exp(i t1) and z2 = r2 exp(i t2), this is equivalent to