Skip to content

Instantly share code, notes, and snippets.

Working on a relaunch.

Charlie Park charliepark

Working on a relaunch.
Block or report user

Report or block charliepark

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 Using Rails to find values within a range
From Rails changeset 5876:
A range may be used in the hash to use the SQL BETWEEN operator:
Student.find(:all, :conditions => { :grade => 9..12 })
... so, presumably ...
User.find(:all, :conditions => { :created_at => '2009-01-01'..'2009-02-01' })
... compare with ...
View gist:54552
Friendlier Error Messages
The default error messages can be a bit stale and off putting. Try somethings like this:
:header_message => "Oops - We couldn't save your user!",
:message => "The following fields were a bit of a problem:",
:header_tag => :h1
View jQuery - update an object's z-index based on the current time.
A way to set your z-index to dynamically update, based on the current time.
When you click on the object ('.element'), the javascript grabs the current time,
concatenates the hours, minutes, and seconds, and sets that number as the z-index for the object.
$('.element').mousedown(function(event) {
var time = new Date();
var hours = time.getHours();
if (hours.toString().length == 1) { hours = "0" + '' + hours }
View A Minimalist CSS Grid Framework
This is intended to be a minimalist alternative to Blueprint ( and other, more fleshed-out CSS grid frameworks. Change 3 variables, and the framework does the rest for you. It's intended for use in Ruby / Rails applications.
Put the following in the <head> of your ERB file (either in a layout file or in a partial, if you're calling it from several pages):
<style type="text/css">
num = number_of_columns = 16
View some attractive text CSS
body {font-family:'helvetica neue', helvetica, arial, sans-serif;}
h1 {font-size:24px;line-height:26px;margin:10px 0 18px;}
p{font-size:14px;line-height:18px;margin:0 0 18px;}
View .htaccess code
place this in public/.htaccess
FileETag none
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
View Capistrano with Passenger
namespace :deploy do
desc "Restarting mod_rails with restart.txt"
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{current_path}/tmp/restart.txt"
[:start, :stop].each do |t|
desc "#{t} task is a no-op with mod_rails"
task t, :roles => :app do ; end
View Setting up a server on SliceHost
View input placeholder text from Jacob Bijani.html
<input type="text" class="text_field placeholder_content"
value="Default value"
if (this.className == 'text_field placeholder_content') {
if (! this.getAttribute('default_value')) {
this.setAttribute('default_value', this.value);
this.value = '';
this.className = 'text_field';
View CSS_gradients.css
background: #999; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#cccccc', endColorstr='#000000'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#000)); /* for webkit browsers */
background: -moz-linear-gradient(top, #ccc, #000); /* for firefox 3.6+ */
/* from */
You can’t perform that action at this time.