Skip to content

Instantly share code, notes, and snippets.

View rondy's full-sized avatar

Rondy Sousa rondy

  • Plataformatec
  • São Paulo, SP
View GitHub Profile
@rondy
rondy / cozinhando_phoenix.md
Last active August 29, 2015 14:01
Cozinhando Phoenix

Cozinhando Phoenix

Ouça a playlist no Rdio.

Música que mostrou a cara da banda pro mundo. Refrão marcante, meio chiclete. Encaixa em qualquer trilha sonora de comercial modernoso.

{
"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,
@rondy
rondy / gist:7372736
Last active December 27, 2015 18:49
# 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 = Logger.new($stdout)
@rondy
rondy / vitrine.rb
Last active December 15, 2015 17:29
class ProductsController < ApplicationController
def index
@products = Product.vitrine(34)
respond_with @products
end
end
class Product < ActiveRecord::Base
def self.vitrine(limit)
with_state(:published).limit(limit)
  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
    
- (void) getDataFromLocalJSON
{
NSString *jsonPath = @"response.json";
NSFileHandle *file;
NSData *databuffer;
file = [NSFileHandle fileHandleForReadingAtPath: jsonPath];
if (file) {
databuffer = [file readDataToEndOfFile];
[file closeFile];
}
@rondy
rondy / gist:3130990
Created July 17, 2012 18:14
Verify network connection
- (BOOL) isConnectedToNetwork
{
Reachability *hostReachable = [Reachability reachabilityWithHostName:@"www.google.com"];
NetworkStatus internetStatus = [hostReachable currentReachabilityStatus];
return ((internetStatus == ReachableViaWiFi) || (internetStatus == ReachableViaWWAN));
}
@rondy
rondy / gist:2819263
Created May 28, 2012 13:42 — forked from cassiomarques/gist:2819167
Display your routes right at Rails Console, instead of waiting for rake to load your app
# 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
rondy / credential.rb
Created April 26, 2012 20:46 — forked from RStankov/credential.rb
Sample code from my Using OO to Manage Control Flow post
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
rondy / 01_usage.markdown
Created April 21, 2012 20:50
Michealis Dictionary
$ michaelis ruby
Michealis Dictionary
Translate: ruby (ingles-portugues)

ruby
ru.by
 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.
---