Skip to content

Instantly share code, notes, and snippets.

@colgraff
colgraff / StarWarsRandomPlanetName.js
Last active November 18, 2022 02:55
Star Wars D20 Planet Name Randomizer
const syllables = ["ad","al","alm","am","an","ant","arb","as","bak","ban","bar","bel","bes","bil","bin","bon","bor","bril","cer","com","cor","cron","dag","dan","dar","dor","dur","en","end","er","fed","fir","gal","gam","gan","gess","gli","glo","goh","gul","hon","is","jum","kal","kam","kar","kes","kom","kur","lan","les","lid","lor","us","mel","mer","mim","myr","nab","nal","nat","nik","nog","nub","om","on","ond","phin","pin","rax","rer","rif","rin","ris","rish","ron","rur","rut","ryl","sav","sel","sen","sem","sul","sum","tal","tan","tel","tis","top","tro","tros","um","val","var","ver","wat","yin","zel","zoc"];
const suffixes = ["a","aan","ar","as","ea","eer","i","ia","in","ine","ior","ir","is","oo","os","oth","u","uk","yi","yn"];
const nameLength = [1,2,2,3,3,4];
const spacing = [[1,,,],[,1,,],[1,1,,],[,,1,],[1,,1,],[,1,1,],[1,1,1,]];
Math.randomInt = function(max, min = 0) { return Math.floor(Math.random()*(max - min + 1)) + min; };
String.prototype.capitalize = function() { return this.charAt(0).toUpperCase()
@colgraff
colgraff / TokenTooltipAlt.json
Created August 29, 2022 17:03
Useful settings for Foundry VTT's Token Tooltip Alt module when you're using the PF2E system,
{
"gmSettings": {
"default": {
"items": [
{
"disposition": "FRIENDLY",
"items": [
{
"value": "{hp = <attributes.hp.value>;\n hpm = <attributes.hp.max>;\n concat(string(hp), \"/\", string(hpm))\n}",
"icon": "fa-heart",
@colgraff
colgraff / InitStructFromData.swift
Last active August 19, 2017 22:10 — forked from ryantxr/InitStructFromData.swift
Initialize a struct from data, dictionary etc
// Credit: https://stackoverflow.com/users/887210/colgraff
struct Header {
let version : UInt
let options : UInt
let records : UInt
}
// adds marshaling
extension Header {
enum Keys: String { case version, options, records }
import Foundation
// Get input from the user
func getInput() -> String? {
print("\nDice: ", terminator: "")
guard let newInput = readLine()?.lowercased() else { return nil }
if newInput == "q" {
print("Thanks for rolling with me!")
exit(EXIT_SUCCESS)