Skip to content

Instantly share code, notes, and snippets.

View mattrw89's full-sized avatar

Matt Webb mattrw89

View GitHub Profile
@mattrw89
mattrw89 / stress-test.sh
Created August 6, 2018 03:01 — forked from cirocosta/stress-test.sh
naive http server stress tester using cURL
#!/bin/bash
#### Default Configuration
CONCURRENCY=4
REQUESTS=100
ADDRESS="http://localhost:8080/"
show_help() {
cat << EOF
@mattrw89
mattrw89 / description.markdown
Created July 19, 2017 15:32 — forked from runemadsen/description.markdown
Reverse polymorphic associations in Rails

Polymorphic Associations reversed

It's pretty easy to do polymorphic associations in Rails: A Picture can belong to either a BlogPost or an Article. But what if you need the relationship the other way around? A Picture, a Text and a Video can belong to an Article, and that article can find all media by calling @article.media

This example shows how to create an ArticleElement join model that handles the polymorphic relationship. To add fields that are common to all polymorphic models, add fields to the join model.