Rustam A. Gasanov

$ echo "Inspired developer's blog" > /dev/null

Dynamic Session Time Management With Devise

| Comments

From the box Devise has 2 options to manage sessions: rememberable and timeoutable. rememberable utilizes database to store the time when user was signed in and compares it with current time - if the difference is more than config’s remember_for setting the user will be signed out. timeoutable first checks if rememberable is being used and not expired, then compares current time with last user’s request time - the difference is then being compared with config’s timeout_in setting. What if you want to have multiple timeout_in settings for different cases?

How to Use ERB With ECO

| Comments

In my current project we use Rails with Backbone(Marionette). For Rails, it’s essential to use .erb. For Backbone, we use .jst.eco. Everything works fine unless you need Ruby helpers(asset_url/asset_path for example) in JavaScript templates. Here I’ll show how to combine the power of erb and eco template engines.

Iptables Basic Configuration and Saving Tutorial

| Comments

To list existing rules type the following command(as root):

1
% iptables -L

If it wasn’t previously configured, output should be:

1
2
3
4
5
6
7
8
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Which, in short words, means “accept everything” or that firewall isn’t active.
Let’s configure firewall to accept only the traffic we need and then save it.

Adapter Design Pattern Usage in Rails Application on Examples

| Comments

Introduction.

Design pattern called Adapter is used, when there are two or more objects, which need to communicate to each other, but unable to do so, because their interfaces do not match. And the adapter is kind of a bridge between these objects. In Rails framework this design pattern is being heavily used. Particularly, in ActiveRecord, adapters are implemented to communicate with different databases and supply developer with a common interface to use, so you don’t bother whether it is PostgreSQL, MySQL or any other database. In ActiveJob adapters are used to communicate with background job providers, and so on.

Examples.

Ok, let’s move on to practical cases and code examples.