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 / addition.mas
Last active February 18, 2024 17:59
https://github.com/mathewmariani/MARIE-Examples. Please feel free to email me if you have any questions.
ORG 0
LOAD X / LOAD X into AC
ADD Y / ADD Y to AC
STORE Z / STORE AC in Z
LOAD Z / LOAD Z into AC
OUTPUT / OUTPUT AC
X, DEC 1 / variable declaration
Y, DEC 2 / variable declaration
@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 / binary.js
Created May 18, 2016 23:22
A quick look at signed and unsigned integers in JavaScript.
var UInt4 = function (value) {
return (value & 0xF);
};
var Int4 = function (value) {
var ref = UInt4(value);
return (ref > 0x7) ? ref - 0x10 : ref;
};
var UInt8 = function (value) {
@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 / 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 / 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):
import os
from shutil import copyfile
library_string = ""
root = "src"
header = (".h", ".hpp")
impl = (".c", ".cc", ".cpp")
variables = []