Skip to content

Instantly share code, notes, and snippets.

View robyurkowski's full-sized avatar

Rob Yurkowski robyurkowski

View GitHub Profile
[ -n "$BASH_VERSION" ] || [ -n "$ZSH_VERSION" ] || return
source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh
chruby ruby-1.9.3
App.ApplicationRoute = Ember.Route.extend
setupController: () ->
@controllerFor('discussionPosts').set('model', App.DiscussionPost.find())
@robyurkowski
robyurkowski / board.rb
Created July 8, 2013 01:50
Tic Tac Toe Board
class Board
def initialize
self.squares = Array.new(9)
end
def rows
self.squares.each_slice(3)
end
@robyurkowski
robyurkowski / s3_metadata_change.rb
Last active December 18, 2015 12:39
Uploading a selection of S3 files' metadata
options = {
'x-amz-metadata-directive' => 'REPLACE',
'Content-Type' => 'application/pdf',
'Content-Disposition' => nil
}
count = 0
files = directory.files.each do |file|
next unless file.key =~ /pdf\z/i
count += 1
module Admin
class UsersController < ::AuthenticatedController
load_and_authorize_resource
def index
users = User.untrashed
render_with :users => users
end
def trashed
FactoryGirl.define do
factory :user do
sequence(:email) { |n| "email#{n}@example.com" }
password "secret"
factory :admin do
after_build {|u| u.roles << :admin }
end
end
end
@robyurkowski
robyurkowski / Gemfile
Created June 27, 2012 15:44
Customizing Menus in RefineryCMS 2.0
# Add this:
gem 'cells'
# Generates the link to determine where the site bar switch button returns to.
def site_bar_switch_link(html_options = {})
if admin? ? admin_switch_link(html_options) : frontend_switch_link(html_options)
end
def admin_switch_link(html_options = {})
link_to t('.switch_to_your_website', site_bar_translate_locale_args),
session[:website_return_to] || refinery.root_path(:locale => (Refinery::I18n.default_frontend_locale if Refinery.i18n_enabled?)),
html_options
end
# Generates the link to determine where the site bar switch button returns to.
def site_bar_switch_link
if admin? ? admin_switch_link : frontend_switch_link
end
def admin_switch_link
link_url = session[:website_return_to].present? ? session[:website_return_to] :
refinery.root_path(:locale => (Refinery::I18n.default_frontend_locale if Refinery.i18n_enabled?))
link_to t('.switch_to_your_website', site_bar_translate_locale_args), link_url, {:class => 'btn btn-primary'}