Skip to content

Instantly share code, notes, and snippets.

@andrew-d
andrew-d / prime_guess.py
Created March 7, 2013 00:00
Snarky prime number guesser
import time
import random
import subprocess
SNARK_CHANCE = 0.5
MAX_PRIME = 100
snark = [
'Are you kidding me?',
'Not yet, really?',
@andrew-d
andrew-d / spiral.c
Created September 17, 2013 05:30
Spiral array generator
#include <stdio.h>
#include <stdlib.h>
// Define me for interactivity!
//#define DEBUG
void print_matrix(int* matrix, int x, int y) {
int i, j;
for( i = 0; i < y; i++ ) {
@andrew-d
andrew-d / bookmarklet.js
Created October 24, 2013 22:31
Bookmarklet to strip names on http://escape.alf.nu Note: not perfect - drops the alt text, for example.
var clear = function(){
var names = {};
var count = 0;
var tds = document.querySelectorAll('div#actualscores td');
for( var i in tds ) {
var text = tds[i].innerText;
if( text !== undefined && !text.match(/^[\d ,]+$/) ) {
var newText = text.split(', ').
#include <stdio.h>
#include <windows.h>
int main(void) {
int ctr = 0;
int i;
for( i = 0; ; i++ ) {
void* ret = VirtualAllocEx(
@andrew-d
andrew-d / gpgverify.py
Created July 7, 2016 21:54
Simple wrapper around `gpg --verify` with some pretty output
#!/usr/bin/env python
from __future__ import print_function
import re
import sys
import subprocess
from datetime import datetime
@andrew-d
andrew-d / unicode.rb
Created August 2, 2016 01:13
Homebrew recipe to install unicode (https://github.com/garabik/unicode)
class Unicode < Formula
desc "Display Unicode character properties"
homepage "https://github.com/garabik/unicode"
version "2.4"
url "https://github.com/garabik/unicode/archive/v#{version}.tar.gz"
sha256 "0e3dbf8ae9b136e1799d3ed59628d2908cd89cf4ee8f3a8277d5cffc6e12e8e4"
# Python 2 has somewhat brain-dead Unicode behavior
depends_on :python3
@andrew-d
andrew-d / int3400-more-uuids.patch
Created September 10, 2018 02:59
Thinkpad X1 Carbon thermal throttling patches for Linux
commit 0000000000000000000000000000000000000000
Author: Andrew Dunham <redacted>
Date: Mon Jan 01 00:00:00 2018 +0100
Apply https://patchwork.kernel.org/patch/8756801/
Original commit message:
Added AdaptivePerformance, EmergencyCallMode,
PassivePolicy2, PowerBoss, VirtualSensor
@andrew-d
andrew-d / cpp-file-macro.patch
Created October 28, 2018 08:02
Testing patch for `cpp` in Nixpkgs that removes store paths from the __FILE__ macro
diff --git i/libcpp/macro.c w/libcpp/macro.c
index c2515534504..ab593251def 100644
--- i/libcpp/macro.c
+++ w/libcpp/macro.c
@@ -288,8 +288,8 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node,
case BT_FILE:
case BT_BASE_FILE:
{
- unsigned int len;
- const char *name;
@andrew-d
andrew-d / update-gvisor-deps.py
Created December 10, 2018 09:06
Very WIP script to update dependencies for gvisor in Nix
#!/usr/bin/env python
from __future__ import print_function
import re
import sys
import json
import random
import shutil
import tempfile
@andrew-d
andrew-d / only-missing.nix
Created February 10, 2020 06:41
Completely untested Nix builder for icon theme with only "image-missing.png"
{ stdenv
, pkgs
, gnome3
, hicolor-icon-theme
}:
stdenv.mkDerivation {
pname = "only-missing";
version = "0.0.1";