Skip to content

Instantly share code, notes, and snippets.

@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).
#
@mgdm
mgdm / .zshrc
Last active December 17, 2015 12:18
zshrc for Antigen setup
ZSHA_BASE=$HOME/.zsh-antigen
source $ZSHA_BASE/antigen/antigen.zsh
antigen-use oh-my-zsh
antigen-bundle git
if [ "$OSTYPE"="darwin11.0" ]; then
antigen-bundle osx
fi
@mgdm
mgdm / pixels.php
Created April 8, 2013 14:05
'Pixellate' a graphic based on mesh gradients
<?php
define('BOX_WIDTH', 45);
define('BOX_MARGIN', 5);
$image = imagecreatefromjpeg('callanish.jpg');
$width = imagesx($image);
$height = imagesy($image);
$s = new CairoImageSurface(CairoFormat::ARGB32, $width, $height);
$c = new CairoContext($s);
Configuring for:
PHP Api Version: 20090626
Zend Module Api No: 20090626
Zend Extension Api No: 220090626
rebuilding aclocal.m4
rebuilding configure
configure.in:150: warning: LTOPTIONS_VERSION is m4_require'd but not m4_defun'd
aclocal.m4:2955: LT_INIT is expanded from...
aclocal.m4:2993: AC_PROG_LIBTOOL is expanded from...
configure.in:150: the top level
@mgdm
mgdm / addrs.c
Created October 18, 2012 21:47
Address parser
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LCD_ALIAS_REAL "DS18B20.28b8c81d300e5.Temp,DS18B20.2816401d3005f.Temp,DS18B20.28ac871d300e4.Temp"
#define LCD_ALIAS_ALIAS "Front_air_intake,Bottom_hose_temp,Top_hose_temp"
int main() {
char **devices;
@mgdm
mgdm / listdir.c
Created July 23, 2012 13:51
List contents of extremely large directories
#define _GNU_SOURCE
#include <dirent.h> /* Defines DT_* constants */
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#define handle_error(msg) \