Timesheet tracking software

November 24th, 2008

In the last few months I was doing the following things:

  • watching my stock loosing its values every day
  • working on a new web based application for tracking timesheets.
The new software is hosted on hhtimesheet.com. The software is a hosted timesheet software. The software is still not ready for production. We hope that software be ready by the end of march 2008. I will keep you posted.

Non obstructive validation with javascript and css

November 6th, 2008

In my recent project I wanted to have some simple validation at javascript level. I wanted to develop a very flexible and generic validation code. My requirement was to make sure that mandatory fields are filles by user and numeric field are filled by only numeric values. The first approach will be adding onsubmit method to each form and do the logic there. But thanks to availble javascript frameworks like prototype I could do it in a very nice and generic way. No custome javascript code for validation.

Behaviour

By defiing an input field as mandatory (<input class=”mandatory”/>), this framework will ensure that user cannot submit the form if the mandatory field is not filled. Also it will add css class error to the field when it has a invalid value (in the case of mandatory fields invalid means empty) so you can simple define a class like: 

input.error {
border: 1px solid red;
}

to give instance feedback to user when a field is not valid. No custom scripting is needed.

How to use my validation framework

  1. Add prototype and my validation.js scripts to your html file.
    <script type="text/javascript" src="prototype-1.6.0.2.js"></script>
    <script type="text/javascript" src="validation.js"></script>
  2. For mandatory fields in your form add mandatory and for numeric fields add number css class to your input fields.
  3. Enjoy!

How it works

This validation framework will look in all the input fields in the forms and add the appropriate hooks to ensure that only valid forms can be submitted. It will also add the error class to invalid fields when user change the value of the field.

How to extend this framework

Extenting this framework is damn easy. You can easily add more validations for new css classes.

Click here to download the validation.js

Click here to download the sample

 

future of rails deployment stack

August 22nd, 2008

I am using Rails for a while and I used rails to develop the garagesales. I should say the rails is a fantastic framework on top of the fanstastic language. But I am a J2EE developer and coming from the J2EE world there are still things in Rails that I don’t like:

  • Lack for extensive libraries
  • performance of the rails
  • single thread model in rails

But as the time is passing by I am reading and hearing more good news about the rails. I think that dots are connecting together to make the rails the best web framework of the future:

  • JRuby: With JRuby rails applications have access to all the libraries and frameworks in java. JRuby performance is getting better and better in every release and sun is dedicated to provide a good platform with great IDE support (netbeans) around JRuby.
  • Rails 2.2: Rails 2.2 is going to be thread safe so multiple requested can be processed inside a single process. With rails becoming thread safe and JRuby becoming more efficient I am seeing more people start to deploy their ruby application inside a Java rails file instead of native ruby. Unfortunately the native ruby implementation of threads is not using the kernel threads and cannot utilize multi-core CPU system.  For the time being I think Rails 2.2 and JRuby will the best deployment stack.

My experience in moving from windows to mac

June 16th, 2008

imac
Hi,
I am writing this post to share my experience in moving for PC to MAC. I made this transition less than two years ago and I couldn’t be happier.

My Previous system
I am a professional IT programmer, previously I had a dell machine with dual boot to windows and Linux. I was using windows for

  • Photoshop and Dreamweaver
  • playing casual games (I am not a hard core gamer)
  • scanning documents as my scanner didn’t have proper Linux driver.
  • voice and video chat with my friends on skype and yahoo.

The reason for me to run linux was:

  • I love the command line and tools that are available in *nix environment.
  • My system was much faster with less hicup when I was running Java IDE, Tomcat, Apache, MySql during the development ( I had 1GB of Memory).

Moving to apple
I was always admiring apple for its high quality hardware but I was student and I couldn’t afford buying a mac plus I was always trying new programs and products which were not available for mac (sometimes) and I was scared of having a mac only system in my home. After the apple move to Intel and emergence of virtualization softwares like parallels and talks about booting windows on apple (this is before the bootcamp) I realize the I can move to mac and keep my old windows license so I can move to windows if needed. So I ordered the first series of Apple iMac 24″.

Why Apple iMac 24″
Well I was thinking about it alot. I wanted a fast system which was affordable too so my options were iMac and Powerbook. With buying 24″inch iMac I lost the mobility which is a great thing. So now when I go to my friends place I can’t take my laptop so I will spend quality time with them. 24″ monitor is also a great thing. I can open multiple windows (Development IDE, shell and Sql browser) and use them at the same time. It is like having to smaller monitors.

Transition (Look and Feel)

Beside all the good things in Mac, I get used to some of the windows terminologies. at the beginning not having the start menu with list of all programs and not having the task bar for confusing but I get used to in couple of weeks. I also start using the Spot light for running programs. I press the <Ctrl><Space> and first characters of the program that I am going to run and it is much faster than going to start menu and choosing the program from the list of menu. After all the general look and feel is something that people will get used but generally I prefer the OS X look and feel over anything else.

Softwares

I have boot camp and fusion on my computer to be able to run windows and the only thing that I use there now is Yahoo messenger when I want to do a voice chat with friends who don’t have skype or when I want to test my website/webapp in IE6.0/7.0. I occasionally come across some softwares which I can’t run in OS X but it is very rare and become least important with fusion integration inside OS X. TOAD is now one of the few development tools which requires me to use windows (for does of you who never heard of TOAD, it is a GUI for using database).

Performance

My computer is running fast, I can keep photoshop, Dreamweaver, Eclipse, MySql , Apache, Tomcat, … all running and switch between them smoothly. When I am not using the photoshiop for few days (Because I am focusing on development) and switch back to it, system is loading the data smoothly from disk after a small hiccup. I can’t image going back to windows which I think it’s paging system is fundamentally flawed.

Software Installation

I think this is a topic that worth to mention. In windows every program is coming with an installer which create the program and keep some information inside the windows registry. Computer is gradually become slower as more programs are putting stuff in registry and un-install will not remove all the entries in windows registry. But in apple there is no installation. Every program is a directory which has a .app extension and contains a file describing the boot program and applications are keeping their data inside the user home directory. So installing the program is copying the folder (Which is mostly packages inside a .dmg file) and un-installing is just removing the program directory. With this approach there was no need to reinstall my operating system, but in windows I had to reinstall my operating system every 6 months as the system was getting slower by the time.

Conclusion

Apple computer is a computer which “Just works”. It is a little bit more expansive by adding the time that it will save you in installing softwares, customizing the environment, resolving driver issues, … and accepting that time is money. It is much cheaper than equivalent windows system. Plus you will get a productive, ready to use and high quality system. I strongly encourage everyone to buy a mac for their next system upgrade and use windows in fusion (or parallels) for their Windows only programs.

Hello world!

June 12th, 2008

Hi,

I am going to start blogging again. This is my first post.

Cheers

Behrang

With SEO you should be patient

April 18th, 2008

I launched the fastgaragesales.com about a month ago. I am noticing that amount of traffic coming to my site from google is increasing slowly from two-three clicks a day to about twelve clicks a day. It is going about as my site have useful content and google is seeing a constantly changing website. I am expecting to get around 500 views per day by the end of this year. 500 views per day means that I will pay for the hosting and few extra dollar in my pocket.

Keep all of your passwords in one place.

April 5th, 2008

This web based application allows you to store all of your accounts and passwords in one location. It is absolutely safe and secure. It store your passwords in a secure environment that no one on the planet can get access to your passwords without having your master password of course.

read more | digg story

New website to handle your list o passwords

April 5th, 2008

There are plenty of websites, each requires separate login and registration. If you are like me, you are probably already confused and cannot remember all the user names and accounts on different websites</p>
Mypazzwords is the solution to your problem. You create on account with a master password to store and retrieve all of your passwords.

I wrote this website this weekend and I hope you enjoy using it. It is secure and free. http://www.mypazzwords.com

go to Google discussion forum for your questions about using this website: http://groups.google.com.au/group/mypazzwords

Regards

Beyond NG

Fast garage sales is finished up and running.

March 19th, 2008

I finished the http://www.fastgaragesales.com website. You can start posting your garage sales and enjoy this website. Thanks to google free geocoding and productivity of rails I was able to provide this service in less than a month. The total development time was about two weeks (full time). I am already thinking about two next projects that I am going to work on. I created the story board for one of them in side the mingle.. I will talk about that project later on. It is about brining an old game that I used to play with my friends in high school into online word. I will keep you posted and thanks for reading this weblog.

Beyond NG

Rails performance

March 3rd, 2008

I always had reservations for rails performance. Ruby is great language it provides many runtime features that increase the programmers productivity but reduce the performance. Also rails is the best web MVC stack that I ever came across. It is fair to say that a ruby code is about 20 times slower than equivalent java or native program. So during writing the my garage sale program, I became concerned about using rails as my development language. It got me to the point that I decided to do some more analysis and googling to choose the best platform before moving forward (BTW my garage sale program is going well I am on the track and hope to be able to finish it by the end of April).

Rails is slow, it is really slow. It will become much faster when it gets its own virtual machine and some byte code optimization like the one that java has. But the richness and plugins and elegance of the framework is too tempting for a developer. So that is the solution for now? There is three solutions to this problem:

  1. Caching
  2. Caching
  3. And caching

Lets do some math; Take my garage sale program as an example, a post will be created once and will be visited 100+ times. So site will have 90% cacheable load and 10% active load. During the 10% active load probably 50% will be backend database and 50% inside the ruby application (probably less in my case as I there is not that much CPU intensive processing other than some image resizing by rmagick and text indexing by ferret which both are ruby front-end and native backend). Furthermore by out souring my images to Amazon S3 I will be able to reduce the rails application even more. So At the end less than 3% of the load should be on the rails application. In this case even if the rails is 5 times slower than any other language the total effect on the performance is about 15%. So how to get to 3% load on application in real world? Here are the recipes that programmers should follow:

  1. Be prepared: Many people are saying that don’t worry about performance until it hits you. I strongly disagree with that argument. When performance issue hits your site you will loose your unhappy customers and by the time that you manage to accommodate for that load, you probably lost your customers to your competitor. So you should be prepared for increase in load from day one of application development. Application should be written in a way that it can be scaled horizontally (means by adding new hardware)
  2. Use Partials: partial is great way of modular code and be prepared for load increase in future. By using partials you would be able to apply the caching strategies around different parts of your html code much easier.
  3. Use RESTful urls: RESTfull urls are much more cache friendly. It will let use to use cache servers much easier. Even in the case that your get very lucky and big your site becomes so popular, you will be able to use Akamai services.

After following these recipes and having a program that is scalable here are the steps that I suggest:

  1. Deploy without caching: Deploy your application without caching as you probably will not get a huge load for few month so it is better to push your application out first and start to worry about the performance as soon as you get some popularity. Time to market is more important at this state.
  2. Add html and action caching as the first step: add caching code around your cacheable actions and views (in my case, like header, footer or view of a garage sale). You can do some manor optimization in your code like adding or removing :includes in queries at this stage.
  3. Have access to extra hardware if needed: In this stage you should ensure that you would be able to increase the capacity of your infra-structure in small fraction of time (if needed). For example you may need to off load the database to another server or if you are on a virtual server you may need to ensure that you can increase your virtual power very easy (EC2 can be great choice for small start ups)
  4. Off-load the cache using memcached and use database replication and application clustering: These are typical clustering techniques that are next step in handling the load. You should be prepared for that when you get to the point that one computer is enough for your current load. You should practise the clustering in your dev environment and ensure that you will be able to roll-out the clustered environment in less than a day (if needed). Alway seek professional help for clustering and replication.
  5. Use Edge servers: Well sometimes the rails internal caching doesn’t work you are too big to be able to handle the load the solution is using Edge servers and esi include. So when you get to the point that you need few database servers and application server you should prepare your self for moving to next stage. The concept is pretty simple (don’t let the names scare you). What you should do is add <esi> tag around your different part of the page and then An edge server will serve the page and make the calls to the server (if needed). for example an edge enabled page for showing a garage sale post will look like this (conceptually not the eact format):
    <esi:include url=”/header” ttl=”100″>
    <esi:include url=”garagesale/view/@garagesale.id”>
    <esi:include url=”footer” ttl=”100″> </esi:include></esi:include></esi:include></li>

Thanks to partials this move should not need lots of refactoring in our code.

Conclusions:

 

  • Although rails is slow in comparison with other platforms like java, as long as you are writing a program that number of view is order of magnitude higher than number of edit operations (which I think is the case in most of the these days applications) rails performance overhead can be negated and we will be able to scale and serve millions of pages per day.
  • To able to keep customers happy, you should always be prepared for the next step in your application scalability.