Sunday, January 23, 2011

GIT Hub - Helpful Commands Push and Pull data from Repo via Bash

Here are some helpful bash commands that may help you in pushing and pulling data from repo. Here I'm using git hub.


Pull data from Repo

git pull git@github.com:sample/newtest_php.git

Push data to Repo
git checkout
git add //Here add all your updated file names
git commit
git push git@github.com:sample/newtest_php.git

I think this post will help those who are newbies to the git hub.

Wednesday, January 19, 2011

Grab/Fetch comments from facebook Wall - PHP

The below php code will help you to grab wall comments from the Facebook. You only need to provide profile name(ex: aravindnc) or user id (ex: 1100586621). Please make sure that on the privacy settings in facebook it is set to every one and not friends. You can use the code in what ever place you can, like you can integrate jQuery into it.

<?php
    $ch = curl_init();
    $user = 'aravindnc';
    $graphURL = "http://graph.facebook.com/".$user."/feed?limit=50";
    curl_setopt($ch, CURLOPT_URL,$graphURL);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $contents = curl_exec ($ch);
    $fbComments = array();
    $content = json_decode($contents,true);
    foreach($content as $a=>$value1)
    {
        foreach($value1 as $b=>$value2)
        {
            $list = (array) $value2;
            if($list['message'])
            {
                echo $list['message'].'<br/>';
            }
        }
    }
?>

Here i'm fetching only the user message. Provide your feedback if this helps you.

Tuesday, January 18, 2011

Itunes XML Parser

This simple php code will help you to parse the Itunes XML so that we can grab whichever data we need.

<?php
$myFile = "itunes.xml"; //XML Path
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);

$artist = array();
$start = explode('<key>Artist</key><string>',$theData); //Change this to which key you want
for($i=1;$i<count($start);$i++)
{
    $end = explode('</string>',$start[$i]);
    array_push($artist,$end[0]);
}
$artistList = array_unique($artist);
print_r($artistList );
?>


Sample XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Major Version</key><integer>1</integer>
    <key>Minor Version</key><integer>1</integer>
    <key>Application Version</key><string>9.0.1</string>
    <key>Features</key><integer>5</integer>
    <key>Show Content Ratings</key><true/>
    <key>Music Folder</key><string>file://localhost/C:/Users/Backup/Backup/My%20Music/iTunes/iTunes%20Music/</string>
    <key>Library Persistent ID</key><string>F4C41DD367C50FF8</string>
    <key>Tracks</key>
    <dict>
        <key>1191</key>
        <dict>
            <key>Track ID</key><integer>1191</integer>
            <key>Name</key><string>futures</string>
            <key>Artist</key><string>Jimmy Eat World</string>
            <key>Album</key><string>Futures</string>
            <key>Genre</key><string>Rock</string>
            <key>Kind</key><string>MPEG audio file</string>
            <key>Size</key><integer>6128689</integer>
            <key>Total Time</key><integer>240509</integer>
            <key>Track Number</key><integer>1</integer>
            <key>Year</key><integer>2004</integer>
            <key>Date Modified</key><date>2004-09-10T22:49:02Z</date>
            <key>Date Added</key><date>2005-10-04T00:38:48Z</date>
            <key>Bit Rate</key><integer>203</integer>
            <key>Sample Rate</key><integer>44100</integer>
            <key>Comments</key><string>-=KSi=-  boozy  -=KSi=-</string>
            <key>Persistent ID</key><string>372A8EE2B07ABD84</string>
            <key>Track Type</key><string>File</string>
            <key>Location</key><string>file://localhost/C:/Documents%20and%20Settings/My%20Documents/My%20Music/Jimmy%20Eat%20World%20-%20Futures/01-jimmy_eat_world-futures-ksi.mp3</string>
            <key>File Folder Count</key><integer>-1</integer>
            <key>Library Folder Count</key><integer>-1</integer>
        </dict>
        <key>1193</key>
        <dict>
            <key>Track ID</key><integer>1193</integer>
            <key>Name</key><string>just tonight...</string>
            <key>Artist</key><string>Jimmy Eat World</string>
            <key>Album</key><string>Futures</string>
            <key>Genre</key><string>Rock</string>
            <key>Kind</key><string>MPEG audio file</string>
            <key>Size</key><integer>5316928</integer>
            <key>Total Time</key><integer>208587</integer>
            <key>Track Number</key><integer>2</integer>
            <key>Year</key><integer>2004</integer>
            <key>Date Modified</key><date>2004-09-10T22:49:12Z</date>
            <key>Date Added</key><date>2005-10-04T00:38:48Z</date>
            <key>Bit Rate</key><integer>203</integer>
            <key>Sample Rate</key><integer>44100</integer>
            <key>Comments</key><string>-=KSi=-  boozy  -=KSi=-</string>
            <key>Persistent ID</key><string>372A8EE2B07ABD85</string>
            <key>Track Type</key><string>File</string>
            <key>Location</key><string>file://localhost/C:/Documents%20and%20Settings/My%20Documents/My%20Music/Jimmy%20Eat%20World%20-%20Futures/02-jimmy_eat_world-just_tonight___-ksi.mp3</string>
            <key>File Folder Count</key><integer>-1</integer>
            <key>Library Folder Count</key><integer>-1</integer>
        </dict>
</plist>

Popular Posts