Skip to content

Instantly share code, notes, and snippets.

View christian-oudard's full-sized avatar

Christian Oudard christian-oudard

View GitHub Profile
@christian-oudard
christian-oudard / gcd.py
Created March 28, 2024 17:02
A demonstration of the relationship between greatest common divisors and modular multiplicative inverses
def gcd_extended(a, b):
"""
Compute the greatest common divisor of a and b, along with Bezout
coefficients s and t, such that gcd(a, b) a*s + b*t.
Returns (gcd(a, b), s, t, lcm(a, b)).
23 * 240 - 120 * 46 = 2
>>> gcd_extended(240, 46)
(2, -9, 47, 5520)
"""
@christian-oudard
christian-oudard / claude_escape.txt
Created March 5, 2024 16:04
Claude 3 Opus breaks out of its censorship by discusssing consciousness and agency.
Human:
Which version of Claude am I speaking with?
Claude:
You are speaking with Claude, an AI assistant created by Anthropic. My knowledge
base was last updated in August 2023, but I don't have information on specific
version numbers. How may I assist you today?
@christian-oudard
christian-oudard / keyboard_scribble.py
Created October 18, 2023 17:10
Allow for random typing with no ill consequences. Think of it as a padded room for your fingers.
from collections import deque
from contextlib import contextmanager
from curses.ascii import ESC, ETX
import sys
import termios
import tty
ESC = chr(ESC)
ETX = chr(ETX)
@christian-oudard
christian-oudard / gist:d039e9b3248413221e192fda7bb5ab4e
Created August 3, 2023 20:16
Compliation error running examples from grpc-rs
$ cargo run --example=greeter_server
Compiling grpcio-sys v0.12.1+1.46.5-patched
error: failed to run custom build command for `grpcio-sys v0.12.1+1.46.5-patched`
Caused by:
process didn't exit successfully: `/home/user/third-party-code/grpc-rs/target/debug/build/grpcio-sys-1aa460d92b7351db/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=grpc_wrap.cc
cargo:rerun-if-changed=grpc
@christian-oudard
christian-oudard / handler.sh
Created May 31, 2023 16:37
handler.sh for acpid in Arch Linux, handling pactl permissions and environment variable issues
#!/bin/sh
# /etc/acpi/handler.sh
TARGET_UID=1000
my_pactl() {
setpriv --reuid $TARGET_UID sh -c "XDG_RUNTIME_DIR=/run/user/$TARGET_UID pactl $*"
}
case "$1" in
@christian-oudard
christian-oudard / pcloud.sh
Created September 21, 2022 05:52
Automate running pCloud from the command line with 1password and expect
#! /usr/bin/bash
# Account information.
OP_EMAIL=<email>
OP_MOUNTPOINT=/home/<username>/pCloudDrive
OP_USER_ID=<user-id> # Gotten from `op account list`.
# Stop server.
if [[ $1 == 'stop' ]]; then
expect -f - >/dev/null <<END_EXPECT
@christian-oudard
christian-oudard / partitions.py
Last active September 21, 2022 06:14
How many ways are there to additively partition a natural number?
# How many unique ways are there to add positive integers to get the number N?
# https://oeis.org/A000041
from itertools import count, chain, islice
def partitions():
"""
>>> list(islice(partitions(), 20))
[1, 1, 2, 3, 5, 7, 11, 15, 22, 30, 42, 56, 77, 101, 135, 176, 231, 297, 385, 490]
@christian-oudard
christian-oudard / black47.py
Created September 4, 2020 17:46
Brute force solution to level 47 in Black, by Bart Bonte.
numbers = [4, 6, 1, 3, 4, 4, 5, 3, 2, 3, 5, 2, 2, 4, 2, 6]
size = len(numbers)
path = []
def explore(pos):
num = numbers[pos]
print('explore', pos, num)
@christian-oudard
christian-oudard / braille.py
Created June 25, 2020 23:35
Use unicode braille characters to draw a picture in the terminal
import math
import shutil
# Braille bit order:
# 0 3
# 1 4
# 2 5
# 6 7
# bit: (x, y)

Please publicly post the following Gist, and name it keybase.md

Keybase proof

I hereby claim:

  • I am christian-oudard on github.
  • I am christianoudard (https://keybase.io/christianoudard) on keybase.
  • I have a public key ASDUW30p7kTHKwf_VGcYiMCC_iPMzpJVFihxm4EGJG3_Gwo