Skip to content

Instantly share code, notes, and snippets.

View benhovinga's full-sized avatar

Ben Hovinga benhovinga

  • St. John's, Newfoundland & Labrador, Canada
  • 08:09 (UTC -02:30)
View GitHub Profile
@benhovinga
benhovinga / array-difference-index.js
Created January 18, 2022 18:06
Find the difference between 2 arrays and return the Index position of that difference
// Find the index position of the difference
const squaresOld = [null, null, null, null, "X", null, "O", null, null];
const squaresNew = [null, null, null, null, "X", null, "O", null, "X"]; // X selected square 8
// What box did X select?
const result = squaresNew.findIndex(function (element, index) {
return squaresOld[index] !== element;
});
@benhovinga
benhovinga / array-differences.js
Created January 18, 2022 17:56
Comparing arrays and returning the differences (3 methods)
// Array Differences
// Source: https://stackoverflow.com/a/33034768
const arr1 = [1,2,3];
const arr2 = [2,3,5];
const intersection = arr1.filter(x => arr2.includes(x));
const difference = arr1.filter(x => !arr2.includes(x));
@benhovinga
benhovinga / fibonacciGenerator.js
Last active February 20, 2021 14:39
Fibonacci Sequence Generator
/**
* Fibonacci Sequence Generator
* @example
* // returns array with 10 numbers in sequence
* fibonacciGenerator(10);
* @param {number} n - Amount of numbers to return
* @returns {array} Fibonacci Sequence
**/
function fibonacciGenerator(n) {
if (n === 0 || n === undefined) {
@benhovinga
benhovinga / fizzBuzz.js
Last active February 19, 2021 15:03
FizzBuzz game generator
/**
* FizzBuzz game generator - If number is divisable by 3 replace with Fizz, if number is divisable by 5 replace with Buzz, if number is divisable by both 3 and 5 replace with FizzBuzz
* @example
* // returns array between 1 and 100
* fizzBuzz(1, 100);
* @param {number} startRange
* @param {number} endRange
* @returns {array} Numbers between startRange and endRange with a number replaced by Fizz, Buzz, or FizzBuzz as required.
**/
function fizzBuzz(startRange, endRange) {
@benhovinga
benhovinga / minecraft_afk_clicker.ahk
Last active December 19, 2020 16:19
AutoHotkey Script to automatically click.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
; Clicker
^K::
Loop {
if stopit = true
{
stopit = false

Minecraft AFK Clicker

This is a quick guide to setup an AFK clicker in Minecraft. An example of where you might want to use this would be a zombie or skeleton xp farm. You can use this to automatically swing your sword every second or 2. Then you can leave the computer, grab some lunch, and when you come back you will have a few more levels.

Works for Java and Bedrock on Windows only.

Prerequisites

AutoHotkey

@benhovinga
benhovinga / Auto Inventory Mover - Minecraft.ahk
Last active December 19, 2020 16:19
Automatically move all stacks of same type from inventory in Minecraft
; Auto Inventory Mover
; Created by Ben Hovinga (https://github.com/benhovinga)
; This script will auto move all items of the same type from your inventory to a chest or in reverse.
; How-to video: https://youtu.be/cKdi5v-dNEE
; Force input mode for speed and reliability.
SendMode Input
; Change F24 to any keybind you like.
F24::

Keybase proof

I hereby claim:

  • I am benhovinga on github.
  • I am benhovinga (https://keybase.io/benhovinga) on keybase.
  • I have a public key whose fingerprint is B9D8 67D8 7955 4186 DB3C B623 71EA 3699 C67A 7E6E

To claim this, I am signing this object: