Just had to create a quick RSS parser for PHP and thought I'd post my solution. The implementation and class follows.
<?php
$rss = new RSSReader('http://news.google.com/?output=rss');
while ($rss -> hasNext())
print_r($rss -> next());
?>
<?php
class RSSReader {
var $xml = null;
var $pos = 0;
var $count = 0;
function __construct($feed_url) {
$this -> load_url($feed_url);
}
function load_url($feed_url) {
$this -> load_string(file_get_contents($feed_url));
}
function load_string($feed_string) {
$this -> xml = simplexml_load_string(str_replace('content:encoded', 'content_encoded', $feed_string));
$this -> pos = 0;
$this -> count = count($this -> xml -> channel -> item);
}
function get_title() {
return $this -> xml -> channel -> title;
}
function get_link() {
return $this -> xml -> channel -> link;
}
function get_pubdate() {
return $this -> xml -> channel -> pubdate;
}
function hasNext() {
return $this -> count > $this -> pos;
}
function next() {
$obj = $this -> xml -> channel -> item[$this -> pos++];
return array(
'title' => (string) $obj -> title,
'link' => (string) $obj -> link,
'description' => (string) $obj -> description,
'content' => (string) $obj -> content_encoded,
'pubDate' => strtotime($obj -> pubDate),
);
}
}
?>
I just created some very simple extensions for Chrome shortly after I taught myself how to create extensions.
As I said, they're VERY simple, but I find them useful, so I figured it wouldn't hurt to share them.
Each extension is a simple lightweight extension that adds a shortcut button to your browser for quick access to your history, extensions, or downloads. It either opens a new tab, or switches to the respective tab if you already have it open in a tab you're not using.
You could nearly accomplish the same thing if you made a bookmark, but this assures you won't open multiple tabs and I like to keep some things separate from the bookmarks bar.
Chrome Extensions Button
Chrome History Button
Chrome Downloads Button
Looking for a [relatively] quick way to identify duplicate records in a table and list how many records there are for each duplicate? Look no further.
In my case, I’ve got a table named Searches which tracks queries on one of my sites. I wanted to check the top queries, so I used this SQL statement:
1
2
3
4
5
| SELECT COUNT(*) AS repetitions, Query
FROM Searches
GROUP BY Query
HAVING repetitions > 1
ORDER BY repetitions DESC; |
There you have it. A simple, effective way to count and label duplicate records.
I've got 30 more Google Wave invites to give away. Leave a comment with your email and I'll send them. First come, first serve.
This is actually a nomination and it may take a little while before you get your actual invite.
From now on, you must retweet the bitly URL (http://bit.ly/2rwYsG) on twitter and reply to me in order to get an invite.
Example tweet:
@xoise Free Google Wave invites: http://bit.ly/2rwYsG #GoogleWave
Then put a comment in the comment section and don't forget your email (doesn't have to be public).
Here's a simple script to retrieve the approximate number of backlinks Yahoo has for a site. The function and how to call it follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| function get_yahoo_backlinks_count($url) {
$appid = ''; // get this from https://developer.apps.yahoo.com/wsregapp/
$url = "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=$appid&query=site:$url&results=1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.yoursite.com/');
$response = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($response);
return $xml -> attributes() -> totalResultsAvailable;
}
echo get_yahoo_backlinks_count('google.com'); |