Skip to content

Instantly share code, notes, and snippets.

View jdx's full-sized avatar
⚜️
mise-en-place!

jdx

⚜️
mise-en-place!
View GitHub Profile
def index
@posts = Post.where(draft: false).order('post_date desc')
@post_months = @posts.group_by { |p| p.post_date.beginning_of_month }
end
working_directory "<%= current_path %>"
pid "<%= unicorn_pid %>"
stderr_path "<%= unicorn_log %>"
stdout_path "<%= unicorn_log %>"
listen "/tmp/unicorn.<%= application %>.sock"
worker_processes <%= unicorn_workers %>
timeout 30
preload_app true
dickeyxxx@dickey-mbp ~/proj/tapjoymarketplace 1.9.3-p194 (mystique ✘)✹✚
✗✗✗ vagrant up
[default] Importing base box 'lucid32'...
[default] The guest additions on this VM do not match the install version of
VirtualBox! This may cause things such as forwarded ports, shared
folders, and more to not work properly. If any of those things fail on
this machine, please update the guest additions and repackage the
box.
Guest Additions Version: 4.1.16
@jdx
jdx / gist:3746550
Created September 18, 2012 22:56
mystique in route constraint
# config/routes.rb
require 'admin_constraint'
Tapjoyad::Application.routes.draw do
# ...
scope constraint: AdminConstraint.new do
resources :secure_things
end
@jdx
jdx / gist:4068500
Created November 13, 2012 21:26
ruby array appends w/ method parameters
dickeyxxx@dickey-mbp ~/proj/vagrant 2.0.0-dev (master ✘)✹✚✭
✗✗✗ irb
irb(main):001:0> RUBY_VERSION
=> "2.0.0"
irb(main):002:0> def foo(arr: [])
irb(main):003:1> p arr
irb(main):004:1> arr << 'x'
irb(main):005:1> end
=> nil
irb(main):006:0> foo
# How do I make this:
skip_authorization do |current_resource_owner, client|
client.application.auto_grant?
end
# Work with this:
!!instance_exec(@server.current_resource_owner, @pre_auth.client) &Doorkeeper.configuration.skip_authorization
# in both 1.8 and 1.9, without failures like this: https://travis-ci.org/applicake/doorkeeper/builds/3540040
@jdx
jdx / dickeyxxx.zsh-theme
Created December 12, 2012 21:13
dickeyxxx zsh theme
# Example:
#
# dickeyxxx@dickey-mbp ~/proj/tapjoykc 1.9.3-p194 (routes ✔)
# ✗✗✗
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
turquoise="%F{81}"
orange="%F{166}"
purple="%F{135}"
hotpink="%F{161}"
count = 0
AdminDevice.all.each do |admin_device|
device = Device.find(admin_device.udid)
unless device.try(:last_run_time_tester)
puts "'last_run_time_tester' was false: #{admin_device.description}"
count += 1
end
end
@jdx
jdx / pg_perf.sql
Last active February 8, 2021 05:35
PostgreSQL performance queries
/* index performance */
SELECT
relname,
100 * idx_scan / (seq_scan + idx_scan) percent_of_times_index_used,
n_live_tup rows_in_table
FROM
pg_stat_user_tables
WHERE
seq_scan + idx_scan > 0
ORDER BY
@jdx
jdx / gist:4957608
Created February 15, 2013 00:16
rubymotion rocks
BW::Location.get do |result|
p result[:to].latitude
p result[:to].longitude
end