Skip to content

Instantly share code, notes, and snippets.

View parndt's full-sized avatar

Philip Arndt parndt

View GitHub Profile
@parndt
parndt / gist:4121385
Created November 20, 2012 21:43
Sublime Text 2 Preferences
// Settings in here override those in "Default/Preferences.sublime-settings", a$
// are overridden in turn by file type specific settings.
{
"font_face": "Monaco",
"font_size": 15,
"draw_white_space": "selection",
"trim_trailing_white_space_on_save": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"tab_completion": true,
@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 / gist:4146131
Created November 26, 2012 01:31
InformIt issues while creating an account and ordering
  • Order form errors when email address contained a + as in [email protected] (which is completely valid!)

    • workaround: change email address to something without a + (boooo!)
  • Won't accept space characters in the account password

  • Forces use of a number in the account password (but won't allow spaces?) for dubious security improvements even though it made my password (and likely other peoples' passwords) far, far harder to remember.

  • 50% off voucher removed previous discount so eBook was $16 not $13 (is this a real problem or a policy?)

  • Passwords mailed in plain text when using password reset functionality. (this was a real shocker!) Attached is the email (with modified email address):

A request for your password has been made on the InformIT web site. If you did not make this request don't worry. This message can only be sent to the email address associated with your profile. If you did not make this request it is safe to disregard this message.
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
# parts is a has_many relationship on Refinery::Page
ActiveRecord::Relation === Refinery::Page.first.parts.where(:title => 'foo')
#=> true
ActiveRecord::Relation === Refinery::Page.first.parts
#=> false
# wat
<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) %>
@parndt
parndt / gist:4341490
Created December 19, 2012 23:13
My troubles with Globalize3
1.9.3p327 :001 > p=Refinery::Page.first
Refinery::Page Load (0.3ms) SELECT "refinery_pages".* FROM "refinery_pages" LIMIT 1
Refinery::Page::Translation Load (0.2ms) SELECT "refinery_page_translations".* FROM "refinery_page_translations" WHERE "refinery_page_translations"."refinery_page_id" = 1
=> #<Refinery::Page id: 1, parent_id: nil, path: nil, slug: "home", show_in_menu: true, link_url: "/", menu_match: "^/$", deletable: false, draft: false, skip_to_first_child: false, lft: 1, rgt: 14, depth: 0, view_template: nil, layout_template: nil, created_at: "2012-12-19 21:18:13", updated_at: "2012-12-19 21:18:13">
1.9.3p327 :002 > p.translations
=> [#<Refinery::Page::Translation id: 1, refinery_page_id: 1, locale: "en", title: "Home", custom_slug: nil, menu_title: nil, slug: "home", created_at: "2012-12-19 21:18:13", updated_at: "2012-12-19 21:18:13">]
1.9.3p327 :003 > p.title
=> "Home"
1.9.3p327 :004 > p.translations
=> [#<Refinery::Page::Translation id: 1, refinery_page_id: 1, locale: "en", title: "H
@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
@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