Ctrl+KB | toggle side bar |
Ctrl+Shift+P | command prompt |
Ctrl+` | python console |
Ctrl+N | new file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Resque job to do the true outbound sending | |
class DeliverEmailJob | |
include ProjectName::Job::Logging | |
@queue = :mail_queue | |
def self.perform(args) | |
message = QueuedEmail.get!(args["message_id"]) | |
logger.info("Delivering (%s) to %s" % [message.subject, message.formatted_recipient]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# normal Gem dependancy declarations | |
# ... | |
group :test, :cucumber do | |
gem 'pdf-reader' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Because we have some old legacy users in the database, we need to override Devises method for checking if a password is valid. | |
# We first ask Devise if the password is valid, and if it throws an InvalidHash exception, we know that we're dealing with a | |
# legacy user, so we check the password against the SHA1 algorithm that was used to hash the password in the old database. | |
#SOURCES OF SOLUTION: | |
# http://stackoverflow.com/questions/6113375/converting-existing-password-hash-to-devise | |
# https://github.com/binarylogic/authlogic/blob/master/lib/authlogic/crypto_providers/sha512.rb | |
# https://github.com/plataformatec/devise/blob/master/lib/devise/encryptors/authlogic_sha512.rb | |
alias :devise_valid_password? :valid_password? | |
def valid_password?(password) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Change devise encryption strategy to match your existing authentication | |
# https://github.com/plataformatec/devise/tree/master/lib/devise/encryptors | |
class MigrateUsers < ActiveRecord::Migration | |
def self.up | |
rename_column :users, :crypted_password, :encrypted_password | |
add_column :users, :confirmation_token, :string, :limit => 255 | |
add_column :users, :confirmed_at, :timestamp | |
add_column :users, :confirmation_sent_at, :timestamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'axlsx' | |
p = Axlsx::Package.new | |
p.workbook do |wb| | |
# define your regular styles | |
styles = wb.styles | |
title = styles.add_style :sz => 15, :b => true, :u => true | |
default = styles.add_style :border => Axlsx::STYLE_THIN_BORDER | |
header = styles.add_style :bg_color => '00', :fg_color => 'FF', :b => true | |
money = styles.add_style :format_code => '#,###,##0', :border => Axlsx::STYLE_THIN_BORDER | |
percent = styles.add_style :num_fmt => Axlsx::NUM_FMT_PERCENT, :border => Axlsx::STYLE_THIN_BORDER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveAdmin.register User do | |
menu :parent => "Users" | |
member_action :impersonate, :method => :get do | |
user = User.find(params[:id]) | |
flash[:notice] = "Successfully logged in as : #{user.email} #{view_context.link_to('Be careful!', root_path)}".html_safe | |
begin | |
warden.set_user(resource,{:scope=>:user,:run_callbacks=>false}) | |
rescue | |
flash[:error] = "Unable to log you in. Poop." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this stuff goes in config/initializers/active_admin.rb | |
ActiveAdmin.setup do |config| | |
# ... | |
# put these lines in the "Controller Filters" section of the ActiveAdmin.setup block | |
# These two are defined in ActiveAdmin::FilterSaver::Controller, which is loaded below. | |
config.before_filter :restore_search_filters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Call scopes directly from your URL params: | |
# | |
# @products = Product.filter(params.slice(:status, :location, :starts_with)) | |
module Filterable | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Call the class methods with names based on the keys in <tt>filtering_params</tt> | |
# with their associated values. For example, "{ status: 'delayed' }" would call |
OlderNewer