Friday, April 12, 2013

Display Formatted Value along X and Y Axis of Chart

var view new google.visualization.DataView(data);

var baseDate /*date to start from, in ms from the Unix Epoch (Jan 1, 1970 00:00:00:000 GMT)*/;
view.setColumns([{
    type'date',
    label'Date',
    calcfunction (dtrow{
        // get ms from minutes
        var ms dt.getValue(row0) 60000;
        return new Date(baseDate ms);
    }
}1]);

to get it in string format use this:

var view new google.visualization.DataView(data);
    
// assumes the DataTable contains the formatted date value
view.setColumns([{
    type'string',
    label'Date',
    calcfunction (dtrow{
        return dt.getFormattedValue(row0);
    }
}1]);

Then you draw the chart using the view instead of the dataTable:

chart.draw(view{/*options*/});






var data new google.visualization.DataTable();
data.addColumn('string''Date');
data.addColumn('number''Weight');
data.addRows([
    ['Jan 1, 2000'{v100f'100 Pounds'}],
    ['Jan 1, 2005'{v140f'140 Pounds'}],
    ['Jan 1, 2010'{v160f'160 Pounds'}]
]);

or this:

var data new google.visualization.DataTable();
data.addColumn('date''Date');
data.addColumn('number''Weight');
data.addRows([
    // javascript dates use a zero-based index for months, so January is 0 not 1
    // date format is "new Date(year, month, day [, hour [, minute [, second [, microsecond]]]])" (hours, minutes, seconds, microseconds optional)
    // so 1:15:35 PM Jan 1, 2000 is: new Date(2000, 0, 1, 13, 15, 35)
    [new Date(200001){v100f'100 pounds'}],
    [new Date(200501){v140f'140 pounds'}],
    [new Date(201001){v160f'160 pounds'}]
]);

Wednesday, April 10, 2013

How to Change MySQL root password on Windows

How to Change MySQL root password on Windows

Use these instructions if you need change the root password for MySQL on Windows or if you need to add additional new users with general or specific limitations.

Setting a root password for MySQL

  1. Start your command line by going to the Start Menu > Run and typing cmd (or type command if you are using an older version of windows)
  2. Change directory to where you installed mysql to:
    C:\> cd C:\mysql\bin
  3. Switch to mysql command line:
    C:\mysql\bin> mysql -u root mysql
  4. Then set a default password:
    mysql> SET PASSWORD FOR root@localhost=PASSWORD('newpass');
    where "newpass" is the password you want to use

Adding more users

  1. Start your command line by going to the Start Menu > Run and typing cmd (or type command if you are using an older version of windows)
  2. Change directory to where you installed mysql to:
    C:\> cd C:\mysql\bin
  3. Switch to mysql command line (if you have not set a root password remove the -p switch when you type it in):
    C:\mysql\bin> mysql -u root -p mysql
  4. Then then add your new user:
    mysql> CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';
    where "jeffrey" is the username and "mypass" is the password you want to use. You can also limit users to specific database, allow only certain remote hosts to connect all using the GRANT statement. However, that is outside the scope of this tutorial so search for more info on using GRANT if you are interested in those features.

Tuesday, April 9, 2013

How to upload the code in code.google.com via svn

  • First of all,  Subversion has to be installed, download and install TortoiseSVN - Downloads
  • Click here  http://code.google.com/hosting/createProject to go to google code create project page.
  •  Search for project name which u decided by clicking the Search projects button on the top right corner. If u find none, proceed with the create project form. Otherwise u have to choose another name.
  • Click the create project button and go to Source tab.
 
  • View svn checkout link from bolow image:
  • Suppose create a folder named "prj" under c drive and go to the directory.
  • Mouse right click and select "SVN Checkout" and pase the url:
  • https://test0-0.googlecode.com/svn/trunk 
  •  urprojectname – name of your project which u created
  • urusername – ur name used while creating ur projec
  • This action will ask for password which u can find under the above command in Source tab by clicking googlecode.com password 
  •  

How to use SVN with Google code

How to use SVN with Google code

http://mzaher.wordpress.com/2009/03/02/how-to-use-svn-with-google-code/

1. Download TortoiseSVN
http://tortoisesvn.net/downloads
2. Installing  TortoiseSVN and restart your computer.
3. To get your GoogleCode.com password go to:
http://code.google.com/hosting/settings
svn3
4.You should now see this new items below if you press right-click on any empty place in the explorer or on any folder
svn1
5. Create a New Folder to hold all your files that you will work on.
6. Right-click on this folder and choose “SVN Checkout…”.

7. In the “URL of repository:” Enter your project’s URL in this formate “https://%5BProjectName%5D.googlecode.com/svn/trunk”      e.g.”https://test.googlecode.com/svn/trunk”
svn22
8. Press OK and Enter your Google username and your GoogleCode.com password - in this case “Bx7QS3by2rX9″ -
svn41
9. In the folder add a new text file “test.txt”
10. Right-click /TortoiseSVN /Add…
11. Select the files you want to upload to the SVN.
svn5
12. You should see this in case of a successful uploading.
svn6
13. Note the RED X meaning that this file isn’t up-to-date with the SVN.
svn7
14. Right-click on the text file and select “SVN Commit…” and enter any message you want to write.
svn81
15. This is what you should see after a successful commit.
svn9
16. Note the green check mark on the file meaning it is up-to-date with the SVN.
svn10

Notes

  • If you ever make a mistake and don’t know what to do with the file, right click on it, go to revert. it’ll take you to the head revision.
  • Before modifying anything, make sure you have the latest files from the svn by going to file, svn update.
  • If someone modified the file that you are trying to upload between the time you downloaded it and now, you will get an error. You have to run an SVN update and it will merge the changes you’ve made with the ones in the SVN repository. Then check to make sure the file works correctly, then commit the merged file.
16.Go to your project web page e.g. http://test.googlecode.com and go to “Source” tab then “Browse”  subtab then choose “Trunk” from the list on your left
svn121

yii installation in windows

  • Download Yii Framework from yiiframework.com or here
  • Unpack the Yii release file to a Web-accessible directory.
  • Tip: Yii does not need to be installed under a Web-accessible directory. A Yii application has one entry script which is usually the only file that needs to be exposed to Web users. Other PHP scripts, including those from Yii, should be protected from Web access; otherwise they might be exploited by hackers.
    Yii Web Programming Framework
    =============================
    INSTALLATION
    Please make sure the release file is unpacked under a Web-accessible
    directory. You shall see the following files and directories:

          demos/               demos
          framework/           framework source files
          requirements/        requirement checker
          CHANGELOG            describing changes in every Yii release
          LICENSE              license of Yii
          README               this file
          UPGRADE              upgrading instructions


    REQUIREMENTS
    ------------

    The minimum requirement by Yii is that your Web server supports
    PHP 5.1.0 or above. Yii has been tested with Apache HTTP server
    on Windows and Linux operating systems.

    Please access the following URL to check if your Web server reaches
    the requirements by Yii, assuming "YiiPath" is where Yii is installed:

          http://hostname/YiiPath/requirements/index.php


    QUICK START
    -----------

    Yii comes with a command line tool called "yiic" that can create
    a skeleton Yii application for you to start with.

    On command line, type in the following commands:

            $ cd YiiPath/framework                (Linux)
            cd YiiPath\framework                  (Windows)

            $ ./yiic webapp ../testdrive          (Linux)
            yiic webapp ..\testdrive              (Windows)

    The new Yii application will be created at "YiiPath/testdrive".
    You can access it with the following URL:

            http://hostname/YiiPath/testdrive/index.php

How to calculate the difference between two dates using PHP

$date1 = "2007-03-24";
$date2 = "2009-06-26";

$diff = abs(strtotime($date2) - strtotime($date1));

$years = floor($diff / (365*60*60*24));
$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));

printf("%d years, %d months, %d days\n", $years, $months, $days);

Getting Dates From Week Numbers in PHP


Getting Dates From Week Numbers in PHP

Recently I've been building a little project that pulls data from Google Analytics and shows your web statistics in a simple form. One thing I wanted to do was show the data for a quarter, but graphing by day is too chaotic and graphing by month only gives three points, so I wanted to graph by week. This was fine but the data returned by Analytics only gives me the week numbers, and since this project is aimed at demystifying web stats for normal people, it really needs normal dates on it!

Using DateTime::setISODate

I found that the DateTime extension has a method setISODate() which accepts the year and week number, and makes a date you can then use as normal.

$week_start = new DateTime();
$week_start->setISODate($year,$week_no);
echo $week_start->format('d-M-Y');


You can also do this the other way around; if you have a date in PHP, there's the 'W' flag for date() which will return you the week number - very handy!


http://www.lornajane.net/posts/2011/getting-dates-from-week-numbers-in-php