Skip to content

Instantly share code, notes, and snippets.

View eileencodes's full-sized avatar
👩‍💻

Eileen M. Uchitelle eileencodes

👩‍💻
View GitHub Profile

Homebrew Formula patching old ImageMagick release 6.7.7-6

Install

$ brew install https://gist.githubusercontent.com/eileencodes/281a8a9c7e0598fc9da9a7d4bf6d1a89/raw/8880be85b339c8206197e59b543c16f2ac1e4839/imagemagick.rb

Tested

@eileencodes
eileencodes / gist:5b0a2fe011dcff6203fe
Last active October 28, 2021 14:21
CollectionProxy `delete_all` and `destroy_all` behavior by dependency AND association type AND strategy

Testing behavior of a CollectionProxy based on :dependent option, delete method used and assocation type (:has_many vs :has_many :through)

:has_many association

class Category < ActiveRecord::Base
	has_many :contacts, through: :categorizations
	has_many :categorizations, dependent: DEPENDENT
end
testing
editing the gist?
@eileencodes
eileencodes / posts.rb
Created August 2, 2012 19:45
adding category selectors to active admin
index do
column :title, :sortable => :title do |post|
link_to post.title, [:edit_admin, post]
end
column :categories do |post|
table_for post.categories.order('title ASC') do
column do |category|
link_to category.title, [ :admin, category ]
end
@eileencodes
eileencodes / emails_controller.rb
Created August 1, 2012 17:27
honeypot response
if params[:sweet_honey].present?
format.html { render :partial => "emails/email_bot", :layout => false }
elsif @email.save
...
else
...
end
@eileencodes
eileencodes / _form.html.erb
Created August 1, 2012 17:23
field for honeypot
<div class="field sweet_honey_for_bots">
<%= label_tag :sweet_honey, "This is a honeypot, if you see this you're CSS is turned off or you're a bot. If you're not a bot don't fill it in." %>
<%= text_field_tag :sweet_honey %>
</div>
@eileencodes
eileencodes / admin_users.rb
Created June 12, 2012 23:31
Admin Users Views for Active Admin
ActiveAdmin.register AdminUser do
index do
column :id
column :email
column :full_name do |field|
"#{field.first_name} #{field.last_name}"
end
column :last_sign_in_at
default_actions
@eileencodes
eileencodes / airbrake.txt
Created March 19, 2012 18:08
What you will see if airbrake runs correctly
append config/deploy.rb
create config/initializers/airbrake.rb
run rake airbrake:test --trace from "."
** Invoke airbrake:test (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute airbrake:test
Configuration:
@eileencodes
eileencodes / link_to_if_ex.rb
Created March 1, 2012 21:21
Example of link_to_if from Rails API
@eileencodes
eileencodes / password_resets_controller.rb
Created January 25, 2012 22:24
class PasswordResetsController < ApplicationController
def edit
@user = User.find_by_reset_pass_token(params[:id])
if @user.nil?
redirect_to '/login', :alert => 'Password reset does not exist.'
elsif @user.reset_pass_expiration < 2.hours.ago
redirect_to '/login ', :alert => "Password reset has expired."
end
end