Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
🤦‍♂️

Josh Kalderimis joshk

💭
🤦‍♂️
View GitHub Profile
View mg_server_cache.vcl
backend default {
.host = "127.0.0.1";
.port = "8000";
}
sub vcl_recv {
if (req.request != "GET"
&& req.request != "HEAD") {
return (pass);
}
View gist:349585
module Devise
module Models
# Authenticable module. Holds common settings for authentication.
#
# Configuration:
#
# You can overwrite configuration values by setting in globally in Devise,
# using devise method or overwriting the respective instance method.
#
# authentication_keys: parameters used for authentication. By default [:email].
View gist:373513
define_index do
...
# it should be this
indexes genres(:name)
# indexes special_tags(:name), :as => 'special_tags'
# and the ugly way to get special_tags working
indexes "GROUP_CONCAT(DISTINCT `special_tags_performances`.`name` SEPARATOR ' ')", :as => 'special_tags'
set_property :custom_joins => "LEFT OUTER JOIN `taggings` special_tags_performances_join ON (`performances`.`id` = `special_tags_performances_join`.`taggable_id` AND `special_tags_performances_join`.`taggable_type` = 'Performance') LEFT OUTER JOIN `tags` special_tags_performances ON (`special_tags_performances`.`id` = `special_tags_performances_join`.`tag_id`) AND `special_tags_performances`.`context` = 'special_tags'"
View conditions_joins_issues.rb
# Conditions in has_many :through behave differently for joins and includes
# Here is an example using Tagging
# The important thing to note from these two models is that the 'context'
# of the Tag is kept in the Tag model and not the Tagging
# (acts-as-taggable-on keeps it in the Tagging model)
class Tag < ActiveRecord::Base
has_many :taggings, :dependent => :delete_all
View attributes.rb
require 'active_support/core_ext/hash/keys'
require 'active_support/core_ext/class/attribute'
module ActiveModel
class MissingAttributeError < NoMethodError
end
# == Active Model Attribute Methods
#
# <tt>ActiveModel::AttributeMethods</tt> provides a way to add prefixes and suffixes
# to your methods as well as handling the creation of Active Record like class methods
View beta_signup_mailer.rb
class BetaSignupMailer < ActionMailer::Base
default :from => "no-reply@test.com"
def send_invite(beta_signup)
@beta_signup = beta_signup
mail_options = {
:to => @beta_signup.email,
:bcc => 'api@test.com',
:subject => "Welcome to the Beta program"
View gist:497837
Example::Application.routes.draw do |map|
constraints :protocol => "https://" do
get "hi_there", :to => "pages#show", :as => "hi_there"
end
end
>> app.get('http://www.example.com')
>> (ignore the output)
>> app.hi_there_url
=> "http://www.example.com/hi_there"
View Gemfile
source :rubygems
gemspec
View gist:519313
/opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/runtime.rb:27:in `setup': You have already activated gemcutter 0.5.0, but your Gemfile requires gemcutter 0.6.1. Consider using bundle exec. (Gem::LoadError)
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/spec_set.rb:12:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/spec_set.rb:12:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/runtime.rb:17:in `setup'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler.rb:95:in `setup'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/cli.rb:292:in `exec'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/vendor/thor/task.rb:22:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/vendor/thor/task.rb:22:in `run'
from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.0.rc.5/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /o
View gist:784304
# - TS related capistrano tasks
require "vendor/plugins/thinking-sphinx/lib/thinking_sphinx/deploy/capistrano"
require 'new_relic/recipes'
set :stages, %w(staging production)
set :default_stage, "staging"
require 'capistrano/ext/multistage'
# Global deployment information
You can’t perform that action at this time.