Student Unions - Throttle Down

I was on the line with a friend who said “I am stuck on the road for hours, this mother f—–s are blocking the road again”. I had to remind him his past, when he told how protests were fun, but it is not so now, he agreed with a heavy sigh!

Violence is the problem

I am in the grounds, every problem should be solved with a gentle fashion. We talk, we compromise, we vote and then we make legislation. I also believe students should not be ragged physically and mentally but rather be involved in our research and development. Carrying these views was what put me in hot waters once and had to join the minority Anti Ragging groups and be Ala (the ignored).

Protests are a bigger problem than SAITM

Students in public universities led by the Anthare (Inter University Students Federation) are hitting the roads very often. I doubt a single day goes by without them showing up in the news. They have no respect for the countries law, nor for the police who keeps the society safe :sweat:.

The demonstrations make damage to public infrastructure, damage private property, makes congestion so bad, hundreds of thousands of man hours lost every protest :sob:.

They are just adrenaline junkies demonstrating the strength and stupidity of the youth. I guess it is a mating ritual which seems to be working :smile:.

Right for Education

Students in SAITM have a right for education. They pay money and they get educated. It is not some thing you should worry about. Your parents and my mother didn’t have money to get us private education, but we shouldn’t be jealous of their parents achievements. Your worry should be how your parents can be better, not cause worry for the parents who are!

For the record, I personally don’t like SAITM. But I strongly believe we need good Private Universities. I stand strong we should help them correct them selves and if they fail to absorb the university to the government and maintain it as a paid university.

Substandard? No problem!

Our public universities are well established, recognized internationally, better equipped, has the best of teachers and the sharpest (may not be the finest or smart - :stuck_out_tongue_winking_eye: - given their collective behavior) students the country has to offer. Why are we worried about them?

I can’t emphasize enough. Every one has a right to learn from who ever they want. Let them learn. But there are points where as responsible professionals we should be involved to defend.

  • I believe, for at least some time, they should be bared from training in government hospitals. They have their “teaching hospital”. They can surly use that. Or partner with any private hospital for the task. The helpless poor people should not be the lab rats, in my opinion.
  • They should have UGC approval and should meet with SL Medical Council Standards and until then their degrees will not be recognized.
  • There should be a common exam for every (government and private) medical student who seeks join SLMC to face.

Even not meeting this facts, I don’t think any one should intervene with their education.

Abolishing SAITM is not at all a solution. We need private universities to be better and we need more of them!

Ruby Symbol GC Misconception

Its Sunday, but I just finished interviewing a Ruby developer to join my team. He will not be joining the team, but not for reasons posted here.

I showed him a piece of code from that was like…

def hire
  data = JSON.parse(params[:data], symbolize_name: true )
  # more stuff wich included N+1 Query

He was quick to point out that the I am creating symbols from a user input. I was curious why he thought it was a problem and he described that Symbols in Ruby don’t get garbage collected. Knowing it was a little higher than what I expected I asked “which interview question website did you pick it from” and I figured out it was Toptal.

That is not entirely true if you are on Ruby 2.2 or higher.

There are two kinds of Symbols in Ruby. Some are mortal while others are immortal. Most symbols you make dynamically get cleared.

A good article on that matter

Ruby API Testing With VCR

The days of isolated websites and apps are over. Applications interact with one another through APIs to access each others specialization. You should write a Ruby GEM for the task. But how are you going to mock API calls. Answer is vcr will and you don’t!

A simple example would be as follows. The API is written using HTTParty but should work with any thing…

it "fetches price trends" do
  VCR.use_cassette "zumper/san-frasisco-ca/lower-haight" do
    price_trends = Zumper::API.get_price_trends(
      city: "san-frasisco",
      neighborhood: "lower-haight",
    # do some thing with price_trends

Here, on your first call, the response will be recorded by you VCR in to a file. This file will be used to replay the API call making it fast and deterministic.

If you are wondering why…

  • Tests should run fast and HTTP is a notoriously slow protocol
  • Tests need to be deterministic - running on http you might come up with internet errors

I was asked what if the API changes…

Firstly and most importantly, APIs shouldn’t implement breaking changes. End points need to be thoroughly tested and changes shouldn’t break tests. Breaking changes can come from a new version ex: v1 -> v2. But it is not under your control.

Secondly, vcr is for you when developing, so the tests run faster. I normally have a VPS that momentarily deletes vcr cassettes and run tests again.

I am out! Happy & snappy testing!

Back to teaching

I loved sharing my knowledge. In the past I used videos and hosted them on YouTube. I am hoping to make a come back in the next few months. The focus of the first series of video tutorials would be Ruby.

The Ruby tutorial will comprise a starter edition and a pro edition.

The starter edition is targeting newbies to coding. This will mostly be video tutorials and be verbose, so that users can visually follow and understand. This is expected to be named Ruby Lite. I will be using a blog post with details and a slide-show with summary which both will be made available through my website.

The pro edition would be for existing software developers. As an existing software developer learning Scala, I believe video tutorials are a waste of time and test is the best way to go forward.

I am actually writing them for my customers/designers/developers who join my teams so that they get to know the language and eventually the stack (Rails, Sinatra, Padrino, Grape).

So yes, once Ruby is complete, I am intending to make tutorials on Rails, Sinatra, Padrino and Grape. But it will take time.

Split Padrino Controllers

Some things are bigger the better. But some, when they are big, are truly ugly! Code makes the top of that list. I recently opened a Padrino class with 2900+ lines of pure spaghetti. It was traumatic to touch that file that had countless number of actions in it.

Making an admin section? Wondering how to avoid writing every thing in app/controllers/admin.rb? Well you are of luck and the approach is really simple.

Xygen is not its real name.

# file: app/controllers/admin/products.rb
class Xygen::App.controllers :admin do
  layout :admin

  get '/products' do
    @products = Product.all
    render 'admin/products/index'

  # get '/products/:id' do
  # end
  # and so on...

Now that you are splitting code in to files, you might wonder where to add common code.

There are few places you can add them to.

  1. Helpers (my preferred)
  2. app.rb (lets keep that slim too, shall we?)
# file: app/helpers/admin.rb
class Xygen::App.helpers do
  def authenticate
    # your foo doo

And finally use it in your code…

# file app/controllers/admin/products.rb
class Xygen::App.controllers :admin do
  before { authenticate }
  # rest of the code ...