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.

@mattrw89
mattrw89 / SassMeister-input.scss
Created May 27, 2014 20:25
Generated by SassMeister.com.
// ----
// Sass (v3.3.7)
// Compass (v1.0.0.alpha.18)
// ----
@mixin triangle($height, $length, $color) {
width: 0;
height: 0;
border-top: $height/2 solid transparent;
border-left: $length solid $color;

Keybase proof

I hereby claim:

  • I am mattrw89 on github.
  • I am mattw (https://keybase.io/mattw) on keybase.
  • I have a public key whose fingerprint is B09F 5100 3799 7551 6B4B 5B40 CD56 2D87 A1F2 384E

To claim this, I am signing this object:

class ApiController < ApplicationController
require 'api_errors'
include ApiErrors
#################################################################################
#####CODE FROM http://www.starkiller.net/2011/03/17/versioned-api-1/ ###########
#################################################################################
@@versions = {}
@@registered_methods = {}
class << self
csd
* executing `staging'
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote https://github.com/twinge/missionhub.git master"
command finished in 1098ms
* executing "if [ -d /var/www/html/integration/mh/shared/cached-copy ]; then cd /var/www/html/integration/mh/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 1a756b2267929f2ee3bec4977099c480638860f4 && git submodule -q init && for mod in `git submodule status | awk '{ print $2 }'`; do git config -f .git/config submodule.${mod}.url `git config -f .gitmodules --get submodule.${mod}.url` && echo Synced $mod; done && git submodule -q sync && git submodule -q update --init --recursive && git clean -q -d -x -f; else git clone -q https://github.com/twinge/missionhub.git /var/www/html/integration/mh/shared/cached-copy && cd /var/www/html/integration/mh/shared/cached-cop
Matt-Webbs-MacBook-Pro:missionhub doulos$ git commit -am "more api tests + fix phone_number&email_address output in people api"
[master a6188a2] more api tests + fix phone_number&email_address output in people api
5 files changed, 134 insertions(+), 40 deletions(-)
rewrite app/controllers/api/contact_assignments_controller.rb (60%)
Matt-Webbs-MacBook-Pro:missionhub doulos$ git pull
Already up-to-date.
Matt-Webbs-MacBook-Pro:missionhub doulos$ git push
Counting objects: 27, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (13/13), done.
def oauth_required(options = {})
if scope = options.delete(:scope)
before_filter options do |controller|
if controller.oauth.authenticated?
if !controller.oauth.scope.strip.split.include?(scope)
controller.send :head, controller.oauth.no_scope!(scope)
end
else
controller.send :head, controller.oauth.no_access!
end
@people.each do |person|
@questions.each do |q|
@answer_sheets[person] = person.answer_sheets.select {|as| q.question_sheets.collect(&:id).include?(as.question_sheet_id)}.flatten.uniq
logger.info @answer_sheets[person].collect {|x| q.display_response(x)}.inspect
logger.info @answer_sheets[person].inspect
#logger.info q.display_response(@answer_sheets[person]).inspect
end
end
factory :person_with_things, :parent => :person do
after_create do |f|
Factory(:friend, :person => f)
Factory(:friend, :person => f)
Factory(:friend, :person => f)
Factory(:education_history_highschool, :person => f)
Factory(:education_history_college, :person => f)
Factory(:education_history_gradschool, :person => f)
Factory(:interest, :person => f)
Factory(:interest_2, :person => f)