random thoughts

Winter is coming... so protect your eyes with Redshift

As they say - winter is coming - and that’s mean the day is getting shorter and shorter. Nowadays it’s getting dark quite fast out here so maybe it’s time to adjust the color temperature and the brightness of your screen accordingly to the time of the day/night? There are two alternatives that I know of that can help you with that:

Winter is coming... so protect your eyes with Redshift

Free github alternative with private repos - meet Bitbucket

Everyone knows github, right? The github community - that the main power of that site. The amount of open-source projects, drafts, ideas is just overwhelming and nobody can’t neglect that. But what if you have a small team that need some github-like platform for hosting your new top-secret project in private and right now you just don’t have few bucks to spare? Well, you can take a look at bitbucket that got totally redesigned last few days, you can read all about all cool features and tweaks here.
Free github alternative with private repos - meet Bitbucket

Breaking Rails, part 2, putting your RoR inside your PHP

Yo dawg, I heard you like…

Purely theoretical (obviously) case: you have existing php app and some legacy rails code that you refreshed a little bit and now someone asks you one simple question - why can’t you just put that code into that code and run it as one app? Sometimes you can reason, sometimes not. But let’s do it - I mean seriously - let’s create some kind of hybrid that will work transparently and silently for the user. Unleash your imagination and get ready for breaking every programming paradigm; treat it like a sport and get ready :).

Let’s ever get a little bit further, let’s create one rails app that will distribute its content for two different domains. Where do we start?

Breaking Rails, part 2, putting your RoR inside your PHP

Breaking Rails, hackery that you probably shouldn't do - rendering views in model

You may have some reason to break outside MVC model and I won’t give you lecture why you shoudn’t really do it, neither I won’t describe how you will burn in hell for commiting that kind of sin. Instead I will provide a working solution how it can be done. Just as a example of bad pratice :P.

So – how to render view inside model in Rails 3.2?

Breaking Rails, hackery that you probably shouldn't do - rendering views in model

Open source airbrake alternative

Monitoring your applications can be tricky, especially when you have to maintain more and more of them, that uses various technologies. So that’s why programmers helps other programmers with those tasks and nowadays you can choose from various monitoring services. I was mostly focused on airbrake, but overall it seems a little bit pricey for me. I mean it’s a great piece of software that fully supports Ruby on Rails and iOS and there are bunch of addons for PHP, .Net, Java, Python - you name it. But I needed something relatively simple that could allow me to monitor my apps build with RoR and PHP only, and I found shiny piece of code named errbit.

Open source airbrake alternative

Using Factory Girl in development

There is a time when you need to put some random data in your database. Maybe build up pretty frontend or manually test some features. I was using rake tasks that with a little help from Faker, at least until last few days - I needed to upgrade my tasks, but I mean - I had my test factories that were up-to-date, so I thought - why not use them? And so I did ;).
Using Factory Girl in development

Fixing GIT https certificate problem (insecure workaround)

If you are using a git repository over https protocol you may encounter error:

server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://your-git-repo fatal: HTTP request failed

Fixing GIT https certificate problem (insecure workaround)

Efficient use of PostgreSQL full text search with highlighting using pg_search

For some time I was struggling with efficient of ts_highligh function of postgres using Rails and pg_search. I had bunch of really long articles and I wanted to highlight search results in the content as well in the title with the power of tsquery and polish dictionary that we feed our database.

In the end solutions was quite simple really, maybe not the most elegant one but does the job just right and in the end your will end up still with ActiveRecord::Relation, so you can easily paginate your results with will_paginate or kaminari gem.

So, let’s break it down.

Efficient use of PostgreSQL full text search with highlighting using pg_search

Batch ERB to HAML conversion

Quick and useful code snippet that you may want to use eg. while upgrading some old Rails projects. That HAML awesomeness you should use, Luke!

Batch ERB to HAML conversion

Setting up Ubuntu 12.04 Web Server

Last week I’ve got a brand new server to play with ;). The mission was clear (I’m going over there, I’m going to do the mission…) - upgrade, install all essential stuff, prepare and migrate the data from the old machine. So here’s what I’ve done so far (except setting up system accounts, ssh access and all that basic stuff).

Setting up Ubuntu 12.04 Web Server