Skip to content

Instantly share code, notes, and snippets.

View warriordog's full-sized avatar

Hazel K warriordog

  • United States
View GitHub Profile
@warriordog
warriordog / gist:ca8ab4a2bf8f4ea6f908
Created November 13, 2014 22:31
(Cheating at) sorting the corners in an AABB by physical location
private void sortCorners() {
//corner1 and corner2 are Vec3is. corner1 is the bottom left corner of the AABB, corner2 is the top right corner.
int corner1X = corner1.x;
int corner2X = corner2.x;
if (corner1X > corner2X) {
corner1.x = corner2X;
corner2.x = corner1X;
}
int corner1Y = corner1.y;
int corner2Y = corner2.y;
public class CellularAutonoma {
public static void main(String[] args) {
boolean[] cells = parseCells(args[0]);
for (int age = 0; age < 25; age++) {
printCells(cells);
cells = tickCells(cells);
}
printCells(cells);
}
@warriordog
warriordog / ExperienceManager.java
Last active February 9, 2019 16:18 — forked from RichardB122/ExperienceManager.java
A simple and easy to use class that can get and set a player's total experience points in Minecraft. This is based off the Bukkit API. The determines this with a mathematical formula based off the player's current level and their progress towards the next one.
/*
AUTHOR: Dev_Richard (https://www.spigotmc.org/members/dev_richard.38792/)
DESC: A simple and easy to use class that can get and set a player's total experience points.
Feel free to use this class in both public and private plugins, however if you release your
plugin please link to this gist publicly so that others can contribute and benefit from it.
Source available at https://gist.github.com/warriordog/6160a1ed45134265fb30b8d224da0426
*/
import org.bukkit.entity.Player;
@warriordog
warriordog / Extractor.java
Created October 27, 2016 12:46
Extractor for a custom archvie format hidden in a firmware blob
import java.io.*;
public class Extractor {
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("Specify a file and output dir!");
} else {
File in = new File(args[0]);
File out = new File(args[1]);
@warriordog
warriordog / #Snapd Managment Scripts.md
Last active April 25, 2024 16:55
Snapd Management Scripts

Snapd Management Scripts

This gist contains some simple scripts that enable control over Snap's automatic updates.

Scripts

  • disable-snap.sh - Disables the snap service and blocks updates.
  • enable-snap.sh - Enables the snap service and allows updates and managing the snap package database.
  • update-snap.sh - Temporarily enables snap and updates all packages. Disables snap when finished.
  • install.sh - Installs all scripts as global commands.

Setup (blocking automatic Snap updates)

@warriordog
warriordog / AOC_2020_Day9.js
Created December 9, 2020 13:29
Solution to Advent of Code 2020 Day 9 in JavaScript
const { parseInputFile } = require('../utils/parser');
// parse input file into array of numbers
const inputNumbers = parseInputFile('day9-input.txt', /^(\d+)$/gm)
.map(([_, num]) => parseInt(num))
;
/**
* Finds the minimum and maximum values of all the numbers in {@link inputNumbers} between indexes start and end.
*
@warriordog
warriordog / AOC_2020_Day10.js
Created December 10, 2020 13:34
Solution to Advent of Code 2020 Day 10
const { parseInputFile } = require('../utils/parser');
// parse input file into array of numbers
const inputNumbers = parseInputFile('day10-input.txt', /^(\d+)$/gm)
.map(([_, num]) => parseInt(num))
.sort((a, b) => a - b) // JS uses an alaphabetic sort by default, even for numbers
;
/**
* @typedef Adapter A charging adapter
@warriordog
warriordog / AOC_2020_Day10_NoRecurse.js
Last active December 11, 2020 01:37
Alternate version of 2020 day 10 challenge that uses no recursion (for a challenge)
const { parseInputFile } = require('../utils/parser');
class Queue {
constructor() {
this.head = null;
this.tail = null;
}
push(value) {
const node = {
@warriordog
warriordog / AOC_2020_Day11_Part1.js
Created December 11, 2020 14:32
Solution to Advent of Code 2020 Day 11 Part 1
const { parseInputFile } = require('../utils/parser');
/**
* @readonly
* @enum {number}
*/
const Seat = {
FLOOR: 0,
EMPTY: 1,
TAKEN: 2
@warriordog
warriordog / AOC_2020_Day11_Part2.js
Last active December 12, 2020 05:51
Solution to Advent of Code 2020 Day 11 Part 2
const { parseInputFile } = require('../utils/parser');
/**
* @readonly
* @enum {number}
*/
const Seat = {
FLOOR: 0,
EMPTY: 1,
TAKEN: 2