Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / main.c
Last active December 1, 2023 12:29
Example of how to get current binary's path using Apple's Code Signing Services
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <Security/Security.h>
// Compile with:
// gcc -o ourpath -framework CoreFoundation -framework Security main.c
#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 / 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(', ').
@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 / 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 / httpd.py
Created December 12, 2012 19:35
Threaded or forking HTTP server in Python
#!/usr/bin/env python
import sys
from SocketServer import ThreadingMixIn, ForkingMixIn
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
class ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
pass
class ForkingSimpleServer(ForkingMixIn, HTTPServer):
@andrew-d
andrew-d / depsearch.rb
Created June 14, 2012 01:15
Quick hacky recursive gem-dependency search script for Ruby
#!/usr/bin/env ruby
require 'logger'
require 'optparse'
require 'rubygems'
require 'net/http'
require 'net/https'
require 'json'
@log = Logger.new(STDERR)