Skip to content

Instantly share code, notes, and snippets.

View shaefer's full-sized avatar

Daniel Shaefer shaefer

View GitHub Profile
@robmathers
robmathers / groupBy.js
Created October 25, 2018 23:18
A more readable and annotated version of the Javascript groupBy from Ceasar Bautista (https://stackoverflow.com/a/34890276/1376063)
var groupBy = function(data, key) { // `data` is an array of objects, `key` is the key (or property accessor) to group by
// reduce runs this anonymous function on each element of `data` (the `item` parameter,
// returning the `storage` parameter at the end
return data.reduce(function(storage, item) {
// get the first instance of the key by which we're grouping
var group = item[key];
// set `storage` for this instance of group to the outer scope (if not empty) or initialize it
storage[group] = storage[group] || [];
@tkfu
tkfu / srd_5e_monsters.json
Last active May 2, 2024 15:04
A JSON file with all the D&D 5e SRD monster data
[
{
"name": "Aboleth",
"meta": "Large aberration, lawful evil",
"Armor Class": "17 (Natural Armor)",
"Hit Points": "135 (18d10 + 36)",
"Speed": "10 ft., swim 40 ft. ",
"STR": "21",
"STR_mod": "(+5)",
"DEX": "9",
@timdetering
timdetering / Random_Dungeon_Design.md
Last active February 24, 2023 03:59
The Secret Workings of Jamis Buck's Dungeon Generator

Random Dungeon Design

The Secret Workings of Jamis Buck's Dungeon Generator

So you've tried my Dungeon Generator http://www.aarg.net/~minam/dungeon.cgi once or twice, and it's got you thinking. Perhaps you're a programmer and would like to incorporate similar features in a program of your own. Or maybe you're not a programmer, but would be interested in an overview of how this program works.

Either way, I've been asked how this random dungeon generator works many, many times, and I finally decided that, to save myself time, I'd just put up the description on a web page.

If you find this explanation useful, please let me know. Likewise, if you feel that I was too technical, or not technical enough, or too ambiguous, let me know that, too, and I can try and improve it.

@barlog-m
barlog-m / SpringBootUndertowHTTP2.java
Created August 23, 2015 09:11
Enable HTTP2 in Undertow with Spring Boot
public class SpringBootUndertowHTTP2 {
@Bean
UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
factory.addBuilderCustomizers(
builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
return factory;
}
}
@nt
nt / NewRelicFinagleFilter.scala
Created December 28, 2012 16:17
Using New Relic with Finagle is a pain
import org.apache.thrift.protocol.TProtocolFactory
import com.twitter.finagle.{Service, SimpleFilter}
import com.twitter.util.{Duration, Time}
import org.apache.thrift.transport.TMemoryInputTransport
import com.newrelic.api.agent.{Response, Request, NewRelic, Trace}
import java.util.Collections
class NewRelicFinagleFilter(protocolFactory:TProtocolFactory) extends SimpleFilter[Array[Byte], Array[Byte]] {
def apply(request: Array[Byte], service: Service[Array[Byte], Array[Byte]]) = {