Issues of Control Flow logic in Respond To Blocks

The following code was written by my boss to simulate an issue arising with a production app that I've been working on at work. class RacersController < ApplicationController def race @racer = Racer.first @was_in_if_block, @was_outside_if_block = false, false respond_to do |format| if @racer.name

Written By
Sohaib Talaat Bhatti on Rails, Bug

Ruby Deep Copy

The fundamental difference between the dup and clone method provided by ruby is that dup does not copy the eigenclass. Also it does not copy the frozen state of the object in question. Both are shallow copies. class Testing def hello p 'calling from class' end end foo = Testing.new

Written By
Sohaib Talaat Bhatti on ruby

Human Action Recognition - Part 2

The Data-set Oddly, the most daunting and frustrating part of the project was creating the data-set. Videos were cropped from the moment the ball left the hand of the bowler to the execution of the shot by the batsman. A total of 267 such videos from 3 different matches from

Written By
Sohaib Talaat Bhatti —

Human Action Recognition - Part 1

This is by far the coolest academic project I've ever worked on. The aim of the project was to be able to develop a system, that could observe the strikes of a cricket batsman and label what kind of a stroke or shot he is playing. Matlab was used for

Written By
Sohaib Talaat Bhatti —

Method invocation in Ruby

Lets have a look at the code below. Any idea to what the output will be? module Foo def print_salutations hello end def hello p 'hello from Foo' end end module Bar def hello p 'hello from Bar' end end class MyClass include Foo include Bar end MyClass.new

Written By
Sohaib Talaat Bhatti —

Importing dates from spreadsheets in Ruby

I encountered an interesting issue yesterday. While importing data present in an xlsx file, I noticed that dates present in the excel file were being imported as numerical floats. My original code below DATE_COL = 10 2.upto(10) do |i| ... excel_file = Excelx.new("#{Rails.root}/temp/final_cand

Written By
Sohaib Talaat Bhatti on Ruby, Excel