Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Jon Atack jonatack

🎯
Focusing
Block or report user

Report or block jonatack

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View test-ransack-scope-and-column-same-name.rb
# test-ransack-scope-and-column-same-name.rb
# This is a stand-alone test case.
# Run it in your console with: `ruby test-ransack-scope-and-column-same-name.rb`
# If you change the gem dependencies, run it with:
# `rm gemfile* && ruby test-ransack-scope-and-column-same-name.rb`
unless File.exist?('Gemfile')
View test-ransacker-arel-present-predicate.rb
# test-ransacker-arel-present-predicate.rb
# Run it in your console with: `ruby test-ransacker-arel-present-predicate.rb`
# If you change the gem dependencies, run it with:
# `rm gemfile* && ruby test-ransacker-arel-present-predicate.rb`
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
View test-ransack-scope-and-column-same-name.rb
# test-ransack-scope-and-column-same-name.rb
# This is a stand-alone test case.
# Run it in your console with: `ruby test-ransack-scope-and-column-same-name.rb`
# If you change the gem dependencies, run it with:
# `rm gemfile* && ruby test-ransack-scope-and-column-same-name.rb`
unless File.exist?('Gemfile')
@jonatack
jonatack / benchmark_building_a_hash.rb
Last active Oct 27, 2018
Benchmark building a Ruby hash: #each - #each_with_object - #reduce - Hash[map] - #map.zip(map).to_h - #reduce-merge
View benchmark_building_a_hash.rb
require 'benchmark/ips'
Benchmark.ips do |x|
Property = Struct.new(:name, :original_name)
PROPERTIES = [
Property.new("Clo", "Chloe" ),
Property.new("Jon", "Jonathan" ),
Property.new("Kris", "Kristin" ),
@jonatack
jonatack / test-ransack-issue-608-order-of-predicate-arguments.rb
Last active Jul 30, 2016
test-ransack-issue-608-order-of-predicate-arguments
View test-ransack-issue-608-order-of-predicate-arguments.rb
# test-ransack-issue-608-order-of-predicate-arguments.rb
# This is a stand-alone test case.
# Run it in your console with: `ruby test-ransack-issue-608-order-of-predicate-arguments.rb`
# If you change the gem dependencies, run it with:
# `rm gemfile* && ruby test-ransack-issue-608-order-of-predicate-arguments.rb`
unless File.exist?('Gemfile')
@jonatack
jonatack / two_associations_one_with_default_scope.rb
Last active Jul 30, 2016
Ransack issue #628 - two associations where the second one is part of the default scope generates invalid SQL.
View two_associations_one_with_default_scope.rb
# two_associations_one_with_default_scope.rb
# Run it in your console with: `ruby two_associations_one_with_default_scope.rb`
# If you change the gem dependencies, run it with:
# `rm gemfile* && ruby two_associations_one_with_default_scope.rb`
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
@jonatack
jonatack / private.xml
Created Dec 26, 2015 — forked from carwin/private.xml
Programmer's Shift Keys: Remapping parens, brackets and braces for to because nerd.
View private.xml
<?xml version="1.0"?>
<root>
<item>
<name>Programmer's Shift Keys</name>
<!--
Author: Carwin Young (@carwin)
Last Updated: 2014.07.18
v.1.1
Programmer's Shift Keys
@jonatack
jonatack / private.xml
Last active Dec 27, 2015
Karabiner custom setting to use the correct shift keys and break bad typing habits. Drop this into your private.xml file using https://github.com/tekezo/Karabiner for Mac OS, click on "Reload XML", then click on "Use the correct shift keys" at the top of the Karabiner Change Key settings.
View private.xml
<item>
<name>Use the correct shift keys.</name>
<identifier>private.correct_shift_keys</identifier>
<autogen>--KeyToKey-- KeyCode::BACKQUOTE, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::1, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::2, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::3, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
<autogen>--KeyToKey-- KeyCode::4, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
@jonatack
jonatack / gist:17a4523ca3c25ea75453
Created Feb 21, 2016 — forked from millisami/gist:3148874
Convert any YouTube video into an audio file you can listen to on the go...
View gist:17a4523ca3c25ea75453
# Convert any YouTube video into an audio file you can listen to on the go, using:
# http://rg3.github.com/youtube-dl/
{ ~ } > brew install ffmpeg
{ ~ } > brew install ffprobe
{ ~ } > wget https://raw.github.com/rg3/youtube-dl/2012.02.27/youtube-dl
{ ~ } > chmod u+x youtube-dl
# Pick which video format you want to download.. (use any YT video link)
@jonatack
jonatack / dual.lisp
Last active Jun 2, 2016 — forked from lispm/dual.lisp
Conjugate Partitions
View dual.lisp
; http://kaygun.tumblr.com/post/145269023094/conjugate-partitions
; version 1
(defun dual (xs &aux k n r)
(loop while xs do
(setf k (reduce #'min xs)
n (length xs)
xs (sort (loop for x in xs
for x1 = (- x k)
You can’t perform that action at this time.