Skip to content

Instantly share code, notes, and snippets.

View Noitabara's full-sized avatar
💭
Coding to the sound of metal and mechanical switches.

Noita Noitabara

💭
Coding to the sound of metal and mechanical switches.
  • Atlanta
View GitHub Profile
@Noitabara
Noitabara / sq.ts
Created November 9, 2021 19:51
Will return an array in which the first element is sent to the back of the array and the others moved forward. Does not mutate origional array.
/**
* Functional queue shift. Will return an array in which the first element is sent to the back of the array and the others moved forward. Does not mutate origional array.
* @param arr The array you want to shift.
* @returns The new shifted array.
*/
function shiftQueue<T>(arr: Array<T>): Array<T> {
const [first , ...rest] = arr
return [...rest, first]
}
@Noitabara
Noitabara / GuildSlashCommand.ts
Last active June 13, 2022 21:52
How I've implemented slash handler and slash command classes for akairo. Will be updated over time- mostly need to meet mvp right now haha
// TODO what if we restructured to take the slash command/other command objects, and then created specific objects for akairo related.
import { AkairoModule, AkairoModuleOptions } from "discord-akairo"
import type { ApplicationCommandData, ApplicationCommandPermissionData, CommandInteraction } from 'discord.js'
/**Outlines permissions that can be passed to define how the command handles being added to the server specified */
export interface ServerCommandPermissionSettings {
/**The server to install this command on. */
serverID: string
/**The server specific roles we want to give this command access to be used by */
@Noitabara
Noitabara / pot_filter.js
Last active December 9, 2019 19:17
adventurelands pot_filter functions. Probably could be a class but meh :)
const pot_filter = {
mp300: (item) => item && item.name == 'mpot0',
mp500: (item) => item && item.name == 'mpot1',
hp300: (item) => item && item.name == 'hpot0',
hp500: (item) => item && item.name == 'hpot1',
find_usable: (input_filter) => character
.items
.findIndex(input_filter),
find_total: (input_filter) => character
.items
@Noitabara
Noitabara / archeage ingame time tracker.js
Created November 10, 2019 23:29
scraped it up really quickly for my discord bot. free for others to use, have fun. Sorry of the code is a bit sloppy. A lot of it was hacked together hah.
const {
DateTime,
Settings,
Duration
} = require('luxon')
const iter = [0, 0]
function resolveOffset() {
const this_second = () => DateTime.local().second
let current_tenth = null
@Noitabara
Noitabara / navboard.js
Created April 30, 2019 19:38
A neat little thing i wrote for the heck of it
class NavBoard {
constructor(size = 0) {
this._map_array = new Map();
this._currentLocation = null;
let current_idex = 0;
for (let i = 0; i < size * size; i++) {
if (this._map_array.size > size - 1 && i % size === 0)
current_idex++;
this._map_array.set(i+1, {position: [current_idex, i % size], state: 'Empty'});
}
@Noitabara
Noitabara / lmao.js
Last active February 18, 2019 20:58
Putting this up here so i can show friend how i make changes over time and what not, what type of improvements to code can be made. wrote this up in like 15 minutes for the hell of it loll.
const readline = require('readline')
let skillList = {
punch: 10,
kick: 20,
bite: 30
}
const skillNames = Object.keys(skillList)
const getRandomInt = MaxRoll => Math.floor(Math.random() * Math.floor(MaxRoll))
const getRandomSkill = skillNames[getRandomInt(3)]
let date = new Date() //Get today
let transformDate = date.getDate() - 30 //Remove 30 days from today
date.setDate(transformDate) //Set the current date to the removed days version variable
console.log(`${date.getFullYear()}-${date.getMonth().toString().length == 1 ? '0' + (date.getMonth()+1) : date.getMonth()}-${date.getDate()}`) //Console logs the new format for sql
@Noitabara
Noitabara / CoolReduce.js
Created May 17, 2018 22:27
Thanks fun fun function
let meme = [['Goofy', 1, 'hello'], ['Goofy', 4, 'bye'], ['Daffy', 1, 'hello'], ['Daffy', 2, 'bye']]
.reduce((test, line)=>{
test[line[0]] = test[line[0]] || []
test[line[0]].push({
quantity: line[1],
query: line[2]
})
return test
}, {})
@Noitabara
Noitabara / neat dedupe stuff.js
Created May 7, 2018 22:26
neat little way to count duplicates in an array and return their counts in an object notified by the name
let count = {}
whateverYourArrayIs.forEach((i)=>{ count[i] = (count[i]||0) + 1 })
console.log(count)
@Noitabara
Noitabara / Sleepy.au3
Created February 23, 2018 15:24
little sleepy snippet.
func Sleepy($time)
for $i = 1 to $time step 1
Sleep(1000)
ConsoleWrite("Sleepy slept for "&$i&" seconds so far."&@CRLF)
Next
EndFunc