This file contains 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
tenant_model_class = TenantModel | |
%x[ls app/models/].split("\n").each do |w| | |
begin | |
model = w[0...-3].camelize.constantize | |
k = model | |
while k != Object | |
if k == ActiveRecord::Base | |
unless model.include? tenant_model_class | |
puts model | |
end |
This file contains 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
[15:10] gregoriokusowski: lunks | |
[15:10] gregoriokusowski: no git | |
[15:11] gregoriokusowski: quero commitar tudo numa paulada | |
[15:11] lunks: git commit -m 'paulada' | |
[15:13] gregoriokusowski: aí q tá | |
[15:13] gregoriokusowski: ele não adiciona | |
[15:13] gregoriokusowski: aí faço git commit -am "paulada" | |
[15:13] gregoriokusowski: e ele não pega os untracked | |
[15:13] gregoriokusowski: mas se faço git commit -uam "paulada" | |
[15:13] gregoriokusowski: n rola |
This file contains 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
%x[ls -R app/models/].split("\n").each do |w| | |
begin | |
w[0...-3].camelize.constantize.unscoped.each{ |u| u.update_attribute(:company_id, Company.unscoped.first.id) } | |
rescue | |
end | |
end |
This file contains 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
# how to use(and abuse) it: | |
# chronno_trigger_ftw! { my_model_instance.update_attributes(:updated_at => my_custom_date) } | |
def chronno_trigger_ftw!(&block) | |
Customer.record_timestamps = false | |
yield | |
Customer.record_timestamps = true | |
end | |
# a threadsafe with ensure block: |
This file contains 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
# https://github.com/jnicklas/capybara/issues/450 | |
# hack | |
ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do | |
def current_connection_id | |
# Thread.current.object_id | |
Thread.main.object_id | |
end | |
end | |
# https://github.com/timcharper/spork/wiki/troubleshooting |
This file contains 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
#how to set spork | |
require 'spork' | |
Spork.prefork do | |
#my old spec_helper.rb here ;) | |
end | |
Spork.each_run do | |
load_schema = lambda { |
This file contains 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
#clazz must be the ActiveRecord::Base, and type must be a type symbol | |
def find_columns(clazz, type) | |
clazz.columns.select do |c| | |
c.type == type | |
end.collect do |c| | |
c.name | |
end | |
end | |
This file contains 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
#rubygem: rubyzip | |
require 'zip/zip' | |
#Ex.: Unzip.from("my_file.zip").to("my_folder") | |
class Unzip | |
def initialize(source) | |
@source = source | |
end | |
def self.from(source) | |
self.new(source) |
This file contains 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
require "open-uri" | |
#Ex.: Download.from("www.blablabla.com/my_download.txt").to("my_downloaded_file.txt") | |
class Download | |
def initialize(source) | |
@source = source | |
end | |
def self.from(source) | |
self.new(source) | |
end |
This file contains 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
#let the computer on, then closing the notebook lid | |
gconftool-2 --set '/apps/gnome-power-manager/buttons/lid_battery' --type string 'nothing' | |
gconftool-2 --set '/apps/gnome-power-manager/buttons/lid_ac' --type string 'nothing' |