Skip to content

Instantly share code, notes, and snippets.

View derekrockwell's full-sized avatar

Derek Rockwell derekrockwell

  • Zipnosis, Inc.
  • Minneapolis
View GitHub Profile
@sowenjub
sowenjub / gist:1033876
Created June 19, 2011 07:29
Quickly dump your heroku production database and load it locally
#!/bin/bash
# This script does the following:
# 1/ capture and download the latest backup
# 2/ load it to your local database
# 3/ run your app and open Safari
# Just replace any uppercase string with your own data
#
@watson
watson / ability.rb
Created October 5, 2011 09:50
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 4, 2024 11:47
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@jamesgary
jamesgary / gist:5485061
Last active December 16, 2015 19:29
Testing HTTP APIs in Ruby - @shaiguitar - RailsConf 2013

Testing HTTP APIs in Ruby

@shaiguitar

  • Everything as a service
  • Test it!
  • Problem statement: Testing a server/client HTTP API
  • Good plan:
    • Create API
    • Build client lib that can be used in confusmer apps
  • Make it easy for consumer apps to test w/ our client library
@jamesgary
jamesgary / gist:5491098
Created April 30, 2013 19:05
Rails vs. The Client - Noel Rappin (@noelrap) - RailsConf 2013

Rails vs. The Client

Noel Rappin (@noelrap)

  • Problem: Want users to have "rich client exp" (even though clients don't know what that means)
  • @dhh and @wycats offer different opinions (document vs json api)
  • But @noelrap just wants to write an e-commerce site
  • We tend to split stuff up into client stuff and server stuff between the user and data
  • @dhh says that the focus is on the server. The app lives on the server
  • @wycats says that the client is the focus, and the server just does whatever the client can't do (i.e. validation, persistence)
  • Where does the heart of your application live?
@naoyamakino
naoyamakino / railsConfNote_documentationTips.md
Last active December 16, 2015 20:29
How to Write Documentation for People That Don't Read Kevin Burke #railsConf
@naoyamakino
naoyamakino / railsConfShopifyScaling.md
Created May 2, 2013 20:31
How Shopify Scales Rails via @johnduff #railsConf

How Shopify Scales Rails John Duff

The Stack:

  • ruby1.9.3-p327
  • rails3.2
  • unicorn 4.5
  • percona Mysql5.5
  • memcache14.14
  • redis2.6

33 app servers, 1172 unicorn workers, 5 job servers, 370 job workers

@naoyamakino
naoyamakino / railsConfAPIDesign.md
Last active October 13, 2016 23:33
"Designing great APIs: Learning from Jony Ive, Orwell, and the Kano" via @jondahl #railsConf
  1. never use a metaphor, simile, or other figure of speech which you are used to seeing in print.
  2. never use a long word where a short one will do
  3. if it's possible to cut a word out, always cut it out.
  4. never use the passive where you can use the active
  5. never use a foreign phrase, a scientific word, or a jargon word if you can think of an everday English equivalent
  6. break any of these rules sooner than say anything outright barbarrous

#Five guiding principles

  1. minimalism
  2. get out of the way
@hopsoft
hopsoft / db.rake
Last active May 22, 2024 22:53
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd