Skip to content

Instantly share code, notes, and snippets.

@jmccartie
jmccartie / instructions.md
Created May 3, 2016 22:03
Patch ImageMagick on Heroku

Patch ImageMagick on Heroku

  • Create a new file on your project: .magick/policy.xml
  • Add the following to its contents:
<policymap>
  <policy domain="coder" rights="none" pattern="EPHEMERAL" />
  <policy domain="coder" rights="none" pattern="URL" />
  <policy domain="coder" rights="none" pattern="HTTPS" />
@jmccartie
jmccartie / search_results.md
Last active May 12, 2017 17:25
Airbnb search results return

Request

https://www.airbnb.com/search/search_results?page=1&source=map&airbnb_plus_only=false&sw_lat=40.77338747897795&sw_lng=-112.35851074218755&ne_lat=41.52173130250669&ne_lng=-109.89757324218755&search_by_map=true&location=Provo%2C+UT%2C+United+States&checkin=06%2F05%2F2016&checkout=06%2F11%2F2016&guests=5&room_types%5B%5D=Entire+home%2Fapt&ss_id=tas1rhta

Results

{
  "filters": "\n  <div class=\"filters-section intro-filter panel-body panel-light\">\n    <div class=\"row\">\n      <div class=\"col-lg-2 col-md-12 text-center-sm text-center-md row-space-sm-1 filter-label\">\n        <label>Dates</label>\n      </div>\n\n      <form class=\"col-lg-9 trip-form\">\n        <div class=\"row row-condensed\">\n          <div class=\"col-md-4 col-sm-6 row-space-1-sm\">\n            <label for=\"map-search-checkin\" class=\"screen-reader-only\">\n              Check In\n            </label>\n            <input name=\"checkin\"\n                   id=\"map-search-checkin\"\n                   type=\"t
@jmccartie
jmccartie / database.rake
Created March 22, 2016 21:48
Copy Heroku production DB to local database
namespace :db do
desc "Copy production database to local"
task :copy_production => :environment do
###
# HEROKU
###
# Download latest dump
@jmccartie
jmccartie / existing_implementation.js
Last active January 25, 2016 00:22
First shot at some React
(function($){
$.fn.searchField = function(){
this.each(function(_index, entry){
var $entry = $(entry);
//1. Add the results dropdown page
// - add the pane
// - add the help message
// - add the results list
//2. Handle the dropdown events
@jmccartie
jmccartie / numeric_vs_uuid
Last active October 22, 2015 04:34 — forked from jgaskins/numeric_vs_uuid
Comparing numeric vs UUID in Postgres. Rehearsal benchmarks are thrown out. Only the second run is kept. Insertions are done all in one query to minimize the impact of I/O. This is harder to do with retrieval, but the ids are randomized in each one to minimize the effects of caching inside the database.
# First
Inserting
user system total real
Numeric 0.060000 0.020000 0.080000 ( 0.977884)
UUID 0.070000 0.010000 0.080000 ( 1.147398)
Retrieving by id
user system total real
Numeric 0.640000 0.920000 1.560000 ( 9.457490)

Keybase proof

I hereby claim:

  • I am jmccartie on github.
  • I am jmccartie (https://keybase.io/jmccartie) on keybase.
  • I have a public key whose fingerprint is D1D2 18ED E24E 7428 F4B9 A777 40C7 361F A211 8B58

To claim this, I am signing this object:

@jmccartie
jmccartie / refactor.rb
Created February 27, 2014 20:42
Oh lordy, this is ripe for a refactor, but I can't quite see it...
case service_time.relation_to_sunday
when "Current"
previous_sunday
when "Before"
if date.wday == service_time.day_of_week
#use date and time
actual_service_time = service_time_with_offset(service_time, date, true)
if time >= actual_service_time
class Beer
attr_accessor :bottle_count
def sing(first, last=0)
first.downto(last).inject("") do |memo, num|
memo << verse(num) + "\n"
end
end
def verse(num)
# How to refactor?
def index
@records = Record.includes(:category, :campus, :event).order("records.id ASC").page(params[:page]).per(params[:per_page])
@records = @records.where(params.slice(:campus_id, :event_id, :category_id, :week_reference))
@records = @records.where("service_date_time >= ?", params[:start_time]) if params[:start_time]
@records = @records.where("service_date_time <= ?", params[:end_time]) if params[:end_time]
@records = @records.where("week_reference >= ?", params[:start_week]) if params[:start_week]
@records = @records.where("week_reference <= ?", params[:end_week]) if params[:end_week]
end
@jmccartie
jmccartie / anagram_v1.rb
Created August 12, 2013 23:08
A refactoring of an Anagram finder (tests here: https://github.com/kytrinyx/exercism.io/blob/master/assignments/ruby/anagram/anagram_test.rb) V1 passed, but the `match` method is pretty hard to read. Really what I wanted that method to do was to "select all the words that are anagrams and aren't duplicates." Using Enumerable's `select` method an…
class Anagram
attr_reader :original_word
def initialize(word)
@original_word = word
end
def match(word_list)
matched_words = []
word_list.each do |word|