Skip to content

Instantly share code, notes, and snippets.

View Nixinova's full-sized avatar

Nixinova

View GitHub Profile
// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary!
// Example using the Next.js App Router.
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
function useLinkHandler() {
let router = useRouter();
useEffect(() => {
let onClick = e => {
@Nixinova
Nixinova / bot.py
Created March 31, 2022 00:48
Discord Python bot template
import os
import random
import discord
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
client = discord.Client()
@Nixinova
Nixinova / basic.css
Last active April 17, 2024 04:36
Basic CSS
html {
max-width: 38rem;
padding: 2rem;
margin: auto;
line-height: 1.5rem;
font-family: sans-serif;
}
@Nixinova
Nixinova / bookmarklet.js
Last active September 21, 2021 06:48
GitHub Lightshow syntax highlighting improver bookmarklet. Makes testing and previewing tmLanguage files much easier
javascript:(()=>{
/*
save this as a bookmark
run on https://github-lightshow.herokuapp.com
*/
document.head.innerHTML += `<style>
.code{background-color:#fff;color:#333;font-family:Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size:12px}
[class*="pl-"] {color: white !important;}
@Nixinova
Nixinova / obfus.js
Last active May 10, 2022 09:50
JavaScript obfuscation
function encode(string) {
const isolate = v => `[${v}][+[]]`;
const ZERO = isolate(`+[]`);
const ONE = isolate(`+!![]`);
const count = n => ('+' + ONE).repeat(n);
const toString = str => isolate(`${str}+[]`);
const FALSE = toString(toString(`!!${ZERO}`));
const TRUE = toString(toString(`!${ZERO}`));
const NAN = toString(isolate(`+[![]]`));
const UNDEFINED = toString(isolate(``));
@broofa
broofa / checkForUndefinedCSSClasses.js
Last active January 21, 2024 17:22
ES module for detecting undefined CSS classes (uses mutation observer to monitor DOM changes). `console.warn()`s undefined classes.
/**
* Sets up a DOM MutationObserver that watches for elements using undefined CSS
* class names. Performance should be pretty good, but it's probably best to
* avoid using this in production.
*
* Usage:
*
* import cssCheck from './checkForUndefinedCSSClasses.js'
*
* // Call before DOM renders (e.g. in <HEAD> or prior to React.render())
@williambl
williambl / AAAAAA.zip
Last active May 6, 2023 01:12
some shader packs for 21w10a
@sindresorhus
sindresorhus / esm-package.md
Last active May 8, 2024 22:50
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@Nixinova
Nixinova / language_id.rb
Last active July 13, 2021 08:20
Linguist language ID generator
#!/usr/bin/env ruby
require 'digest'
language = 'InsertLangHere' # replace with full lang name
id = Digest::SHA256.hexdigest(language).to_i(16) % (2**30 - 1)
puts id
@Cadiboo
Cadiboo / Conventions.md
Last active July 2, 2023 14:23
Conventions (WIP)

What, Why, Consequences of not doing it, How to do it right

Required Java conventions

What: Lowercase package naming.
Why: Some file systems (windows) consider iTeMs and items to be the same, but every other system considers them to be different.
Consequences: Not doing this may never cause any issues (and very likely won't in your dev environment), but on other operating systems with different case-sensitivities from yours this can cause massive problems.
How: Name your packages all in lowercase.

What: Packaging that reflects your web presence.
Why: Avoid name collisions - your web presence is unique so it is commonly used.
Consequences: Errors loading classes with other mods installed, usually happens when 2 mods never changed their packaging from the default in the MDK.