Perl-inspired notation to quote strings: by using % (percent character) and specifying a delimiting character.
Any single non-alpha-numeric character can be used as the delimiter, %[including these], %?or these?, %~or even these things~.
| RSpec.configure do |config| | |
| config.before(:suite) do | |
| DatabaseCleaner.clean_with(:truncation) | |
| end | |
| config.before(:each) do | |
| DatabaseCleaner.strategy = :transaction | |
| end | |
| config.before(:each, js: true) do |
| def dates_to_time(date_string, created_at) | |
| if date_string[/[0-9]+/].blank? | |
| # there aren't any numbers in it | |
| return 0 | |
| else | |
| # there's at least one number to derive date from | |
| if date_string[/\'(\d){2}/].present? | |
| # uses Month '14 for example | |
| matched_year = date_string[/\'(\d){2}/] | |
| # extrapolate the decade from when this record was created |
| # fireway configured with: http://major.io/2007/07/01/active-ftp-connections-through-iptables/ | |
| require 'net/ftp' | |
| require 'stringio' | |
| # allows us to upload files by content instead of writing to disk first | |
| class Net::FTP | |
| def puttextcontent(content, remotefile, &block) | |
| f = StringIO.new(content) | |
| begin |
| require "net/http" | |
| def start_server | |
| # Remove the X to enable the parameters for tuning. | |
| # These are the default values as of Ruby 2.2.0. | |
| @child = spawn(<<-EOC.split.join(" ")) | |
| XRUBY_GC_HEAP_FREE_SLOTS=4096 | |
| XRUBY_GC_HEAP_INIT_SLOTS=10000 | |
| XRUBY_GC_HEAP_GROWTH_FACTOR=1.8 | |
| XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0 |
| Remove osxfuse if installed via homebrew: | |
| > brew uninstall osxfuse | |
| Install osxfuse binary and choose to install the MacFUSE compatibility layer: | |
| http://sourceforge.net/projects/osxfuse/files/latest/download?source=files | |
| Reboot (optional but recommended by osxfuse) | |
| Install ntfs-3g via homebrew: | |
| > brew update && brew install ntfs-3g |
| # Assumes gem install 'roo' has been done | |
| require 'roo' | |
| # Spreadsheet filename I want to read | |
| file_path = ENV["CONTACT_PATH"] | |
| puts "Importing data from " + file_path | |
| # Opening the file using roo | |
| spreadsheet = case File.extname(file_path) |
| # Login to your server as root | |
| # Stop ghost service to prevent database corruption | |
| service ghost stop | |
| # Do some manual backups | |
| cd /var/www | |
| CURRENT_GHOST_TAR=/var/www/ghost-$(date +"%Y-%m-%d").tar | |
| tar cvf $CURRENT_GHOST_TAR /var/www/ghost |
| gibbon = Gibbon::API.new | |
| view = ActionView::Base.new('app/views/', {instance_variable_for_templates: 5324}, ActionController::Base.new) | |
| campaign = gibbon.campaigns.create( | |
| type: "regular", | |
| options: { | |
| list_id: 'xxxy', | |
| from_email: '[email protected]', | |
| from_name: 'Your From', | |
| subject: "the subject", |