Skip to content

Instantly share code, notes, and snippets.

View FlyingJester's full-sized avatar

Martin McDonough FlyingJester

View GitHub Profile
@FlyingJester
FlyingJester / mkmk.py
Created October 25, 2016 21:36
Starter Makefile generator
import glob
import os
import sys
def WriteTarget(file, name, depends):
file.write(name + ".o: ")
for d in depends:
file.write(d + " ")
file.write("\n\t$(CC) $(CCFLAGS) -c " + name + ".c -o " + name + ".o\n")
@FlyingJester
FlyingJester / oh-god-windows.md
Created September 20, 2016 19:49 — forked from fasterthanlime/oh-god-windows.md
Getting rock 0.9.9 to make 32-bit binaries with MSYS2 on Windows

It seems the command-line toolchain of choice changes every fortnight on Windows (except if you're in the MSVC camp, but that's a no-go for ooc at the time of this writing).

The new kid on the block is msys2, which I first had doubts about, but it turns out it's a great way to get a shell, install the packages you need via pacman (!) and get started with ooc on windows.

MSYS2 32-bit

from string import Template
import inspect
import os
import sys
import math
autogen_warning = """
/* THIS FILE IS AUTOGENERATED BY:
* tools/athena_bin_to_c.py
* DO NOT EDIT THIS FILE MANUALLY
@FlyingJester
FlyingJester / lime_string.cpp
Last active July 15, 2016 18:16
Lime String Implementation
#include "lime_string.hpp"
#if ! (defined LIME_STRING_NEW && defined LIME_STRING_DELETE)
#include <cstdlib>
#endif
namespace Lime{
#ifndef LIME_STRING_NEW
@FlyingJester
FlyingJester / SConstruct
Created April 25, 2016 21:30
autoconf-style enable/disable options for a SCons file
def EnableableOption(name, default):
AddOption("--enable-" + name,
action="store_true", dest="en_" + name, default=False,
help="Enables " + name)
AddOption("--disable-" + name,
action="store_true", dest="dis_" + name, default=False,
help="Disables " + name)
enable = GetOption("en_" + name)
disable = GetOption("dis_" + name)
@FlyingJester
FlyingJester / mercury.schemedef
Created February 25, 2016 18:23
Mercury Scheme for Programmer's Notepad
<?xml version="1.0" encoding="UTF-8"?>
<Scheme>
<keyword-classes>
<keyword-class name="mercury.keywords">
module end_module use_module import_module include_module
bound ground free unique cloberred mostly_unique
is
if then else
foreign_code foreign_decl foreign_proc foreign_enum
interface implementation
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Single_Window.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Slider.H>
#include <FL/Fl_Group.H>
#include <FL/Fl_Box.H>
#include <FL/fl_draw.H>
#include <cstdio>
@FlyingJester
FlyingJester / guid.m
Created February 2, 2016 00:04
GUID implementation in Mercury
:- module guid.
:- interface.
:- import_module io.
% A larger but dependable GUID type.
:- type guid.guid.
% Simpler but more naive. Also more performant to generate and compare.
:- type guid.id.
@FlyingJester
FlyingJester / inst_test.m
Created January 31, 2016 19:38
An example of defining a mode for a type that only maintains partial uniqueness
:- module inst_test.
:- interface.
% An example of defining a mode for a type that only maintains partial uniqueness.
% The type.
% In the inst, we will want to keep the string unique, but we won't worry about the int's uniqueness.
:- type test ---> test(int, string).
% Define the start and end states for the test_di mode.
:- inst test_in_di ---> test(ground, unique).
:- module unique_integer.
:- interface.
% Written without testing...ignore small errors :P
:- type xyz ---> xyz(int).
:- pred abc(int::in, xyz::uo) is det.
:- implementation.
:- import_module int.