Skip to content

Instantly share code, notes, and snippets.

Padronização dos commits

➡️ Os commits seguirão um padrão adaptado para nós.

Todos os commits devem seguir de um prefixo.

Commit type Emoji
Initial commit 🎉 :tada:
Version tag 🔖 :bookmark:
@1moita
1moita / quiz.js
Created September 8, 2021 17:04
Create random calculations for quizzes.
function generate() {
const random = (min, max) => Math.floor(Math.random() * (max - min) + min);
const numbers = [random(1, 100), random(1, 100)];
const pointer = ['+', '-', '*', '/'][Math.floor(Math.random() * ['+', '-', '*', '/'].length)];
let result;
try {
result = eval(`${numbers[0]} ${pointer} ${numbers[1]}`);
} catch {
@1moita
1moita / yesindexing.js
Created October 17, 2021 22:39 — forked from evinism/yesindexing.js
cjsp2
class Indexable {
constructor(){
this._indexer = Symbol();
}
[Symbol.toPrimitive](){ return this._indexer }
}
class Animal extends Indexable {}
const cat = new Animal();
@1moita
1moita / main
Created October 17, 2021 22:44 — forked from kriradevska/CreditCardChecker
Codecademy Credit Card Checker PRoject
// All valid credit card numbers
const valid1 = [4, 5, 3, 9, 6, 7, 7, 9, 0, 8, 0, 1, 6, 8, 0, 8];
const valid2 = [5, 5, 3, 5, 7, 6, 6, 7, 6, 8, 7, 5, 1, 4, 3, 9];
const valid3 = [3, 7, 1, 6, 1, 2, 0, 1, 9, 9, 8, 5, 2, 3, 6];
const valid4 = [6, 0, 1, 1, 1, 4, 4, 3, 4, 0, 6, 8, 2, 9, 0, 5];
const valid5 = [4, 5, 3, 9, 4, 0, 4, 9, 6, 7, 8, 6, 9, 6, 6, 6];
// All invalid credit card numbers
const invalid1 = [4, 5, 3, 2, 7, 7, 8, 7, 7, 1, 0, 9, 1, 7, 9, 5];
const invalid2 = [5, 7, 9, 5, 5, 9, 3, 3, 9, 2, 1, 3, 4, 6, 4, 3];
@1moita
1moita / BukkitSerialization.java
Created October 20, 2021 20:12 — forked from graywolf336/BukkitSerialization.java
Serialize and deserialize the player's inventory, including armor and content.
/**
* Converts the player inventory to a String array of Base64 strings. First string is the content and second string is the armor.
*
* @param playerInventory to turn into an array of strings.
* @return Array of strings: [ main content, armor content ]
* @throws IllegalStateException
*/
public static String[] playerInventoryToBase64(PlayerInventory playerInventory) throws IllegalStateException {
//get the main content part, this doesn't return the armor
String content = toBase64(playerInventory);
@1moita
1moita / reset.css
Created November 27, 2021 16:15
modern css reset
*, *::before, *::after {
box-sizing: border-box;
}
* {
margin: 0;
}
html, body {
height: 100%;
Experienced: JavaScript, TypeScript
Intermediate: C, C++, Java, V
Beginner: Go, Rust, Assembly (intending to learn)
@1moita
1moita / Cache.java
Last active March 5, 2022 23:36
Easy data caching in Java using ArrayList and generic type.
public final class Cache<T> extends ArrayList<T> {
protected T find(Predicate<T> predicate) {
for(T value : this)
if(predicate.test(value))
return value;
return null;
}
}
@1moita
1moita / JsonItemStack.java
Created March 21, 2022 05:57 — forked from DevSrSouza/JsonItemStack.java
Parse Bukkit ItemStack to JSON
import com.google.gson.*;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import org.bukkit.Material;
import org.bukkit.block.banner.Pattern;
import org.bukkit.block.banner.PatternType;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@1moita
1moita / NPC.java
Created April 29, 2022 23:02 — forked from DanielTheDev/NPC.java
Advanced NPC Util. [1.17] (Packets)
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.datafixers.util.Pair;
import io.netty.buffer.Unpooled;
import net.minecraft.core.BlockPosition;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.PacketDataSerializer;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.*;