Skip to content

Instantly share code, notes, and snippets.

James Harton jimsynz

Block or report user

Report or block jimsynz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View completely_made_up_example.html.erb
# Oh no!
# I have to do this:
<h1><% if @title.nil? %>Attack of the parisian bouncy castles! No title!<% else %><%=h @title %><% end %></h1>
# instead of this:
View ipaddr.rb
# Version: MPL 1.1
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
View gist:262010
# Getting a list of reverse zones needed to fully
# delegate a prefix:
=> ["", "", "", "", "", "", "", ""]
=> ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
View gist:262012
# Prefix scoping:
View gist:293203
[13:31][jnh@marvin]~$ macgem install threadify
/Library/Frameworks/MacRuby.framework/Versions/0.5/usr/lib/ruby/1.9.0/time.rb:351: too short escaped multibyte character: /\A\s*
/Library/Frameworks/MacRuby.framework/Versions/0.5/usr/lib/ruby/1.9.0/time.rb:358: too short escaped multibyte character: /\A\s*
# Need to copy data from your SQLite development environment
# to your Postgres production environment? No problem.
set -e
echo Starting migration from $SOURCE to $DESTINATION
View _login.html.haml
= form_for(@user_session, :method => :put, :remote => true) do |f|
%td{:colspan => '2'}
- if @user_session.errors.any?
= pluralize(@user_session.errors.count, "error")
when logging in.
View gist:563393
$ gem install rails --version=3.0.0
$ rails new ArelBug
$ cd ArelBug
$ rails generate model post text:string type:string
$ rails generate model mention post_id:integer user_id:integer
$ rake db:create db:migrate
$ rails console
> pt = Post.arel_table
> mt = Mention.arel_table
# SELECT "posts"."id" FROM "mentions" INNER JOIN "posts" ON "posts"."id" = "mentions"."post_id" WHERE "mentions"."user_id" = 14 AND "posts"."type" != 'ReTweet'
View gist:563420
class Personal < Cluster
def posts
if UserSession.find && UserSession.find.record == creator
# It's our favourite user:
# Show the posts in clusters they follow,
# posts that mention their nickname
# and posts in their own timeline.
pt = Post.arel_table
View authlogic_model.rb
module AuthlogicModel
def self.included(model)
model.class_eval do
extend ClassMethods
include InstanceMethods
include ProtectedAttributes
field :username
field :email
field :crypted_password
You can’t perform that action at this time.