Include keystrokes in a screencast
To show your key inputs on screen, e.g. for a screencast or screen sharing, you can use screenkey Show archive.org snapshot .
A really useful flag is --show-settings
. Running screenkey --show-settings
shows a settings window, which allows you to easily adjust the key overlay.
The option Select window/region
is especially useful for choosing where the overlay is placed.
Related cards:
How to capture a screen-cast on Linux
Recording
SimpleScreenRecorder
I recommend simplescreenrecorder, it produces an adequate output with only a few clicks. The audio recording contained some static noises, but that might be...
Ruby: Checking if a class is a descendant of another class
If you want to find out whether a Class object is directly inheriting from another class, use superclass
:
ActiveRecord::RecordNotFound.super_class == ActiveRecord::ActiveRecordError # => true
To check if an...
How to load only a subset of a massive MySQL dump
I had a huge MySQL dump that took forever (as in: days) to import, while I actually just wanted to have the full database structure with some data to use on my development machine.
After trying several suggestions on how to speed up slow MySQL du...
Rails: How to provide a public link in a mail
Lets say we have a user
with a contract
whereas contract
is a mounted carrierwave file.
Now we want to send the link to the contract in a mail. For this use case join the root_url
with...
Bugfix: Rails 2 does not find an association when it is named with a string instead of a symbol
Association named 'variations' was not found; perhaps you misspelled it?
I just was hunting down a strange error with this model:
class Model
placeholder = 'variations'
has_many placeholder
nested_scope :v...
Rbenv: How to remove a gem installed from a Github source
Normally you can list all gems of the current ruby version with gem list
, which also includes the gems of you Gemfile
. These can be uninstalled with gem uninstall gemname
.
List and uninstall a gem installed via Bundler from Github
This d...
Test that a hash contains a partial hash with RSpec
To test whether a hash includes an expected sub-hash:
expect(user.attributes).to match(hash_including('name' => 'Bruce Wayne'))
expect(User).to receive(:create!).with(hash_including('name' => 'Bruce Wayne'))
How Ruby method lookup works
When you call a method on an object, Ruby looks for the implementation of that method. It looks in the following places and uses the first implementation it finds:
- Methods from the object's singleton class (an unnamed class that only exists fo...
Associations named using a string cannot be included in a scope
If you defined your association via
class Article
belongs_to "category"
end
and you try
Article.scoped(:include => :category)
you will get an error message
in `preload_one_association': Association named 'cat...
Stripping all non-word-characters (a.k.a \W) and preserve diacritics (a.k.a Umlaute) in utf-8
Sometimes you want to strip a text of every special char. If you use \W, the result might not be what you wanted:
irb> "Eine längliche Kristall §$&&%& Lampe über dem Esstisch verschönert jedes noch so kahle \n Speisezimmer".gsub(/\W+/,...