Skip to content

Instantly share code, notes, and snippets.

View FlyingJester's full-sized avatar

Martin McDonough FlyingJester

View GitHub Profile
include <stdlib.h>
#include <ncurses.h>
/* setting up typing function */
char * nr_echo( int start_y, int start_x, int h, int w ){
int ch, y, x, end_y, end_x, ch_count ;
int ch_count_in;
char *stored_line;
stored_line = malloc(100000);
@FlyingJester
FlyingJester / conf.py
Created December 3, 2017 09:22
Configuration utility, to run in a different process.
#!/bin/python
# Copyright (c) 2017 Martin McDonough
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
@FlyingJester
FlyingJester / exception_example.cpp
Created November 16, 2017 20:58
Exceptions help you write such safe code.
#include <exception>
#include <stdexcept>
#include <vector>
#include <assert.h>
#include <stddef.h>
// Returns a munged/hash of an int.
// Always returns something different than what is passed in.
int munge(int i){
@FlyingJester
FlyingJester / cinnabar.m
Last active March 12, 2017 06:51
Do not lose this
config.load(Config, !IO),
( Config ^ config.gl_version = window.gl_version(2, _) ->
thread.mvar.init(TimeMVar, !IO),
thread.mvar.init(SceneMVar, !IO),
thread.mvar.put(SceneMVar, gl2_scene, !IO),
thread.mvar.put(TimeMVar, 0, !IO),
Renderer = render(gl2_render.gl2_render, SceneMVar),
Engine = engine(gl2_render.gl2_render, TimeMVar, SceneMVar),
window.run_threaded(
;
:- module rule_test.
:- interface.
:- type a ---> a1 ; a2.
:- type b ---> b1 ; b2.
% Verify that if a is a1, b is b2.
:- pred check(a::in, b::in) is semidet.
:- implementation.
@FlyingJester
FlyingJester / watcom.txt
Created January 20, 2017 18:14
Open Watcom Linker Help
usage: wlink {directive}
commands valid for all executable formats:
directive ::= "File" obj_spec{","obj_spec}
| "Name" exe_file
| "OPtion" option{","option}
| "Library" library_file{","library_file}
| "OPTLIB" library_file{","library_file}
| "Path" path_name{";"path_name}
@FlyingJester
FlyingJester / bufferfile.m
Created December 23, 2016 01:57
Bufferfile implementation in Mercury
:- module bufferfile.
%==============================================================================%
:- interface.
%==============================================================================%
:- use_module io.
:- use_module maybe.
:- type buffer.
:- type file.
@FlyingJester
FlyingJester / scene.m
Created December 17, 2016 01:14
Scene Graph rought draft for CinnabarEngine
:- module scene.
%==============================================================================%
:- interface.
%==============================================================================%
:- use_module render.
:- use_module mglow.
:- include_module scene.matrix_tree.
:- include_module scene.tree.
@FlyingJester
FlyingJester / wavefront.m
Created November 19, 2016 23:44
(WIP) Wavefront shape/obj loader
:- module wavefront.
:- interface.
:- use_module io.
:- import_module list.
:- type point ---> point(x::float, y::float, z::float).
:- type vector ---> vector(vx::float, vy::float, vz::float).
:- type tex ---> tex(u::float, v::float).
:- type vertex ---> vertex(vert_index::int, tex_index::int).
.include "system.mk"
.c.o:
$(XCC) $(XCFLAGS) -c $*.c
.cpp.o:
$(XCXX) $(XCXXFLAGS) -c $*.cpp
.s.o:
$(XAS) $*.s $(XASFLAGS) -o $*.o
export LIBGCC=${PWD}/libgcc.a