Skip to content

Instantly share code, notes, and snippets.

View parndt's full-sized avatar
🇺🇦

Philip Arndt parndt

🇺🇦
View GitHub Profile
@parndt
parndt / pages_controller_decorator.rb
Created June 11, 2013 19:05
Workaround to enable home page 404 support in Refinery
# app/decorators/controllers/refinery/pages_controller_decorator.rb
Refinery::PagesController.class_eval do
before_filter :error_404, :unless => :current_user_can_view_page?, :only => :home
end
@parndt
parndt / gist:5750490
Last active November 30, 2017 02:07
Rails 2, Rails 3, Rails 4, Hanami Server and Console
# Rails 2, 3, 4, and Hanami console
function rc {
if [ -e "./script/console" ]; then
./script/console $@
elif [ -e "./bin/rails" ]; then
./bin/rails console $@
elif [ -e "./apps" ]; then
hanami console $@
else
script/rails console $@
@parndt
parndt / gist:5548788
Last active December 17, 2015 04:09
`bundle exec` like a sudoer
04:52:02: [master±|2.0.0p0] /code/parndt/forem$ rake forem:dummy_app
rake aborted!
You have already activated rake 10.0.4, but your Gemfile requires rake 10.0.3. Using bundle exec may solve this.
04:52:04: [master±|2.0.0p0] /code/parndt/forem$ bundle exec !!
bundle exec rake forem:dummy_app
Copying over Forem migrations... # success
@parndt
parndt / gist:5523721
Created May 6, 2013 06:57
how many times have I wanted a better alternative to this?
- if local_assigns[:mass_moderation]
= render '/forem/posts/moderation_tools', :post => post
- else
= form_tag forem.forum_moderate_posts_path(post.topic.forum), :method => :put do
= render '/forem/posts/moderation_tools', :post => post
@parndt
parndt / index.html.erb
Created May 2, 2013 21:30
app/views/forem/forums/index.html comparison
<div id='forums_container'>
<h1 id='forums_title'><%= t('.title') %></h1>
<%= render @categories %>
</div>
<br>
<footer id='admin_link'>
<% if forem_admin? %>
<%= link_to t("area", :scope => "forem.admin"), forem.admin_root_path %>
@parndt
parndt / pre-commit
Last active December 16, 2015 11:59 — forked from ideasasylum/pre-commit
Place this in ~/.git_template/hooks/pre-commit and chmod to 755. Now, ensure you have git >= 1.7.1 and run: git config --global init.templatedir '~/.git_template' Back in your repository, run git init again and the hook will appear.
#!/usr/bin/env ruby
spec_hits = []
checks = {
'_spec\.rb$' => ['focus:[:space:]*true'],
'\.rb$' => ['binding\.pry', 'debugger']
}
# Find the names of all the filenames that have been (A)dded (C)opied or (M)odified
filenames = `git diff --cached --name-only --diff-filter=ACM`.split("\n")
<div id="slider">
<!--<img src="images/image1.jpg" alt="image1"/>
<a href="#link"><img src="images/image2.jpg" alt="image2"/></a>
<img src="images/image3.jpg" alt="image3"/>
<img src="images/image4.jpg" alt="image4"/>
</div>-->
<%= image_tag 'Composite1.png', { :alt => 1 } %>
<%= image_tag 'Composite2.png', { :alt => 2 } %>
<%= image_tag 'Composite15.png', { :alt => 15 } %>
<%= image_tag 'Composite14.png', { :alt => 14 } %>
@parndt
parndt / gist:5285677
Last active December 15, 2015 15:59 — forked from cue232s/gist:5285635
class PromotionAttachment < ActiveRecord::Base
belongs_to :promotion
attr_accessible :like_gate_image, :promotion_image, :app_icon, :video_url
validate :validate_like_gate_image_dimensions
[:like_gate_image, :promotion_image].each do |file_name|
options = {
styles: {
@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 / gist:5275347
Created March 30, 2013 04:21
Bundler with glob option

Seems to work:

  • git 'git://github.com/grounded/afterburnercms.git', :branch => 'wip_rearch', :glob => "{,**/*}.gemspec" do
  • git 'https://github.com/grounded/afterburnercms.git, :branch => 'wip_rearch', :glob => "{,**/*}.gemspec" do
  • path '/path/to/root', :glob => "{,**/*}.gemspec" do

Doesn't seem to work: