Skip to content

Instantly share code, notes, and snippets.

@PaulMaynard
PaulMaynard / die.js
Last active May 2, 2016 16:13
Generator and Iterator manipulation
/** Sample die roller */
function die(pattern) {
let [, sign = '+', amt = 1, sides = 6, num, mod] = die.regex.exec(pattern)
let gen
if (num) {
gen = _.fill(Number(num))
} else {
let die = _.func(() => Math.floor(Math.random() * sides) + 1)
gen = _.combine(sum, ...Array(amt).fill(die))
}
@Putnam3145
Putnam3145 / Spawnunit.lua
Last active December 27, 2015 03:09 — forked from warmist/Spawnunit.lua
forked it so I can make age more proper. Also fixed it for r4's release and moved random numbers to local rng instead of global.
--create unit at pointer or given location. Usage e.g. "spawnunit DWARF 0 Dwarfy"
--Made by warmist, but edited by Putnam for the dragon ball mod to be used in reactions
--note that it's extensible to any autosyndrome reaction to spawn anything due to this; to use in autosyndrome, you want \COMMAND spawnunit CREATURE caste_number name \LOCATION
args={...}
local rando=dfhack.random.new()
@Putnam3145
Putnam3145 / itemsyndrome.lua
Last active July 25, 2022 23:51
**Obsoleted by DFHack's item-trigger**. Itemsyndrome. Usage is given when "itemsyndrome help" is used. Updated for DFHack 0.34.11 r4. lso updated with Boltgun's changes to the assignment function.
-- Checks for inventory changes and applies or removes syndromes that items or their materials have. Use "disable" (minus quotes) to disable and "help" to get help.
local args = {...}
local function printItemSyndromeHelp()
print("Arguments (non case-sensitive):")
print(' "help": displays this dialogue.')
print(" ")
print(' "disable": disables the script.')
print(" ")
@ejdyksen
ejdyksen / mini-console.html
Last active September 18, 2017 22:13
A tool for getting at a JS console when there is none available.
<div id="consolelog" style="font-family: 'Courier New', Courier, monospace; font-size: 12px; margin: 40px 30px 0px; background-color: white; border: 2px solid black; padding: 10px;"></div>
<input type="text" id="consoleinput" style="margin: 0px 30px; width: 400px;" onkeypress="return evalConsoleInput(event, this.value);" />
<script type="text/javascript">
var appendConsole = function(message, type) {
var color = "black";
if (type === "error") {
color = "red";
} else if (type === "debug") {
@hsablonniere
hsablonniere / LICENSE.txt
Created April 8, 2012 17:01 — forked from 140bytes/LICENSE.txt
Mother Effing JavaScript Loader - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@140bytes
140bytes / LICENSE.txt
Created May 9, 2011 16:13
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE