Skip to content

Instantly share code, notes, and snippets.

View mikecmpbll's full-sized avatar
🎯
Focusing

Mike Campbell mikecmpbll

🎯
Focusing
  • Skipton, North Yorkshire
View GitHub Profile
module Plugin1
def some_method
puts "ha!"
end
end
module Plugin2
def some_method_again
puts "hrn..."
end
select student_id
from (
select gs.student_id, g.id as group_id
from groups_students gs
inner join groups g on g.id = gs.group_id
inner join group_types gt on gt.id = g.group_type_id
where gt.permission_group = 1
) s
left outer join (
select g.id as group_id
-- SELECT distinct `students`.`id` -- takes ~8ms
SELECT count(distinct `students`.`id`) -- takes 6.4seconds!
FROM `students`
INNER JOIN `categories_students` ON `categories_students`.`student_id` = `students`.`id`
INNER JOIN `categories` ON `categories`.`id` = `categories_students`.`category_id`
LEFT OUTER JOIN `groups_students` ON `groups_students`.`student_id` = `students`.`id`
LEFT OUTER JOIN `groups` ON `groups`.`id` = `groups_students`.`group_id` AND `groups`.`group_type_id` = 1
left outer join (
select student_id
from (
@mikecmpbll
mikecmpbll / home.rb
Last active August 29, 2015 13:56 — forked from joelbrewer/home.rb
def home
render 'signed_out_home' and return unless signed_in?
current_user.active_subscription? ? load_signed_in_page : redirect_to plans_path
end
def show
@purchase = Purchase.find(params[:id])
end
class AgenciesController
def new
@client = Client.find(params[:client_id])
@agency = @client.agencies.new
end
end
def update_inventory
if self.item_id_changed?
old_item = Item.find(self.item_id_was)
old_item.quantityInStock -= self.quantity_was
old_item.save!
elsif self.quantity_changed?
quantity_diff = self.quantity - self.quantity_was
self.item.quantityInStock += quantity_diff
end
end
require "bundler/capistrano"
load 'deploy/assets'
require "rvm/capistrano"
# SCM Settings
set :use_sudo, false
# Server addresses
role :web, "manage.theapp.net" # Your HTTP server, Apache/etc
role :app, "manage.theapp.net" # This may be the same as your `Web` server
mbp4:manage mike.campbell$ cap shell
triggering load callbacks
* executing `shell'
====================================================================
Welco§ to the interactive Capistrano shell! This is an experimental
feature, and is liable to change in future releases. Type 'help' for
a summary of how to use the shell.
--------------------------------------------------------------------
cap> whoami
[establishing connection(s) to manage.theapp.net]
@log_rows = WillPaginate::Collection.create(log_data.parsed_response["current_page"]["_dc_obj"], log_data.parsed_response["per_page"], log_data.parsed_response["total_entries"]) do |pager|
pager.replace(@log_rows)
end