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
if Rails.env.production? | |
require 'fileutils' | |
FileUtils.mkdir_p(Rails.root.join("tmp", "stylesheets", "admin")) | |
template_path = "#{Gem.loaded_specs['activeadmin'].full_gem_path}/lib/active_admin/stylesheets" | |
old_compile_path = "#{Rails.root}/public/stylesheets/admin" | |
new_compile_path = "#{Rails.root}/tmp/stylesheets/admin" | |
Sass::Plugin::remove_template_location template_path, old_compile_path | |
Sass::Plugin::add_template_location template_path, new_compile_path |
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
#!/usr/bin/env ruby | |
SPECIAL_TOKEN = 'SpecialTokenForSearch' | |
WITHOUT_MERGES = "--no-merges" | |
GIT_COMMIT_LINK="https://github.com/some_projects/commit/:commit" | |
cmd = `git show-ref --tags` | |
tags = [] | |
cmd.each do |l| | |
tag_commit, tag_name = l.chomp.split(" ") |
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
Rails.application.routes.draw do | |
get '/(:locale)/products/(:category)/(page/:page).:extension', | |
:to => 'products#index', | |
:as => :products, | |
:constraints => { | |
:locale => /[a-z]{2}/, | |
:category => /.+?/, | |
:page => /\d+/ | |
}, |
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
describe Address do | |
permute "validations" do | |
cases [ | |
[:address, :address_2, :city, :state, :zip, :country, :valid, :errors_on], | |
[ nil, nil, nil, nil, nil, nil, false, ['address', 'city', 'state', 'zip', 'country']], | |
['123 Main St', 'Apt 100', 'Pleasantville', 'NC', '12345', 'US', true, []], | |
['123 Main St' 'Apt 100', 'Pleasantville' 'NC' '12345' nil, false ['country']] | |
['123 Main St' 'Apt 100', 'Pleasantville' 'NC' '12345' 'U', false ['country']] | |
['123 Main St' 'Apt 100', 'Pleasantville' 'NC' '12345' 'USA', false ['country']] | |
] |
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
#!/usr/bin/env ruby | |
# Twitter Hashtag Counter | |
# | |
# Script to count a twitter hashtag and save the result and last_tweet_id to | |
# hashtag_counter_result.txt and last_tweet_id.txt | |
# | |
# Requirements: twitter gem. | |
# To install twitter gem: [sudo] gem install twitter | |
require 'rubygems' |
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
# app/controllers/users/password_controller.rb | |
class Users::PasswordsController < Devise::PasswordsController | |
def resource_params | |
params.require(:user).permit(:email, :password, :password_confirmation) | |
end | |
private :resource_params | |
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
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
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
# We need this to fix the random timeout error that we were seeing in CI. | |
# May be related to: http://code.google.com/p/selenium/issues/detail?id=1439 | |
Capybara.register_driver :selenium_with_long_timeout do |app| | |
client = Selenium::WebDriver::Remote::Http::Default.new | |
client.timeout = 120 | |
Capybara::Driver::Selenium.new(app, :browser => :firefox, :http_client => client) | |
end | |
Capybara.javascript_driver = :selenium_with_long_timeout |
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
#!/usr/bin/env ruby | |
# Usage: gitio URL [CODE] | |
# | |
# Turns a github.com URL | |
# into a git.io URL | |
# | |
# Copies the git.io URL to your clipboard. | |
url = ARGV[0] | |
code = ARGV[1] |
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
cat example.com.access.log | cut -f1 -d ' ' | sort | uniq -c | sort -g -r |
OlderNewer