Skip to content

Instantly share code, notes, and snippets.

Michael Maclean mgdm

Block or report user

Report or block mgdm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

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
Inclusive ranges in Rust
View wat.md

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);
    }
}
View broker_log.txt
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 Dec 3, 2015
Explain this
View wat.js
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 ]
View index.html
<!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 Jul 9, 2015
OpenSSL Security Advisory [9 Jul 2015]
View gist:d0065afc6ffd51716f55
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 Jul 8, 2015
Websockets HTTP server crash
View gist:667172cad4c87b8007b1
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 Jul 6, 2015
Using MFFI to drive a SureElec LCD display
View sureelec.php
<?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 Apr 5, 2015
Fix compile on Linux
View win32.diff
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) /* {{{ */
@mgdm
mgdm / gol.py
Last active Aug 29, 2015
Game of Life in Python
View gol.py
import numpy as np
import os, sys, time
from random import randrange
def make_board(width, height):
board = np.zeros((width, height))
for y in xrange(0, height):
for x in xrange(0, width):
if randrange(10) > 8:
You can’t perform that action at this time.