Skip to content

Instantly share code, notes, and snippets.

View colinvh's full-sized avatar

Colin von Heuring colinvh

View GitHub Profile
@colinvh
colinvh / mysqli-delete-multiple.php
Created March 28, 2019 17:28
Delete multiple rows by ID with one statement (mysqli)
$ids = [1, 2, 3];
$qqq = join(', ', array_fill(0, sizeof($ids), '?'));
$iii = str_repeat('i', sizeof($ids));
$stmt = $conn->prepare("DELETE FROM table WHERE id IN ($qqq)");
$args = $ids;
array_unshift($args, $iii);
call_user_func_array([$stmt, 'bind_param'], $args);
$stmt->execute();
#!/usr/bin/env python
import random
def descriptor(described):
d = random.choice(DESCRIPTORS)
if d[-1] == '-':
if lower(described[0]) in 'aeiou':
return d[:-2] + described
else:
@colinvh
colinvh / randsym.py
Last active May 1, 2018 17:29
Random symbolic identifiers
# -*- coding: utf-8 -*-
import codecs
from collections import Counter
import random
import sys
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
DIACRITICS = [
@colinvh
colinvh / INDEX.md
Created April 13, 2018 21:09
The Motorcyclist's Creed

The Motorcyclist's Creed

With apologies to Steven King and Roland Deschain.

I do not accelerate with my hand; He who accelerates with his hand has forgotten the displacement of his motor.

I accelerate with my wrist.

I do not steer with my arms; He who steers with his arms has forgotten the displacement of his motor.

#!/usr/bin/env perl
# PRAGMA
use warnings;
use strict;
# DECLARE
sub kaprekar_distance(_);
sub fmt(_);
code ltr pro num punc eur notes
. E
- T
.. I
.- A
-. N
... S
-- M
..- U
.-. R
@colinvh
colinvh / surface-gravity.odt
Last active December 19, 2015 22:21
Surface Gravity of Terrestrial Bodies in the Solar System
@colinvh
colinvh / pep-440-semver.md
Last active February 29, 2024 13:25
440 Semantic

PEP-440-Compatible Semantic Versioning

This document attempts to refine Python's PEP 440 to include the principles of Semantic Versioning.

Specification

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

@colinvh
colinvh / seven-table.md
Created September 9, 2015 20:09
7-segment display tables
Dec 7-Seg
0 126
1 48
2 109
3 121
4 51
5 91
6 95
7 112