Skip to content

Instantly share code, notes, and snippets.

View parndt's full-sized avatar

Philip Arndt parndt

View GitHub Profile
@parndt
parndt / gist:5282335
Last active December 15, 2015 15:29 — forked from Siron/gist:5282262
module Refinery
module PhotoGallery
module Extensions
module Pages
def has_one_page_album
has_many :album_page, :as => :page, :dependent=> :destroy
has_many :album, :through => :album_page
has_many :photos, :class_name => Refinery::PhotoGallery::Photo, :through => :album , :order => "created_at ASC"
@parndt
parndt / User.rb
Last active December 11, 2015 05:18 — forked from patrickcurl/User.rb
# == Schema Information
# Schema version: 20130116180743
#
# Table name: users
#
# id :integer not null, primary key
# name :string(255)
# email :string(255)
# created_at :datetime not null
# updated_at :datetime not null
@parndt
parndt / gist:4505891
Last active December 10, 2015 22:58 — forked from tpendragon/gist:4505845
def content_with_parent_fallback
content_without_parent_fallback.presence || translation_for(parent_translation(I18n.locale)).try(:content)
end
alias_method_chain :content, :parent_fallback
<section id="carousel">
<div id="myCarousel" class="carousel slide">
<ul class="carousel-inner">
<% @slides.each_with_index do |slide, i| %>
<% if i==0 %>
<li class="item active">
<% else %>
<li class="item">
<% end %>
<%= link_to image_fu(slide.image, '1200x490!'), refinery.slides_slide_path(slide) %>
<section id="carousel">
<div id="myCarousel" class="carousel slide">
<ul class="carousel-inner">
<% @slides.each_with_index do |slide, i| %>
<% if i==0 %>
<li class="item active">
<% else %>
<li class="item">
<% end %>
<%= link_to image_fu(slide.image, '1200x490!'), refinery.slides_slide_path(slide) %>
require 'gh'
contributions = {}
repositories = {}
longest_name = 0
GH.with(username: ENV['GITHUB_USERNAME'], password: ENV['GITHUB_PASSWORD']) do
GH["orgs/#{ENV['ORG']}/repos"].each do |repository|
repositories[repository['full_name']] = GH["repos/#{repository['full_name']}/contributors"]
end
@parndt
parndt / gist:4127297
Created November 21, 2012 20:02 — forked from ugisozols/gist:4125166
Stop subclassing array
diff --git a/core/lib/refinery/plugins.rb b/core/lib/refinery/plugins.rb
index a22497f..cef123e 100644
--- a/core/lib/refinery/plugins.rb
+++ b/core/lib/refinery/plugins.rb
@@ -1,5 +1,10 @@
module Refinery
- class Plugins < Array
+ class Plugins
+ include Enumerable
+
@parndt
parndt / Gemfile
Created March 19, 2012 21:57 — forked from joemsak/Gemfile
source 'http://rubygems.org'
gem 'rails', '~> 3.0.11'
gem 'foreman'
gem 'unicorn'
gem 'airbrake'
gem 'delayed_job'
gem 'compass', '~> 0.12.alpha'
gem 'acts-as-taggable-on', '~>2.1.0'
@parndt
parndt / gist:1726580
Created February 2, 2012 23:54
change theme in your helper for joshuascott
def current_theme
# first, check if we've tried to access this already and if so @current_theme will be populated with a value.
@current_theme ||= if params[:ChangeTheme] == "true"
# If the user is trying to change the theme, first: construct an array of possible themes.
# then: reject the theme in the current session if it is present.
# Finally, grab a random sample to use a random theme from the array of themes.
%w[power.css creative.css communication.css].reject{|theme| theme == session[:current_theme]}.sample
else
# The user is not trying to change the theme so just return the current theme saved to sesssion OR
# return the default theme which is 'power.css'
@parndt
parndt / application.html.erb
Created February 2, 2012 23:08
Change theme
<%= stylesheet_link_tag(current_theme) %>