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
$(window.open().document.body).html( | |
"<style>textarea { font-size: large; font-family: monospace;}</style>" + | |
"<h4>Cucumber failures</h4><textarea style='height: 25%;width: 100%'>cucumber " + | |
$.makeArray($.unique( | |
$('span.red').filter(function() { | |
return (this.textContent).match(/cucumber .+:\d+/) | |
}).map(function() { | |
return $(this).text().match(/cucumber (.+)/)[1] | |
}) | |
).sort()).join(' ') + |
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 ActiveRecord::Base | |
def self.find_each_by(column, options={}, &block) | |
return enum_for(:find_each_by_column) unless block_given? | |
last_value = last_id = nil | |
order = options.fetch(:order, :asc) | |
batch_size = options.fetch(:batch_size, 1000) | |
operator = order == :asc ? '>=' : '<=' | |
loop do |
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
if Rails.application.config.report_model_creation_counts | |
class ReportModelCreationCounts < ActiveRecord::Observer | |
@@creates = Hash.new { |hash, key| hash[key] = 0 } | |
def after_create(record) | |
@@creates[record.class] += 1 | |
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
if Rails.application.config.log_test_names | |
RSpec.configure do |config| | |
config.before(:each) do |x| | |
Rails.logger.info('*' * 10 + 'Start Example: ' + x.example.metadata[:example_group][:full_description]) | |
end | |
config.after(:each) do |x| | |
Rails.logger.info('*' * 10 + 'Finish Example: ' + x.example.metadata[:example_group][:full_description]) |
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
# within app/importer/api.rb | |
module Importer | |
class API | |
# class body here | |
end | |
end |
This file has been truncated, but you can view the full file.
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
2012-01-27 18:12:33,517 [4154324] INFO - plication.impl.ApplicationImpl - Not enough pooled threads; creating one at: | |
java.lang.Throwable | |
at com.intellij.openapi.application.impl.ApplicationImpl$1.newThread(ApplicationImpl.java:150) | |
at java.util.concurrent.ThreadPoolExecutor.addThread(ThreadPoolExecutor.java:672) | |
at java.util.concurrent.ThreadPoolExecutor.addIfUnderMaximumPoolSize(ThreadPoolExecutor.java:721) | |
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:657) | |
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:78) | |
at com.intellij.openapi.application.impl.ApplicationImpl.executeOnPooledThread(ApplicationImpl.java:425) | |
at com.intellij.openapi.project.FileContentQueue.queue(FileContentQueue.java:85) | |
at com.intellij.openapi.project.CacheUpdateRunner.processFiles(CacheUpdateRunner.java:72) |
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
# A small DSL for helping parsing documents using Nokogiri::XML::Reader. The | |
# XML Reader is a good way to move a cursor through a (large) XML document fast, | |
# but is not as cumbersome as writing a full SAX document handler. Read about | |
# it here: http://nokogiri.org/Nokogiri/XML/Reader.html | |
# | |
# Just pass the reader in this parser and specificy the nodes that you are interested | |
# in in a block. You can just parse every node or only look inside certain nodes. | |
# | |
# A small example: | |
# |
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
require 'net/http' | |
require 'xmlsimple' | |
url = "http://www.user-agents.org/allagents.xml" | |
xml_data = Net::HTTP.get_response(URI.parse(url)).body | |
data = XmlSimple.xml_in(xml_data) | |
agents = data['user-agent'].select{|agent| type = agent["Type"].first; type.include?("R") || type.include?("S")} | |
agent_names = agents.collect {|agent| agent["String"].first} |
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
SELECT CASE WHEN total IS NULL THEN '' ELSE name END AS table, | |
index, | |
pg_size_pretty(size) AS size, | |
CASE WHEN total IS NULL THEN '' ELSE pg_size_pretty(total) END AS total | |
FROM | |
(SELECT name, | |
index, | |
size, | |
total | |
FROM |
OlderNewer