Skip to content

Instantly share code, notes, and snippets.

View brennovich's full-sized avatar
👋
Hey, there

Brenno Costa brennovich

👋
Hey, there
View GitHub Profile
@brennovich
brennovich / replaceSpecialChars.js
Created October 19, 2011 04:02
Replace special characters
var specialChars = [
{val:"a",let:"áàãâä"},
{val:"e",let:"éèêë"},
{val:"i",let:"íìîï"},
{val:"o",let:"óòõôö"},
{val:"u",let:"úùûü"},
{val:"c",let:"ç"},
{val:"A",let:"ÁÀÃÂÄ"},
{val:"E",let:"ÉÈÊË"},
{val:"I",let:"ÍÌÎÏ"},
@brennovich
brennovich / deploy.rb
Created October 29, 2011 14:47
Capistrano task for database.yml
namespace :deploy do
desc "Symlinks the database.yml"
task :symlink_db, :roles => :app do
run "ln -nfs /home/#{user}/#{domain}/shared/database.yml #{release_path}/config/database.yml"
end
end
@brennovich
brennovich / my_model.rb
Created November 20, 2011 22:57
Decent URL's
def to_param
"#{id}-#{attribute.downcase.parameterize}"
end
@brennovich
brennovich / i18n.rb
Created November 24, 2011 03:01
Active admin i18n.rb initalizer
I18n.locale = :'pt-BR' # or whatever your default locale is
I18n.load_path += Dir[Rails.root.join("config/locales/**/*.yml")]
I18n.reload!
@brennovich
brennovich / ability.rb
Created December 25, 2011 01:46
Ability example.
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new # guest user (not logged in)
if user.type == 'Admin'
can :manage, [ThematicGroup, Coordinator]
can [:read, :edit, :update], MiniCourse
can :read, Participant
can :panel, Admin
@brennovich
brennovich / application.html.haml
Created December 27, 2011 17:04 — forked from dagda1/application.html.haml
application.html.haml
!!!
%head
%meta{:charset => "utf-8"}
%meta{:author => "Brenno Costa"}
%title Application Layout Hamlfy
=stylesheet_link_tag "application"
=javascript_include_tag "application"
=csrf_meta_tags
%body
@brennovich
brennovich / Gemfile
Created December 27, 2011 17:38 — forked from chriseppstein/readme.md
How to integrate Compass with Rails 3.1 asset pipeline
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass', '~> 0.12.alpha'
# include other compass plugins here. E.g.:
gem 'compass-susy-plugin', :require => 'susy'
end
@brennovich
brennovich / ajax.js
Created December 29, 2011 02:56
Unobtrusive Ajax Example for Rail 3.1
$("select").change(function() {
var form = $(this.form);
$.post(
form.attr("action"),
form.serialize(),
null,
"script" // Datatype needed to format.js work
);
return false;
});
@brennovich
brennovich / bundles.sh
Created January 5, 2012 00:10 — forked from mkdynamic/bundles.sh
Install all of http://github.com/phuibonhoa's TM bundles (OS X only)
#!/usr/bin/env bash
#
# install all of http://github.com/phuibonhoa's TM bundles (OS X only)
#
echo "Installing bundles..."
# backup dir
if [ -d ~/desktop/_tm_bundle_backups ]; then rm -rf ~/desktop/_tm_bundle_backups; fi
@brennovich
brennovich / nginx
Created January 6, 2012 23:55 — forked from nofxx/nginx
nginx rc.d script archlinux
#!/bin/bash
# NGINX RC.D SCRIPT
# Archlinux
NGINX_CONFIG="/opt/nginx/conf/nginx.conf"
NGINX_BIN="/opt/nginx/sbin/"
#. /etc/conf.d/nginx
. /etc/rc.conf
. /etc/rc.d/functions