Skip to content

Instantly share code, notes, and snippets.

select airbnb_bookings.id, airbnb_links.airbnb_connection_id from airbnb_bookings join bookings ON bookings.id = airbnb_bookings.booking_
 id join properties ON properties.id = bookings.property_id join airbnb_links ON airbnb_links.property_id = properties.id where bookings.id in (__booking_ids__)
airbnb_booking_id = __airbnb_booking_id__;
airbnb_connection_id = __airbnb_connection_id__;

thread = AirbnbBookingRepository.new.find(airbnb_booking_id).thread;
@mrship
mrship / divisor-by-zero.sql
Created December 11, 2017 17:24
divisor-by-zero.sql
SELECT '<span class=''xl green''>' ||
COUNT_SHARE ||
'%' ||
'</span>' ||
' of lost opportunities are of ' ||
'<span class=''xl blue''>' ||
COMPLEXITY ||
'</span>' ||
' complexity, representing ' ||
'<span class=''xl red''>' ||
select 'Qualified pipeline worth ' ||
'<span class=''xl green''>' ||
CASE WHEN currency = 'GBP' THEN '&pound;' ELSE '&euro;' END ||
LTRIM(TO_CHAR(CAST(SUM(CASE WHEN OPPORTUNITY_STAGE != 'Identify' THEN VALUE ELSE 0 end) AS INTEGER), '999G999G999G999')) ||
'</span> (' ||
CAST(100*SUM(CASE WHEN OPPORTUNITY_STAGE != 'Identify' THEN VALUE ELSE 0 end)/SUM(VALUE) AS INTEGER) ||
'% of total), made up of ' ||
'<span class=''xl blue''>' ||
LTRIM(TO_CHAR(CAST(SUM(CASE WHEN OPPORTUNITY_STAGE != 'Identify' THEN NUMBER_OF_OPPORTUNITIES end) AS INTEGER), '999G999G999G999')) ||
'</span>' ||

Upgrading OpenSSL on production

We will run the following on all production servers:

ssh admin@X.housetrip.com
sudo -i
apt-get update
apt-get upgrade
@mrship
mrship / travis-fail-5224836.md
Last active August 29, 2015 14:01
Travis Fail for 5224836

The failing Travis build

The bundle of specs that was running:

bundle exec spec -O spec/spec.opts --format o spec/behaviors/adyen_form_hidden_values_spec.rb spec/behaviors/has_cacheable_methods_spec.rb spec/behaviors/queueable_deletion_spec.rb spec/behaviors/sync_availabilities_spec.rb spec/behaviors/with_full_urls/rewrite_options_spec.rb spec/config/initializers/erb_util_silence_spec.rb spec/config/schedule_spec.rb spec/controllers/account/dashboard_controller_spec.rb spec/controllers/account/payments_controller_spec.rb spec/controllers/admin/access_rights/invoices_controller_spec.rb spec/controllers/admin/accounting/reports_controller_spec.rb spec/controllers/admin/cancellation_requests/tickets_controller_spec.rb spec/controllers/admin/destinations/informal_destinations_controller_spec.rb spec/controllers/admin/dta/dta_export_logs_controller_spec.rb spec/controllers/admin/excluded_secure_booking_locations_controller_spec.rb spec/c

try vs andand vs early return (x2)

Which is the preferred way to determine if a chained call is nil? i.e:

  1. company.andand.name
  2. company.try(:name)
  3. return nil if company.nil?; company.name
  4. (company or return nil).name

For the last one, you must use the predicate or rather than || to make the return work correctly.

@mrship
mrship / gist:5522044
Created May 5, 2013 20:20
Config.rb for middleman
require "bundler/setup"
Bundler.require
###
# LiveReload
###
activate :livereload
###
# Compass
@mrship
mrship / filepicker-drop-pane.js
Created November 23, 2012 17:34
FilePicker Q2
filepicker.makeDropPane($('#mfl-fp')[0], {
maxsize: 1048576,
multiple: true,
dragEnter: function() {
dragDropPane.addClass('drag');
$('#mfl-fp-message').text('Files should be less than 1Mb in size.');
},
dragLeave: function() {
dragDropPane.removeClass('drag');
},
@mrship
mrship / fiepicker-multiple.js
Created November 23, 2012 17:25
FilePicker Q1
$('#mfl-fp-select').on('change', function() {
console.log($(this)[0].files);
disableBeforeUpload($(buttonFinderText));
$('#mfl-fp-message-image').removeClass('hidden');
filepicker.store(this, function(fpFile) {
mfl.addUploadedFileImage(fpFile);
$('#mfl-fp-message-image').addClass('hidden');
$('#mfl-fp-message').text(completeMessage);
enableAfterUpload($(buttonFinderText));
}, function(fpError) {
@mrship
mrship / gist:3883684
Created October 13, 2012 07:34
Phrase crash 1.9.3
No file or directory specified, using ./config/locales/
Uploading /Users/andy/dev/mfl/config/locales/devise.en.yml...
/Users/andy/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799: [BUG] Bus Error
ruby 1.9.3p194 (2012-04-20 revision 35410) [i386-darwin10.8.0]
-- Control frame information -----------------------------------------------
c:0023 p:---- s:0107 b:0107 l:000106 d:000106 CFUNC :connect
c:0022 p:0011 s:0104 b:0104 l:0021a8 d:000103 BLOCK /Users/andy/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799
c:0021 p:0031 s:0102 b:0102 l:000101 d:000101 METHOD /Users/andy/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:54
c:0020 p:0026 s:0090 b:0090 l:000089 d:000089 METHOD /Users/andy/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/timeout.rb:99