Imanel's blog

by Bernard Potocki

Read this first

Moving forward with WebSockets

Two years ago I created LibWebSocket - gem designed to abstract complicated WebSocket API and make it easy to use. During this time a lot things happened - several big gems started using LibWebSocket (like Selenium-Webdriver and Pusher), and it was downloaded nearly 1,5 million times. A lot changed in WebSocket world itself - couple drafts passed, specification was standardized and most browsers implemented native support for WS protocol.

But time passes and old solutions needs updates. Unfortunately, because big changes in specification it’s impossible to keep LibWebSocket up to date - mostly because of new features that are incompatible with some design decisions made during creation of LibWebSocket. Because of that I decided that best option is to rewrite it from scratch, with new standards in mind. As a result I would like to announce new gem: WebSocket-Ruby.

Most of you will ask

Continue reading →

How to change default search engine in Safari 6?

When new Safari will be released plugins like Safari Omnibar will be obsolete - new Safari has functionality similar to Chrome Omnibox. Yet - one function is missing: option to change search provider. I’m pretty sure that a lot of us use plugins like SafariOmnibar not just to integrate Google Search with URL bar, but also to be able to use different search providers than Google, Bing and Yahoo.

Good news: it is still be possible to use custom search. Bad news: it’s little different that earlier.

If you want to integrate multiple search engines like Wiki, Youtube, Quora and many more, then I would suggest to use to DuckDuckGo and it’s awesome !Bang syntax - not only it will allow accessing multiple search engines, but will provide much more functionality than standard Google.

 How to change provider to DuckDuckGo?

I know that there’s a lot of scary methods around net that will show you

Continue reading →

How to install MySQL Ruby gem in OS X Snow Leopard

I know this was posted multiple times by other people, but this information is scattered and hard to find so I’m posting quick summary.

First of all you must download MySQL binary. Be aware that ruby gem will not work with version newer than 5.1, and in Snow Leopard you should use 64-bit version.

After installing it(it should land in /usr/local) you can start compiling mysql gem. In order to do so you need to specify arch flags and path to your mysql dir:

env ARCHFLAGS="-arch i386" gem install mysql -- \
  --with-mysql-dir=/usr/local/mysql \
  --with-mysql-lib=/usr/local/mysql/lib \

Note that if you are using rvm then you shouldn’t install it in @global gemset - bundler will not see that and will try to recompile it again. So you will need to run this command for every gemset you will be using.

Continue reading →

Building WebSocket server in Ruby

Vti’s post about building WebSocket server inspired me to write another one, but this time about both server and client in Ruby.

Currently we have couple of great implementations of WebSocket in Ruby - em-websocket, web-socket-ruby or sunshowers to name a few. And looking at each one of them I can see two things - they all are great, and they all are alone. What I mean?

Github alone says that there are 40 projects in Ruby connected to WebSocket. Some of them are basing one on another, but there are more than 15 server implementations from scratch. Only two support both Draft 75 and Draft 76. And only one support newer drafts. Am I only one who see the problem?

That’s why I built LibWebSocket library whose main purpose is to eliminate the problem of aging server implementations - wrapper around multiple drafts of WebSocket with common API that any server implementation can build

Continue reading →

Socky Announcement

Meet Socky - the ultimate open-source, cross-platform, secure push server solution for your web applications! Socky uses standard WebSockets where available, with graceful fallback to Flash-based component making it usable even on mobile devices running iOS, Android and other Flash-enabled browsers.

Socky project consists of two independent tools - the Ruby-based push server and client-side library. Socky was developed with performance in mind - the server scales well among any number of hosts and can handle thousands of users on a single host making it perfect for things like chat, broadcasting and other real-time communication features.

What makes Socky different from the competing products? It’s is free of charge, doesn’t require any external servers, uses web standards where possible and has few dependencies making it the easiest, cheapest and most universal solution. Over 700

Continue reading →

Web standards in mobile browsers

For the past few weeks I focused on developing Socky - new WebSocket based push server for Ruby on Rails. Its main advantage was to be working well in places where there is no flash - like iPhone or iPad. It is therefore obvious that I became very sensitive to standard implementation in so called “modern browsers” - also mobile ones. So, taking the opportunity of just released iOS4, I decided to write a few words about standard support in mobile browsers.

First tested was the latest iOS4 - loudly advertised as a strong HTML5 supporter. A set of rapid tests showed that the most important elements actually works flawlessly - audio and video, geolocation or SVG. Also, elements such as CSS 3 border-radius, CSS animations and reflections are working properly. But the most important feature for me, WebSockets, is missing. I don’t understand why this protocol isn’t there, when in lately

Continue reading →

CSS3 in every browser with SASS and PIE

Recently, more and more popular is the use of the HTML5 and CSS3. Everyone rushed to them and this is perfectly understandable - after all, developers will be able to bet on semantic instead of doing work arounds for some browsers. But the problem is that at the moment even the “modern” browsers have problems handling some common attributes. The most common example is the border-radius, which has up to three versions - so if we want all browsers display the same rounding, we need to write this as:

#round_me {
  -moz-border-radius: 1em;
  -webkit-border-radius: 1em;
  border-radius: 1em;

And this isn’t “uniformity”, but hopefully that for some time only one of them will be needed. At the moment we need to put the whole set every time. And we often forget - as the example GitHub who sometimes remember and sometimes not to use “border-radius.”

Fortunately, if you use the help such as

Continue reading →

Cucumber testing for multiple users - continuation

A little over a month ago you could read my article about real-time applications testing using Cucumber. In the meantime a new version of Cucumber emerged with Capybara support added. Since the previous method posed several problems during system to system migration (especially Snow Leopard hacks occasionally did not work in other systems) we’ll try a new approach - this time working OOTB in every system.

As always, I will not describe the installation nor configuration process (you can find this in Capybara’s documentation) so let’s get straight to the practice. By default Capybara does not allow you to open multiple browser instances. According to the main developer - “it’s impossible by design”. As they say - It’s impossible. But doable ;) After taking a glance at Capybara’s code (I must admit that it is written quite nice) I found a couple of points where you could bypass this

Continue reading →

Testing Juggernaut using Cucumber and Selenium

During tests development you usually use well-known and tested solutions like RSpec or Cucumber + Webrat. They let you develop in a fast and convinient way. Unfortunately there are times when you need to get you hands dirty. If your application use only javascript then Celerity may help. But as soon as you incorporate Flash or Java into your application things get much harder. For such situations the Selenium framework should be well-suited. It lets you test your app by simulating user actions through any (supported) web browser. Connection of Selenium and Cucumber seem to be very interesting option too - for more details look at Cucumber wiki.

By default Cucumber uses one browser to open your application and perform selected tests. But from time to time you may need more instances to run in parallel mode - e.g to test real-time user communication. Luckily there is an easy way to

Continue reading →

Accents in Sphinx

When writing web applications you need to use full-text search from time to time. Sphinx or Ferret may be of interest to you in such situation. I do prefer the Sphinx because of its speed and ease of use. But it can pose a problem for you from time to time - especially when searching in languages with accents. By default it does not convert UTF-8 properly - Sphinx treats characters outside the ASCII default set as the separation marks. You can find many pages with a simple solution to this issue - just add appropriate conversion rules to the configuration file:

charset_table: "0..9, a..z, _, A..Z->a..z, U+00C0->a, U+00C1->a, U+00C2->a, U+00C3->a, U+00C4->a, U+00C5->a, U+00C7->c, U+00C8->e, U+00C9->e, U+00CA->e, U+00CB->e, U+00CC->i, U+00CD->i, U+00CE->i, U+00CF->i, U+00D1->n, U+00D2->o, U+00D3->o, U+00D4->o, U+00D5->o, U+00D6->o, U+00D9->u, U+00DA->u, U+00DB->u, U+00DC->u, U+00DD->y,

Continue reading →