Skip to content

Instantly share code, notes, and snippets.


Rondy Sousa rondy

View GitHub Profile
rondy / README.txt
Created Apr 14, 2012 — forked from ffmike/README.txt
Rails Assert pipeline changes for controller-specific assets
View README.txt
By default, Rails 3.2 loads everything in app/javascripts and everything in app/stylesheets on
every page, despite controller-specific file naming. If you want to load controller-specific
files only on views from their respective controllers, you need to change the manifests and the
layout. The basic idea is to NOT require the entire trees, but only specific subfolders, in the
manifests, and then load the controller-specific files separately in the layout.
Any file you DO want loaded on every page should be placed in app/assets/javascripts/general or
For this to work in production, you also need to ensure that the individual files are precompiled by modifying your production.rb file, listing all of the controller-specific files.
rondy / 01_usage.markdown
Created Apr 21, 2012
Michealis Dictionary
View 01_usage.markdown
$ michaelis ruby
Michealis Dictionary
Translate: ruby (ingles-portugues)

 n 1 Min rubi, rubim. 2 cor do rubi. 3 algo semelhante ao rubi em cor como: vinho tinto, carbúnculo, sangue. 4 Typogr tipo de corpo 5 1/2. • vt ruborizar. • adj da cor do rubi, vermelho-vivo.
rondy / credential.rb
Created Apr 26, 2012 — forked from RStankov/credential.rb
Sample code from my Using OO to Manage Control Flow post
View credential.rb
class Credential
include ActiveModel::Validations
attr_accessor :screen_name, :oauth_token, :oauth_secret, :token, :description
validates_presence_of :screen_name, :oauth_token, :oauth_secret, :message => 'required'
validate :user_exists, :unless => :errors?
def initialize(attributes = {})
attributes.each { |k, v| set_recognized_attribute(k, v) }
rondy / gist:2819263
Created May 28, 2012 — forked from cassiomarques/gist:2819167
Display your routes right at Rails Console, instead of waiting for rake to load your app
View gist:2819263
# This is part of my .pryrc.
# I put this at the section where I load Rails stuff, so I can use Pry instead of IRB
# for my Rails Console sessions
# Once this is loaded, just run the display_routes method from the console to see the same output that rake routes displays.
# I think it's better because I always leave a Rails console session running :)
require 'rails/application/route_inspector'
rondy / gist:3130990
Created Jul 17, 2012
Verify network connection
View gist:3130990
- (BOOL) isConnectedToNetwork
Reachability *hostReachable = [Reachability reachabilityWithHostName:@""];
NetworkStatus internetStatus = [hostReachable currentReachabilityStatus];
return ((internetStatus == ReachableViaWiFi) || (internetStatus == ReachableViaWWAN));
View gist:3151012
- (void) getDataFromLocalJSON
NSString *jsonPath = @"response.json";
NSFileHandle *file;
NSData *databuffer;
file = [NSFileHandle fileHandleForReadingAtPath: jsonPath];
if (file) {
databuffer = [file readDataToEndOfFile];
[file closeFile];
  1. Add debugger to Gemfile

  2. Run bundle

  3. Require debugger on config/application.rb

  4. Run git stash save 'debugger'

  5. Add the following aliases to .gitconfig:

     debugger = stash apply stash^{/debugger}
     dropdebugger = checkout Gemfile Gemfile.lock config/application.rb
View vitrine.rb
class ProductsController < ApplicationController
def index
@products = Product.vitrine(34)
respond_with @products
class Product < ActiveRecord::Base
def self.vitrine(limit)
View gist:7372736
# This initializer adds a method, show_mongo, when running a rails console. When active, all
# moped commands (moped is mongoid's mongodb driver) will be logged inline in the console output.
# If called again, logging will be restored to normal (written to log files, not shown inline).
# Usage:
# > show_mongo
if defined?(Rails::Console)
def show_mongo
if Moped.logger == Rails.logger
Moped.logger =$stdout)
View gist:7422763
"auto_match_enabled": true,
"bold_folder_labels": true,
"caret_style": "phase",
"color_scheme": "Packages/User/Xcode_default.tmTheme",
"draw_white_space": "false",
"ensure_newline_at_eof_on_save": true,
"font_face": "Monaco",
"font_size": 15.0,
"highlight_line": true,
You can’t perform that action at this time.