Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Jeff Dickey jdxcode

👋
View GitHub Profile
View gist:1388330
def index
@posts = Post.where(draft: false).order('post_date desc')
@post_months = @posts.group_by { |p| p.post_date.beginning_of_month }
end
View gist:3319573
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
View gist:3694581
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
@jdxcode
jdxcode / gist:3746550
Created Sep 18, 2012
mystique in route constraint
View gist:3746550
# config/routes.rb
require 'admin_constraint'
Tapjoyad::Application.routes.draw do
# ...
scope constraint: AdminConstraint.new do
resources :secure_things
end
@jdxcode
jdxcode / gist:4068500
Created Nov 13, 2012
ruby array appends w/ method parameters
View gist:4068500
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
View gist:4229182
# 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
@jdxcode
jdxcode / dickeyxxx.zsh-theme
Created Dec 12, 2012
dickeyxxx zsh theme
View 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}"
View check_admin_devices.rb
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
@jdxcode
jdxcode / pg_perf.sql
Last active Feb 8, 2021
PostgreSQL performance queries
View pg_perf.sql
/* 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
@jdxcode
jdxcode / gist:4957608
Created Feb 15, 2013
rubymotion rocks
View gist:4957608
BW::Location.get do |result|
p result[:to].latitude
p result[:to].longitude
end