sandip's blog
Submitted by sandip on Thu, 01/26/2006 - 11:10
Here's a quick tip at sorting VARCHAR type data in mysql database with values in a column.
With the default sort, it would look something like below:
mysql> SELECT column FROM table_name ORDER BY column;
column
======
100
1000
10000
200
2000
20000
...
Now with "... ORDER BY column+0", I get it sorted right:
mysql> SELECT column FROM table_name ORDER BY column+0;
column
======
100
200
1000
2000
10000
20000
...
This is a quick fix instead of sorting to CAST operator.
Submitted by sandip on Sun, 01/22/2006 - 13:47
Support LinuxWeBLOG by purchasing pixels at the pixels homepage. It is being introduced for just 10 cents a pixel for a limited time, so don't miss out the opportunity to advertize your site and begin receiving traffic from us.
The site is already spidered by the bigger search engines like -- google, yahoo, msn, aol etc...
This is a one time deal and your link remains on the site forever. With the growing hits and membership on the site, the cost will not remain the same... Buy Pixels NOW !!
Submitted by sandip on Wed, 01/11/2006 - 11:09
Here's a quick way to create a listing of images uploaded to a folder with php:
<?php
// file name: list_pics.php
global $startDir;
/**
* List Directories function, which transverses sub-folders
* listing out the image files that exists within it.
*/
function listDir( $path ) {
global $startDir;
$handle = opendir( $path );
while (false !== ($file = readdir($handle))) {
if( substr( $file, 0, 1 ) != '.' ) {
if( is_dir( $path.'/'.$file ) ) {
listDir( $path.'/'.$file );
}
else {
if( @getimagesize( $path.'/'.$file ) ) {
/*
// Uncomment if using with the below "pic.php" script to
// encode the filename and protect from direct linking.
$url = 'http://domain.tld/images/pic.php?pic='
.urlencode( str_rot13( substr( $path, strlen( $startDir )+1 ).'/'.$file ) );
*/
$url='http://domain.tld/images/'.
substr( $path, strlen( $startDir )+1 ).'/'.$file;
// You can customize the output to use img tag instead.
echo "<a href='".$url."'>".$url."</a><br>";
}
}
}
}
closedir( $handle );
} // End listDir function
$startDir = '.';
listDir( $startDir );
?>
Submitted by sandip on Mon, 12/26/2005 - 01:07
GnoCHM is a CHM (Microsoft Compressed HTML Help) file viewer. It is designed to integrate nicely with Gnome. It uses PyCHM, a Python package that exports the CHMLIB API.
You will need to add the following lines to your yum config, "/etc/yum.repos.d/dries.repo":
[dries]
name=Extra Fedora rpms dries - $releasever - $basearch
baseurl=http://ftp.belnet.be/packages/dries.ulyssis.org/fedora/linux/$releasever/$basearch/dries/RPMS
gpgcheck=1
enabled=0
Import dries GPG key:
# rpm --import http://dries.studentenweb.org/rpm/RPM-GPG-KEY.dries.txt
Run yum enabling dries repos and install "gnochm":
# yum --enablerepo=dries install gnochm
This will also install all the required packages: chmlib, python-chm and gnome-python2-gconf.
Submitted by sandip on Thu, 12/22/2005 - 23:42
Below is a simple php script to generate a playlist of the mp3 files placed in a folder. I have tested it to work with XMMS media player on FC4 and should work with others too. Substitute the path and the url of the music folder.
<?php
// music_playlist.php
$folder_path = './music_folder';
$folder_url = 'http://domain.tld/music_folder/';
if ($handle = opendir($folder_path)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$song_list .= $folder_url.$file."\n";
}
}
closedir($handle);
}
else {
echo "Music folder does not exist!";
exit;
}
// send header of audio/x-mpegurl content type
header('Content-type: audio/x-mpegurl');
if (preg_match("/MSIE 5.5/", $HTTP_USER_AGENT)) {
header("Content-Disposition: filename=\"my_playlist.m3u\"");
}
else {
header("Content-Disposition: inline; filename=\"my_playlist.m3u\"");
}
echo "$song_list";
?>
Related Reading: Listen to mp3 songs using XMMS in Redhat/Fedora
Submitted by sandip on Thu, 12/22/2005 - 09:31
Nepali version of Linux ‘NepaLinux’ launched - Madan Puraskar Pustakalaya undertook the Nepal component of the 30-month long PAN Localization Project, a multi-nation localization project being conducted in Afghanistan, Bangladesh, Bhutan, Cambodia, Laos, Nepal, and Sri Lanka, with the support of International Development and Research Center (IDRC), Canada. This project includes a Nepali GNU/Linux distribution 'NepaLinux' comprising of localized GNOME, OpenOffice.org, Mozilla suite, and other utilities that include Nepali Spellchecker, Thesaurus, Nepali Unicode support, etc. This distribution can be used in Nepali as well in English environment.
Now to get my hands-on and do some testing...
Submitted by sandip on Mon, 12/12/2005 - 10:00
Recently had a problem with my volume control applet after an up2date on FC4 which would come up with the error, "No volume control elements and/or devices found".
Doing a simple `gst-register-0.8` as root. Logging out and logging back in resolved this issue.
It registers all the GStreamer plug-ins and creates a listing of their properties so that the plugin is loaded on startup of GStreamer based applications.
Submitted by sandip on Sun, 12/11/2005 - 22:31
If you are looking to purchase printers compatible with Linux... I would suggest going with HP products as I have had no problems with configuring and priting to HP printers.
HP has an opensource Linux Inkjet Driver Project located at: http://hpinkjet.sourceforge.net/ with excellent installation documentation at: http://hpinkjet.sourceforge.net/install.php
The HP Linux Printing project provides printing support for over 300 printers including DeskJets, OfficeJets, Photosmarts, Business Inkjets and LaserJets. Check the products supported via: http://hpinkjet.sourceforge.net/productssupported.php
Submitted by sandip on Wed, 12/07/2005 - 00:46
Php Object Generator, (POG) is an open source PHP code generator which automatically generates clean & tested Object Oriented code for PHP4/PHP5 application to access the underlying database. By generating PHP objects with integrated CRUD methods, POG gives you a head start in any project and saves you from writing and testing SQL queries. The time you save can be spent on more interesting areas of your project. Give it a try!
Submitted by sandip on Wed, 12/07/2005 - 00:41
MyDBO is a powerful object-oriented code generator for PHP/MySQL Web application developers. It is designed to remove the hassle of implementing familiar database operations (select, update, insert, etc) over and over again when creating Web applications. It creates code for accessing your database tables without you having to worry about connections or SQL queries. It also allows you to approach your database in an object-oriented fashion, thus giving you real flexibility. It uses templates to generate code, so it is also possible to create your own templates.
|