Different types of methods in ruby

FYI, I cross posted over – Coderwall

I was quite surprised seeing how ruby deal with different types of methods. After digging in ruby source code I’ve found out the following types of ruby methods -

This flag is used to any ruby method which is referenced from source code.

VM_METHOD_TYPE_ISEQ

Method which is created on behalf of native C function

VM_METHOD_TYPE_CFUNC

When we are declaring attribute setter using “attr_writer” this flag is used.

VM_METHOD_TYPE_ATTRSET

When we are declaring attribute getter using “attar_reader” this flag is used.

VM_METHOD_TYPE_IVAR

When we are declaring method using “define_method” and passing proc for method body this flag is used.

VM_METHOD_TYPE_BMETHOD

If we are explicitly declaring method scope (private, public or protected) from the class hierarchy, ruby will redeclare method in the child class and mark that one with this flag.

VM_METHOD_TYPE_ZSUPER,

When any method is undef using (undef_method or undef) will be marked with this flag. (Still method exists but won’t respond to)

VM_METHOD_TYPE_UNDEF,

If not implemented c function (which actually refers to rb_f_notimplement function)

VM_METHOD_TYPE_NOTIMPLEMENTED,

This flag is used for separating few set of methods from rest. so that VM can handle them better and optimized way.

VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */

When method_missing is declared and none existing method falls into this loop. This missing method is dynamically generated and flagged as this.

VM_METHOD_TYPE_MISSING, /* wrapper for method_missing(id) */

This is new feature and only introduced in 2.0.0, This one is used when we are using refinement.

VM_METHOD_TYPE_REFINED

See there are 11 types of methods in ruby :) I didn’t know that before. Now i know :)

Four types of ruby closures block, Proc, lambda and method

Ruby is an awesome piece of creation, Everyday I’m learning and discovering ruby in lot different and better way. just like other days today i dug more into how ruby closures work. here is my brief explanation after reading about ruby closures. thanks to the author for his wonderful writeup.

As we know ruby does lotta stuffs with closure, like in array iteration we are using closures in everywhere. Ruby has 4 type of closures – Block, Procs, Lambda and Method. I’m trying to explain them in brief. So i could use this post as my future reminder.

Block

It’s used with ‘&’ sign prefixed variable also executes using yield or *.call.

Procs (Procedures)

Its used as other ruby data types (array, hash, string, fixnum etc..), it’s reusable and could be used across multiple calls. also several procedures could be passed at a time.

lambda

It’s a procedure (Proc) but with required parameter checking.

Also there is another difference between lambda and Proc. Proc’s “return” will stop method and will return from Proc on the other hand lambda‘s “return” will only return it’s own value to the caller method.


Because Proc’s return is just like method’s own return. because it works like reusable code snippet.

Method

Method is another way around in ruby to use existing method as closure.

Thats the brief about Ruby closures. I learned it from hear - http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/

Simple trick to work with ActiveRecord dynamic column and encapsulated accessor

Just writing this so i can remind if i need it again :) I’m in the middle of creating a generic flexible domain modeling module (i call it flexi-model).

In brief flexi-model is schema less flexible modeling tool. It can store your data of any kinda it does trick just providing generic value method and pick up the right column type from preset column definition from model class.

Just to make it easier to grasp here is a sample code -

I’ve the following structure in -

[Collection - for dynamic schema] -< [Record] -< [Value]

On the form I’m using f.datetime_select :value where (f denotes fields_for of Value instance)
after submission rails was trying to figure out what is :value column in table definition.
since it’s not an existing column so rails was throwing up MultiparameterAssignmentErrors error.

Just after digging bit deep it looks like read_value_from_parameters is responsible for loading real column definition.
So to mock it i’ve added the following code and it works –

thants all :)

Simple ruby on rails based application deployment script using nodejs’s control

I’m bit fascinated by what NodeJS lately came up with. So i was just wondering how it could help me on setting up my staging server. I’ve been using Capistrano for a long while so it was suppose to be easy to do another capistrano based deployment. But i’m more into nodejs these days. So searched about what nodejs and other contributors can provide for SSH client implementation. Thus i’ve figured out “Control” is something i’ve been looking for.
Just after couple of hours efforts i could finally complete “Khadok.com’s” staging server deployment. You can check it out here.

Here is my script for those who finds it interesting

PhpXperts seminar 2010 a great success!

Being part of it, i’ve been thinking how perfectly it was crafted, it was so mind blowing that I couldn’t even think how could it be so short. So many interesting topics so many passionate speakers just ignited each of us. Their passionate talk just gave us hope that we can MAKE IT!

PhpXperts 2010 proved once again, Bangladesh is the nation where we have plenty of technologically skilled talents. All we were just waiting for leadership. If we can get space, get air and light we can even grow faster than any.

So being active speaker of phpXperts seminar since 2005, i’ve been awarded once again getting chance to be there. Though being de-touched from PHP community, I didn’t feel that i’m no longer part of it. like always phpXperts community is always a place I feel second home. Because of it’s gearing persons in background.

So one fine day I was called by hasin bhai, he informed me about the new event. So when he asked for my topic. He also mentioned me, “hasan I wanna get some techy stuffs from you this time :)
well, I used to give techy speech but recently I turn to be a motivator speaker due to seeing enough lacking here in our IT industry. I believe, everyone can do whatever they wanna do but they need room to grow up!.

Thanks goes to hasin bhai and his team and sponsors to let it be what it has ended up being :)

These are the few things I loved this time -

  • Allowing companies to sponsor
  • Passionate venue (brac university seminar room)
  • Load of topics
  • So many new speakers
  • Exciting and passionate talks
  • Load of audience
  • Audience active participation
  • Online video streaming

Few suggestions for next event -

  • Splitting event into 2 days long
  • Choosing a bit larger space
  • Asking sponsor companies to bring their best to present on a small sponsor’s showroom.
  • Inviting foreign guest
  • Having phpXperts feast or other events (which might require ticket) where we could have barbeque and dinner together and IT chit chat.
  • Open career hunting panel (so at the end of the event some of them might be awarded by their final job interview)

My presentation on “CodeMan! NoSQL!”

you can download the source file here.

best wishes

WellTreat.Us a Ruby on Rails based SaaS platform to build your restaurant and business web site on it :)

So i guess my blog title reflects what i’m trying to make point here, YES! This is all about running well treat us as a SaaS platform.

Let me draw a line between those who already got it or those who yet struggling :)
well, frankly speaking my weekend goes with my newly started start up “http://welltreat.us

i guess many of those who already have been there might think “Well Treat Us” as a simple platform for reviewing restaurant. This is very true! Indeed, this is a review platform!!

But the fact is far behind the simple review platform :) “Well Treat Us” is a platform for reviewing ANYTHING that matters in our daily LIFE :)

Wait a minute! Did you get it ? “Well Treat Us” domain was intentionally picked up so it could be related with “store.WellTreat.Us”, “electricians.WellTreat.Us”, “CarService.WellTreat.Us”, “BookAuthor.WellTreat.Us”, “Movie.WellTreat.Us”, “Newspaper.WellTreat.Us”, “Doctor.WellTreat.Us”, “Government.WellTreat.Us” and it goes on…

so if you are still not getting the idea! I should blame myself for not succeeding to reaching those above words through your tough skull :)

anyway! In a brief, “Well Treat Us is a platform to read review about our daily mostly used services and products. It helps people and business to grow mutually with feedbacks from each other.”

Ah! let’s back into the topic :)

So by now you should have understood, “Well Treat Us” is a platform where it can be used for reviewing on anythings, though currently you can only see “http://restaurant.welltreat.us” but at certain point you would be able to see everything that matters your daily living. (we promise)

Keeping this in mind, we have been developing WellTreatUs platform following agile and lean mindset. Since our inception we have been adding each and every features based on our visitors opinion. Perhaps you spoke that over review or over facebook fan page or in a friendly discussion, we are listening and keeping your wishes in our product feature list (product backlog). So we can give more efforts to bring those for you :) . we suggest you better don’t feel shy to share what cross your mind.

So let’s back to the main topic :)

“Well Treat Us” as a SaaS (Software As a Service) how that stands up ?

Well, as i’ve already mentioned well treat us is built on the concept of “topic”.
In every data structure there is dependent parent object which we call “topic” so whatever goes through the “Well Treat Us” every contents are put under specific “topic”. This topic based architecture helped us to isolate and identify separate type of contents. (ie. Doctors, books, restaurants, donors, stores etc..)

Just imagine your web site is built on “Well Treat Us” CMS

So as “Well Treat Us” is a platform for hosting several topics dependent review platform, we kept another side around which enables us to provide a complete make over using your own preference to build your own business web site or e-commerce store.

Let me make it more understandable. As you can see today you can browse any restaurant page which looks like the following picture -
http://restaurant.welltreat.us/t/restaurants/captains-world/4?l=en

As you can see every restaurant page comes with a simple predefined attributes, such as title, description, tags, location, images and so on. Which can be varied from topic to topic, for example – doctors review site might need different attributes than what we have with restaurant. Fortunately everything could be configured over topic administration system as we have in well treat us admin panel.

A different make over as your wish!

“Well Treat Us” is not only about having multiple topics based review platform it is also about creating web site for your own business need. Where “Well Treat Us” as SaaS comes into play.
The following image is an illustration how it could help you to build your web site as your own wishes and preferences. Check it out -

Also don’t forget about having your own web site address (ie. Http://laalshop.com) and so much customization that you can do with any CMS these days. (like joomla, sitefinity etc..)

“Well Treat Us” Web Site Content Management System – “We kept Everything Visual!”
Till now we haven’t unveiled the GREAT secret about “Well Treat Us”, you might be wondering what that could be ? Well you know! You know! ;) the secret is all about secret we shouldn’t unveil it :) well here is the secret -

“We have build “Well Treat Us” for our own usages” it means, we haven’t built it for having another fancy service around, we built it because we meant it we wanted it. We kept it mind that we are gonna use it for our own purposes. Our business ideas and web sites will be built on it.

So you can understand, how much efforts we give only to keep it more useable for our own demand. We have been doing it with passion for us and for our clients.

Let us show you some examples, how does it looks, when you have a web site on well treat us SaaS platform

A web site built on “Well Treat Us SaaS paltform”

This is an example, how your web site's featured images are administrated over the admin panel.

This is another example which demonstrates how easy it is to let you manage your web site menu on the fly.

Ah! what a easy way to create a new content with SEO friendly url :)

It's your web site, you got freedom and control, so you better add as much video clip as you want :) -

Also control total number of items to be displayed -

Also you are king of your own content edit it live on the site in edit mode so you can see how might appear on screen :)

I guess i should have completed my post bit earlier :) but my passion toke me further. Anyway! Thanks for reading the whole thing :)

best wishes,

Ruby Twitter OAuth API : 401 Unauthorized error also says Failed to validate oauth signature and token

Ah! what a waste, after trying out for couple of hours i’ve suddenly found out a blessing post from “blaine garrett” . hussss! he really got it fixed through synchronizing system time. my system time was around 30 mins beyond twitter server time.

so far i can assume, this problem was occurring due to twitter oauth service call validation, since the attached timestamp (through OAuth timestamp or some other header which was carrying request time stamp) was giving far beyond time (ie 30 mins beyond in my case). thus twitter was rejecting the request.

anyway, after synchronizing my system date and time, i can see it’s working.

thanks “baline garrett” :)

Continuation of “Internship monthly salary” related discussion on agile bangladesh group

[This is the continuation of the on going thread at agile bangladesh group]

Hi sudipta,

i think you are doing great!, you have raised your concerns and showed up your eagerness to talk about this with all of us.
frankly speaking i think this group would be better utilized when more concerning, frustrating and real problem oriented mails are poped up.
i’m damn sure i ain’t only enjoyed reading out this thread as well as i’ve enjoyed seeing people’s different room of thoughts about internship.

so far i’m more sure till now, we all wanna see bangladesh as the BEST IT software development base.
wanna see we have pool of passionate talents those who never care about any challenge.
who can put sharp edge of bleeding sword to any technological challenge. can slice challenge into pieces and solve with GUT and passion!

@sudipta, you guys are doing great!, all you need just a little adjustment to understand what is internship is all about and what you can expect and how you can build.

software is thought product, software developers are used to be very emotional and creative. most of them are right brainers, they love to illuminate software with their skill craftsmanship.

did you see any artist ? (who draw other’s portrait)

so far i understand no education can build artist, artist are born with right brain dominated. later they figure out where they are the best on.
and they pursue their own dream rather not pursuing their parents dream. (becoming doctor, pilot, engineer etc..)

let me ask you another question, why did you join IT ? Is it your own will or you parents will ?
i saw people who has picked up IT because their parents or other influences told him this is good career to earn money!.
frankly speaking this is modern and more trendy profession where you can have smart salary as well.

BUT, to get smart salary you need to be SMART! i guess damn SMART!

the way you expressed your mail, it feels to me, you are having ZERO (0) confidence on your OWN!.
seems like you just stumbled upon something you were never ready for.

let me ask you! if you were computer science student what else you have done rather addafying with friends, gossiping with friends, studying for better grade ? did you write any program which blows the whole SYSTEM ? did you write any code which bought other’s attention to your coding skill?
did you beaten your poorly knowledge teacher by your PASSION and overwhelming study over wikipedia ?
did you read any software industry related magazines or books EVER ?

i don’t get it, how come you guys passed 4/5 years without even thinking about industry ? where you have to settle in.
i understand our teachers should have played as mentoring role,
it feels to me, teacher are providing their service because they ain’t get any other options left (not all teacher).

just cut the crap! if we consider you to take as an intern in our company. we would have asked for the following key values from you -

  • Can you hold up your negative thought and keep focusing on learning ?
  • Are you focused on software development ?
  • Do you study yourself (from wiki, google) ? or do you need spoon feeding?
  • Can you move alone when you are shown to a path ? (self study, try to understand or ask too many questions to understand)
  • Did you ever joined in any other bangladeshi software groups beside Agilebd ? (like jpgroup for java, phpexperts for php)
  • Do you have the craziness ? do you feel it! do you feel you can ignite yourself ?

i have another question for you -

  • Can you tell me where do you wanna see yourself in next 5 years ? Is it europe or bangladesh?

i know 5 years is far away, but not so far than 10 years or rest of your remaining life times.
if you wanna get well paid, you gotta prove it. you gotta prove why company won’t pay you more.
you have to show up your GUT! your passion. otherwise you have to be happy with what you are getting (by the bless of BASIS minimum 5K suggestion). if you are having such attitude (not self learner, not passionate, no patience to give try out) and come to us for internship. we would never let such guy in our company (sounds rude! but you know it’s very very very TRUE!).

you gotta PROVE yourself then you will create your need, otherwise you are not welcomed :)
so my last few suggestions for your own improvement -

  • You ask yourself, “Am i in love with Software programming?”
  • You start reading book from the scratch.
  • You build personal projects to learn more inside.
  • When you have completed 1/2 books and practiced lotta times. you try to join in any company as trainee, intern or junior developer
  • You become the most proactive, never care what company is paying you now!
  • Perhaps you might face hard time to survive, you NEVER GIVE UP! you can take money from you friends and family but don’t invest yourself in tuition or other none IT related profession.
  • Keep single company focus
  • Learn as much work as possible
  • Prove yourself “Why won’t company kiss you :)
  • Create your own image with the colleagues and company.

I guess you guys can understand this is not a short process, you might need at least 2/3 years to insert into a better level.
so you better get ready and sail your boat.

btw, we (hasin hayder (leevio), emran (right brain solution and me (tasawr interactive) have started workshop in university campus. (right now we are at brac university, we have already taking 7/8 classes)

where we are training students to learn web development with whole domain coverage. (ie we also let them get in touch with html, css, javascript with jquery, database, php, php with codeigniter)

we are planning to improve our curriculum frequently and bring this workshop from BRAC university to any other universities through out the whole nation.

frankly speaking we are doing it for free! actually we are investing our time. since i have office on saturday, my company (tasawr interactive) allowed me 3 days weekend, where i’m utilizing my 3rd day (on saturday) to take class here. thus my company is also investing. all we want better IT growth in bangladesh.

i think other bangladeshi IT professionals should be coming forward to take such initiative to improve our university students, encourage them motivate them and add more fuel on them so they can ignite :)

anyway! thanks guys for reading out this pretty long mail :) khekk!

Learning how not to use “AND” or “OR” condition while you are breaking down the tasks

:) _), Suddenly this topic came out, i think it is one of the important
issues to keep sprint task simple and easy to accomplish and
estimate.

i was about to write this sprint backlog task for my pet project
(http://welltreat.us)

“Email notification should include review content Or comment content”

so while i was writing it down, suddenly this thing poped up!, how
about if i break it down and accomplish part by part, since
technically it states two tasks in one sentence. also more preciously
i can’t work on the different tasks at the same time.

so, if you break it down you might see the following tasks -

1. Review notification email should have user’s review content

2. Comment notification email should have user’s comment content

Now it came up with more implementable units.
from my personal observation, i found breaking down task to very small
implementable units make it very easy to discuss, implement as well as
test.

moreover usually very small unit of task is easy to implement a day,
which gives developer better satisfaction. because you have completed
some tasks.

psychologically it helps to build confidence and GUT on the their
ownself, which is very important to keep their motivation level high
to bring coolness and WOWness with in the team.

already posted in agile bangladesh group

best wishes,
see you guys in ruby on rails seminar on 13th (10 am) at basis
conference room :) _)

OpenAgile and related stuffs!

Posted in agile bangladesh group

Guys!
can anyone enlighten me here? i’ve read an article yesterday on OpenAgile,
which actually drew my attention, you can read it here

it seems to me a combination of lean and scrum, they kept nearly synonymous terms adhered from scrum world.
so far i can understand, they want to keep it open and collaborative. where scrum is religiously maintaining all related practices & terms otherwise inferior complexion is created through ScrumBut.
here is a peek from the blog -

….Another major difference between OpenAgile and Scrum is how the community operates. OpenAgile is an open-source method that has a specific structure for community involvement that allows for continuous improvement of the system. Scrum is closed. It is closely managed by it’s founders and this has led to challenges with the method becoming dogmatic. OpenAgile is meant to constantly evolve and grow…..

so it seems like OpenAgile will be an openly accepted ScrumBut. Sounds to me cool! again,
i wish they will keep it as thin and more adaptive like lean (3 processes)  & scrum (8/9 processes)

from my understanding, prescriptive process is always rigid and provides less option to adapt companies own branded culture thus it might fail or irritate everyone. or it might ended up with cloning the same formal attitude.
probable this is the reason why most of the creative companies create their own way to ensure everyone get’s chance to be creative.

on the other side, less prescribed process such as lean can motivate you to learn how to do better in what situation. gradually it helps you to come up with your own process.
but one problem might happen, people used to pretend they understood the principles very well, in reality, they actually didn’t get it. thus they miss use it. hence it becomes burden and becomes unstable.

it seems me, like writing all logic in View rather not understanding why MVC (model view controller) and why those separations are needed. MVC got very few principles (only 3 infact) but you got bunch of other practices adhered from community, design patterns and technical prophets (mentors ;) _)

best wishes,

my tweets

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

May 2013
S S M T W T F
« Jul    
 123
45678910
11121314151617
18192021222324
25262728293031

Flickr Photos



iMirror

Someone trying to get some rain drops



Shawarma house banani

More Photos
Follow

Get every new post delivered to your Inbox.