Skip to content

Instantly share code, notes, and snippets.

View mathewmariani's full-sized avatar

Mathew Mariani mathewmariani

View GitHub Profile
@mathewmariani
mathewmariani / kmap.cs
Last active November 14, 2015 21:18
The Karnaugh map, also known as the K-map, is a method to simplify boolean algebra expressions.
using System;
class MainClass
{
// The Karnaugh map, also known as the K-map, is a method to simplify boolean algebra expressions.
public static void Main(string[] args)
{
// kmap cells
var kmap = new bool[4];
var gulp = require('gulp');
var coffee = require('gulp-coffee');
// @NOTE compile coffeescript into javascript
gulp.task('coffee', function () {
gulp.src('./_coffee/**/*.coffee')
.pipe(coffee({bare: true}))
.pipe(gulp.dest('./js/'))
});
@mathewmariani
mathewmariani / deploy.sh
Last active May 12, 2016 01:42
Used for deploying to a build repository using Travis-CI
#!/bin/bash
# Exit with nonzero exit code if anything fails
set -e
# set up some variables
SOURCE_BRANCH="<source_branch>"
TARGET_BRANCH="<target_branch">
GITHUB_REF="github.com/<username>/<repo_name>.git"
NAME="<your_name>"
@mathewmariani
mathewmariani / elisa.hpp
Last active July 5, 2016 21:32
A small meta programming header for C++11.
#pragma once
/**
* elisa: a small metaprogramming header.
* FIXME: code cleanup and comment,
*/
namespace elisa {
template<class T>
using invoke = typename T::type;
@mathewmariani
mathewmariani / benchmark_macro.hpp
Last active August 19, 2016 02:22
A simple macro for quick benchmarking.
#pragma once
// https://gist.github.com/gongzhitaao/7062087
class Timer {
using clock_ = std::chrono::high_resolution_clock;
using milli_ = std::chrono::duration<double, std::milli>;
public:
Timer() : beg_(clock_::now()) {}
void reset() { beg_ = clock_::now(); }
double elapsed() const {
return std::chrono::duration_cast<milli_>
@mathewmariani
mathewmariani / test_macro.hpp
Last active August 19, 2016 02:23
A simple macro for quick unit testing.
#pragma once
#define TEST(__condition) \
if ((__condition)) { \
printf("[PASSED]\t%s\n", #__condition); \
} else { \
printf("[FAILED]\t%s\n", #__condition); \
}
#define TEST_THROW(__condition, __exception) \
try { \
@mathewmariani
mathewmariani / maccleanup.py
Created September 25, 2016 22:52
Useful for removing macOS specific files.
import os
from fnmatch import fnmatch
# pretty useless if youre using git.
root = "./"
search = ["._*", ".DS_Store", ".AppleDouble", ".LSOverride"]
for (path, dirs, files) in os.walk(root):
@mathewmariani
mathewmariani / main.cpp
Last active February 22, 2017 23:50
Subsystem Registration/Initialization
#include <iostream>
#include "module.h"
class MyModule : public Module {
DECLARE_MODULE(Module::M_TYPE_ONE);
public:
MyModule() {}
};
REGISTER_MODULE(MyModule);
// C/C++
#include <fstream>
#include <iostream>
#include <math.h>
// OpenGL
#include "opengl.h"
// utility
#include "matrix4.h"
static SQRegFunction reg[] = {
// I believe the main reason this fails is due to the arguments.
// but when looking at DXSquirrel (specifically DXSquirrel_Device.cpp) there's nothing special done about it.
{ "getData", wrap_getData, 2, _SC("ts") },
{ "getTestData", wrap_getTestData, NULL, NULL },
{ 0, 0 }
};
int wrap_getData(SQVM* v) {