Skip to content

Instantly share code, notes, and snippets.

View mathewmariani's full-sized avatar

Mathew Mariani mathewmariani

View GitHub Profile
// https://flatuicolors.com/palette/ca
const colors = ["#ff9ff3", "#feca57", "#ff6b6b", "#48dbfb", "#1dd1a1"];
window.addEventListener("mousedown", (e) => {
const color = colors.shift();
document.documentElement.style.setProperty("--highlight-color", color);
colors.push(color);
});
@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 / 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) {
#include <stdio.h>
#include <stdint.h>
static uint8_t reg[4] = {0x0, 0x0, 0x0, 0x0};
void reset()
{
for (uint8_t i = 0; i < 4; ++i)
{
reg[i] = 0x0;
import os
from shutil import copyfile
library_string = ""
root = "src"
header = (".h", ".hpp")
impl = (".c", ".cc", ".cpp")
variables = []
tell application "Messages"
set myid to get id of first service
set mybuddy to buddy "+11234567890" of service id myid
set message to ""
repeat 10000 times
set message to message & "😘"
end repeat
send message to mybuddy
class Foo {
constructor() {
print("Foo has been constructed\n")
}
</ min = 0, max = 5 />
function test(i) {
local min = Foo.getattributes("test").min
local max = Foo.getattributes("test").max
return i < min ? min : (i > max ? max : i)
@mathewmariani
mathewmariani / uuid4.nut
Last active August 20, 2017 23:34
Generates a random UUID string; version 4 as specified in RFC 4122.
function uuid4() {
local fn = function(c) {
local r = (((1.0 * rand() / RAND_MAX) * 16) + 1).tointeger();
local v = (c == "x") ? r : (r & 0x3 | 0x8);
return format("%x", r);
}
local string = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
local expression = regexp(@"[xy]");
local captures = expression.capture(string);
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) {
// C/C++
#include <fstream>
#include <iostream>
#include <math.h>
// OpenGL
#include "opengl.h"
// utility
#include "matrix4.h"