Nitish Upreti

Musings on Code , Technology and the Entrepreneurial world.

The Overwhelming Urge to Success

| Comments

I have an overwhelming urge to succeed. It is almost overpowering.

Things I care deeply about :

“Programming as a craft”, “Authority on web engineering”, “Disruption on a large scale”, “Building brands that last for decades to come” and “Enriching millions of lives”.

Journey is the reward.

A List of Rails Best Practices

| Comments

Today I was watching the codeschool’s Rails Best Practices screencast and learnt a couple of new insightful things. This post is to document the ones I can quickly recall. For a detailed version watch the screen-cast itself!

Here is the list :

  • Fat Models and Skinny Controllers is the law of the land (Take code out of your controller in your model).
  • Avoid setting instance variables in a private controller method.
  • Use ActiveModel::Conversions for dealing with models which are not persisted in the database.
  • Try the ‘REST’ approach when designing your controllers. However do not overdo it with multiple levels of nesting and urls such as /users/1/posts/2/comments/3.
  • Use Presenters to avoid setting multiple instance variable in a single controller action thus making your code testable and maintainable.
  • Implement caching with ActiveSupport::Memoizable.
  • Reject SQL-Injection by never writing code which reads like : User.where("id = #{params[:id]}")
  • Ensure indexes creation in your database for faster query load times.
  • Use a server monitoring tool such as newrelic.
  • Use Rails Date Helpers to increase readability of your code.
  • Use ’seeds.rb’ to populate your database with seed values.
  • Use pluralize method to pretty print a singular word unless count is 1.
  • Use find_each instead of find for batch-processing and thus avoid rails trying to load millions of record at once in the memory.
  • Override the to_s method in a model to define how should its string representation be.
  • Use to_param in a model to build seo and human friendly urls.
  • NEVER EVER fire a query from a Rails view.
  • Avoid rail’s partials using instance variables, instead pass local variables to a partial on invocation.
  • Use try to invoke a method on a object without having to worry if a NoMethodError exception will be raised. Example : user = User.find_by_login("wolfman") followed by user.try(:email)

What best practices do you follow in Rails? Hit the comments button and let me know! :)

Node.js Hack Ideas: Analytics & Predictions for Graduate Admissions

| Comments

Waiting for Graduate Results from US colleges pretty much sucks! With no definitive deadlines for result declarations and almost no way to guessing if you will be accepted, the wait is tiring and also many a times frustrating.

Applying for Masters in Computer Science this year, I have been in a similar state since the past one month (though I have an offer from Penn State already). In my hours of desperately waiting for results, GradCafe has been of much help. GradCafe has a forum like board where students can post on their result updates and other ‘desperate’ students like me can follow up on the admission status for a university.

For instance: After multiple students received a series of acceptance letters from Austin Texas and before the college could officially reject me, I pretty much knew my fate.

For lazy folks, here is a GradCafe screen-shot to give you an idea:

Recently I have been quite intrigued by Node.js. I also hacked on some code but then lost interest on the project idea after a while. After procrastinating for few weeks, it is time to get back to node. This time with a more challenging and meaningful idea.

I believe a small web application which crawls all this data and then provide analytics on results date, percentage of admits, average accepted GRE scores for the program etc is feasible. Also with simple NLP capabilities and a machine learning model, we can perhaps overtime predict if a student has a chance of getting admitted. A room for a hack definitely exists.

Is Node.js perfect fit for the problem in hand? Not a debate for now, as the idea behind the exercise is more of learning node and getting acquainted with a framework like Express and say a package like Mongoose.

A famous quote by Linus Torvalds strikes me : ”Talk is cheap, show me the code.

Lets get cracking now!

What Do You Think of Uncertainty?

| Comments

I am personally not much of an ‘Uncertainty’ fan. Are you?

As a student, life has not much of inherent risk. You study as much as you like, slog a little harder during exams and are good to go. Similarly in a job, you meet your daily expectations and receive your fix salary in the end.

Things change a lot when you are working for yourself. The efforts you put in have at times no definite measurable output or outcome. Perhaps a tiny bit of you doubts yourself for undertaking the work. Maybe having a boss is actually good?

As Humans we fear Uncertainty and Unknown (Also explains the fear of dark, strangers and supernatural). There is also a part of us which is thrilled by it. However, even if you seek stability all the time , it is always good to be in different shoes. You then get to experience the world with a different mindset. The transition can be tough at times but it feels good to get out of it.

Reminds me of a beautiful quote, Taking no risk is The Greatest Risk of All.

Pursuing something similar, I hope to learn a lot! :)

End of Year Contemplation

| Comments

This is the ‘end of year’ post where I contemplate on the year. In an ideal world, the post would be about my entire year at a glance. However, for now, I am just writing on things I need to keep in my head.

Here I go :

Confront things and Handle Pressure.

Running away wont help. Attack your fears and win small battles that make you better. Learn to handle pressure.

Get Shit done!

Stop doing nothing wondering if your anyways working. Just get shit done and move on.

Be Flexible, Be Water.

Get rid of strong opinions. Get rid of strong habits. Get rid of the need to be in certain environment and with a specific group of people. Learn to Adapt.

Accept your Flaws.

You have lots of flaws. Learn to accept.

Accept your limited knowledge / experience and work to grow.

Another kid in the town? You don’t have to be like this always. Keep learning.

Fake it till you make it wont work.

Stop fooling around killing time. It wont work in the long run. Time is money.

Don’t settle.

Strive for excellence. Don’t ever settle.

In the end, quoting Steve Jobs, “Have a variety of experiences”. Life is good. :)

Beginning of a Lifelong Entrepreneurial Journey

| Comments

“When an opportunity knocks at your doorstep, you grab it without hesitating.”

Giving a little background, I have a great opportunity this moment to work in a niche ‘Education Software’ Industry in India independently with strong partnership. The risk seems to be quite limited and the gains are projected to be high. Perfect water to step your feet on. Doing something out of your comfort zone, staying motivated on your own and learning loads while building stuff. A test of my ‘mettle’.

Hope to make a small dent somewhere in the universe. :)

Indian E-Commerce Startup Super #FAIL

| Comments

I recently encountered this website 99labels which promises to sell premium brands clothing online. Info Edge is the investor backing 99labels which has a strong repute in India with other investments like Zomato and Naukri. Reading the background first and then visiting the site, I had high hopes from the service. Maybe I have discovered something cool?

So I visit the signup form on the website. Here is a screenshot :

A total WTF moment! The third input box is for your password! A signup form with password in plaintext? Can you forgive this? I don’t think this is something which can go unnoticed. Who is writing this code?

I immediately post a tweet:

So @99labels how are we supposed to take you seriously if you don’t even mask passwords on the sign up form. :|

To which the next day I get a response from them:

Hi, thank you for your feedback. Seems like a technical glitch there. Will have a look at it at the earliest. Sorry about this.

So is this a technical glitch? Designing a form where password isn’t masked? I bleed for humanity.

Have never tried the service and wont be signing up for now. If they cant mask my password, I hardly doubt if they will encrypt it before storing it on their database.