This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "math" | |
| ) | |
| const Psi = -1.0 / math.Phi | |
| var Sqrt5 = math.Pow(5.0, 0.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Generate random gemstones for D&D 5e | |
| It always bothered me that the tables in the DMG won't let you randomly | |
| generate a diamond worth 50gp, or 300gp, or 500gp, when these are all common | |
| spell components. | |
| This script generates random gemstones and values. It considers that you might | |
| have a small diamond worth 50gp, but probably not a giant azurite worth 5000gp. | |
| First, we get a base and a multiplier. A base could be e.g. 10, 100, 1000. A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| import random | |
| __all__ = ['d4', 'd6', 'd8', 'd10', 'd12', 'd20', 'd100'] | |
| class D(): | |
| """A die. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package ex | |
| import ( | |
| "fmt" | |
| "testing" | |
| ) | |
| func Multiplier(in int) int { | |
| return in * 2 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import functools | |
| import operator | |
| import random | |
| class D(): | |
| """A die. | |
| Simulates an n-sided die, e.g. to create a d6, pass 6: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function batchFunctionFinally(commands) { | |
| const batchStats = this.startBatch(commands) | |
| let error = null | |
| let response = null | |
| try { | |
| response = await this.redis.multi(commands) | |
| } catch (e) { | |
| error = e | |
| throw e | |
| } finally { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import argparse | |
| import random | |
| import re | |
| import string | |
| import sys | |
| sr = random.SystemRandom() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Logs 'rejected Error: sync error' | |
| const p = new Promise((resolve, reject) => { | |
| throw new Error('sync error'); | |
| }).then(null, e => console.log('rejected', e)); | |
| // q never settles, uncaught error | |
| const q = new Promise((resolve, reject) => { | |
| setImmediate(() => { throw new Error('async error'); }); | |
| }).then(null, e => console.log('rejected', e)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import division, print_function, unicode_literals | |
| import operator | |
| import re | |
| import sys | |
| WHITESPACE_RE = re.compile(r'\s+') | |
| NUMBER_RE = re.compile(r'-?\d+(\.\d+)?') | |
| OPERATORS = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var format = require('util').format; | |
| function Logger() { | |
| } | |
| Logger.prototype.log = function $$Logger_log(msg) { | |
| var context = this.getContext(); | |
| console.log(format('%s:%s:%s(%s): %s', context.pathname, context.lno, context.col, context.func, msg)); |
NewerOlder