Web progamming and database development

Diary of problems and solutions related to web programming, database development and related technologies and platforms.

Copying files and folders from DOS

To copy all the files located in a folder "Suresh" then.

copy source destination

C:\>copy "Suresh*.*" "E:\Suresh\"

Copying and pasting folders, sub-folders and files, we need to use xcopy command
C:\>xcopy "H:\Suresh" "E:\Suresh" /e

Syntax of xcopy is

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
[/EXCLUDE:file1[+file2][+file3]...]

Where,
source: Specifies the file(s) to copy.
destination: Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set,
doesn't change the attribute.
/M Copies only files with the archive attribute set,
turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/V Verifies each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does
not support encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

No comments :

Post a Comment

Moodle Installation - Blank page after Database screen

While trying to install moodle, I got the blank page after Database screen. To solve this issue, I went to different sites including the moodle forum and found nice solution there

http://moodle.org/mod/forum/discuss.php?d=100472
http://moodle.org/mod/forum/discuss.php?d=128498

What I did is that, I changed the created the new copy of config-dist.php and renamed it with config.php (config-dist.php is a template of config.php). The problem was becuase that it installation wizard couldn't create config.php file. So, I did the manual change in the file itself as follows:

 $CFG->dbtype    = 'mysql';  // mysql or postgres7 (for now)
$CFG->dbhost = 'localhost'; // eg localhost or db.isp.com
$CFG->dbname = 'moodle'; // database name, eg moodle
$CFG->dbuser = 'root'; // your database username
$CFG->dbpass = ''; // your database password
$CFG->prefix = 'mdl_'; // Prefix to use for all table names

 $CFG->wwwroot   = 'http://localhost/moodle'; 

 $CFG->dirroot   = 'C:\wamp\www\moodle'; 

 $CFG->dataroot  = 'C:\wamp/moodledata'; 

Save this configuaration and start to install again.

During installation, you will be forwarded to this URL below automatically
http://localhost/moodle/admin/index.php

You will see to go through processes where you have to click on Continue button. Good Luck :)

No comments :

Post a Comment

Managing User authentication with Restful Authentication Plugin

Restful Authentication Plugin is one of the best tools to manage user authentication.

To install:

gem install restful_authentication

After it gets installs run the following script:

script/generate authenticated user sessions

In this command, “authenticated” is the name of the generator; “user” is the name of the model that will store user names and passwords; and “sessions” is the name of the controller that will manage user sessions.

It will create the migration file for us. Then lets migrate the database

rake db:migrate

No comments :

Post a Comment

WAMP localhost not found, giving a blank page

When I tried to open http://localhost after starting the WAMP server, then it gave me the blank page. Then I went to search for the problems from where I discovered the easy solution for escaping from that problem.

1. It is the problem of Port 80 which has been used by some other program. To check/solve this, left-click on the WAMP icon in the system tray which at the bottom right side of the screen:

Apache > Service > Test Port 80
2. Following screen/output pops up in the command mode:


It shows that port 80 is being used by the Skype.

3.Then shut down the Skype program and started browsing http://localhost/ You are done now. You can see the localhost page along with the list of my projects.

Alternative one:

I also saw one video tutorial to solve this issue too. You may have a look

Watch the video

No comments :

Post a Comment

My Favourite Quotations

"Stay hungry stay foolish" - Steve Jobs

"The ultimate measure of a man is not where he stands in moments of comfort, but where he stands at times of challenge and controversy." - Martin Luther King, Jr.

"Our lives begin to end the day we become silent about things that matter." - Martin Luther King Jr.

"Live as if you were to die tomorrow. Learn as if you were to live forever." - Mahatma Gandhi

"The people choose who their leaders are. Whereas I think in the real world a lot of privilege comes from where you were born and how much money you have." - Joichi 'Joi' Ito

No comments :

Post a Comment

Website's performance using Firebug and YSlow

In this episode, I am going to measure the website's performance on the browser's side. I am going to test the responsiveness (the amount of time it takes to load on web browser) of the website. I am going two things

1. Measure the responsiveness
2. Improve the responsiveness

1. Measure the responsiveness


There are two different methods to measure responsiveness. One is through

a. Firebug

Firebug is a plugin. It integrates with Firefox to put a wealth of development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page (Source Ads on for Firefox). You can download it from its official website. (https://addons.mozilla.org/en-US/firefox/addon/1843/ )

After you install firebug, open the firebug (For this go to Tools>>Firebug >> Open Firebug ).

Today I am going to test the responsiveness of the famous news portal of Nepal ie nepalnews.com. To check its responsiveness, browse www.nepalnews.com and check its performance by going to Net Menu and All submenu and it shows the result like this:


If you view the large section of the image, then you can see the timeline which show the time to load different components like CSS, Javascript files, images, and so on. Here in this figure, it shows

Total time to load is 28.45 seconds
Total size loaded is 200 KB.

It seems pretty slow responsiveness of the website. We will analyze the reason for taking much time to load in the browser and will optimize to make the website load fast.

b. Using Safari

For this go to Settings>> Preference and then click on Advanced tab there. You can check in Show Develop Menu in menu bar

Now you have Develop menu added. Click on that menu and go Show Web Inspector and then click on Resources tab.

Enter nepalnews.com in the URL section and you can see the total time it takes to load all the components. You can also see the separate section where it provides the total time it takes to load documents, stylesheets, images, scripts and so on. The snapshot is shown below:

Here,
Total time to load is 33.8 seconds
Total size loaded is 477.07 KB

Here the total size loaded and total time to load differs in two different approaches based on the total size of the files loaded from cache.


2. Improve the responsiveness

Basically there are some ways to improve responsiveness which are:

a. By improving server performance
b. By improving browser load time

By improving server performance is not really worthy for the time being to improve/optimize the time it takes to load the components in the browser end. So we are going to discuss the ways to improve the browser load time.

To improve the performance, the first step is to install YSlow plugin, which is Firefosx's adds on created by Yahoo!. To download and install it, here you go by following this link (https://addons.mozilla.org/en-US/firefox/addon/5369/)
You will see the little icon at the bottom right side of the browser and looks like this
Then go to nepalnews.com, click on this icon and and click on Run Test to see the performance report.


We can see that the nepalnews.com got the perfomance score 59 and grade E, which is very much poor with respect the responsiveness.

There are various ways we can improve responsiveness which has also been listed out there by YSlow:

I will go through some of the steps so that we can improve on these topics.

The very first one is making fewer HTTP requests, where the site has got even below the average grade ie F.

The reason behind this poor grade has also been shown by YSlow:

The reasons are

a. This page has 12 external Javascript scripts. Try combining them into one.
b. This page has 9 external stylesheets. Try combining them into one.
c. This page has 14 external background images. Try combining them with CSS sprites.

You may the see the actual screen shot of the analysis here too:

The suggestion is like this:

"Decreasing the number of components on a page reduces the number of HTTP requests required to render the page, resulting in faster page loads. Some ways to reduce the number of components include: combine files, combine multiple scripts into one script, combine multiple CSS files into one style sheet, and use CSS Sprites and image maps."

To implement this, I am using Ruby programming language which works on Rails framework.

Rails has some built-in tools to solve this issue. One of the ways we can do is by caching javascript pages. We using the following source code to implement this:
<%= javascript_include_tag :all, :cache =>true %>

What this code will do is that, suppose if I have three JavaScript files viz application.js, prototype.js and effects.js, then this code will help merge the javascript pages into one called all.js

We can also customize the name of the cache if we like to. We can do this by changing the above code a little bit:
 <%= javascript_include_tag :all, :cache => "main" %>

,Now the name of cache file will be created as main.js

No comments :

Post a Comment

will_paginate: for pagination

will_paginate: This is the rails plugin which is used for pagination. To install this plugin run the following statement from command prompt.

=> gem install will_paginate

No comments :

Post a Comment

Ruby on Rails - Brief Introduction

It is web application framework which helps to build database driven applications.
It works in MVC (Model-View-Controller) pattern.

View:
- It is also called presentation
- Responsible for inserting pre-built data in between HTML tags

Model:
- Contains "smart" domain objects (eg Account, Product, Person, Post) that holds business logic and know how to persist themselves to the database.

Controller:
- Handles incoming request (eg Save new account, update product, show post) by manipulating the model and directing data to the view.


Model is controlled by ActiveRecord, which is object relational mapping layer.
While Controller and View are controlled by ActionController and ActionView which are bundled in the same package called ActionPack. They are packed in a same package because they are dependent with each other. In contrast ActiveRecord and ActionPack are separate.

Source: Ruby on Rails Documentation

No comments :

Post a Comment

Useful Links

How to Write Your Own Facebook App in 5 Minutes

No comments :

Post a Comment

Setup your own Proxy Server in 5 Minutes for Free

There’re situations where you can’t access your favourite website because your ISP ‘accidentally’ blacklisted it somehow. Most of the time, a proxy service is an easy way to get around.

Anyway, find a nice public proxy server is difficult. And once you got it, it’s possible that it will gone away very soon. So it’s a good idea to set up your own. And it will be even better if you can have it FOR FREE :)

This video tutorial by Digital Inspiration, shows you how to create a free proxy server with Google App Engine. In short, App Engine is a Google’s service that let you run a computer code on its server, for free. So we just put a code for proxy service into our App Engine space, and we will got our very own personal proxy server.

No comments :

Post a Comment

Video Lectures of Computer Science

I found a good list of video lectures for computer science domain from Surendra Sedhai, one of my friends. Here is the link of his blog for the list of video lectures

http://sedhai.blogspot.com/2010/01/video-lectures-of-computer-science.html

No comments :

Post a Comment

Yak Shaving

One of my friends used this term during SDQI presentation and I was interested to know the meaning of it. Here are some meanings obtained from different sources:

1) Any apparently useless activity which, by allowing you to overcome intermediate difficulties, allows you to solve a larger problem.
I was doing a bit of yak shaving this morning, and it looks like it might have paid off. (http://en.wiktionary.org/wiki/yak_shaving)

2) [MIT AI Lab, after 2000: orig. probably from a Ren & Stimpy episode.] Any seemingly pointless activity which is actually necessary to solve a problem which solves a problem which, several levels of recursion later, solves the real problem you're working on. (http://www.ist.rit.edu/~jxs/jargon/html/Y/yak-shaving.html)

3) "Yak shaving" is a programmer's slang term for the distance between a task's start and completion and the tangential tasks between you and the solution. If you ever wanted to mail a letter, but couldn't find a stamp, and had to drive your car to get the stamp, but also needed to refill the tank with gas, which then let you get to the post office where you could buy a stamp to mail your letter—then you've done some yak shaving. (http://en.wiktionary.org/wiki/Citations:yak_shaving#English)

No comments :

Post a Comment

10 Skills to make a perfect Project Manager

Basic 10 skills a project manager should have are:
  1. A good HR manager, maintaining a cohesive team who works in collaboration; has to be a strong bonding agent in his team.

  2. Focused and positive towards his team members. Should maintain a good relationship with other team members even if he doesn't like them.

  3. Be confident, make yourself and other team members feel comfortable.

  4. Should have excellent presentation skills since he is the person working in between customer and organization. To update, convince and win the customer about the progress of software development, the progress of implementation and the completion of project i.e. sign off from customer at various stages, the project manager has to sell himself by having marvelous presentation skills

  5. Project Manager has to inculcate the leadership skills in all his team members so as to make them independent in handling adverse situations and coming out of it successfully. Also in this way he will have to burn less energies in tackling each situation.

  6. Project Manager has to have strong technical skills so that his team members do not lose confidence in him or do not fool him in technical aspects of the project. Although he doesn’t have to do much of the technical work with his own hands but still having those skills to understand how his team members are doing and whether they are in the right direction, is very important during development and implementation.

  7. Project Manager should be a firm believer in the Japanese term KAIZEN. He should ensure in making everyone believe that improvement has no end and is a continuous process.

  8. Project Manager, along with having good presentation skills, should have equally strong communication skills too. During project lifecycle, 50% of his time is the acid test of his communication abilities.

  9. Project Manager should be a strong estimator, a proactive in this regard. He should be able to estimate the progress of each individual, the skills of each member, the abilities, the show stoppers during the project, the customer delays or any other activity where an estimation is required.

  10. And last but not the least, a Project Manager should be good parent, in regard to understanding himself, his team members, management, customer, other teams, peers – i.e. all involved in the project. He should have a good understanding of his words he is going to speak to his customer, the instructions he is going to give to his team members, the decisions he is going to take. He should be well aware of impact and effect of each of the activity he does during a project lifecycle.

Source: IT Knowledge Exchange

No comments :

Post a Comment

Static vs. non-static methods

You may refer to this site for the best answer:

http://www.pp.rhul.ac.uk/~george/PH2150/html/node48.html

No comments :

Post a Comment

Service oriented architecture (SOA)

A service-oriented architecture is essentially a collection of services. These services communicate with each other. The communication can involve either simple data passing or it could involve two or more services coordinating some activity. Some means of connecting services to each other is needed.

Service-oriented architectures are not a new thing. The first service-oriented architecture for many people in the past was with the use DCOM or Object Request Brokers (ORBs) based on the CORBA specification. For more on DCOM and CORBA (Reference: Douglas K. Barry)

SOA also generally provides a way for consumers of services, such as web-based applications, to be aware of available SOA-based services. For example, several disparate departments within a company may develop and deploy SOA services in different implementation languages; their respective clients will benefit from a well understood, well defined interface to access them. XML is commonly used for interfacing with SOA services, though this is not required.

SOA defines how to integrate widely disparate applications for a world that is Web based and uses multiple implementation platforms. Rather than defining an API, SOA defines the interface in terms of protocols and functionality. An endpoint is the entry point for such an SOA implementation. (Reference: Wikipedia)

No comments :

Post a Comment

J2EE Vs J2SE

Both J2EE(Java Enterprise Edition) and J2SE(Java Standard Edition) are editions of java (JDK). J2EE is used to develop server-side applications such as Java servlets and Java Server Pages (JSPs). J2SE is used to develop client-side objectives.

No comments :

Post a Comment

About me

I am Suresh Raj Bhattarai, currently studying Master of Science in Information Management in the fourth semester in Asian Institute of Technology, Thailand (August 2008 - May 2010). Recently I have been doing research in data mining. My research topic is: Ensemble Techniques for Predicting the Consumer Rating of Movies. I have been doing research under the supervision of my adviser, Associate Prof. Dr. Sumanta Guha.

The purposes of creating this blog are:
1)To make a useful resource for my own understanding of tech stuffs.
2)To share my tech news, problems and solutions with you tech geeks.

No comments :

Post a Comment