Skip to content

Instantly share code, notes, and snippets.

View fnhipster's full-sized avatar
💭
clear cache && refresh

Carlos A. Cabrera fnhipster

💭
clear cache && refresh
View GitHub Profile
@fnhipster
fnhipster / env.rb
Created August 13, 2010 19:59 — forked from mborromeo/env.rb
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
@fnhipster
fnhipster / Setting_Up_Cucumber_Rails3.rb
Created August 23, 2010 21:29
Setting up Cucumber on Rails 3
# /Gemfile
# We do Behaviour Driven Development
group :development, :test do
gem 'cucumber'
gem 'cucumber-rails'
gem 'webrat'
end
#---
@fnhipster
fnhipster / gist:747856
Created December 20, 2010 00:08
Get next record while it exists.
def some_method
self.find(:all, :order => "position DESC").each do |obj|
next_obj = self.find(:first, :conditions => ["position > ?", obj.position], :order => "position DESC")
# ...
break if next_obj == self.last
end
end
@fnhipster
fnhipster / gist:756325
Created December 27, 2010 17:33
Route 404 in Rails 3
# routes.rb
...
constraints(:subdomain => "sub_domain_name") do
match "*id" => "pages#four_o_four"
end
...
# pages_controller.rb
...
def four_o_four
@fnhipster
fnhipster / gist:771489
Created January 9, 2011 06:39
Remove dotted border on hyperlinks in Firefox
a:active, a:focus {
outline: none;
-moz-outline-style: none;
}
@fnhipster
fnhipster / gist:778245
Created January 13, 2011 17:42
WordPress Nav Menu (InfusionWP) Email
<div id="log_in">
<?php global $user_ID;
if ('' != $user_ID) {
wp_nav_menu('menu=Logged In Users&menu_class=dd-menu');
} else { ...
@fnhipster
fnhipster / html5.haml
Created April 9, 2011 01:19
HTML5 HAML Template
!!! 5
%html
%head
%title= "Your Website"
%meta{ :content => "", :name => "description" }
%meta{ :content => "", :name => "author" }
%meta{ :content => "3 days", :name => "revisit-after" }
%link{ :href => "http://creativecommons.org/licenses/by/3.0/", :rel => "license", :title => "Creative Commons Attribution 3.0 Unported License" }
%link{ :href => "/feed", :rel => "alternate", :title => "Atom", :type => "application/atom+xml" }
%link{ :href => "/css/screen.css", :media => "screen", :rel => "stylesheet" }
/* You must be using jQuery and jQuery UI (w/ Autocomplete)
* http://jqueryui.com/demos/autocomplete/
*/
// For Comma Splitting
function split( val ) {
return val.split( /,\s*/ );
}
function extractLast( term ) {
@fnhipster
fnhipster / gist:1174272
Created August 26, 2011 19:53
Get boxes in the last column and row of a table of 3 columns
// Making fancy borders on the product listing page.
var total = $(".ProductList li").length;
var last_row = Math.ceil(total/3);
var n;
var current_row;
$(".ProductList li").each(function(i){
n = i+1;
current_row = Math.ceil(n/3);
@fnhipster
fnhipster / hack.sh
Created April 1, 2012 00:08 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#