Jun 23
My Sites: My Blog | My Tech Blog | Follow me on Twitter
—-

I’m going to be bespectacled and have been advised to reduce and limit my computer usage considerably. A bit of nostalgia set in on hearing this and I thought about my short journey so far in this wonderland of solid-state and otherwise.

First time I touched a computer.
> 1989, at school in 2nd standard

First command I typed on a computer.
> “dir”, 1990, 3rd standard

First game I played on a computer.
> “bricks”, 1991, 4th standard

First Colored game I played on a computer.
> “Dangerous Dave”, 1991, 4th standard

First program I wrote on a computer.
> “Hello, Ankit!” in basic, 1992, 5th standard(The pre-teenage rebel in me substituted the “world” by “Ankit”. Why “Ankit”? That’s a mystery ;-) )

First time I held a mouse.
>1992, 5th standard, Windows 3.0

First Windows Program I used
>PaintBrush (MSPaint today), 1992, 5th standard

First “3d” game I played
> Wolfenstein 3D (or Wolf), 1993, 6th standard Continue reading »


—-
If you liked this post, then you can Subscribe to my feed
Quote of the day: “There’s a time and a place for everything, and it’s called college.” — Chef

written by Shantanu Goel \\ tags: , , , , , , ,

May 03
My Sites: My Blog | My Tech Blog | Follow me on Twitter
—-

GLib - An Introduction:

GLib is a utility library for C, which augments the standard C library in several purposeful ways to make your life that much easier while programming. GLib has the following things to offer you:

1. Portability: The main issue that haunts any C developer is the portability of code. One cannot rely on the standard C library for this as you may find many functions that work differently under different platforms are aren’t there at all sometimes. GLib ensures that the all the functionality exposed by it remains consistent across platforms, so that you can rest assured that your code will work the way its supposed to work irrespective of the Operating System it’s being used for (Of course, this assumes that you have ensured about portability aspects of your non-GLib related source code). Moreover, GLib is available for a vast array of contemporary Operating Systems including GNU/Linux, Microsoft Windows and Mac OS X.

2. Security: Though you still need to be careful about things like freeing allocated memories properly, etc but GLib does ensure that all its functionality is secure. Moreover, GLib has a policy of ensuring that all its functions are threadsafe. This saves you from a lot of checks and balances and locks and scheduling considerations if you had written all this yourself.

3. Useful Data Types: GLib exposes a lot of data types. Some are very basic that maintain portability across OS’s and 32-bit and 64-bit systems. e.g. you can rest assured that gint32 will always be 32 bit and gint64 will always be 64 bit data types.

Apart from this, it also provides a lot of derived data types e.g. singly linked lists, doubly linked lists, hash tables, stacks, queues, trees, and much more. It’d basically cover most of you data structure needs that you’d have otherwise had to implement yourselves. And it also provides helper functions that makes working with them so much more easier. If you have ever used Perl, and have wished that C programming could be a bit faster like it, you will be pleasantly surprised.

4. Utility Functions: GLib also provides various utility functions to ease out your manipulation of data. Some of the functions are meant as more secure and portable replacements for those provided with standard C library, while rest are meant to provide other useful functionality which you earlier had to implement in your code. Some of the major areas covered by GLib’s utility functions are String manipulation, character set manipulation and conversion (including unicode and base64), using regular expressions, file manipulation, shell functions, config file parsing (my favourite), etc.

End Note: I can understand that there would be a lot of people who believe that use of GLib is dumbing down programming in C. After all, we take pride being in control of our code and this is why we love progrmming in C because we have options to do things in our own way. Yes, that is all true but there comes a time where you’d like to spend more time in developing the core functionality of your app, or focus more on giving a rapid shape to your new idea, rather than reinventing the wheel and fumbling around with writing the helper functions. So, keeping that in mind I believe GLib is wonderful piece of code that has enabled me to churn out new apps that much faster.


—-
If you liked this post, then you can Subscribe to my feed
Quote of the day: Homer: Kids, you tried your best and you failed miserably. The lesson is, never try.

written by Shantanu Goel \\ tags: , , , , , , , , ,

Apr 07
My Sites: My Blog | My Tech Blog | Follow me on Twitter
—-

Many users reported errors while activating the version 1.0.1 of my WordPress plugin shantz-wp-prefix-suffix. I tracked it down to a typo that crept into the release somehow. So, if you are using it, then download the fixed version 1.0.2 from the shantz-wp-prefix-suffix homepage.


—-
If you liked this post, then you can Subscribe to my feed
Quote of the day: Ralph: Me fail English? That’s unpossible.

written by Shantanu Goel \\ tags: , ,

Apr 06
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

Some time back I had posted a little hack to fix an issue that users of i3theme have, i.e., their right sidebar drops to below the main content area in IE6. But it wasn’t that good as it took care of only the situation when this phenomena was caused by the tag cloud widget. So, here is a little modification I did to fix the issue more properly.

1. Go to your wp-content/themes/<i3theme> folder and open the style.css file in your favourite text editor.

2. Search for “#sidebar” (without the quotes) until you reach the following code:

CODE:
  1. #sidebar-right,
  2. #sidebar-left {
  3.  width: 210px;
  4.  color: #666666;
  5.  line-height: 160%;
  6. }

3. Now, modify this code to look like:

CODE:
  1. #sidebar-right,
  2. #sidebar-left {
  3.  width: 210px;
  4.  color: #666666;
  5.  line-height: 160%; 
  6.  word-wrap: break-word;
  7. }

4. That’s it. Save your file and you are done.

So what does it do? Basically I just added an attribute “word-wrap: break-word” to the sidebar handling. So, if there is a word that cannot fit in the sidebar width, the word will be broken to continue in the next line and thus the sidebar alignment will remain intact. let me know if you face any issues with this.

Note that this particular word-wrap property is Internet Explorer specific. Firefox (and other browsers) will ignore it, but since the problem with sidebar alignment occurs only with IE, so it will enable IE to display your site properly.


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: Grandpa: My Homer is not a communist. He may be a liar, a pig, an idiot, a communist, but he is not a porn star.

written by Shantanu Goel \\ tags: , , , , , , , , ,

Mar 23
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

There are many code syntax highlighter plugins available for WordPress (e.g. iG Syntax Highlighter, WP-Syntax, etc) but almost all of them have a problem. They want you to write the code in “HTML editing mode”. If you use any kind of WYSIWYG or visual editors (like built in TinyMCE or offline clients’ similar modes), there is a grave problem. Your code becomes garbled. e.g.:

If you intend to write:

CODE:
  1.  cat abc > /dev/null

It might turn out as:

CODE:
  1. </p>
  2. <p>&nbsp;cat abc &gt; /dev/null
  3. </p><p>

 The issue here is that the code highlighting plugins use the “exact” text entered within the [ code ] (or similar) tags, and since we used the WYSIWYG/visual editors, they add html formatting tags to the code and also convert some special characters into HTML entities (e.g. > into &gt;, < into &lt;, white space into &nbsp;, etc).

The workaround is that you can write the code in html editing mode. But the problem here is that if you happen to switch to the visual mode or edit your post in this mode any time later, the problem will come back which makes editing posts a pain. So, here is a simple hack that will let you write your code in visual/WYSIWYG mode without doing anything special.

Continue reading »


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: Morpheus: Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony.

written by Shantanu Goel \\ tags: , , , , , , , , , , , , ,

Mar 23
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

ShantzTodayChanger is a little tool written by me for your Windows Mobile based phones (WM5/WM6) which will cycle ur today background or theme after a set interval of time. It has a lot of features and options and you can even use it to achieve something other than changing wallpapers as well (e.g. running applications at set times) but that depends on your imagination.

Changes in this version:

1.53 - 23-March-08 -> RECOMMENDED UPDATE
i)Theme Color Detection has been improved a lot. Should work much more accurately now.

For more information about this tool, queries, feature requests, updates and downloads, please visit ShantzTodayChanger Home Page.

 


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: Grandpa: My Homer is not a communist. He may be a liar, a pig, an idiot, a communist, but he is not a porn star.

written by Shantanu Goel \\ tags: , , , , , , , , ,

Mar 19
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

Disclaimer: I’m neither a WordPress guru nor a PHP expert. This is what it is, a dirtly little hack, otherwise I’d have called it an “enhancement”

Now onto the main things.

Aim: You would have used wp_list_pages (or plugins like dd-list-subpages, that use it) to display a list of your pages/subpages on a particular page. e.g., I use it on my “Projects” pages hierarchy to list all the relevant projects under a particular heading. Now, the thing is that wp_list_pages gives you a lot of options to display things like dates, page title, page link, etc, but that’s not enough. I need to provide a small description for each page as well, to put things into perspective. Obviously, I don’t expect the visitors to go inside each link to see what it holds in store for them.

The Hack: What you need to do is locate a file called “classes.php” in your wordpress installation. It is usually located at <WordPress Base>/wp-includes.

Now, open the file and find a function called “start_el”. This is a function in the “Walker” class, which is used in WordPress to parse tree-like structures. Here, it used by wp_list_pages to list out all the pages. Now, at the very end of this function (just after the closing brace of if ( !empty($show_date) ) { ), place the following piece of code:


CODE:
  1. $description = get_post_meta($page->ID, "description", true);
  2.             if ($page->ID != $current_page)
  3.             {
  4.                 $output .= "    ";
  5.                 if (!$description)
  6.                 {
  7.                     $description = strip_tags(substr($page->post_content, 0, 250));
  8.                 }
  9.                 $output .= $description;
  10.             }!

What this code does is:

1) Look for a custom field called “description” in your pages. If present, it will show what you wrote there after each of your page in the list generated by wp_list_pages. (To add a custom field to your page, look at the very bottom of your “write” page or “manage” page in the WordPress dashboard.

2) If the “description” field is not present (obviously you might not like to go back and add a custom field to all your pages), it takes the first 250 characters of your page’s content and displays that.

The Hack Is Not Finished Yet: There is just one little thing left to do. As I mentioned, this function is used other times as well (e.g. making your navigation menu). So, you don’t want the description to be appearing always, otherwise it will wreak havoc on your site’s layout. So, there is again a dirty little trick to prevent this.

At the place where you are calling wp_list_pages, modify the call to include the following code before and after the call:

CODE:
  1. update_option('my_wp_list_pages_option', 1);
  2.         $content .= wp_list_pages($your_wp_list_pages_options);
  3.         update_option('my_wp_list_pages_option', 0);

And, modify the previously listed code as well to look like:

CODE:
  1. $my_wp_list_pages_option = get_option('my_wp_list_pages_option');
  2.  
  3.         if ($my_wp_list_pages_option == 1)
  4.         {
  5.             $description = get_post_meta($page->ID, "description", true);
  6.             if ($page->ID != $current_page)
  7.             {
  8.                 $output .= "    ";
  9.                 if (!$description)
  10.                 {
  11.                     $description = strip_tags(substr($page->post_content, 0, 250));
  12.                 }
  13.                 $output .= $description;
  14.             }
  15.         }

What this does now is that it adds an option/variable to WordPress database, which you set to 1 before calling wp_list_pages to tell your code that now its time to display the description, and then restore its state to 0, to prevent the description from being displayed for any other wp_list_pages call.

For your reference, I'm attaching my copy of classes.php here.File Attachment: classes.php.zip (6 KB).
For an example of how it finally looks like, take a look at my “Project” page.

Now It Is Finished: Yes, am not lying. It’s done. All your “Thank You’s” are accepted, and so are your flames, if any .


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: "There's a time and a place for everything, and it's called college." -- Chef

written by Shantanu Goel \\ tags: , , , , , , , , , ,

Mar 16
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

I’m sure you have copied/moved files on your computer from one place to another. And I’m sure often you have to do more than just “single-shot” copying that is copy a few files to one place, move a few to another, and copy yet some more to one more location. Well, I had to do this quite a few times (e.g. I ran out of disk space recently on a partition and had to empty out my “Movies” and “Songs” folders to move a few movies/songs each to all other partitions/disks according to the space available). Hence, I wrote this little command line program, which behaves like a basket.

You can put any number of files from any number of different locations into it in a single shot. It will store their locations and give them an ID. Now, you can copy/move those files to different destinations based on their IDs. What's even better is that your basket will remain intact even across reboots. So, you can continue working on the files in the basket even for days.

Do check it out at Shantz Copy Basket

Note: Packages for windows as well as linux have been uploaded. If you have perl, a perl script is also given that works in both platforms without change. I have tested it on Windows XP SP2 and Ubuntu Feisty Fawn 7.04.


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: Homer: Kids, you tried your best and you failed miserably. The lesson is, never try.

written by Shantanu Goel \\ tags: , , , , , , , , ,

Mar 15
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

Just some news on my WordPress plugins front. shantz-wp-qotd has been updated to version 1.2.1 and shantz-wp-prefix-suffix has been updated to 1.0.1. It is just a minor update meant for people still using a WordPress version < 2.1. The update makes the “page exclusion” feature of both the plugins (i.e. the option to prevent the plugins from acting on “pages”) compatible with WP < 2.1 as well.

Go to their respective pages for downloads:

shantz-wp-qotd

shantz-wp-prefix-suffix


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: Homer: [drunk] Look, the thing about my family is there's five of us. Marge, Bart, Girl Bart, the one who doesn't talk, and the fat guy. How I loathe him.

written by Shantanu Goel \\ tags: , , , ,

Mar 06
My Sites: My Blog | My Tech Blog | Follow me on Twitter
----

Admin Note: Rahul is a long time friend of mine, and is a well known geek amongst his friends and colleagues. I'm happy to announce that he will be enriching this site from time-to-time as a guest editor/author. First up is a small tid-bit of a script that he wrote to ease up his life between installations and reinstallations of everyone's favourite OS: Ubuntu. Over to his post..

Have you ever had to reinstall your ubuntu installation, and then bear the pain of manually installing the applications you've come to love (i mean use :)) everyday? If yes, then cheer up buddy, because all you really need is some magic (read scripting), some typing and spend some time digging the package names of your favourite applications.

To get started, you'll need to type the package information in a configuration file. The format of the file is really simple

  • Any line starting with a # is ignored
  • Blank lines are ignored
  • Any other line, the first word is taken as the package name you want to install

Next, download this script, and make it executable

CODE:
  1. chmod +x rapt-client-install-packages.sh

Continue reading »


----
If you liked this post, then you can Subscribe to my feed
Quote of the day: "You will be who you will be. We are our choices. And we can choose to lead humanity away from this... darkness." - Icarus/Helios

written by Rahul Gupta \\ tags: , , , , , , , , , , , , , ,