Skip to content

Instantly share code, notes, and snippets.

View charlespeach's full-sized avatar

Charles Peach charlespeach

View GitHub Profile
@charlespeach
charlespeach / clear_rails_sessions.md
Last active December 19, 2015 22:08
How to clear sessions in rails

Resetting user sessions

First check what type of session store your application is setup for

This config usually lives here: config/initializers/session_store.rb

ApplicationName::Application.config.session_store :cookie_store, key: '_application_name_session'
@charlespeach
charlespeach / install_gems.rb
Created July 9, 2013 03:38
Install a list of gems from a `.gems` file.
gems = File.open(".gems")
gems.each do |gem|
puts "Installing #{gem}"
`gem install #{gem}`
end
# gem "prawn", "0.8.4"
# Sometime there is no enough space for the last table row when it reaches the end of page
Prawn::Document.generate("text_group_overflow_question.pdf") do |pdf|
add_page_break_if_overflow(pdf) do |pdf|
# generating table here
# ...
end
end
@charlespeach
charlespeach / sendmail.md
Last active December 15, 2015 18:58
Just some useful stuff for sendmail

Sendmail

Checking Queue

sendmail -bp or mailq

to check whats in the sendmail queue

namespace :associate_users do
desc "Update users external builder" do
@users = User.where(:external_builder_id => nil)
@users.each do |user|
#associate ExternalBuilder with User
unless user.lbp_number.blank?
@builder = ExternalBuilder.where(:lbp_number => user.lbp_number.gsub("BP", "").to_i)
if [email protected]?
u.update_column(:external_builder_id, @builder)
end