Skip to content

Instantly share code, notes, and snippets.

View andrehjr's full-sized avatar

André Luis Leal Cardoso Jr andrehjr

  • Florianópolis, Imbituba - SC - Brazil
View GitHub Profile
@andrehjr
andrehjr / rails_helper.rb
Created January 12, 2024 12:28
Top slowest factories
def red(text)
"\033[31m#{text}\033[0m"
end
load_begin = Time.now
# This will return slowest factories within the suite
stats = {}
ActiveSupport::Notifications.subscribe("factory_bot.run_factory") do |_name, start, finish, _id, payload|
execution_time_in_seconds = finish - start
@andrehjr
andrehjr / output
Created November 28, 2023 16:24
GoodData resolution fails with Rails 6.0
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
/Users/andrehjr/.rbenv/versions/3.2.0/lib/ruby/site_ruby/3.2.0/bundler/resolver.rb:108:in `rescue in solve_versions': Could not find compatible versions (Bundler::SolveFailure)
Because rails >= 6.0.1.rc1, < 6.0.1 depends on activesupport = 6.0.1.rc1
and rails >= 6.0.2.rc1, < 6.0.2.rc2 depends on activesupport = 6.0.2.rc1,
rails >= 6.0.1.rc1, < 6.0.1 OR >= 6.0.2.rc1, < 6.0.2.rc2 requires activesupport = 6.0.1.rc1 OR = 6.0.2.rc1.
And because rails >= 6.0.2.rc2, < 6.0.2 depends on activesupport = 6.0.2.rc2,
rails >= 6.0.1.rc1, < 6.0.1 OR >= 6.0.2.rc1, < 6.0.2 requires activesupport = 6.0.1.rc1 OR = 6.0.2.rc1 OR = 6.0.2.rc2.
And because rails >= 6.0.3.rc1, < 6.0.3 depends on activesupport = 6.0.3.rc1
# frozen_string_literal: true
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

require 'net/http'
module Net
class HTTP
def self.enable_debug!
# raise "You don't want to do this in anything but development mode!" unless Rails.env == 'development'
class << self
alias_method :__new__, :new
def new(*args, &blk)
instance = __new__(*args, &blk)
instance.set_debug_output($stderr)
@andrehjr
andrehjr / gist:4328db63fc086e12af3c
Created August 18, 2014 21:44
Playing with blocks
def using_blocks(some_array)
some_array.each do |element|
yield element
end
end
using_blocks([1, 2, 3]) { |element| puts element * 2 }
using_blocks([1, 2, 3]) { |element| puts element - 1 }
node git:(master) make test
make -C out BUILDTYPE=Release V=1
make[1]: Nothing to be done for `all'.
ln -fs out/Release/node node
/usr/bin/python tools/test.py --mode=release simple message
=== release test-dgram-empty-packet ===
Path: simple/test-dgram-empty-packet
/Users/andrehjr/work/node/test/simple/test-dgram-empty-packet.js:56
throw new Error('Timeout');
^
@andrehjr
andrehjr / gist:5151783
Created March 13, 2013 12:52
Go links
http://golang.org/ref/spec
http://www.youtube.com/watch?v=ytEkHepK08c
http://commandcenter.blogspot.com.au/2012/06/less-is-exponentially-more.html
http://tour.golang.org/
http://golang.org/doc/install
http://www.youtube.com/watch?v=XCsL89YtqCs
http://golang.org/doc/code.html
http://golang.org/doc/effective_go.html
http://golang.org/pkg/ - use as reference
http://www.youtube.com/watch?v=f6kdp27TYZs
# Never forget :| used against those dynamically loaded another version of libxml annoying stuff.
gem install nokogiri -- --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include
@andrehjr
andrehjr / gist:1575556
Created January 7, 2012 18:23
Installing node
$ git clone git://github.com/joyent/node.git
$ git checkout v0.6.7
$ ./configure --prefix=~/local/node
$ make && make install