Storing trees in databases
This card compares patterns to store trees in a relation database like MySQL or PostgreSQL. Implementation examples are for the...
ruby-sass: Do not use comments between selector definitions
Sass lets you easily specify multiple selectors at once like this: .some-block &.has-hover, &:hover outline: 1px solid red...
Generating barcodes with the Barby gem
Barby is a great Ruby gem to generate barcodes of all different sorts. It includes support for QR codes via...
ActiveRuby
Looks like ActiveState is trying to market a new Ruby distribution for Enterprises: ActiveRuby Enterprise Edition is designed for businesses...
Running external commands with Open3
There are various ways to run external commands from within Ruby, but the most powerful ones are Open3.capture3 and Open3.popen3...
Ruby: Return boolean for regex comparison
A collection of code snippets which return a boolean value for a regex comparison. regexp.match?(string) # Recommended for Ruby >= 2.4...
Ruby: Benchmarking different implementations against each other with the benchmark-ips gem
Choosing the right gems for your project
Adding a gem means you take over the liability towards the external code. Checklist Based on "To gem, or not...
rbenv: A basic introduction
We have projects that have been developed using many different versions of Ruby. Since we do not want to...
When upgrading/downgrading RubyGems and Bundler on a server, you must clear bundled gems
On application servers, gems are usually bundled into the project directory, at a location shared across deployments. This is usually...
Ruby 1.8.7: Bundler crashes with "deadlock" and core dump
deadlock 0x7f8a4160a360: sleep:- (main) - /home/me/.rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/bundler-1.14.3/lib/bundler/worker.rb:43 deadlock 0x7f8a38c03b08: sleep:- - /home/me/.rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/bundler-1.14.3/lib/bundler/worker.rb:56 *** longjmp causes uninitialized stack frame ***: /home/me/.rbenv/versions/1.8.7-p375/bin/ruby terminated
How to install guard-livereload 2.5.2 on Ruby < 2.2.5
There are some inconvenient Gem dependencies. Resolve them by adding/modifying these lines in your Gemfile: gem 'guard-livereload', '>= 2.5.2', require...
[jruby] TruffleRuby Status, start of 2017
TruffleRuby is an experimental Ruby implementation that tries to achieve ~10x performance over MRI. This has been on our radar...
How to tackle complex refactorings in big projects
Sometimes huge refactorings or refactoring of core concepts of your application are necessary for being able to meet new requirements...
Enabling ** in your bash
You may know the double asterisk operator from Ruby snippets like Dir['spec/**/*_spec.rb'] where it expands to an arbitrary...
Ruby: String representations of regular expressions
Ruby's regular expressions can be represented differently. When serializing them, you probably want to use inspect instead of to...
Fix Rubygems binary error: undefined method `activate_bin_path' for Gem:Module (NoMethodError)
So you're getting an error like this: undefined method `activate_bin_path' for Gem:Module (NoMethodError)
Net::SSH::Exception: could not settle on encryption_client algorithm
TL;DR: Update the 'net-ssh' gem by adding to your Gemfile: gem 'net-ssh', '=2.9.1' Now run bundle update...
Bundler: Gemfile.lock is corrupt & gems are missing from the DEPENDENCIES section
So you're getting this failure when running bundle install on an older project: Your Gemfile.lock is corrupt. The following...
A collection of graph and diagram tools
Plot graphs in Ruby WebGraphviz renders in your browser via JavaScript (to store the rendered graph, extract the SVG using...
Summarizing heredoc in Ruby and Rails
This card tries to summarize by example the different uses of heredoc. In Ruby << vs. <<- vs. <<~ In Rails strip_heredoc...
Linux: Using grep with a regular expression
You can use three different versions of the regular expression syntax in grep: basic: -G extended: -E(POSIX)
Ruby: Writing specs for (partially) memoized code
When you're writing specs for ActiveRecord models that use memoization, a simple #reload will not do: it 'updates on...
Subclassing module
Yesterday I stumbled across a talk in which the guy mentioned module sub-classing. I was curious what you can...