This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # So I can remember... | |
| ActiveRecord::Base.logger = Logger.new(STDOUT) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (BOOL)application:(UIApplication *)application | |
| didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
| if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { | |
| [self.window addSubview:self.splitVC.view]; | |
| } else { | |
| [self.window addSubview:self.navigationController.view]; | |
| } | |
| [self.window makeKeyAndVisible]; | |
| return YES; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| top -n1b | awk '{print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13}' | tail -n +8 >> /var/log/processes_monitor.csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| = will_paginate WillPaginate::Collection.create(@objects.page, @objects.per_page, @objects.total_results) {|p| p.replace @objects} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| named_scope :random, lambda { |*args| { :joins => "JOIN (SELECT id | |
| FROM #{table_name} | |
| ORDER BY RAND() | |
| LIMIT #{(limit = args.first.to_i) > 0 ? limit : 1} | |
| ) AS random_ids | |
| ON #{table_name}.id = random_ids.id"}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module SQLGrowler | |
| class Subscriber < ActiveRecord::Railties::Subscriber | |
| def sql(event) | |
| super | |
| g('%s (%.1fms) %s' % [event.payload[:name], event.duration, event.payload[:sql].squeeze(' ')]) | |
| end | |
| end | |
| def self.enable | |
| if Kernel.respond_to?(:g) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Widget < ActiveRecord::Base | |
| validates_numericality_of :custom_width | |
| has_attached_file :file, | |
| :storage => :s3, | |
| :s3_credentials => "#{Rails.root}/config/amazon_s3.yml", | |
| :path => "widgets/:id/file/:normalized_file_file_name_:style.:extension", | |
| :url => ":s3_alias_url", | |
| :s3_host_alias => "#{S3Config[:bucket]}", | |
| :styles => lambda { |attachment| attachment.instance.file_styles } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def gravatar_url(email,options = {}) | |
| require 'digest/md5' | |
| hash = Digest::MD5.hexdigest(email) | |
| url = "http://www.gravatar.com/avatar/#{hash}" | |
| options.each do |option| | |
| option == options.first ? url+="?" : url+="&" | |
| key = option[0].to_s | |
| value = option[1].to_s | |
| url+=key + "=" + value | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| ################################################################################ | |
| ENV["RAILS_ENV"] = ARGV[1] || 'development' | |
| require File.dirname(__FILE__) + '/../config/environment' | |
| require 'mechanize' | |
| path = '/root/path' | |
| File.open(File.join(path, 'climatempo.txt', 'w+')) do |f| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pt-BR: | |
| errors: | |
| messages: | |
| not_found: "não encontrado" | |
| already_confirmed: "já foi confirmado" | |
| not_locked: "não foi bloqueado" | |
| devise: | |
| failure: | |
| unauthenticated: 'Para continuar, faça login ou registre-se.' |