Skip to content

Instantly share code, notes, and snippets.

@gonzedge
gonzedge / index_filter.sh
Created April 27, 2012 06:37
Git: Removing sensitive data and rewriting history
git filter-branch --index-filter 'git rm --cached --ignore-unmatch -- resources/*.mp3' --prune-empty -- --all
@gonzedge
gonzedge / Gemfile
Created February 10, 2012 01:30
Rambling Trie: A custom Trie data structure implementation in Ruby
gem 'rambling-trie'
@gonzedge
gonzedge / export.xml
Created February 3, 2012 20:07
Migrating your blog posts to Markdown with Upmark and Nokogiri
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- ... -->
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.1/excerpt/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:wp="http://wordpress.org/export/1.1/"
>
@gonzedge
gonzedge / Gemfile
Created February 3, 2012 17:29
Writing your blog posts in Markdown with Postmarkdown
gem 'postmarkdown'
@gonzedge
gonzedge / Gemfile
Created January 12, 2012 23:49
Rails 3.1: Treating your '.swf' files as assets
gem 'swf_fu'
@gonzedge
gonzedge / Gemfile
Created January 5, 2012 03:55
Replacing ERb with HAML on your Rails application generators
gem 'haml-rails'
@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 / _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 / Gemfile
Created January 3, 2012 23:18
Generating your site menu with the 'simple-navigation' gem
gem 'simple-navigation'
@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 = -> # ...