Rest-ORM for Angular: Restmod

Restmod creates objects that you can use from within Angular to interact with your RESTful API.

Alternative for Ruby singletons

require 'net/http'

module Cheat
  extend self # the magic ingredient

  def host
    @host ||= 'http://cheat.errtheblog.com/'
  end

  def http
    @http ||= Net::HTTP.start(URI.parse(host).host)
  end

  def sheet(name)
    http.get("/s/#{name}").body
  end
end

# use it
Cheat.sheet 'migrations'
Cheat.sheet 'singletons'

Full list of Skype emoticons and icons

Unfortunately, the hidden emoticons are some of the most expressive and useful ones.

Hidden codes

(skype) (ss)
(call)
(talk)
(u) (U)
(o) (O) (time)
(e) (m)
(~) (film) (movie)
(mp) (ph)
(drunk)
(punch)
(smoking) (smoke) (ci)
(toivo)
(rock)
(headbang) (banghead)
(bug)
(poolparty)
(talktothehand)
(idea)
(sheep)
(cat)  :3
(bike)
(dog)

DevDocs - Documentation Browser

DevDocs combines multiple API documentations in a fast, organized, and searchable interface.

Pretty awesome project. You can select multiple docs to be searched simultaneously, offline in your browser. Supports OpenSearch, so you can hit Tab in your Chrome and search your downloaded docs.

Input: Fonts for Code

Customizable font for programming.

Angular directives: How to find out if you have transcluding content

When you have an Angular directive that transcludes content, you might want to do something in case there is no content inside your element, like showing some default content.

Unfortunately, you can not do something like <span ng-transclude>default goes here</span>. Angular will always empty that element's text, even if there is nothing to transclude.

But you can use your directive's link function. Here's some CoffeeScript for you:

    @app.directive 'myStuff', [->
      restrict: 'E'
      transclude: true
      
      te...

MySql lost connection trouble

Directly from the MySql docs:

There are three likely causes for this error message.

Usually it indicates network connectivity trouble and you should check the condition of your network if this error occurs frequently. If the error message includes during query, this is probably the case you are experiencing.

Sometimes the during query form happens when millions of rows are being sent as part of one or more queries. If you know that this is happening, you should try increasing net_read_timeout from its default of 30 seconds to 60 s...

Feedjira

Great gem to consume RSS feeds. I was missing some features on Ruby's RSS::Parser that I found in Feedjira:

  • Speed
  • Does not break on slightly malformed RSS feeds (like a missing length attribute on an <enclosure> tag on gizmodo.de's feed)
  • It automatically resolves Feedburner-mangled URLs (hooray!)

The GitHub project has only a minimalistic readme. You can find its documentation on their homepage.

Iterating over a Ruby Hash while tracking the loop index

You know each_with_index from arrays:

    ['hello', 'universe'].each_with_index do |value, index|
      puts "#{index}: #{value}"
    end
    # 0: hello
    # 1: universe

This also works on hashes. However, mind the required syntax:

    { hello: 'universe', foo: 'bar' }.each_with_index do |(key, value), index|
      puts "#{index}: #{key} => #{value}"
    end
    # 0: hello => universe
    # 1: foo => bar

The reason is that each_with_index yields 2 elements to the block, and you need to deconstruct the first el...

How to undo a 'git reset --hard'

So you erased a whole day's work? There is hope! The linked article tells how to recover from an accidental git reset --hard.

On a Mac

You will need to install GNU find utils as described in this SO post.

Cucumber: Skipping steps in a scenario outline, based on the current example

In Cucumber, scenario outlines help avoiding tests that are basically the same, except for a few variables (such as different inputs). So far, nothing new.

The problem

Now what if your test should (or should not) do something, like filling in a field only for some tests?

    Scenario Outline: ...
      When I open the form
        And I fill in "Name" with "<name>" # <= we want to do this only occasionally
      Then everybody should be happy
      
    Examples:
      | name  |
      | Alice |
      | Bob   |

You could o...

Fixing Ruby debugger: *** Unknown command: "something". Try "help".

So you have placed a breakpoint somewhere and now want to dig around, but not even inspecting variables is working:

(rdb:3) @order_item
*** Unknown command: "@order_item".  Try "help".

The reason is, you must tell the debugger to evaluate your expression. One workaround is to call irb to open an irb session at your breakpoint. Resume by sending Ctrl+D twice or by returning to the outer irb with "exit" and then continuing with "c".

However, the native debugger command for your issue is eval (or its shorter alias `e...

Manually purge binary logs on MariaDB

Open a MySQL root shell and use this command:

PURGE BINARY LOGS BEFORE DATE(NOW() - INTERVAL 3 DAY) + INTERVAL 0 SECOND;

6 front-end techniques for Rails developers. Part I: From big ball of mud to separated concerns

Amazing guide how to divide a ball of Javascript spaghetti distinct separate layers (model, view, controller, backend adapter).

It does not use a Javascript framework.

gazay/ids_please

Parses URLs of social networks to extract IDs or screen names.

It does not get confused by child routes: you may also pass URLs like a user's twitter photo stream and the gem will extract their twitter ID .

Note that it just parses URLs, and does nothing magic like looking up IDs when the URL contains only a screen name (e.g. the Instagram API requires you to send the user ID almost always while you at first only know their screen name).

Rails 4 drops support for the :assets group in Gemfile

Previously the assets group existed to avoid unintended compilation-on-demand in production. As Rails 4 doesn't behave like that anymore, it made sense to remove the asset group.

RSpec 3 no longer chooses a spec's type based on its directory

While RSpec 1 and 2 decided that specs inside spec/model are model specs, and those inside spec/features are feature specs (and so on), RSpec 3 will no longer do that by default.

This will result in errors such as missing routing helpers, etc.

There are 2 ways to fix this:

  • Explicitly set the type on each spec. For example:

    describe '...', type: 'feature' do
      # ...
    end
    
  • Add this to your spec_helper.rb (inside the RSpec.configure block) to restore the old behavior:

    ...

Git: Listing branches with their latest author

Run this command to list the authors of the most recent commit of each branch:

git for-each-ref --format='%(committerdate) %09 %(authorname) %09 %(refname)' | sort -k5n -k2M -k3n -k4n

Credits go to DarVar on SO.

Test if all your favicons exist

When you don't only have a favicon.ico in your project but also PNGs of different sizes and backgrounds, you should test if all those files are actually reachable.

Here are a few selectors to get you started:

    'link[rel~="icon"]' # regular ones, matches "shortcut icon" and "icon"
    'link[rel="apple-touch-icon"]' # iOS
    'meta[content][name="msapplication-TileImage"]' # IE11
    'meta[content][name^="msapplication-square"]' # IE11

A s...

Spreewald 1.1.0 released

Spreewald 1.1.0 drops the be_true and be_false matchers in order to be RSpec 3 and Ruby 2 compatible. For backward compatibility, these matchers are replaced with == true and == false.

Note the slightly more changed semantics of the update.

blatyo/page_rankr

Provides an easy way to retrieve Google Page Rank, Alexa Rank, backlink counts, and index counts.