Comments

First of all here is a small video with highlight of R

Installation

First of all, prerequisites for installing R with homebrew is XQuartz and homebrew itself. You can find XQuartz here.

The installation itself is just couple of lines:

1
2
3
brew update
brew tap homebrew/science
brew install gcc r

That’s it, to test your environment just type r in the terminal and you will be prompted to r shell. To quit it use q() command.

If you are using zsh shell you also need to disable binding for r(by default it’s mapped for repeating last command). You can do so by adding disable r line to the .zshrc file.

Comments

I’m frequently find myself in need to measure request time of remote request from my application to an API or service. Previously, i used simple block of ruby code with start_time and end_time. Finally i decided to find out more robust method of doing so. I’m using faraday gem for remote requests, because it’s easy extendable by middlewares and great overall. You can take a look at the project with collection of middlewares for faraday on github. This project contains Instrumentation middleware that we will use for tracking time of our request.

Before we start, here is an image of Dr. Faraday from LOST:

By the way github handle of faraday author is @lostisland. Coincidence? I don’t think so :)

Read on →
Comments

Jenkins

This is a short guide on how to setup Jenkins(Hudson) for Rails project with cucumber features. The steps are described for Ubuntu machine. First of all – what is Jenkins?

Jenkins is an award-winning application that monitors executions of repeated jobs, such as building a software project or jobs run by cron. Among those things, current Jenkins focuses on the following two jobs:

  • Building/testing software projects continuously, just like CruiseControl or DamageControl. In a nutshell, Jenkins provides an easy-to-use so-called continuous integration system, making it easier for developers to integrate changes to the project, and making it easier for users to obtain a fresh build. The automated, continuous build increases the productivity.
  • Monitoring executions of externally-run jobs, such as cron jobs and procmail jobs, even those that are run on a remote machine. For example, with cron, all you receive is regular e-mails that capture the output, and it is up to you to look at them diligently and notice when it broke. Jenkins keeps those outputs and makes it easy for you to notice when something is wrong.

Let’s install Jenkins with following commands:

Read on →
Comments

Nowadays almost every Rails application interact with the remote service or API. The problem is that you can’t fully trust those services and you forced to add a lot of test coverage and exception handling for this part of code. Once i worked with the API that had mirror server for case when the main one is unavailable. I write a middleware for Faraday, which will use backup host(provided by user) if the original one is unresponsive.

Read on →
Comments

I want to share my experience with multiple database and Rails 3.2 application. Today on one of my project i was in need to implement support ticketing system. Database for this system was already working for a good amount of time, so i was forced to use it as a source. So let’s start, first of all we should create base class in the /app/models/, so we can inherit models, that will use external database as source.

app/models/support_base.rb
1
2
3
4
5
6
7
8
class SupportBase < ActiveRecord::Base

  self.abstract_class = true

  databases = YAML::load(IO.read('config/database_support.yml'))
  establish_connection(databases[Rails.env])

end
Read on →

Copyright © 2014 - Mikhail Nikalyukin - Powered by Octopress