Skip to content

Instantly share code, notes, and snippets.

@stujo
stujo / ab.sh
Created April 3, 2018 18:15 — forked from brentertz/ab.sh
Apache Bench - Load test a protected page
#!/bin/bash
COOKIE_JAR="ab-cookie-jar"
COOKIE_NAME="_myapp_session"
USERNAME="foo@bar.com"
PASSWORD="password"
LOGIN_PAGE_URI="http://localhost:3000/users/sign_in"
TEST_PAGE_URI="http://localhost:3000/dashboard"
echo "Logging in and storing session id."
@stujo
stujo / ab.sh
Created April 3, 2018 18:15 — forked from brentertz/ab.sh
Apache Bench - Load test a protected page
#!/bin/bash
COOKIE_JAR="ab-cookie-jar"
COOKIE_NAME="_myapp_session"
USERNAME="foo@bar.com"
PASSWORD="password"
LOGIN_PAGE_URI="http://localhost:3000/users/sign_in"
TEST_PAGE_URI="http://localhost:3000/dashboard"
echo "Logging in and storing session id."
@stujo
stujo / songs.rb
Created November 10, 2014 17:42
Restful HTML
get '/songs' do
@songs = Song.all.order(id: :asc)
erb :"songs/index"
end
get '/songs/new' do
@song = Song.new
erb :"songs/new"
end
motorbike = {
max_speed: 100,
color: :red,
number_of_wheels: 2,
current_speed: 0,
current_heading: 0,
engine_running: false,
odometer: 0
}
@stujo
stujo / atom_helper_sample.txt
Created January 24, 2017 19:03
Atom Helper Sample During Freeze with webpack esformatter and eslint
Sampling process 7644 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Analysis of sampling Atom Helper (pid 7644) every 1 millisecond
Process: Atom Helper [7644]
Path: /Applications/Atom.app/Contents/Frameworks/Atom Helper.app/Contents/MacOS/Atom Helper
Load Address: 0x10279b000
Identifier: com.github.atom.helper
Version: 1.13.0 (1.13.0)
Code Type: X86-64
Parent Process: Atom [6943]
@stujo
stujo / session-auth-sinatra-app.rb
Created January 6, 2017 00:28
sinatra session auth example (without database)
require 'sinatra'
enable :sessions
# helpers/session_helper.rb
helpers do
def session_user_id
session[:user_id]
end
@stujo
stujo / codewars-test-stubs.js
Last active January 2, 2017 06:21
code-wars-test-stubs.js
var Test = {
describe: Test_describe,
before: Test_before,
expect: Test_expect,
it: Test_it,
context: Test_context,
contexts: [],
assertEquals: Test_assertEquals,
logError: Test_logError,
logSuccess: Test_logSuccess,
@stujo
stujo / example-extends-vs-includes.rb
Last active December 19, 2016 18:24
How to include a module
module Timeable
def start_timer
@timeable_timer = Time.now.utc
end
def end_timer
Time.now.utc - @timeable_timer
end
end
class DragRace
@stujo
stujo / mutable_string.rb
Last active December 19, 2016 18:23
Mutable Strings in Ruby
puts "Assign bob = \"bob\""
bob = "bob"
puts "bob_smith is also a bob"
puts "So bob_smith = bob (the variable reference)"
bob_smith = bob
puts "We want to capitalize bob so : bob.capitalize!"
@stujo
stujo / abstract_method_pattern.rb
Created December 12, 2016 22:39
Using Mix-Ins with the Abstract Method Pattern
# The SuperPower blast_them method depends on the abstract method projectile
module Blastable
def blast_them
puts "BLASTING: #{projectile} (#{self.class.name})"
end
end
class Tyrannosaurus
include Blastable