Make custom web font available within CKEditor content

  1. Make your custom web font available

  2. Add to ckeditor/config.js

    CKEDITOR.editorConfig = function(config) {
      config.contentsCss = [
        '/assets/myCkeditorStyles.css', // any other file to encapsulate custom styles
        '/assets/myFontFaceTags.css'  
      ];
    }
    

It's not enough to provide the font face tags within your public folder. You have to explixitly call it within the ckeditor/config.js.

...

Redis Desktop Manager

"Redis Desktop Manager (aka RDM)— is a cross-platform open source Redis DB management tool (i.e. Admin GUI). Redis Desktop Manager developed to replace a hundreds of slow and ugly tools for redis."

Rails 4 Engines - TechRabbit

At TaskRabbit, we have gone through a few iterations on how we make our app(s). In the beginning, there was the monolithic Rails app in the standard way with 100+ models and their many corresponding controllers and views. Then we moved to several apps with their own logic and often using the big one via API. Our newest project is a single “app” made up of several Rails engines. We have found that this strikes a great balance between the (initial) straightforwardness of the single Rails app and the modularity of the more service-oriented ar...

How to call overwritten methods of parent classes in Backbone.js

When you are working with Backbone models and inheritance, at some point you want to overwrite inherited methods but call the parent's implementation, too.
In JavaScript, there is no simple "super" method like in Ruby -- so here is how to do it with Backbone.

Example

BaseClass = Backbone.Model.extend({
  initialize: function(options) {
    console.log(options.baseInfo);
  }
});

MyClass = BaseClass.extend({
  initialize: function(options) {
    console.log(options.myInfo);
  }
});

ne...

Removing Dot-Underscore Files ~ Kadin2048's Weblog

This is just a quick note, mostly for my own reference, of a few ways to easily delete the dot-underscore (._foo, ._bar, etc.) files created by (badly-behaved) Mac OS X systems on non-AFP server volumes.

RulersGuides.js demo

RulersGuides.js is a Javascript library which enables Photoshop-like rulers and guides interface on a web page

Also available as a bookmarklet.

Checking the character length of a text containing markup (e.g. WSYIWYG)

If you have a text that is edited by WSYIWYG-Editor but want some length checking nevertheless, you need to strip all tags and then the special characters:

  def hard_sanitize(text)
    ActionController::Base.helpers.strip_tags(text).gsub(/[^[:word:]]+/, " ")
  end
   :001 > hard_sanitize("This is <strong>beautiful</strong> <h1>markup<h1>")
   => "This is beautiful markup" 

If you allready have nokogiri on board, you can use that as well, though it has no extra benefit:

   :001 > Nokogiri::HTML("This is <strong>beau...

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+/, " ")
    => "Eine l ngliche Kristall Lampe ber dem Esstisch versch nert jedes noch so kahle Speisezimmer"

You need to use "[^[:word:]]", which is magically given to us by the spirit of the community

    irb> "Eine längliche Kristall §$&&%& ...

Protip: Always leave a failing test

Mornings can be rough. To make them a little easier, leave yourself a failing test if your work isn’t finished. When you come back to the project, it makes it much easier to understand where you were and figure out what you still need to do.

Resolving Element cannot be scrolled into view (Selenium::WebDriver::Error::MoveTargetOutOfBoundsError) on Mavericks

After I upgraded to Mac OS X Mavericks, I regularly got this error message when running Cucumber features with Selenium:

Element cannot be scrolled into view:[object XrayWrapper [object HTMLInputElement]] (Selenium::WebDriver::Error::MoveTargetOutOfBoundsError)

I had the Terminal window running the test on my secondary screen, whereas the Selenium-webdriven Firefox always started on my primary one. Now if I had focused the secondary screen when running the tests, Selenium could not start Firefox and switch to it (probably because t...

We are not normal people

Nice thoughts about marketing and sales for developers.

Ruby number formatting: only show decimals if there are any

Warning: Because of (unclear) rounding issues and missing decimal places (see examples below),
do NOT use this when dealing with money. Use our amount helper instead.


In Ruby, you can easily format strings using % (short for Kernel#sprintf):

'%.2f' % 1.23456 #=> 1.23
'%.2f' % 2 #=> 2.00

However, what if you only want the decimals to be shown if they matter? There is g! It will limit the total number of displayed digits, disregarding...

[Openstack] "Failed to schedule_prep_resize: No valid host was found." when trying to resize an instance

If you get this error while trying to resize an openstack instance:

# nova resize fooinstance 16 --poll

==> /var/log/nova/nova-scheduler.log <==
2014-01-30 17:40:34 WARNING nova.scheduler.manager [req-aaaaaaa-bbbb-cccc-dddd-1ed34b64adef bajd7394hftgs71dba31d642342effa0f bfe2djhg6538sg384jgb82ks070ce0b] Failed to schedule_prep_resize: No valid host was found. 
2014-01-30 17:40:34 WARNING nova.scheduler.manager [req-aaaaaaa-bbbb-cccc-dddd-1ed34b64adef bajd7394hftgs71dba31d642342effa0f bfe2djhg6538sg384jgb82ks070ce0b] Setting ...

git: How to forget a recorded resolution

If you recorded a bad fix for a conflict, you can tell git to forget that bad resolution:

git rerere forget your_file.rb

Afterwards, the badly resolved file will still be in your working directory. To get it back with confict markers, say:

git checkout -m your_file.rb

Resolve the conflict again, properly now. ;)

orgsync/active_interaction

Alternative approach to form models.

ActiveRecord's where.not

Rails 4.0 introduced a helpful new method for ActiveRecord queries: where.not. It can make clunky queries easier to read.

Trailer, a faster and easier way to deal with pull requests

Introducing Trailer from HouseTrip, a simple menu bar app that helps you manage your GitHub pull requests. It’s one feature we felt was lacking from our workflow!

rbenv: How to switch to another Ruby version

If you want to switch to another ruby versions, you have several options, depending on what you want: Do you want to switch temporarily, per project, or globally?
Here is a short guide.

Unlike RVM, rbenv does not offer a command like rvm use. By default, it respects your project's .ruby-version file.

If you need to change manually, you have several options:

  1. rbenv shell
  2. rbenv local
  3. rbenv global

You probably want rbenv shell.

How to switch your Ruby version temporarily: rbenv shell

In case you only want to...

Code Colorizer Formatter — LibreOffice Extensions

Colorizes code in LibreOffice Writer.

Note that you need to create a paragraph style _code for this to work.

krisleech/wisper

Publish/subscribe for Ruby classes. Bonus: You do not have to declare events before using them.

Bash: Setting the title of your terminal tab

If your terminal has many tabs, you'll want to keep them organized. To change their title from the prompt, run this function:

function tab_title {
  if [ -z "$1" ]
  then
    title=${PWD##*/} # current directory
  else
    title=$1 # first param
  fi
  echo -n -e "\033]0;$title\007"
}

Put it into your ~/.bashrc to have it always available. Adjust to your needs.

Usage

$> tab_title
# title set to the current directory's name
$> tab_title new_title
# title set to "new_title"

Auto-setting the title
=================...

Pure CSS Timeline | CSSDeck

Clever hack to allow user interaction without Javascript (by using radio buttons and selecting on :checked).