Never use SET GLOBAL sql_slave_skip_counter with a value higher than 1

If you have a replication error with MySQL and you know the "error" is okay (e.g. you've executed the same statement at the same time on 2 masters which sync each other), you can skip this error and continue with the replication without having to set up the slave from the ground up.

stop slave;
set global sql_slave_skip_counter = 1;
start slave;

But what if you have multiple errors which you want to skip? (e.g. you've executed multiple statement at the same time on 2 masters which sync each other)
Still do not use a value highe...

Ruby 1.8.7: Bundler crashes with "deadlock" and core dump

Error

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

... followed by a backtrace, memory map and more.

Fix

The culprit seems to be Bundler 1.14 when used with Ruby 1.8.7. [Downgrade to the maximu...

Error "undefined method last_comment"

This error message may occur when rspec gets loaded by rake, e.g. when you migrate the test database.

NoMethodError: undefined method 'last_comment' for #<Rake::Application:0x0055a617d37ad0>

Rake 11 removes a method that rspec-core < 3.4.4 depends on. To fix, lock Rake to < 11 in your Gemfile:

  gem 'rake', '< 11', # Removes a method that rspec-core < 3.4 depends on

RSpec matcher to check if two numbers are the same

You can usually just use the eq matched to compare two numbers:

expect(deal.total).to eq(120)

If the actual value is a BigDecimal, you might have issues when you match it against a Float:

expect(deal.total_price).to eq(1200.99)

In these cases, try matching it against another BigDecimal:

expect(deal.total_price).to eq BigDecimal(1200.99)

If you don't like the syntax, our rspec_candy gem has a matcher that will compare Fixnums (integers), Floats and `BigDecima...

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: false # Fixes a security issue
  gem 'listen', '< 3.1' # 3.1 requires Ruby 2.2.5

It is not possible to install guard-livereload 2.5.2 on Ruby 1.8.7 because it depends on guard 2.8, which requires Ruby 1.9.

eventmachine 1.0.3 failing to install native extensions

Try updating to 1.0.4 right in the Gemfile.lock.

JSONP for Rails

The rack-contrib gem brings a JSONP middleware that just works™. Whenever a JSON request has a callback parameter, it will wrap the application's JSON response appropriately.

The project is a bit dated, but the JSONP middleware is ok.

Sass: Don't put CSS rules into partials that you import multiple times

TLDR: When you put CSS rules into a partial and import that partial multiple times, the CSS rules will be duplicated in the compiled CSS.


Here is a Sass partial called _fonts.sass that contains both CSS rules and a mixin:

@font-face
  font-family: SuperType
  src: url('supertype.woff')
  
=title-font
  font-family: SuperType

This _fonts.sass is not practical in CSS projects that are organized over multiple files: When you...

[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 for a while. They seem to have made significant progress running Rails, reducing start-up time and becoming runtime-independent of the JVM.

Also see [Running Optcarrot, a Ruby NES emulator, at 150 fps with the GUI!](https://eregon.me/blog/2016/11/28/optcarrot.htm...

Geordi 1.6.1 released

  • dumple uses --clean option for PostgreSQL/pg_dump

An Introduction to Sending HTML Email for Web Developers

A comprehensive introduction to sending HTML emails.

Intro:

HTML email: Two words that, when combined, brings tears to a developer’s eyes. If you’re a web developer, it’s inevitable that coding an email will be a task that gets dropped in your lap at some time in your career, whether you like it or not. Coding HTML email is old school. Think back to 1999, when we called ourselves “webmasters” and used Frontpage, WYSIWYG editors and tables to mark up our websites.

Table of Contents

  • Introduction To Sending Email Link
  • Email List B...

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 number of directories.
However, it is disabled by default on most systems. Here is how to enable it.

If you check your globstar shell option, it is probably disabled:

$ shopt globstar
globstar           off

In that case, ** behaves just like * and will match exactly 1 directory level.

$ ls spec/**/*_spec.rb
spec/models/user_spec.rb

To enable it, run

shopt -s globstar

The double ast...

Chartkick

Create beautiful Javascript charts with one line of Ruby.

Promising chart library for easily rendering charts with Google Charts.

This seems to not submit your data points to Google.

Use Memoizer instead of ActiveSupport::Memoizable

ActiveSupport::Memoizable will be removed from Rails and has a lot of strange caveats that will ruin your day.

Use the Memoizer gem instead. It works in all past and future Railses and has none of the annoying "features" of ActiveSupport::Memoizable. It just does memoization and does it well.

The syntax is similiar also:

class Foo
  include M...

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_s.

For the examples below, consider the following Regexp object.

regexp = /^f(o+)!/mi

to_s

Using to_s will use a format that is correct but often hard to read.

>> regexp.to_s
=> "(?mi-x:^f(o+)!)"

inspect

As the Ruby docs say:

...

Puppet: Could not evaluate: Field 'device' is required

If you get an error like this for a puppet mount:

$ > puppet agent --test 
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for example.makandra.de
Info: Applying configuration version '1483001792'
Info: Computing checksum on file /etc/fstab
Info: FileBucket got a duplicate file {md5}34b9adc036cf1dbd2392df84f921547d
Notice: /Stage[main]/Foobar/Swap_file::Files[default]/Mount[/var/swapfile]/ensure: defined 'ensure' as 'defined'
Error: /Stage[main]/Foobar/Swap_file::Files[default]/Mount[/var/s...

Search everywhere in RubyMine

Have you tried the Search everywhere dialog? You can open it by pressing Shift twice.

search_everywhere.png

Font Combiner

Font Combiner offers a way to tweak and adjust any TTF or OTF font (license permitting), by bringing in font glyphs as vector shapes, providing a completely overhauled font generated to the user's specification with alternative metrics options, alternative hinting types, kerning and spacing options and the facility to make any average free font look great.

Examples are here

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)

Here is what happened:

  • You installed a recent version of Rubygems
  • You installed some gems that install a binary (like bundle, rake or rails) with code that only works with modern Rubygems versions
  • You downgraded Rubygems to an older versions, which doesn't change any binaries
  • When calling binaries with the old Rubygems version, it cannot process the line Gem.activate_pin_path(...) that was written out by th...

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 net-ssh. It has no dependencies so it shouldn't update other gems.

If you're using Ruby 1.8.7 and want to update net-ssh to a version > 2.9.1 you also need to add this to your gemfile:

gem 'backports', :require => false

... and in your deploy.rb add this:

require 'backports/1.9.2/array/select' 

Background

You propably have an older version of Capistrano and thereby an older version of `n...

Passenger 5/6 requires a config.ru file to run Rails 2.3 projects

Put the following into config.ru in your Rails root folder:

# Require your environment file to bootstrap Rails
require ::File.dirname(__FILE__) + '/config/environment'

# Dispatch the request
run ActionController::Dispatcher.new

Otherwise, your Rails 2.3 project will not be considered by Passenger 5+ and you will probably see 403 errors returned by nginx or Apache.

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 gems are missing from the DEPENDENCIES section: 'archive-tar-minitar' 'hoe' 'rcov'

This happens when you are using a new version of Bundler with a project that was bundled with a very old version of Bundler. For reasons unknown, the Bundler dependency API returns different dependencies for some gems (like ruby-debug or rainpress) than the dependencies found in the downloaded gemspecs. While old versi...

Angular: Quick and easy animation on changed binding value

With ngAnimate, you can easily animate certain events (see directive support). We'll make use of ngClass animations to style an element on changed binding value.

Say we have a slider and a separate details container. Each time the slider changes, we want to "flash" the details container by hiding it and fading it back in.

HTML

Add a custom class to the element you want to animate, i.e. the details container:

<div class="details slide-index-{{ currentSlideIndex }}">
  {{ co...

A collection of graph and diagram tools