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);
});
#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;
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)
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
@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"
@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);
import os
from shutil import copyfile
library_string = ""
root = "src"
header = (".h", ".hpp")
impl = (".c", ".cc", ".cpp")
variables = []
@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):