Hari's Corner

Humour, comics, tech, law, software, reviews, essays, articles and HOWTOs intermingled with random philosophy now and then

Plagiarism by the print media

Filed under: People and society by Hari
Posted on Fri, Oct 3, 2008 at 08:45 IST (last updated: Fri, Oct 3, 2008 @ 09:12 IST)

I meant to write about this earlier. Of late, there have been a few bloggers who have had their photographs and images lifted off the internet without permission and published in a mainstream newspaper in India. Is this a stray case? While I would love to think so, the indications are that it is not.

What is alarming is the lack of education and knowledge among the editors and staff of this paper. They seem to imagine that they are entitled to use "free images" available on the internet. As far as I can understand from Sudipta's article on the issue, these newspaper have had a history of doing this while individual content producers are blissfully unaware that their copyrighted material is being filched for commercial purposes.

What should we do about it? First of all, I think that if we allow these relatively small copyright violations to go by without any action, newspapers will consider our intellectual property to be fair game for their benefit. Secondly, being aware of this issue and spreading the word will certainly help more bloggers keep a look-out for any such blatant violations of copyright in future. After all, an individual blogger might not have the power to take on a powerful media giant, but together, we can definitely ensure that such incidents don't go unnoticed in future.

It's in our self-interest to spread the word. The print media certainly ought to behave better in such cases, considering all the holier-than-thou stuff that their editors spout off from time to time. Even if they think internet images are "free" for their use, they ought to contact the image copyright holders for permission to publish in print. If they are so cheap that they are unable to pay photographers or photo journalists to produce original content for them it's their problem, but at the very least they should have respect for other people's hard work. Today it's photographs. Tomorrow they might lift off entire "free" articles from the internet for their use.

But in the meantime there are a few things bloggers can do to help:
  1. Always attribute third party images you might use on your own blogs and set an example first. If possible, write to the original copyright holder and ask for permission courteously. If by chance the original image copyright holder still asks you to remove their image, even if attributed, apologize and comply with their request.
  2. Never upload your own hi-resolution photographs to the internet directly. Always scale it down to a size where it will look horrible in print. Also keep the DPI resolution low (like 72 dpi or lower). Experiment with watermarking images so that the watermarks will be visible in print.
  3. Respect others' copyrights in the same way and don't quote other people's written material without permission and/or attribution.

Finally please use your blog to spread awareness of this issue whoever you might be. Maybe the higher-level authorities in these newspapers might sit up and take notice if enough of us write about it.
Comments (13)  

Function to generate a pagination link list in PHP

Filed under: Tutorials and HOWTOs by Hari
Posted on Wed, Oct 1, 2008 at 12:04 IST (last updated: Sat, Apr 28, 2012 @ 09:01 IST)

When I was writing my blog software code, I came across a challenge peculiar to website scripts which require to display several pages of data. While actually retrieving the data for a particular page is simple enough using SQL queries (using SQL SELECT's LIMIT and OFFSET mechanism) generating a list of navigable links for each page of data is another cup of tea.

Let's assume that you want to generate a list of pages in PHP. E.g. You need to create a blog navigation toolbar, with links to each page on the footer.

The assumption is that you have hundreds of pages to display and you cannot display each page in the navigation toolbar, because that would become unwieldy. What you want is actually a list looking like this below (bolded item is current page):
Page: 1 2 3 4 5 ... 100

Or if the page is in the middle of the the navigation
1 ... 70 71 72 73 74 75 76 78 79 ... 100

If the page is at the end of this list
1 ... 92 93 94 95 96 97 98 99 100

This navigation scheme is not perfect, but it is adequate for most purposes. The following PHP function creates an array of navigable links which can be easily used to create such a pagination. This can be used as a generic pagination function, because it accepts all necessary parameters (including the base URL as well as the query string to use), total number of pages, current page and pagination limit. The pagination limits how many pages are actually shown around the current page.

<?php // Function to generate pagination array - that is a list of links
// for pages navigation
function paginate ($base_url, $query_str, $total_pages, 
                    $current_page, $paginate_limit)
{
    // Array to store page link list
    $page_array = array ();
    // Show dots flag - where to show dots?
    $dotshow = true;
    // walk through the list of pages
    for ( $i = 1; $i <= $total_pages; $i ++ )
    {
       // If first or last page or the page number falls 
       // within the pagination limit
       // generate the links for these pages
       if ($i == 1 || $i == $total_pages || 
             ($i >= $current_page - $paginate_limit && 
             $i <= $current_page + $paginate_limit) )
       {
          // reset the show dots flag
          $dotshow = true;
          // If it's the current page, leave out the link
          // otherwise set a URL field also
          if ($i != $current_page)
              $page_array[$i]['url'] = $base_url . "?" . $query_str .
                                         "=" . $i;
          $page_array[$i]['text'] = strval ($i);
       }
       // If ellipses dots are to be displayed
       // (page navigation skipped)
       else if ($dotshow == true)
       {
           // set it to false, so that more than one 
           // set of ellipses is not displayed
           $dotshow = false;
           $page_array[$i]['text'] = "...";
       }
    }
    // return the navigation array
    return $page_array;
} ?>

To use the function in a PHP page, you just have to simply walk through the array:
<?php // To use the pagination function in a 
// PHP script to display the list of links
// paginate 100 pages - current page is 50 and show
// 5 links around the current page
$pages = paginate ("myurl.php", "page", 100, 50, 5); ?>

<p>Pages: 
<?php 
// list display
foreach ($pages as $page) {
    // If page has a link
    if (isset ($page['url'])) { ?>
        <a href="<?php echo $page['url']?>">
		<?php echo $page['text'] ?>
	</a>
<?php }
    // no link - just display the text
     else 
        echo $page['text'];
} ?>
</p>

The output of the above code will be

Pages: 1 ... 45 46 47 48 49 50 51 52 53 54 55 ... 100

That's all. Hope you find it useful in your own PHP coding project. :)
Comments (14)  

Back to studentship

Filed under: Life and Leisure by Hari
Posted on Fri, Sep 26, 2008 at 20:14 IST (last updated: Wed, Oct 29, 2008 @ 22:48 IST)

I'm officially a student again: a Law College student to be precise. As of now I've attended a grand total of 4 lectures in 2 days already.

Yes, I am going to become a lawyer in roughly 3 years time. Now everybody run for cover while there's still time. :p

On a serious note, this is a chance for me to practice what I preach - that everybody should know the basics of Law - if only to know our rights and duties in a democratic society. The only thing about my course is that the college is quite distant from home and it takes a one-and-a-half hour train journey (apart from travel to and from the railway station) to get there. So nearly four hours a day is wasted on travel alone, but that's not too bad. The course looks to be interesting and becoming a practising advocate (or barrister, if you prefer) at the end of it has a lot of perks and benefits in society (along with the prestige).
Comments (7)  

Screens of my blog software in development

Filed under: My software by Hari
Posted on Mon, Sep 22, 2008 at 21:54 IST (last updated: Wed, Oct 29, 2008 @ 22:45 IST)

Without giving too much away (especially the name I have in mind) I have decided to release a few pre-alpha screenshots of my (top secret :P) blog software in development if only to motivate myself to complete it in a reasonably short duration.

I'm finding that splitting the PHP code into many separate files (especially to separate forms from their actions, not using a templates system and avoiding predefined constants for every single message string is saving a lot of time.

Admin panel home

Admin panel home

Blog configuration settings:

Blog settings

Categories management

Manage categories

Create/update a category

Create/Update category

Delete category

Delete category
Comments (6)  

Roadmap of my blogging system

Filed under: My software by Hari
Posted on Fri, Sep 19, 2008 at 14:30 IST (last updated: Fri, Sep 19, 2008 @ 14:30 IST)

I've been planning to write my own blog software using PHP 5 and SQLite for a while now, but it's been on the backburner as I've not even had time to update this blog recently.

However, I've been working on the idea and have come up with a "road-map" of ideas to work on. The base idea is to keep it clean, non-bloated and with only the features I will require. The code, of course, will be released under GNU/GPL when I'm done.

So here's a list of ideas/features in no particular order for my own reference as well as for those who might be interested:

In other words, my blog software will have none of the frills found in other blog systems like multi-language support, AJAX, WYSIWYG editors, tagging, file/image uploads (which are insecure anyway), pinging, pingbacks, trackbacks, static pages, dashboard statistics, multiple skins/themes (most of the visual aspects of a website can be edited within the CSS file 90% of the time), multiple users with different permission levels, user registration (used mostly by spammers anyway), drag-and-drop widgets, calendar displays, etc.

In other words, this blog software will be tailored to the blogger who knows a bit of HTML and PHP, is willing to edit CSS and configuration files, knows a bit about FTP or SSH for file transfer and needs a no-frills, fully functional blogging system.
Comments (2)  

Lunch breaks and effective working hours

Filed under: People and society by Hari
Posted on Wed, Sep 10, 2008 at 15:02 IST (last updated: Thu, Oct 30, 2008 @ 08:14 IST)

I've really been thinking about the productivity of working hours. I am a firm believer that the number of hours of work shouldn't matter if the quality of effort put in is optimized as I explained in an article on 6-day working weeks.

I am amazed at how much time can be wasted at the office. The potential for time-mismanagement is huge, considering how little work actually gets done in the most productive hours of the day - mornings and afternoons. I see no reason for anybody to put in overtime or staying back an extra hour without something really important to do. I actually think that even the busiest employee need not spend more than 6 hours a day at work provided time is managed properly.

I see the lunch-break hour as the prime culprit in reducing working efficiency for the second half of the day. Most organizations tend to have a lunch break between 1 pm and 3 pm and it's during this time that people tend to relax a bit. Now I'm not denying the need for relaxation, but for two reasons a long mid-day break can really affect work quality and output. Firstly an hour-long gap tends to stop the momentum of work. Secondly the intake of a good meal late in the afternoon can slow one down considerably, both mentally and physically. I have found that an evening after a heavy lunch can be sleepy and dull. Creativity is at a lower ebb. Effectively we spend more time at work, but achieving less and having fewer hours of relaxation afterwards.

To me, the solution is to have a good solid, wholesome meal in the mornings which keeps our energy levels up and work taking only short regular breaks. Cut out the lunch hour, have a light snack and leave early. The extra hour of relaxation after work is much more beneficial from every point of view. This is because we avoid the extra cycle of having to get back into the groove after lunch. The momentum of work is sustained and light snacks are enough to sustain energy levels. Light snacks and regular shorter breaks can do wonders as I've found out personally.

I can also think of other reasons to have a heavy meal in the mornings. Food tends to get digested better when the metabolic rate is higher (as is common for most people) and the effective energy is spread over a longer period of time.

If you're in the habit of taking a light morning breakfast and feeling very hungry by early afternoon and then consuming a heavy lunch which leaves you feeling dull afterwards, try to reverse the timing of your meals. It might just be the answer to improving your workplace productivity.
Comments (13)