Skip to content

Instantly share code, notes, and snippets.

View ctcherry's full-sized avatar
🎯
Rusty Gopher

Chris Cherry ctcherry

🎯
Rusty Gopher
View GitHub Profile
github = GitHub.new
gist = github.create_application('gist')
gist.make_most_awesome_paste_site!
*if block:*
Pretty straightforward.
<% if @property.floorplans.size == 1 %>
<div>Show This if the property only has 1 floorplan</div>
<% else %>
<div>Show This if the property has any other number of floorplans</div>
<% end %>
#!/bin/bash
if [ -d $1 ]; then
echo "Directory $1 already exists"
exit
else
echo "Creating Rails project in ./$1 using edge rails..."
echo "- Making directory $1"
mkdir $1
@ctcherry
ctcherry / gist:48519
Created January 18, 2009 01:54 — forked from Lytol/gist:45845
# Rails template for a basic project assuming the following:
#
# - SQLite for DB
# - Git for version control
#
# Based on a similar template by: Brian Smith (bsmith@swig505.com)
# Basic housekeeping
#
run "rm public/index.html"
# application_controller.rb
before_filter :hijack_ie_default_format
def hijack_ie_default_format
if request.user_agent =~ /MSIE/ and params['format'].nil?
params['format'] = 'html'
end
end
module Rack
class Roll
def initialize(app)
@app = app
end
def call(env)
if roll?
return [302, {'Location' => 'http://www.youtube.com/watch?v=oHg5SJYRHA0'}, ["You've been rick rolled"]]
@ctcherry
ctcherry / gist:221740
Created October 29, 2009 19:47
100 slowest requests from standard rails log
grep "Completed in [0-9]\{0,\}ms" log/production.log | sort -g -k3 | tail -100
@ctcherry
ctcherry / gist:236251
Created November 16, 2009 19:22
Regular expression to validate URLs
Regular expression to validate URLs
^https?\:\/\/[a-z0-9\-]+(\.[a-z0-9\-]+)+(\:\d{1,5})?(/|/[a-z0-9\_\-\/\?\=\.]*)?$
VALID
http://chrischerry.name
https://chrischerry.name
http://chrischerry.name/
http://chrischerry.name:1234/
/^([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*[\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)$/i
{"contributors":null,"text":"just testing, dont mind me","geo":null,"place":null,"in_reply_to_screen_name":null,"favorited":false,"source":"web","in_reply_to_user_id":null,"coordinates":null,"created_at":"Wed Jul 28 06:44:15 +0000 2010","user":{"lang":"en","profile_use_background_image":true,"profile_sidebar_fill_color":"efefef","following":null,"geo_enabled":false,"followers_count":106,"location":"San Diego, CA","verified":false,"profile_sidebar_border_color":"eeeeee","follow_request_sent":null,"notifications":null,"friends_count":88,"description":"Bleeding edge Web Applications Developer","favourites_count":0,"profile_background_color":"131516","url":"http://chrischerry.name","profile_image_url":"http://a1.twimg.com/profile_images/94668409/redfeedicon_528_normal.png","listed_count":7,"profile_background_image_url":"http://s.twimg.com/a/1279056489/images/themes/theme14/bg.gif","time_zone":"Pacific Time (US & Canada)","profile_text_color":"333333","protected":false,"statuses_count":2224,"created_at":"Thu Mar