Skip to content

Instantly share code, notes, and snippets.

@jonikorpi
jonikorpi / resize.js
Last active April 20, 2023 08:48
Resize canvas to match actual device pixels… mostly
const observer = new ResizeObserver((entries) => {
const entry = entries[0];
if (entry.devicePixelContentBoxSize) {
canvas.width = entry.devicePixelContentBoxSize[0].inlineSize;
canvas.height = entry.devicePixelContentBoxSize[0].blockSize;
} else if (entry.contentBoxSize) {
// Annoying fallback. Assumes window.devicePixelRatio includes browser zoom.
// Currently that's how it works in Chrome, but not in Safari.
// As a result current Safari will end up with the wrong size if browser zoom is in use.
@jonikorpi
jonikorpi / css.js
Last active September 4, 2021 01:38
Single-file components in React, using Constructable Stylesheets
// https://github.com/calebdwilliams/construct-style-sheets
import "construct-style-sheets-polyfill";
export default strings => {
if (document.readyState === "loading") {
window.addEventListener("DOMContentLoaded", () => adopt(strings));
} else {
adopt(strings);
}
};
@jonikorpi
jonikorpi / ReglEngine.js
Last active March 12, 2020 21:21
Messy react + regl framework for simple instanced and batched rendering
import React, {
useContext,
useEffect,
useRef,
createContext,
useState,
useCallback,
} from "react";
import createCamera from "perspective-camera";
@jonikorpi
jonikorpi / gist:af5a8362388cd28e9f6cdd9a82ebc5b6
Last active December 5, 2018 13:44
Getting the pointy hex coordinates of a hex region's center hex in this arrangement: https://www.redblobgames.com/grids/hexagons/#wraparound (Both the input and output are in "cube" hex coordinates. r is the radius of the regions.
const cubeCoordinatesToRegionCenter = (x, y, z, r) => {
const centerX = x * 2 * r + x + r * z;
const centerZ = z * -2 * r - z - x + -r * x;
return [centerX, -centerX-centerZ, centerZ];
};
@jonikorpi
jonikorpi / gist:78b228e46fe34e8f8879
Last active August 29, 2017 07:33
Getting nokogiri to work in Ruby 1.9.3
xcode-select --install
gem install nokogiri -v '1.7.0.1' -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --use-system-libraries
@jonikorpi
jonikorpi / styles.less
Last active September 7, 2016 16:23
Atom stylesheet based around Solarized Dark, Input Mono, and Input Sans Narrow
/*
I should probably have turned this into a theme…,
but who has time for that?
Installation:
1. Choose "Atom Dark" as your UI theme.
2. Choose "Solarized Dark" as your syntax theme.
3. Install Input from http://input.fontbureau.com/
(It's free for personal use.)
input[type="text"],
input[type="email"],
input[type="password"],
textarea,
.fieldset-footer,
.hint,
input[type="submit"],
button,
.button,
.error,
;; User behaviors
;; -----------------------------
;; Behaviors are stored as a set of diffs that are merged together
;; to create the final set of functionality that makes up Light Table. You can
;; modify these diffs to either add or subtract functionality.
;;
;; Behaviors are added to tags, objects with those tags then automatically gain
;; whatever logic the behavior imparts. To see a list of user-level behaviors,
;; start typing a word related to the functionality you want in between the square
;; brackets (e.g. "theme").

Armoury system

The Armoury System is FFXIV's class system.

  • Start the game as a Class.
  • Class is based on equipped weapon - Gladiator/Sword - Marauder/Axe - Lancer/Lance - Pugilist/Fist Weapon - Archer/Bow - Conjurer/Staff - Thaumaturge/Rod - Arcanist/Book -
  • Traits are for the class you currently are only.
  • Classes can use cross-class abilities from other classes. As you level up, you gain more ability slots for cross-class abilities (10 slots at level 50).
  • Classes can use certain abilities from every other class. For example, you can equip the Pugilist's "Internal Release" and Lancer's "Blood for Blood" as a Gladiator.
  • Your class can be changed in the field by changing your weapon once you unlock the Armoury System at level 10.
@mixin georgia {
font-family: 'GeorgiaProW01-Regular', Arial, serif;
}
@mixin georgia-italic {
font-family: 'GeorgiaProW01-Italic', Georgia, serif;
font-style: normal; // Has to be set like this, because fonts.com serves each font in a family separately
.wf-inactive & { font-style: italic; } // Fallback, in case fonts.com fails
}