Currently Browsing: Quickies

The “European Knowledge” experiment

I have just started a very small poll that is part of a small experiment i am conducting. If you’re interested please check it out and vote here. Please do not lookup the answer online. It will only take a minute to complete. The results of the experiment will be revealed once i close the survey, in about a week or so. I would like to thank anyone that participates in advance.

WordPress plugin competition submission: YANewsflash

As i said on the releasing article of my plugin YANewsflash, i have started the submission process of it to the WordPress plugin competition with this introductory article. As i also said before, i don’t think it stands a chance but still, it is a plugin released within the competition time limits so, i thought i’d go on with it. I just thought i’d give you the heads up so if it comes to a vote you know what to do ;)

Creating a search page on WordPress

You all know i had a theme change about a week ago. This theme is great and i really love it. As it seems you guys love it too. Anyways, since day one i noticed there is no search field nowhere in the theme. That was a pretty strange fact i hadn’t seen in any theme i’ve seen and tried out before. I didn’t really care much in the beginning since i can search from the admin area and i really thought that you guys, my readers, wouldn’t really need the search function. I was mistaken. My friend and loyal reader Giwrgos (George) came back to me with a comment about the missing search functionality. As he is a techy guy himself, he was able to pull out a search the hard way, but, i was troubled about how any other non techish guy could do it. So i started considering my various options.

For starters i could add a search field somewhere in the theme. That was not really an option since i am not that good on designing and i could really mess up the look and feel of the site (something i’d hate to do since i really like this look). And here is what i came up with.

(more…)

Easily create paragraph sidenotes

When i talk about WordPress you all know that i prefer doing something by hand rather install a plugin to do it – provided that the task at hand is easy to do. I have already shown you how to get rid of the various sociable plugins and do it yourself easily through some php and css tweaking. Here i am about to show you how to easily add paragraph sidenotes. I first saw the usage of sidenotes on WordPress on the blog of my dear friend Mike Nichols. I have no idea if he does it by hand or has a plugin do it for him. In general, sidenotes make a large text much more easier to read and grab the concept. When going through large chunks of text with so much info on them it’s a good thing to have a phrase that summarizes what will be discussed in the next few lines. The process we will follow is pretty simple. We will tweak a little our theme’s CSS and that’s about it. Then adding a sidenote will be as easy as wrapping it with a div. Here is an example output:

sidenotes

Let’s get down to business. We are going to have every sidenote appear floating left of our paragraph. Here is the CSS block that will do  just that:

(more…)

Quick URL parsing using Perl

Have you ever stumbled on a page that you would like to copy-paste all the links from and, darn, they were many? For instance when you get that directory listing and you want to download all the files? Well, i faced the problem these days. I wanted to copy more than 30 consequtive links from a directory listing and i thought that it’s plain stupid doing it by hand. Now, the first thing that popped into my mind was a FireFox plugin. I started looking here and there and every one of those had something i didn’t like. So, then it came to me. I would copy the page source and then use a little Perl script to extract those links. Sounds hard? Well it’s not since Perl is the right thing for this job. So, a little tinkering here and there and this is what i came up with.

  1. #!/usr/local/bin/perl
  2. package MyParser;
  3. use base qw(HTML::Parser);
  4. $prefix = "http://a_site_do_use.com";
  5. sub start {
  6.         my ($self, $tagname, $attr, $attrseq, $origtext) = @_;
  7.         if ($tagname eq ‘a’) {
  8.                 print $prefix.$attr->{ href }."\n";
  9.         }
  10. }
  11. package main;
  12. $file = "urls.txt";
  13. open(URLS, $file);
  14. @lines = ;
  15. close(URLS);
  16. $html = "";
  17. foreach $line (@lines){
  18.         $html .= $line;
  19. }
  20. $parser = MyParser->new;
  21. $parser->parse( $html );

A quick explanation of it is this. We use the HTML parser that Perl brings in. It’s a pretty nifty tool. If you want to use this as is you need to check out two things. One is that the contents of the page to extract the links should be on a file “urls.txt” and the second is that if the URL’s are relative (just like the ones that apache produces on a directory listing) you need to add the full prefix on the “$prefix” variable. If you want to tweak it be my guest. It’s draftly written anyway. If you don’t feel comfortable with code then go for those plugins. They are pretty good. Just not for me.

So, i hope this helps out for you guys as it surely did for me!

PS: I know it can be written more effectively but it works so i’m done tweaking :)

« Previous Entries