hasan's blog (বল্গ)

work for fun!!!

Archive for August 2007

damn simple!!!, define instance variables in ruby way

without comments

i was creating a new class where a hash object will be passed with value and key. my class suppose to iterate for each key and value. and those key will be treated as the instance variable.

so the pretty simple job i did is the following lines of code block -

def initialize(p_params = {})
super()
unless p_params.empty?
p_params.each do |key, value|
eval %(
self.#{key} = value
)

end
end
end

surprisingly my instance variable declaration became soooooo simple and easy.

update:
i didn’t know that self.send(“#{key}=”, value) does the same job, obviously send is prefer way to do this job.

Written by nhm tanveer hossain khan

August 31, 2007 at 12:39 am

Posted in Ruby, tips

It seems LinkedIn moved on tomcat !

with one comment

after a long while i got myself on linked in site, as i got “Server spy” installed on my firefox browser, so i was getting the server name from the browser status menu.

anyway, today i found something different, actually “Server spy” said, linked in is using “Apache-Coyote/1.1″, as far i can remind, linked in was using sun application server previously.

i think it is really interesting, what led linked in to move over tomcat backed or tomcat based servlet container instead of sun application server?

anyway, if i find any info i would love to feed my blog :)

Written by nhm tanveer hossain khan

August 21, 2007 at 10:41 pm

Posted in Introduction, Java, server

“শ্রম মিটার”, রিক্সা আর ঠেলা গাড়ির জন্য

with 4 comments

আজ রিক্সায় করে আসার সময় ভাবলাম, কেমন হয় আমরা যদি রিক্সা ওয়ালাদের তার প্রাপ্পটা একটা যথাযথ নিয়মে দিতে পারি ?

ত ভাবলাম “শ্রম মিটার” এর ব্যপারে, “শ্রম মিটার” একটা সহজ সিস্টেম, যার কাজ হবে, রিক্সাওয়লার “কেলরি” আর “দুরত্ব” হিসাব করবে ।

এই ২টা হিসাবের মাধ্যমে বের হবে রিক্সার ভাড়া ।

একটা রাফ আইডিয়া, জানিনা কেমন হেব ।

Written by nhm tanveer hossain khan

August 19, 2007 at 11:16 pm

Performance issue with tomcat 5.x.x series

with one comment

one of our escenic colleagues (Simen L. Haagenrud) just noticed a bottleneck with tomcat 5.x.x series containers. so we had a details digging to let find the reason.

as he mentioned it was because of recurring invocation of “getAttribute”, and tomcat 5.x.x series is using synchornization block inside “getAttribute” method, where lock is kept on “attributes” variable.
so i had a quick look on the source code of the 3 recent series -

1. 5.0.28
http://svn.apache.org/repos/asf/tomcat/container/tags/tc5.0.x/TOMCAT_5_0_28/catalina/src/share/org/apache/catalina/core/ApplicationContext.java

2. 5.5.24 (the last version from 5.5.x series)
http://svn.apache.org/repos/asf/tomcat/container/tags/tc5.5.x/TOMCAT_5_5_24/catalina/src/share/org/apache/catalina/core/ApplicationContext.java

3. 6.0.x (trunk)
http://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/ApplicationContext.java

so the code says 6.0.x series came with the fixes, the fix is the replacement of HashMap with ConcurrentHashMap.

in his case, recurring invocation of “getAttribute” was nearly reduced 50% server request handling capability.
best wishes,

Written by nhm tanveer hossain khan

August 6, 2007 at 8:36 am

Posted in Fix, Java, java ee, server, tomcat