Skip to content

Instantly share code, notes, and snippets.

View Nixinova's full-sized avatar

Nixinova

View GitHub Profile
@Nixinova
Nixinova / Main.java
Last active January 28, 2021 22:08
An example of the bare essentials for creating a Minecraft mod, adding a block and an item.
package $PACKAGE;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.block.material.Material;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@Nixinova
Nixinova / inventoryTab.txt
Last active February 7, 2021 03:28
Valid Modcrafter parameter values
# Default values for parameter 'inventoryTab'
# If the argument does not match one of the values below a custom inventory tab will be created
BREWING
BUILDING_BLOCKS
COMBAT
DECORATIONS
FOOD
HOTBAR
INVENTORY
@Nixinova
Nixinova / center.css
Last active February 25, 2021 06:49
Centering in CSS
.grid {
display: grid;
place-items: center;
}
/* or */
.flex {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
@Nixinova
Nixinova / normal-date.js
Last active May 4, 2021 07:39
Date normaliser: convert a prose date to ISO
function normalise(str, outSep = ',') {
const R = String.raw
const re = str => RegExp(
str.replace(/ /g, R`\s*`).replace(/-/g, r.sep).replace(/[DMY]/g, c => r[c.toLowerCase()]),
'g'
)
const monthsL = 'January February March April May June July August September October November December'.toLowerCase().split(' ')
const monthsS = monthsL.map(month => month.substr(0, 3))
@Nixinova
Nixinova / decss.js
Last active May 11, 2021 08:10
Strip all CSS from HTML source
// Place in devtools
function decss(html) {
return html
.replace(/<link\s+rel=('|"|\s*)stylesheet.*?>/g, '')
.replace(/style=".+?"/g, '')
}
basehtml = document.getElementsByTagName('html')[0]
basehtml.innerHTML = decss(basehtml.innerHTML)
@Nixinova
Nixinova / neural-add.js
Created May 20, 2021 01:07
Neural network attempts addition
const Synaptic = require('synaptic');
const NUM_INPUTS = 2;
const HIDDEN = 1;
const NUM_OUTPUTS = 1;
const network = new Synaptic.Architect.Perceptron(
NUM_INPUTS,
HIDDEN,
NUM_OUTPUTS
);
@Nixinova
Nixinova / nested-css-token-flattener.ts
Last active May 27, 2021 06:23
Nested CSS Tokenizer example
let cssOutput = `
outer1 {
prop1: true;
inner {prop2: true;}
}
outer2 {
prop3: false;
}
`
@Nixinova
Nixinova / typed.js
Last active June 3, 2021 04:44
Simple JavaScript type checking
function _(type, val) {
if (!(val instanceof type) && (type(val) !== val))
throw new TypeError(`${JSON.stringify(val)} is not assignable to type "${type.name}"`);
return val;
}
@Nixinova
Nixinova / refpass.js
Created June 18, 2021 22:30
JavaScript: pass-by-reference demonstration
let a = [1]
let b = a
b.push(2)
console.log(a) // [1,2]
@Nixinova
Nixinova / regex-flatten.js
Last active July 10, 2021 07:51
Convert regex free-spacing mode (`(?x)`) to normal regex
function flatten(str) {
return str.replace(/\r?\n|^\s+|\s+#\s.+$/gm, '').replace('(?x)', '')
}