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

Monday, April 8, 2013

yii bootstrap install and buttons types



Setup

Download the latest release from Yii extensions by following the link below:
Download Yii-Bootstrap
Unzip the extension under protected/extensions/bootstrap and modify your application configuration accordingly:
If you wish to use the provided Bootstrap theme copy the theme directory to your themes directory.
// Define a path alias for the Bootstrap extension as it's used internally.
// In this example we assume that you unzipped the extension under protected/extensions. 
// Add the following line to /protected/config/main.php 
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
 
return array(
    'theme'=>'bootstrap', // requires you to copy the theme under your themes directory
    'modules'=>array(
        'gii'=>array(
            'generatorPaths'=>array(
                'bootstrap.gii',
            ),
        ),
    ),
    'components'=>array(
        'bootstrap'=>array(
            'class'=>'bootstrap.components.Bootstrap',
        ),
    ),
);
You're done! Now you can start using Bootstrap in your application. For examples on how to use the widgets please visit the docs.

googla analytics api call details

https://developers.google.com/analytics/resources/articles/gdataCommonQueries 
http://ga-dev-tools.appspot.com/explorer/ 

Site referrals

$ga = $this->service->data_ga->get(
    "ga:34343434",
    $startDate,
    $endDate,
    "ga:visits",
    array(
        "dimensions" => "ga:source",
        'sort' => '-ga:visits',
        'segment' => 'gaid::-8'
    )
);
Search referrals

 $ga = $this->service->data_ga->get(
                $this->accountId,
                $this->startDate,
                $this->endDate,
                "ga:visits",
                array(
                    "dimensions" => "ga:keyword",
                    'sort' => '-ga:visits',
                    "filters" => "ga:medium==organic"
                )
            );
It would seem
ga:medium
ge:visits
does the trick,
  • (none) is "direct traffic
  • organic + cpc is search engine
  • referral is non search engine link
then, the sum of everything else is "campaign"

Keywords from Search Engines

$ga = $this->service->data_ga->get(
    $this->accountId,
    $this->startDate,
    $this->endDate,
    "ga:visits",
    array(
        "dimensions" => "ga:keyword",
        'sort' => '-ga:visits'
    )
);
$ga = $this->service->data_ga->get(
    $this->accountId,
    $this->startDate,
    $this->endDate,
    "ga:visits",
    array(
        "dimensions" => "ga:keyword",
        'sort' => '-ga:visits',
        "filters" => "ga:medium==organic"
    )
);

Search Engines

$ga = $this->service->data_ga->get(
    $this->accountId,
    $this->startDate,
    $this->endDate,
    "ga:visits",
    array(
        "dimensions" => "ga:source",
        'sort' => '-ga:visits',
        "filters" => "ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc"
    )
);
Top Landing Pages

$ga = $this->service->data_ga->get(
    $this->accountId,
    $this->startDate,
    $this->endDate,
    "ga:visits",
    array(
        "dimensions" => "ga:landingPagePath",
        'sort' => '-ga:visits'
    )
);
Search referrer details

$ga = $this->service->data_ga->get(
$this->accountId,
$this->startDate,
$this->endDate,
"ga:visits,ga:bounces,ga:visitors,ga:newVisits,ga:timeOnSite,ga:entrances,ga:pageviews,ga:timeOnPage,ga:exits",
array(
"dimensions" => "ga:referralPath",
'sort' => '-ga:visits',
'segment' => 'gaid::-8',
"filters" => "ga:source==".urlencode($referrer)
)
);



 Get segments list

$segments = $analytics->management_segments->listManagementSegments();
Google_Segments Object
(
    [username] => 623644681999-dmg2maloc8obsuiiru0k0fv8no0bouv2@developer.gserviceaccount.com
    [kind] => analytics#segments
    [__itemsType:protected] => Google_Segment
    [__itemsDataType:protected] => array
    [items] => Array
        (
            [0] => Google_Segment Object
                (
                    [definition] => 
                    [kind] => analytics#segment
                    [segmentId] => gaid::-1
                    [created] => 
                    [updated] => 
                    [id] => -1
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-1
                    [name] => All Visits
                )

            [1] => Google_Segment Object
                (
                    [definition] => ga:visitorType==New Visitor
                    [kind] => analytics#segment
                    [segmentId] => gaid::-2
                    [created] => 
                    [updated] => 
                    [id] => -2
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-2
                    [name] => New Visitors
                )

            [2] => Google_Segment Object
                (
                    [definition] => ga:visitorType==Returning Visitor
                    [kind] => analytics#segment
                    [segmentId] => gaid::-3
                    [created] => 
                    [updated] => 
                    [id] => -3
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-3
                    [name] => Returning Visitors
                )

            [3] => Google_Segment Object
                (
                    [definition] => ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==ppc
                    [kind] => analytics#segment
                    [segmentId] => gaid::-4
                    [created] => 
                    [updated] => 
                    [id] => -4
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-4
                    [name] => Paid Search Traffic
                )

            [4] => Google_Segment Object
                (
                    [definition] => ga:medium==organic
                    [kind] => analytics#segment
                    [segmentId] => gaid::-5
                    [created] => 
                    [updated] => 
                    [id] => -5
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-5
                    [name] => Non-paid Search Traffic
                )

            [5] => Google_Segment Object
                (
                    [definition] => ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc
                    [kind] => analytics#segment
                    [segmentId] => gaid::-6
                    [created] => 
                    [updated] => 
                    [id] => -6
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-6
                    [name] => Search Traffic
                )

            [6] => Google_Segment Object
                (
                    [definition] => ga:medium==(none)
                    [kind] => analytics#segment
                    [segmentId] => gaid::-7
                    [created] => 
                    [updated] => 
                    [id] => -7
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-7
                    [name] => Direct Traffic
                )

            [7] => Google_Segment Object
                (
                    [definition] => ga:medium==referral
                    [kind] => analytics#segment
                    [segmentId] => gaid::-8
                    [created] => 
                    [updated] => 
                    [id] => -8
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-8
                    [name] => Referral Traffic
                )

            [8] => Google_Segment Object
                (
                    [definition] => ga:goalCompletionsAll>0
                    [kind] => analytics#segment
                    [segmentId] => gaid::-9
                    [created] => 
                    [updated] => 
                    [id] => -9
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-9
                    [name] => Visits with Conversions
                )

            [9] => Google_Segment Object
                (
                    [definition] => ga:transactions>0
                    [kind] => analytics#segment
                    [segmentId] => gaid::-10
                    [created] => 
                    [updated] => 
                    [id] => -10
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-10
                    [name] => Visits with Transactions
                )

            [10] => Google_Segment Object
                (
                    [definition] => ga:isMobile==Yes
                    [kind] => analytics#segment
                    [segmentId] => gaid::-11
                    [created] => 
                    [updated] => 
                    [id] => -11
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-11
                    [name] => Mobile Traffic
                )

            [11] => Google_Segment Object
                (
                    [definition] => ga:bounces==0
                    [kind] => analytics#segment
                    [segmentId] => gaid::-12
                    [created] => 
                    [updated] => 
                    [id] => -12
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-12
                    [name] => Non-bounce Visits
                )

            [12] => Google_Segment Object
                (
                    [definition] => ga:isTablet==Yes
                    [kind] => analytics#segment
                    [segmentId] => gaid::-13
                    [created] => 
                    [updated] => 
                    [id] => -13
                    [selfLink] => https://www.googleapis.com/analytics/v3/management/segments/gaid::-13
                    [name] => Tablet traffic
                )

        )

    [itemsPerPage] => 1000
    [previousLink] => 
    [startIndex] => 1
    [nextLink] => 
    [totalResults] => 13
)