/*
*= require "application/all"
*/
This file contains hidden or 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
| class DishonestString < String | |
| def is_utf8? | |
| return false if calling_method == 'quote' | |
| super | |
| end | |
| end |
This file contains hidden or 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
| worker_processes 1; | |
| error_log /usr/local/var/log/nginx.error.log; | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| include mime.types; |
This file contains hidden or 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
| #!/bin/bash | |
| verbose=0 | |
| function usage() { | |
| echo >&2 "Usage: rbenv each [-v] ..." | |
| echo >&2 " -v Verbose mode. Prints a header for each ruby." | |
| } | |
| while getopts vh option | |
| do case "$option" in |
This file contains hidden or 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
| # WAIT! Do consider that `wait` may not be needed. This article describes | |
| # that reasoning. Please read it and make informed decisions. | |
| # https://www.varvet.com/blog/why-wait_until-was-removed-from-capybara/ | |
| # Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations? | |
| describe 'Modal' do | |
| should 'display login errors' do | |
| visit root_path |
This file contains hidden or 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
| def self.read_barcode_from_image path | |
| # Call the barcode reader - and get a response of multiple lines | |
| ls = `/usr/bin/zbarimg '#{path}'`.lines | |
| # Handle a variety of unexpected responses that we have seen and debugged quickly over time | |
| ls = [ls] if ls.is_a?(String) | |
| barcodes = [] | |
| return barcodes if ls.nil? || ls == 0 | |
This file contains hidden or 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
| # RubyGems has this functionality built-in. Just specify | |
| # the particular version you want to use as the first argument | |
| # of the command, surrounded by underscores. | |
| $ gem install rails --version 3.0.9 | |
| ... | |
| $ gem install rails --pre | |
| ... | |
| $ rbenv rehash | |
| $ rails --version |
This file contains hidden or 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
| /** | |
| * Simply compares two string version values. | |
| * | |
| * Example: | |
| * versionCompare('1.1', '1.2') => -1 | |
| * versionCompare('1.1', '1.1') => 0 | |
| * versionCompare('1.2', '1.1') => 1 | |
| * versionCompare('2.23.3', '2.22.3') => 1 | |
| * | |
| * Returns: |
This file contains hidden or 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
| module MigrationHelper | |
| #options are: | |
| # :pk_table_name | |
| # :pk_column_name | |
| # :cascade_delete | |
| # :cascade_update | |
| def add_fk(fk_table_name, fk_column_name, options = {}) | |
| fk_table_name = fk_table_name.to_s | |
| fk_column_name = fk_column_name.to_s | |
| pk_table_name = options[:pk_table_name] || fk_column_name[0, fk_column_name.index("_id") || fk_column_name.length].pluralize |
This file contains hidden or 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
| class Merchant < ActiveRecord::Base | |
| def foobarable? | |
| # ... | |
| end | |
| end | |
| class Customer < ActiveRecord::Base | |
| belongs_to :merchant | |
| def foobar=(something_else) | |
| self[:foobar] = something_else if merchant.foobarable? |