TODO: make gem for this
This was tested using Rails 3.2 and Rails 4.0 on Ruby 2.0.0.
-
Set the install directory for Bower components:
// .bowerrc
| class Bottles | |
| def verse(num) | |
| case num | |
| when 0 | |
| "No more bottles of beer on the wall, no more bottles of beer.\n" + | |
| "Go to the store and buy some more, 99 bottles of beer on the wall.\n" | |
| when 1 | |
| "1 bottle of beer on the wall, 1 bottle of beer.\n" + | |
| "Take it down and pass it around, no more bottles of beer on the wall.\n" |
| #!/usr/bin/env ruby | |
| # From: http://ngauthier.com/2014/06/scraping-the-web-with-ruby.html | |
| require 'capybara' | |
| require 'capybara/poltergeist' | |
| require 'csv' | |
| require 'gdbm' | |
| class NickBot | |
| include Capybara::DSL |
| set :application, '<APP_NAME>' | |
| set :repo_url, "<git@PATH/REPO.git>" | |
| # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp } | |
| set :deploy_to, "/home/deploy/rails/<APP_NAME>" | |
| # set :scm, :git | |
| set :format, :pretty | |
| set :log_level, :debug |
| #!/usr/bin/env ruby | |
| require "rubyXL" | |
| require "pry" | |
| require "json" | |
| # define from input | |
| @key_col = 0 | |
| @translation_col = 2 | |
| file = PATH_TO_FILE |
| require 'net/scp' | |
| namespace :db do | |
| desc 'pull the latest backup & restore locally' | |
| task :restore do | |
| Rake::Task['db:download'].invoke | |
| Rake::Task['db:replace'].invoke | |
| end | |
| desc 'pull down the lastest backup from production' |
| #! /usr/bin/env python2 | |
| # Requires: PIL, colormath | |
| # | |
| # Improved algorithm now automatically crops the image and uses much | |
| # better color matching | |
| from PIL import Image, ImageChops | |
| from colormath.color_objects import RGBColor | |
| import argparse | |
| import math |
| --colour | |
| -I app |
| class UrlValidator < ActiveModel::EachValidator | |
| def validate_each(record, attribute, value) | |
| valid = begin | |
| URI.parse(value).kind_of?(URI::HTTP) | |
| rescue URI::InvalidURIError | |
| false | |
| end | |
| unless valid | |
| record.errors[attribute] << (options[:message] || "is an invalid URL") |