Skip to content

Instantly share code, notes, and snippets.

@mgdm
mgdm / nominimise.json
Last active January 14, 2024 11:51
Custom modification for Karabiner to disable the cmd-m minimise shortcut
{
"title": "Prevent unintended command-m minimising",
"rules": [
{
"description": "Disable Cmd+m minimise",
"manipulators": [
{
"type": "basic",
"description": "",
"from": {
@mgdm
mgdm / iteration.php
Last active October 12, 2017 16:12
Mandelbrot code demonstrating Recki-CT
<?php
/**
* @param double $cReal
* @param double $cImag
* @param int $maxIterations
* @return int
*/
function mandelbrotIteration($cReal, $cImag, $maxIterations)
{

Keybase proof

I hereby claim:

  • I am mgdm on github.
  • I am mgdm (https://keybase.io/mgdm) on keybase.
  • I have a public key ASDHaQqvHGJCoKwBFuvjgDzHmp_DXOeMRCd9lX9Cfw9avgo

To claim this, I am signing this object:

@mgdm
mgdm / wat.md
Last active May 2, 2016 22:18
Inclusive ranges in Rust

I was writing some code in Rust 1.8.0, which needed to iterate through all the values of a u8. My first attempt looked like this:

fn main() {
    for i in 0u8..255 {
        println!("Iteration {}", i);
    }
}
1454016307: Sending CONNACK to mosq/QNQA<M\fj0`IEBIKjk (0, 0)
1454016307: Received PUBLISH from mosq/QNQA<M\fj0`IEBIKjk (d0, q2, r0, m1, 'test/mgdm', ... (5 bytes))
1454016307: Sending PUBREC to mosq/QNQA<M\fj0`IEBIKjk (Mid: 1)
1454016307: Received PUBREL from mosq/QNQA<M\fj0`IEBIKjk (Mid: 1)
1454016307: Sending PUBCOMP to mosq/QNQA<M\fj0`IEBIKjk (Mid: 1)
@mgdm
mgdm / Makefile
Last active January 1, 2016 11:19
A simple and probably flawed base for a plugin system using DSOs in C.
all:
gcc -g -o plugin main.c
gcc -o test.so -g -fPIC -shared test.c
@mgdm
mgdm / gist:8037751
Created December 19, 2013 11:20
Unicode take 2
<?php
function ♫() {
echo "hello";
}
function 😃 () {
echo " world!";
}
♫();
@mgdm
mgdm / gist:8037720
Created December 19, 2013 11:18
Unicode FTW
<?php
function ♫() {
echo "hello";
}
♫();
<?php
const POSTCODE_REGEX = '/^
([A-Z]+[0-9]+[A-Z]?) # outward code, eg G51, EC1A
\s*([0-9][A-Z]+)? # inward code, eg 1PQ, optional
$/x';
@mgdm
mgdm / notify
Last active December 20, 2015 00:09
Fire up terminal-notifier without requiring a Ruby wrapper to do so.
#!/bin/sh
# Fire up terminal-notifier.app without needing a Ruby wrapper
# Stolen from the `mvim` script distributed with MacVim.
#
# Credits for the MacVim version are:
# Based on a script by Wout Mertens and suggestions from Laurent Bihanic. This
# version is the fault of Benji Fisher, 16 May 2005 (with modifications by Nico
# Weber and Bjorn Winckler, Aug 13 2007).
#