Skip to content

Instantly share code, notes, and snippets.

View FelicitusNeko's full-sized avatar

Felix R FelicitusNeko

View GitHub Profile
@FelicitusNeko
FelicitusNeko / shuffler.c
Last active May 28, 2024 00:52
Shuffles and outputs a list of .txt files in the pwd.
// TXT Shuffler by FelicitusNeko is marked with CC0 1.0.
// To view a copy of this license, visit https://creativecommons.org/publicdomain/zero/1.0/
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef struct listing_t {
@FelicitusNeko
FelicitusNeko / recodeq.js
Created August 13, 2022 20:09
A script I just made to convert lossless OBS .MKV recordings to compressed .MP4 files, also outputting per-track .MP3 files. Requires ffmpeg on path, as well as TeraCopy to move converted files.
// Copyright (c) 2022 FelicitusNeko
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
const { readdirSync, writeFileSync, unlinkSync } = require("fs");
const { spawn } = require("child_process");
const { join, basename } = require("path");
const convertTarget = "C:\\Path\\To\\ConvertedFiles";
@FelicitusNeko
FelicitusNeko / advent2019-16.1.js
Created December 18, 2019 01:36
Advent of Code 2019 Day 16
‎‎​const FFT = (input, maxPhase) => {
let data = input.split('').map(i => parseInt(i));
for (let phase = 0; phase < maxPhase; phase++) {
let newData = [];
for (let X = 0; X < input.length; X++) {
let newVal = 0;
for (let Y = X; Y < input.length; Y++) {
switch (~~((Y + 1) / (X + 1)) % 4) {
@FelicitusNeko
FelicitusNeko / advent2019-15.1.js
Created December 17, 2019 21:48
Advent of Code 2019 Day 15
const fs = require('fs');
const DIR_NORTH = 1, DIR_SOUTH = 2, DIR_WEST = 3, DIR_EAST = 4;
const TURN_LEFT = 0, TURN_NO = 1, TURN_RIGHT = 2, TURN_BACK = 3;
const STAT_WALL = 0, STAT_STEP = 1, STAT_OXY = 2;
const MAP_WALL = 0, MAP_OPEN = 1, MAP_FINISH = 2, MAP_START = 3, MAP_LHR = 4, MAP_RHR = 5, MAP_BOTH = 6;
class IntOpcodeMachine {
constructor(pgm) {
this.pgm = pgm.split(',').map(i => parseInt(i));
@FelicitusNeko
FelicitusNeko / advent2019-13.1.js
Last active December 17, 2019 22:06
Advent of Code 2019 Day 13
class IntOpcodeMachine {
constructor(pgm) {
this.pgm = pgm.split(',').map(i => parseInt(i));
this.originalPgm = this.pgm.slice(0);
this.position = 0;
this.relBase = 0;
this.cmdSize = { 1: 4, 2: 4, 3: 2, 4: 2, 5: 3, 6: 3, 7: 4, 8: 4, 9: 2, 99: 1 }
this.input = []; this.output = [];
}
@FelicitusNeko
FelicitusNeko / advent2019-12.1.js
Created December 14, 2019 06:20
Advent of Code 2019 Day 12
const pos3d = { x: 0, y: 0, z: 0 }
const gravObject = { pos: { x: 0, y: 0, z: 0 }, vel: { x: 0, y: 0, z: 0 } };
const gravMachine = (data, cycles) => {
let gravObjects = data.split(/[\r\n\<\>]+/).filter(i => i.length).map(i => {
let retval = { pos: Object.assign({}, pos3d), vel: Object.assign({}, pos3d) };
i.split(', ').map(ii => ii.split('=')).forEach(ii => retval.pos[ii[0]] = parseInt(ii[1]));
return retval;
});
@FelicitusNeko
FelicitusNeko / advent2019-11.1.js
Last active December 17, 2019 22:11
Advent of Code 2019 Day 11
class IntOpcodeMachine {
constructor(pgm) {
this.pgm = pgm.split(',').map(i => parseInt(i));
this.originalPgm = this.pgm.slice(0);
this.position = 0;
this.relBase = 0;
this.cmdSize = { 1: 4, 2: 4, 3: 2, 4: 2, 5: 3, 6: 3, 7: 4, 8: 4, 9: 2, 99: 1 }
this.input = []; this.output = [];
}
@FelicitusNeko
FelicitusNeko / advent2019-10.1.js
Last active December 17, 2019 22:10
Advent of Code 2019 Day 10
class Point {
constructor(x, y) {
this.X = x; this.Y = y;
}
distanceTo(rhs) {
if (!(rhs instanceof Point)) throw new Error('Parameter is not a Point');
return Math.abs(Math.sqrt(Math.pow(rhs.Y - this.Y, 2) + Math.pow(rhs.X - this.X, 2)));
}
@FelicitusNeko
FelicitusNeko / advent2019-9.1.js
Last active December 18, 2019 04:34
Advent of Code 2019 Day 9
// Day 9 part 2 is literally the exact same code except the input is 2 instead of 1
class IntOpcodeMachine {
constructor(pgm) {
this.pgm = pgm.split(',').map(i => parseInt(i));
this.originalPgm = this.pgm.slice(0);
this.position = 0;
this.relBase = 0;
this.cmdSize = { 1: 4, 2: 4, 3: 2, 4: 2, 5: 3, 6: 3, 7: 4, 8: 4, 9: 2, 99: 1 }
this.input = []; this.output = [];
@FelicitusNeko
FelicitusNeko / advent2019-8.1.js
Last active December 17, 2019 22:10
Advent of Code 2019 Day 8
const imagizer = (data, w, h) => {
const layerSize = w * h;
let retval = [];
for (let z = 0; z * layerSize < data.length; z++) {
let layer = [];
for (let y = 0; y < h; y++)
layer.push(data.substr((layerSize * z) + (w * y), w).split('').map(i => parseInt(i)));
retval.push(layer);
}