How do we start?

Leave a comment

Hi Guys

Long time no see 🙂 sometimes I feel like I should tell that to myself as well.

So how do we start, we start by noting down what we need to do, and while we are at it, we note down what we didn’t write in the first place and also few more things which you should have thought of before. To do things is to improvise, learn and also to keep on adding more things to do, obviously a to-do list never ends, because to do something or to learn something, you need to do a lot of things 🙂

To understand that lets write a blog post 🙂 This is going to be quick. All you need is rails setup in your system.

Lets start with creating a blank app

rails new todoapp # this will create a blank slate for you to work on

rails g scaffold todo task:string complete:boolean parent_task_id:integer # this will create your model/views/controller/migration etc etc files which you will do the work for you

rake db:migrate # if this throws an error, you gotta do “rake db:setup first” this will create your database migration and the schema for todo tasks.

Now we need to build something like the below to sorta have a parent child relationship between the tasks. Why ? just read the 2nd para again from top.

Parent Task 1
—- Child Task 1
—- Child Task 2
Parent Task 2
Parent Task 3
—- Child Task 1
——– Child Task 2

In your new and shiny app/models/todo.rb add these two lines to create the parent child hierarchy.

has_many :child_tasks, :class_name => 'Todo', :foreign_key => "parent_task_id"
belongs_to :parent_task, :class_name => 'Todo', :foreign_key => "parent_task_id"

Now a bit of magic is needed to the views to allow us to easily select the Parent tasks for any child task.

Head over to your app/views/todos/_form.html.haml or *.erb file depending on the templating engine and change the f.parent_task_id to a collection_select

.field
= f.label :parent_task_id
= collection_select :todo, :parent_task_id, Todo.all + [Todo.new], :id, :task

This will allow us to choose a parent task, whenever we are creating a new task with – not a very bad hack? 😛

Finally in the show and index page, we need to display the parent task.

replace your todo.parent_task_id with
Todo.find_by_id(@todo.parent_task_id).task rescue "No Parent Task"

And the end result is tada!!!

Todoapp

Advertisements

Where do we belong!

Leave a comment

Hey guys!

Writing something down after a long time. I always get these urges to write something, but never do that due to lack of time or investing time in other worldly problems.

Of late, I have been thinking about the direction in which my career is heading. Even though I like my current job, understanding how large manufacturing companies work and implement oracle for them. However it is not entirely what I imagined myself to be doing when I was a kid.

Ofcourse when are are younger, we imagine us to be a lot of things, lots of dreams and then when you grow up, we stop chasing the dreams and start running to just get the things done in front of us. Somehow the tasks at our hand are too pressing and we forget what we always wanted.

All of us want to find our place in the world. Some find it, some make one and some just are happy with what they get. What if you are one of those, who have to make a place for yourself in the world and it is always there in the back of your mind. Even if you choose to ignore it, your sub conscious mind keeps on telling you, you don’t belong here. There are places you must go to and see for yourself, where you fit and if you don’t make a place for yourself. I have always loved Anime series. You get to learn a lot from them.

One of the Characters in the show Nanatsu no Taizai says, if I live long enough, maybe something will happen to me, I am waiting for that something to happen. We long for that something to happen, but it never might. We have very limited time in our hands and cannot wait an eternity for that moment. We have to work towards reaching that moment. We can only wish.

With that wish in my ghost, I will try to find the place where I belong.

 

Stackoverflow ?

Leave a comment

Hey guys!! wassup!

I have been a member of StackOverflow since 4-5 years now, but just recently, I thought, why do I search for answers and not help others with their questions. So I have started answering questions on SO as well. I try to help people with SQL, Web Development related queries and related techs.

Now that I think about it, I am not entirely sure, why I never tried it in the first place, but then again, better late than never. Planning to be active and try to help as many people I can 🙂 come on now, an answer from you, makes their day at office easy 🙂

So yeah! guys go out there and try and be active at communities on stackexchange.

You can find me on SO @ http://stackoverflow.com/users/1013142/sudipta-mondal

Things that matter to me!!

Leave a comment

I have always been thinking, about what matters to me the most. I like coding, I like sweet things, I like to be around people, cute things. I like soft and fluffy things 😛 I like my laptop a lot, like really a lot. I can marry it. If I don’t get to touch my laptop for a few days, I get withdrawal symptoms and after a few days, I just want to hug my laptop 😥

Too many things interest me and I feel, I can’t just keep my head into a single thing, I wanna try out so many things out there. I wanna try A, I wanna try B, till I get hang of B, I wanna try out C or whatever. I am random. ADHD perhaps.. not sure.

I used to live in one of the major cities in India and never ever lived or cared too much about people outside of that big city. Neither did I know much. Thank fully I got to work in a company, where I got to meet people from all over India. I have absolutely loved it.. There are so many people from so many places, with so much varied experiences, talent.

I have learned, I am not smart, I am definitely not intelligent. people are out there, some who think like you, some who are different, some who hate you, some whom you like. But people, so many to experience. I used to think, my way was always the right way, that I was correct in thinking always. I was so god damn wrong, for like 23-24 years of my life 🙂 I have learnt, about mistakes that I had made, thinking they were right. I could do only after meeting so many people. These things were never taught in college or school. These things you can only learn, if you go out there and experience, learn, see, listen.

Go, Get out there, talk to people, share your view, hang out, go to movies, but most importantly listen, to what everyone has to say. Listen and understand. I am sure, you will figure out the real you.

What I am working on

Leave a comment

For a long time, I always wanted to make a one stop dashboard for me, which would allow me to do everything, for which, I have to go to a lot of different websites, Twitter, Facebook, Gmail, WordPress, checking stats of my sites, notifications, calendar, tasks etc etc.

In the end, I gave in to the temptation of making a personal dashboard which would really help me in solving the problem of having so many tabs open in my browser. 🙂

Will keep on blogging about the development on the dashboard and would put a github link soon 🙂

Start of Job hunt

Leave a comment

hey guys!!!

long time no see… So finally after almost 2 years, I am starting to search for a job. These days I feel, finding a job has become like finding the right pair of shoes for you. The ones which fit the bill, aren’t that good and ones which look cool are not that comfortable 😦

Need to find a job which is somewhere in the middle of pay and play. First preference to money though, because in the Immortal words of the Wolf of Wall street – ‘Let me tell you something. There’s no nobility in poverty. I’ve been a rich man, and I’ve been a poor man. And I choose rich every fucking time.’

Life made easy

Leave a comment

I am wondering

Why? always ?

sudo nano file_name
sudo apt-get install whatever
sudo apt-get install -f
sudo apt-get remove

Why not just!! Simplify.

Edit your ~/.bash_profile.

nano ~/.bash_profile

and add something like the following lines, which you use on a daily basis.

alias snano='sudo nano'
alias apt-update='sudo apt-get update'
alias apt-fix='sudo apt-get -f install'
alias apt-remove='sudo apt-get remove'

close and re-open it.

Now you can simply use apt-fix instead of typing sudo apt-get -f install

Life made simpler 🙂

Older Entries