Skip to content

Instantly share code, notes, and snippets.

View arantesxyz's full-sized avatar
♥️
Coding your dreams

Gustavo Arantes arantesxyz

♥️
Coding your dreams
View GitHub Profile
@arantesxyz
arantesxyz / test.js
Created August 30, 2020 06:46
JS knowledge research
// Please do not comment or give the answer to anybody, let people try to solve it
function makeRequest(endpoint, before) {
return new Promisse((res, rej) => {
before("Making request to " + endpoint);
fetch(endpoint).then(a => res(a)).catch(a => rej(a));
});
}
@arantesxyz
arantesxyz / ProgressBar.ts
Created September 14, 2020 16:25
TypeScript progressbar builder.
const COMPLETE_CHAR = "█";
const INCOMPLETE_CHAR = "░";
class ProgressBar {
constructor(public total = 15) {}
setTotal(total: number) {
this.total = total;
}
@arantesxyz
arantesxyz / arduino.cc
Last active November 11, 2020 23:45
Jogo arduíno
// Constantes
int nums[17][7] = {
{1, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 1},
{0, 1, 0, 1, 1, 1, 1},
{0, 0, 1, 0, 0, 1, 0},
{0, 0, 0, 0, 1, 1, 0},
{0, 1, 0, 1, 1, 0, 0},
{1, 0, 0, 0, 1, 0, 0},
@arantesxyz
arantesxyz / egg-node-js-v12-0.json
Created November 30, 2020 18:55
NodeJS v12 egg for pterodactyl
{
"_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO",
"meta": {
"version": "PTDL_v1"
},
"exported_at": "2020-11-30T19:48:12+01:00",
"name": "NodeJs v12",
"author": "spam@arantes.dev",
"description": "NodeJS v12 egg based on https://github.com/parkervcp/eggs/blob/master/bots/discord/discord.js/egg-discord-js-generic.json",
"features": null,
@arantesxyz
arantesxyz / RandomCollection.java
Created January 22, 2021 16:51
Random collection with weight in java
public class RandomCollection<E> {
private final NavigableMap<Double, E> map = new TreeMap<>();
private final Random random;
private double total = 0;
public RandomCollection() {
this(new Random());
}
@arantesxyz
arantesxyz / MyListener.java
Created February 2, 2021 01:32
example nms
class MyListener implements Listener {
// Nome do atributo que será salvo no NBT
private static String ATTRIBUTE_NAME = "pick_xp";
@EventHandler
public void onBreak(BlockBreakEvent event) {
// Pega o jogador e o item na mão
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
@arantesxyz
arantesxyz / gamemode.java
Created February 13, 2021 23:43
Custom gamemode command for Bukkit
package dev.arantes.acore.modules.essentials;
import dev.arantes.acore.exceptions.NoPermissionException;
import dev.arantes.acore.exceptions.NotEnoughArgumentsException;
import dev.arantes.acore.exceptions.PlayerNotOnlineException;
import dev.arantes.acore.modules.globaluser.GlobalUser;
import dev.arantes.acore.templates.Command;
import dev.arantes.lib.exceptions.CustomMessageException;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@arantesxyz
arantesxyz / sqliteasync.js
Last active February 19, 2021 23:59
Example of working with sqlite3 and async/await
const sql = require("sqlite");
async function create(data) {
if (!data) throw new Error("No data!");
return await sql.run(
"INSERT INTO Veicle (id, type, model) VALUES ($id, $type, $model)",
data,
);
}
@arantesxyz
arantesxyz / mongodbsample.js
Last active February 20, 2021 21:28
Mongo db sample
import { MongoClient } from "mongodb"
const run = async () => {
const uri = "mongodb+srv://user:pass@sample.host/?poolSize=20&writeConcern=majority"
const client = await MongoClient.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true
})
const db = client.db("MeuAppTop")
@arantesxyz
arantesxyz / checkEmpty.ts
Created March 3, 2021 00:15
Custom error creator for checking empty strings. Depends on 'validator'
import isEmpty, { IsEmptyOptions } from 'validator/lib/isEmpty'
const checkEmpty = (
error: (message: string) => unknown,
options?: IsEmptyOptions
) => (value: string, fieldName: string): void => {
if (isEmpty(value, options)) {
throw error(`Field ${fieldName} cannot be empty!`)
}
}