Skip to content

Instantly share code, notes, and snippets.

View apauly's full-sized avatar
😎

Alex Pauly apauly

😎
View GitHub Profile
@cmoran92
cmoran92 / preload_counts.rb
Last active October 19, 2020 11:24 — forked from apauly/preload_counts.rb
Preload the count of associations similar to the familiar "preload"
#
# PreloadCounts
#
# Usage:
# collection = Post.limit(10).preload_counts(:users)
# collection.first.users.count # fires one query to fetch all counts
# collection[1].users.count # uses the cached value
# collection.last.users.count # uses the cached value
#
# Call `::PreloadCounts.enable!` inside of an initializer to enable preloading of association counts
@mul14
mul14 / profile.md
Created October 26, 2018 00:35 — forked from ezekg/profile.md
iTerm key bindings

Open the iTerm preferences ⌘+, and navigate to the Profiles tab (the Keys tab can be used, but adding keybinding to your profile allows you to save your profile and sync it to multiple computers) and keys sub-tab and enter the following:

Delete all characters left of the cursor

⌘+←Delete Send Hex Codes:

  • 0x18 0x7f – Less compatible, doesn't work in node and won't work in zsh by default, see below to fix zsh (bash/irb/pry should be fine), performs desired functionality when it does work.
  • 0x15 – More compatible, but typical functionality is to delete the entire line rather than just the characters to the left of the cursor.

Delete all characters right of the cursor

⌘+fn+←Delete or ⌘+Delete→ Send Hex Codes:

  • 0x0b
@ryderstorm
ryderstorm / installing_rmagick_ubuntu_16.04.txt
Last active May 17, 2023 00:28
Installing rmagick gem on Ubuntu 16.04
# the instructions from here: https://stackoverflow.com/questions/3704919/installing-rmagick-on-ubuntu/31089915#31089915
# worked, but only after I added in line 8
sudo apt-get purge graphicsmagick graphicsmagick-dbg imagemagick-common imagemagick imagemagick-6.q16 libmagickcore-6-headers libmagickwand-dev graphicsmagick-libmagick-dev-compat
sudo apt-get autoremove
sudo apt-get install imagemagick libmagickwand-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config /usr/bin/Magick-config
export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig
gem install rmagick
@apauly
apauly / application.css
Last active December 20, 2015 01:08
Compass Retina "spriting": use a seperate css file with data-urls of .svg images instead of a normal "sprite"
@import "svg-sprites.css"; // client-side import; just like a large sprite image
@mcmire
mcmire / enumerable_matchers.rb
Created June 25, 2013 16:40
Enumerable RSpec matchers
module EnumerableMatchers
# RSpec already lets you do this:
#
# arr.should be_any {|item| item["foo"] == 2 }
#
# However, that's kind of unwieldy to say. So we add this matcher so we
# can say one of these alternatives instead:
#
# arr.should have_any {|item| item["foo"] == 2 }
# arr.should have_an {|item| item["foo"] == 2 }
@mattbrictson
mattbrictson / Gemfile
Created May 18, 2012 23:06
Faster Capybara Specs
gem 'database_cleaner', group: :test
@edouard
edouard / dominant_colors.rb
Created February 10, 2012 08:53
A ruby script to get the most dominant colours in an image (uses ImageMagick)
require 'RMagick'
TOP_N = 10 # Number of swatches
# Create a 1-row image that has a column for every color in the quantized
# image. The columns are sorted decreasing frequency of appearance in the
# quantized image.
def sort_by_decreasing_frequency(img)
hist = img.color_histogram
# sort by decreasing frequency