Skip to content

Instantly share code, notes, and snippets.

View luavixen's full-sized avatar
🦊
teehee! :3c

Lua MacDougall luavixen

🦊
teehee! :3c
View GitHub Profile
@luavixen
luavixen / fizzbuzzfast.asm
Created October 31, 2019 03:03
FizzBuzz in x86 NASM, now faster! No `call`s!
bits 32
cpu 386
global _start
%define count 1073741824
section .data
fizzMsg db "Fizz!", 0x0A
fizzLen equ $ - fizzMsg
@luavixen
luavixen / time.js
Created November 4, 2019 23:42
Display a timer on the page.
/*
* ## time.js ##
* counts how long the page has been open for and writes it to a clock
* to use: create an element with the id "clock" and run this script
*/
(function () {
//-- config section --//
// element id to look for
var elemId = 'clock';
@luavixen
luavixen / platform.h
Last active April 28, 2020 20:17
Header file that detects and defines what platform you are compiling for
#pragma once
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#define PLATFORM_WINDOWS 1
#define PLATFORM_NT 1
#ifdef _WIN64
#define PLATFORM_WINDOWS64 1
#define PLATFORM_64 1
#else
#define PLATFORM_WINDOWS32 1
@luavixen
luavixen / toArray.js
Created September 14, 2020 05:35
Object.prototype.toString is a thing, so how about toArray?
function toArray() {
var length = this.length;
if (
typeof length === "number"
&& length === length
&& length > 0
) {
var array = new Array(length);
for (var i = 0; i < length; i++) {
array[i] = this[i];
@luavixen
luavixen / raw_request.rs
Created September 14, 2020 23:35
Request guard for https://rocket.rs/ that allows you to access the raw request.
use std::ops::Deref;
use rocket::request::{Request, FromRequest, Outcome};
pub struct RawRequest<'a, 'r> (pub &'a Request<'r>);
impl<'a, 'r> Deref for RawRequest<'a, 'r> {
type Target = Request<'r>;
@luavixen
luavixen / chroot-create.sh
Last active June 12, 2025 05:34
Create a new Debian `chroot` environment in Alpine Linux
#!/bin/sh
if [[ $(id -u) -eq 0 ]]; then
echo "This script cannot be run as root, root access will be requested through \`sudo\`"
exit 1
fi
user="$USER"
group="$user"
@luavixen
luavixen / lua.sh
Last active January 31, 2022 01:25
Lua's shell profile
#!/bin/sh
#
# Lua's shell profile
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or distribute
# this software, either in source code form or as a compiled binary, for any
# purpose, commercial or non-commercial, and by any means.
#
@luavixen
luavixen / sleepsort.js
Created March 13, 2021 17:00
JavaScript sleep sort implementation using async iterators.
function race(promises) {
return new Promise((resolve, reject) => {
for (const promise of promises)
if (
promise
&& typeof promise === "object"
&& typeof promise.then === "function"
) promise.then(resolve, reject);
});
}
@luavixen
luavixen / blaze.c
Last active April 18, 2021 19:21
Speedy Brainfuck interpreter with a convienent REPL.
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <setjmp.h>
#include <errno.h>
#include <unistd.h>
#include <readline/readline.h>
@luavixen
luavixen / mirrorbench.js
Last active December 15, 2021 08:11
Node.js script to find the fastest Arch Linux mirrors.
const target = '/core/os/x86_64/linux-firmware-20210818.c46b8c3-1-any.pkg.tar.zst';
const targetReplace = '/$repo/os/$arch';
const timeoutMs = 20_000;
const mirrors = [
// Canada
'https://mirror.0xem.ma/arch/$repo/os/$arch',
'https://mirror.csclub.uwaterloo.ca/archlinux/$repo/os/$arch',
'https://mirror2.evolution-host.com/archlinux/$repo/os/$arch',