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 Item | |
| def self.find_each(params = {}) | |
| return enum_for(:find_each) unless block_given? | |
| page = nil | |
| while page.nil? || page.current_page < page.total_pages | |
| if page.nil? | |
| page = all params | |
| else | |
| page = all params.merge(page: page.current_page + 1) |
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
| require 'benchmark' | |
| MAX = 1000 | |
| RANGE = (0..MAX).to_a | |
| array = [] | |
| hash = {} | |
| RANGE.each do |i| | |
| array[i] = i |
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
| # dropbox service | |
| DROPBOX_USERS="olly" | |
| DAEMON=.dropbox-dist/dropbox | |
| start() { | |
| echo "Starting dropbox..." | |
| for dbuser in $DROPBOX_USERS; do | |
| HOMEDIR=`getent passwd $dbuser | cut -d: -f6` | |
| if [ -x $HOMEDIR/$DAEMON ]; then |
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
| UKPostcode = begin | |
| an_naa_or_ann_naa = '^([A-PR-UWYZ]{1}\d{1,2})\s?(\d[ABD-HJLNP-UWXYZ]{2})$' | |
| aan_naa_or_aann_naa = '^([A-PR-UWYZ]{1}[A-HK-Y]{1}\d{1,2})\s?(\d[ABD-HJLNP-UWXYZ]{2})$' | |
| ana_naa = '^([A-PR-UWYZ]{1}\d[A-HJKSTUW]{1})\s?(\d[ABD-HJLNP-UWXYZ]{2})$' | |
| aana_naa = '^([A-PR-UWYZ]{1}[A-HK-Y]{1}\d[ABEHMNPRVWXY]{1})\s?(\d[ABD-HJLNP-UWXYZ]{2})$' | |
| historic_code="GIR\s?0AA" | |
| postcode_spec = "#{an_naa_or_ann_naa}|#{aan_naa_or_aann_naa}|#{ana_naa}|#{aana_naa}|#{historic_code}" | |
| pattern = /#{postcode_spec}/i | |
| 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
| module Clipboard | |
| def pbcopy(data) | |
| IO.popen('pbcopy', 'w') {|io| io.write(data)} | |
| end | |
| def pbpaste | |
| IO.popen('pbpaste', 'r').read | |
| 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
| [2013-02-10T19:28:38+00:00] INFO: Processing apt_repository[brightbox-ruby-ng] action add (application::rails line 67) | |
| ================================================================================ | |
| Error executing action `add` on resource 'apt_repository[brightbox-ruby-ng]' | |
| ================================================================================ | |
| RuntimeError | |
| ------------ | |
| The repository file to create is nil, cannot continue. |
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 Rack::File | |
| def warn(*) | |
| 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
| matcher = ->(model) do | |
| begin | |
| model.valid? | |
| true | |
| rescue ActiveModel::StrictValidationFailed | |
| false | |
| end | |
| end | |
| RSpec::Matchers.define :pass_strict_validations do |
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
| [2012-12-12 16:15:29] ./Configure darwin64-x86_64-cc -I/Users/Olly/.rvm/usr/include -L/Users/Olly/.rvm/usr/lib zlib no-asm no-krb5 shared --prefix=/Users/Olly/.rvm/usr | |
| current path: /Users/Olly/.rvm/src/openssl-1.0.1c | |
| command(10): ./Configure darwin64-x86_64-cc -I/Users/Olly/.rvm/usr/include -L/Users/Olly/.rvm/usr/lib zlib no-asm no-krb5 shared --prefix=/Users/Olly/.rvm/usr | |
| [31m/Users/Olly/.rvm/scripts/functions/utility:116 [32m__rvm_log_command:32[37m ./Configure darwin64-x86_64-cc -I/Users/Olly/.rvm/usr/include -L/Users/Olly/.rvm/usr/lib zlib no-asm no-krb5 shared '--prefix=/Users/Olly/.rvm/usr' '' | |
| target already defined - darwin64-x86_64-cc (offending arg: ) |
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
| [2012-12-12 16:07:46] ./Configure darwin64-x86_64-cc -I/Users/Olly/.rvm/usr/include -L/Users/Olly/.rvm/usr/lib zlib no-asm no-krb5 shared --prefix=/Users/Olly/.rvm/usr | |
| target already defined - darwin64-x86_64-cc (offending arg: ) |