I spent almost two hours, looking for Wordpress widget, which supports multiple instances and can embed banners into the sidebar. It looks like the solution is dead simple. Just use an instance of the default Text Widget and paste the HTML code for the banner inside.
Get band's top songs from last.fm
Last.fm is great service. It provides a lot of information, which I find particularly useful for scenata.com. This is an example on how to get band’s top listened songs with the Audioscrobbler’s Webservices API using PHP’s XML Parser. The XML feed is formed as follows:
http://ws.audioscrobbler.com/1.0/artist/artistname/toptracks.xml
The function to use is <pre lang="php">function GetFromLastFm($bandname)</pre> and it returns an array of $bandname’s top listened songs. You may consider caching the results to reduce the server’s threshold.
Download: lastfmsongs.php.gz
eyeOS Bulgarian translation
Here is the Bulgarian translation for eyeOS version 1.1.0.1:
Prime numbers in PHP
This is quite fast (but unfortunately memory consuming) algorithm for generating all prime numbers up no n:
$n = 100; //this is the upper limit
for ($i = 2; $i <=$n; $i++){
$primes[] = $i;
}
foreach ($primes as $num){
if ($num != 1){
$step = $num;
for ($i = 2*$num-2; $i <= count($primes); $i= $i + $step){
if ($primes[$i] != 1) {
$primes[$i] = 1;
}
}
}
}
$primes = array_unique($primes);
$primes = array_values($primes);
sort($primes);
unset($primes[0]);
I found this on Wikipedia here. It needs optimization (for example count($primes) doesn’t need to be called on every iteration) but helped me a lot for solving some Project Euler problems.
Datecs FP-550T
If you’re planning to develop for FP-550T Fiscal printer through the COM Server, don’t download it from the website. Get it from Datecs’ FTP Server: ftp.datecs.bg. The version on the website is obsolete and doesn’t work correctly. This may save you a support call. :)
Live RSS Feed page in Wordpress
Iko has an idea of showing Live RSS feeds in Wordpress Pages. Here is my solution to accomplish this task. Wordpress supports Page templates, on which this solution is based.
- Locate page.php in your template's direcotory.
- Copy the file and rename it to something like rsspage.php, and then open it for editing
- Add or modify header comment of the file to:
- Locate the_content() function in the code and insert the following code after it:
items, 0, $maxitems); } ?>
- Save rsspage.php into your template directory
- Create new page in Wordpress: Write->Page and change Page Template to RSS Page from the right column.
- Save the page
- Go to Manage -> Pages and Edit the page You just created.
- Scroll to the bottom and add new field in Custom Fields named RSS with the RSS feed, You want to show as value. Click Add Custom Field and then Publish the page
That’s all.
The Main code section is provided by Iko
Note! The Create -> Edit procedure is required due to bug in Wordpress 2.3.1
PySnoop 0.1r5
For one of my websites scenata.com, I use two tracking services. The first one is Google Analytics, ant the second is reinvigorate.net. I use Analytics for long term statistics and observation of visitors’ trends and reinvigorate for live user’s statistics like who is on the website at this moment and what pages are open. Also the referrers are displayed with their full URLs in reinvigorate. The service also provides application called Snoop for live visitors’ statistics, which is great but it comes only for Windows and MacOS X. My primary computers is running Debian Linux and I was able to run the Windows version of Snoop but it just looks ugly :). So I decided to implement the protocol used for communication between reinvigorate and Snoop in Python (not my primary language but I’m writing my graduation paper on it so I gave it a try). This gave birth to PySnoop: Python class and sample script, which gives you the ability to monitor your reinvigorate account. It’s still in early alpha stage of development ‘cause I’m the only one using it :), but even this version is working fine.
I you’re interested, you can download the latest version here: GoogleCode or use svn with Anonymous checkout:
svn checkout http://pysnoop.googlecode.com/svn/trunk/ pysnoop
@scenata.com
The latest musical events I’ve visited:
Initial Import
The purpose of this blog is to keep track on the projects I’m working on.