This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All is good, just a tiny suggestion: | |
# app/controllers/dashboard_controller.rb: line 18 | |
# Instead of: | |
@watched_objects = current_user.user_config.watched_data_objects.split(", ").map{|id| DataObject.find(id)}.flatten.group_by(&:data_type) | |
# Taking of .find syntax accepting list if id's, consider finding them all at once (please test it first) | |
# also .flatten is not needed) | |
DataObject.find(current_user.user_config.watched_data_objects.split(", ")).group_by(&:data_tytpe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
# We are not loading Active Record, nor Active Resources etc. | |
# We can do this in any app by simply replacing the rails gem | |
# by the parts we want to use. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
gem "tzinfo" | |
# Let's use thin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include Survey::DSL | |
survey 'Finances Questionnaire' do | |
q "Do you have a Durable Power of Attorney for Finances?" do | |
yes do | |
a "Who is the designated agent for handling your finances?" do | |
field 'Full Name' | |
phone 'Phone Number' | |
email 'Email' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# blog post: | |
module ActiveAdmin | |
module ViewHelpers | |
# lib/active_admin/view_helpers/auto_link_helper.rb | |
def auto_link(resource, link_content = nil) | |
content = link_content || display_name(resource) | |
if can?(:read, resource) && registration = active_admin_resource_for(resource.class) | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remote repo aliases assumed: | |
# git remote add production production_heroku_app_git_repo | |
# git remote add staging staging_heroku_app_git_repo | |
# add addons if not already | |
# heroku addons:add pgbackups --remote staging | |
# heroku addons:add pgbackups --remote production | |
heroku pgbackups:capture --remote production | |
heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copied and adapted from https://github.com/matschaffer/zsh-matschaffer/blob/master/tools.zsh | |
# Bundle grep, search for text in bundled gems | |
bgrep() { | |
grep -r "$@" $(bundle show --paths) | |
} | |
# Find files or directories like $1 | |
# Shortcut for: find <dir> -name *<search>* | |
flike() { | |
local search dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nmap _hr :%s/\v:(\w+) \=\>/\1:/g<cr> | |
nmap _h :s/\v:(\w+) \=\>/\1:/g<cr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this in Rakefile (doesn't matter where) | |
require 'benchmark' | |
class Rake::Task | |
def execute_with_benchmark(*args) | |
bm = Benchmark.measure { execute_without_benchmark(*args) } | |
puts " #{name} --> #{bm}" | |
end | |
alias_method :execute_without_benchmark, :execute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# adapted from http://devblog.springest.com/a-script-to-remove-old-git-branches | |
# This has to be run from master | |
git checkout master | |
# Update our list of remotes | |
git fetch | |
git remote prune origin | |
# Remove local fully merged branches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Shortcuts for backbone.js via the asset pipeline | |
" using backbone-on-rails gem and generate with backbone namespace | |
autocmd User Rails Rnavcommand bmodel app/assets/javascripts/backbone/models -suffix=.js.coffee -glob=* | |
autocmd User Rails Rnavcommand bcollection app/assets/javascripts/backbone/collection -suffix=.js.coffee -glob=* | |
autocmd User Rails Rnavcommand brouter app/assets/javascripts/backbone/routers -suffix=.js.coffee -glob=* | |
autocmd User Rails Rnavcommand btemplate app/assets/backbone/templates -suffix=.jst.hbs -glob=**/* | |
autocmd User Rails Rnavcommand bview app/assets/javascripts/backbone/views -suffix=.js.coffee -glob=**/* |
OlderNewer