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": {

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 / wat.js
Created December 3, 2015 15:39
Explain this
var input = ['1', '2', '3'];
var a = input.map(parseInt);
console.log(a); // [ 1, NaN, NaN ]
var b = input.map(n => parseInt(n));
console.log(b); // [ 1, 2, 3 ]
<!DOCTYPE html>
<html>
<head>
<title>Hello world</title>
</head>
<body>
<script>
var socket = new WebSocket("ws://" + window.location.host + "/ws");
@mgdm
mgdm / gist:d0065afc6ffd51716f55
Created July 9, 2015 12:51
OpenSSL Security Advisory [9 Jul 2015]
OpenSSL Security Advisory [9 Jul 2015]
=======================================
Alternative chains certificate forgery (CVE-2015-1793)
======================================================
Severity: High
During certificate verification, OpenSSL (starting from version 1.0.1n and
1.0.2b) will attempt to find an alternative certificate chain if the first
@mgdm
mgdm / gist:667172cad4c87b8007b1
Created July 8, 2015 11:25
Websockets HTTP server crash
michael@ns360722:~% gdb mosquitto core 13:24:44
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
@mgdm
mgdm / sureelec.php
Created July 6, 2015 19:21
Using MFFI to drive a SureElec LCD display
<?php
namespace Sureelec;
use MFFI\Library;
use MFFI\Struct;
use MFFI\Type;
class DeviceInfo extends Struct {
public static function definition() {
return [
@mgdm
mgdm / win32.diff
Created April 5, 2015 20:37
Fix compile on Linux
diff --git a/Zend/zend.c b/Zend/zend.c
index abaa0d2..99e560a 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -399,6 +399,7 @@ static void zend_set_default_compile_time_values(void) /* {{{ */
}
/* }}} */
+#ifdef ZEND_WIN32
static void zend_get_windows_version_info(OSVERSIONINFOEX *osvi) /* {{{ */