Measure Spec Execution Time

Sometimes it doesn’t feel good if you have to wait for so long to get all specs executed or get stuck with the one at the very end. How about making the spec faster ? well, first we need to know what exactly slowing down everything right ? How about keeping record of each spec execution time and later printing them out over the console. So you could take a quick look and judge which spec performed the worst. So here is my coderwall code snippet – https://coderwall.com/p/l3nl_w

How to Add Space to Your Existing Mongodb Instance

We’ve Mongodb instance with RAID-10 array with Logical volumes. Just few days back we came to the point where we’ve to expand it or reshape the whole instance.  Since we haven’t planned to get into mongodb replication, as our single node can serve our demand for the time being. We thought how about adding up few more disks.

So here are the steps we’ve followed to add new space in our current instance: 

  1. First Created 4 more EBS from AWS console (with 200GB + IOPS 600)
  2. Kept Backup for Existing Drives (Can’t bet on uncertainty)
  3. Attached 4 new EBS with Mongodb EC2 instance 
  4. Log into Mongodb Instance
  5. Created New RAID-10 array
  6. Created Physical Drive
  7. Extended Volume Group
  8. Allocated New Space
  9. Extended Filesystem to Utilize New Space
  10. Checked & Done!

First Created 4 more EBS from AWS console (with 200GB + IOPS 600)

Just created 4 more EBS drives from AWS Volumes page. We’ve set 200GB with IOPS 600. Then attached them with Mongodb EC2 Instance.

Kept Backup for Existing Drives (Can’t bet on uncertainty)

You can take snap from AWS console or you can do it using command line tools. Check out status over the AWS console, It take a while based on your storage size.

Attached 4 new EBS with Mongodb EC2 instance

Attach your newly created 4 EBS volumes and assign name which you can recall later. We used /dev/sdn1 to 4. But those were renamed to /dev/xvdn1-4 by system itself. Refresh AWS console just to make sure you’ve connected to all of them.

Log into Mongodb Instance

$ssh your-server-address

Created New RAID-10 array

We will name this new array /dev/md1 because our first array was named /dev/md0

Just execute the following command –

$ sudo mdadm --verbose --create /dev/md1 --level=10 --chunk=256 --raid-devices=4 /dev/xvdn1 /dev/xvdn2 /dev/xvdn3 /dev/xvdn4

So this should be done without any error (If all of your volumes are ok). You can execute the following code to see the detail – 

$ sudo mdadm --detail /dev/md1

Add new array to mdadm configuration file – 

$ echo 'DEVICE /dev/xvdn1 /dev/xvdn2 /dev/xvdn3 /dev/xvdn4' | sudo tee -a /etc/mdadm/mdadm.conf
$ sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf

Created Physical Drive

Based on mongodb tutorial, this is how read-ahead is configured –

$ sudo blockdev --setra 128 /dev/md1
$ sudo blockdev --setra 128 /dev/xvdn1
$ sudo blockdev --setra 128 /dev/xvdn2
$ sudo blockdev --setra 128 /dev/xvdn3
$ sudo blockdev --setra 128 /dev/xvdn4

Set zero to first 512 bytes of first block.

$ sudo dd if=/dev/zero of=/dev/md0 bs=512 count=1

Now finally create physical drive – 

$ sudo pvcreate /dev/md1

Extended Volume Group

We have new physical drive, now we can attach them with our existing volume group.

$ sudo vgextend vg0 /dev/md1

AllocateD New Space

$ sudo vgs

Check how much unallocated (VFree) space is listed. In our case we got around 400GB space to allocate. We’ve to expand our existing partitions /data, /log and /journal.

You can use %FREE if you want to allocate by percentage or you can set specific number. We’ve done with % so let’s show we did.

$ sudo lvextend /dev/vg0/data -l +80%FREE
$ sudo lvextend /dev/vg0/journal -l +10%FREE
$ sudo lvextend /dev/vg0/log -l +10%FREE

And kept few space as unallocated so if we need in future we can utilize them.

ExtendED Filesystem to Utilize New Space

Unmount from system – 

$ sudo umount /data

Checkout partitions if everything is ok – 

$ sudo e2fsck -f /dev/vg0/data

Resize partition with the following command – (This should utilize all available space from the volume)

$ sudo resize2fs -p /dev/vg0/data

Continue this process for all of your partitions.  After it’s done mount all devices. 

$ sudo mount /data

Note: In case if you can’t unmount some device, You can try – 

$ lsof | grep /log

And terminate process which is holding it back, Now try to unmount.

Checked! & Done!

Now let’s check how much storage you have. – 

$ df -h

Thats all🙂

Btw i’ve followed most instructions from – http://docs.mongodb.org/ecosystem/tutorial/install-mongodb-on-amazon-ec2/#install-mongodb-on-amazon-ec2 and later from here – http://pubmem.wordpress.com/2010/09/16/how-to-resize-lvm-logical-volumes-with-ext4-as-filesystem/

Thanks to them🙂

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!

my tweets

December 2016
S S M T W T F
« Apr    
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Flickr Photos

Exploring New York

Exploring New York

Exploring New York

Exploring New York

Exploring New York

More Photos

RSS my shared links on google reader

  • An error has occurred; the feed is probably down. Try again later.