Calendar quarter calculations in Ruby and MySQL

Posted Almost 12 years ago by Henning Koch.

ActiveSupport >= 3 has Date.parse('2011-02-10').beginning_of_quarter #=> 2011-01-01 Date.parse('2011-02-10').end_of_quarter...

Organize large I18n dictionary files in Ruby on Rails

Posted Almost 12 years ago by Henning Koch.

If you're suffering from a huge de.yml or similiar file, cry no more. Rails lets you freely organize your...

Ruby: Natural sort strings with Umlauts and other funny characters

Posted Almost 12 years ago by Henning Koch.

Why string sorting sucks in vanilla Ruby Ruby's sort method doesn't work as expected with special characters (like...

archan937/ruby-mass

Posted Almost 12 years ago by Henning Koch.
github.com

Introspect the Ruby Heap by indexing, counting, locating references to and detaching (in order to release) objects.

Rails asset pipeline: Why relative paths can work in development, but break in production

Posted Almost 12 years ago by Tobias Kraze.

When using the asset pipeline your assets (images, javascripts, stylesheets, fonts) live in folders inside app: app/assets/fonts app/assets/images...

Random numbers in Ruby

Posted Almost 12 years ago by Dominik Schöler.
dzone.com

A collection of snippets to generate random number under certain conditions, as: gaussian with a specified distribution triangular distribution

Plotting graphs in Ruby with Gruff

Posted Almost 12 years ago by Dominik Schöler.
github.com

Geoffrey Grosenbach has created Gruff for easily plotting graphs. It is written in pure Ruby and integrates with Rails applications...

The Ruby Toolbox – a collection of good gems

Posted Almost 12 years ago by Dominik Schöler.
ruby-toolbox.com

If you need a gem for a certain purpose, be sure to check this site. The rankings are determined by...

Mysterious "margin" below an image

Posted Almost 12 years ago by Dominik Schöler.

Consider the following HTML & CSS: ^ img { background-color: red; } div { border: 1px solid black; } This will leave a margin of...

RubyMine: Set specific Ruby version per project

Posted Almost 12 years ago by Arne Hartherz.

If your project uses another version than your default Ruby, RubyMine will give you incorrect inspections, for example.\

How to use pessimistic row locks with ActiveRecord

Posted Almost 12 years ago by Thomas Eisenbarth.

When requests arrive at the application servers simultaneously, weird things can happen. Sometimes, this can also happen if a user...

Aspect Oriented Programming in Ruby

Posted About 12 years ago by Dominik Schöler.
objectmentor.com

Slides presenting ways to integrate the ideas of Aspect-Oriented Programming in Ruby. Outline Why Aspect-Oriented Programming?

Fix error: can’t find executable rails

Posted About 12 years ago by Henning Koch.

If you get an error like this … can’t find executable rails for rails-3.2.3 (Gem::Exception) … one of several...

OCRA

Posted About 12 years ago by Arne Hartherz.
ocra.rubyforge.org

OCRA (One-Click Ruby Application) builds Windows executables from Ruby source code. The executable is a self-extracting, self-running...

Authorize allowed values with assignable_values

Posted About 12 years ago by Henning Koch.

All our projects have enum-like requirements like this: An attribute value must be included in a given set of...

Convert primitive Ruby structures into Javascript

Posted About 12 years ago by Henning Koch.

Controller responses often include Javascript code that contains values from Ruby variables. E.g. you want to call a Javascript function...

Inspecting a live Ruby process

Posted About 12 years ago by Tobias Kraze.
weblog.jamisbuck.org

How to get a backtrace from a running Ruby process: Ruby 2.6 # First, find out the PID of your Ruby...

Ruby blocks: Braces and do/end have different precedence

Posted About 12 years ago by Henning Koch.
robots.thoughtbot.com

TL;DR {} binds stronger than do … end (as always in Ruby, special characters bind stronger than words) Demo

Use the Ruby debugger on Rails 2 script/runner scripts

Posted About 12 years ago by Arne Hartherz.

This card needs to be updated for Rails 3+. Since there is no --debugger flag you need to run:

Ruby: Making your regular expressions more readable with /x and alternative delimiters

Posted About 12 years ago by Henning Koch.

The following two hints are taken from Github's Ruby style guide: If your regular expression mentions a lot of...

Ruby: Find the most common string from an array

Posted About 12 years ago by Arne Hartherz.
stackoverflow.com

This will give you the string that appears most often in an array: names = %w[ foo foo bar bar bar...

Change how Capybara sees or ignores hidden elements

Posted About 12 years ago by Ulrich Berkmueller.

Capybara has a global option (Capybara.ignore_hidden_elements) that determines whether Capybara sees or ignores hidden elements.

Connecting the "sequel" gem to MSSQL via ODBC

Posted About 12 years ago.

After you configured your ODBC describe in Fix [RubyODBC]Cannot allocate SQLHENV when connecting to MSSQL 2005 with Ruby 1.8.7...

Fix [RubyODBC]Cannot allocate SQLHENV when connecting to MSSQL 2005 with Ruby 1.8.7. on Ubuntu 10.10

Posted About 12 years ago.

I followed this nice guide Connecting to MSSQL with Ruby on Ubuntu - lambie.org until I ran in the following errors...