Skip to content

Instantly share code, notes, and snippets.

@gonzedge
gonzedge / .bashrc
Created November 23, 2011 02:20
Deploying on shared servers with git
if [ -d "$HOME/git/bin-wrappers" ]; then
PATH="$PATH:$HOME/git/bin-wrappers"
fi
@gonzedge
gonzedge / Gemfile
Created November 23, 2011 03:09
Stripping down Rails 3.1: Using only the database migrations
source 'http://rubygems.org'
gem 'git-deploy'
gemfile = File.open(File.join(File.dirname(__FILE__), 'deploy', 'Gemfile'))
eval gemfile.read
@gonzedge
gonzedge / add_wmode.coffee
Created November 23, 2011 04:17
IE and the flash "wmode" madness
clone.find('object').prepend('<param name="wmode" value="opaque" />') unless clone.find('param[name=wmode]').length
clone.find('embed').attr wmode: 'opaque'
@gonzedge
gonzedge / add_override_transitions.js
Created November 30, 2011 15:20
Extending the jQuery Rambling Slider
$(window).load(function(){
$('#slider').ramblingSlider({
imageTransitions: {
/* Add a 'fadeInSlices' transition */
fadeInSlices: function() {
/* ... */
},
/* Override the 'sliceUpRight' transition */
sliceUpRight: function() {
/* ... */
@gonzedge
gonzedge / crontab_after.sh
Created December 15, 2011 21:57
Using RVM within a cron job
0 */12 * * * /bin/bash -l -c 'source "$HOME/.rvm/scripts/rvm" && rvm use 1.9.2 && rvm gemset use records_app && cd /path/to/the/records_app/ && rake check_expired_records'
@gonzedge
gonzedge / first.try.coffee
Created December 16, 2011 19:17
CoffeeScript: The '=>' operator
outerFunctionWithCallback = (options, callback) ->
# Do something with options
callback()
theFunction = ->
self = @
@doFirstThing = -> # ...
@doSecondThing = -> # ...
@gonzedge
gonzedge / Gemfile
Created January 3, 2012 23:18
Generating your site menu with the 'simple-navigation' gem
gem 'simple-navigation'
@gonzedge
gonzedge / _post.html.erb
Created January 4, 2012 04:45
Writing elegant HTML with HAML
<div id="single_post">
<h2 class="post_title"><%= link_to post.title, post %></h2>
<div class="post_content">
<div class="post_date">
Posted on <%= post.date.strftime '%e %B %Y' %>
</div>
<div class="posted_by">
By: <%= post.author %>
</div>
<div class="comments_number">
@gonzedge
gonzedge / application_controller.rb
Created January 5, 2012 02:34
Rails 3.1 - Adding custom 404 and 500 error pages
class ApplicationController < ActionController::Base
# ...
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: lambda { |exception| render_error 500, exception }
rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception }
end
private
def render_error(status, exception)
@gonzedge
gonzedge / Gemfile
Created January 5, 2012 03:55
Replacing ERb with HAML on your Rails application generators
gem 'haml-rails'