Skip to content

Instantly share code, notes, and snippets.

@domtes
domtes / generate.c
Created February 18, 2024 17:04 — forked from munificent/generate.c
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@domtes
domtes / evade.py
Created June 26, 2020 10:53
Migrate all your mercurial Bitbucket private repositories to GitHub
import os
import requests
BITBUCKET_USERNAME = os.getenv('BITBUCKET_USERNAME')
BITBUCKET_PASSWORD = os.getenv('BITBUCKET_PASSWORD')
GITHUB_USERNAME = os.getenv('GITHUB_USERNAME')
GITHUB_TOKEN = os.getenv('GITHUB_TOKEN')
#!/bin/sh
# This is the command used to install pycurl with openssl on OSX (where curl and openssl have been installed with homebrew)
LDFLAGS="-L/usr/local/opt/openssl/lib -L/usr/local/opt/curl/lib" \
CFLAGS="-I/usr/local/opt/openssl/include -I/usr/local/opt/curl/include" \
PYCURL_CURL_CONFIG=/usr/local/opt/curl/bin/curl-config \
PYCURL_SSL_LIBRARY=openssl \
pip install --compile pycurl

Keybase proof

I hereby claim:

  • I am domtes on github.
  • I am domenico (https://keybase.io/domenico) on keybase.
  • I have a public key ASAeZ4u30j3I5cHLEHtUCXg1-GtyD0sbdBczbEYy5vaIFQo

To claim this, I am signing this object:

@domtes
domtes / many_preds.py
Last active August 29, 2015 14:02
How to eval multiple predicates over a value without using 'if'
# -*- coding: utf-8 -*-
import string
def ensure_encoding(coding):
def _test(value):
try:
value.decode('ascii')
except UnicodeDecodeError:
return "Must be {0} encoded".format(coding)