Posts Tagged ‘behavior’

Set different download locations for different filetypes using Opera

There is one thing about most browsers that really annoys me. It’s related to the download location. First of all it can take you half an hour to find how to change the default download location and after you find it you realize that you can setup only one download location for all types of files. Now this may seem a bit nitpicky, but when you download a lot files you certainly expect a little more sophisticated behavior from your browser. Of course you could always use a download client, but considering how advanced are our browsers it is kind of ridiculous to use such a client nowadays.

Introducing Opera’s download settings – a browser that lets users set their default download location for each filetype. In this short tutorial we will show you how to do just that.

First of all open Opera, click on the Opera button select Settings > Preferences:

Note: Alternatively, you can use Ctrl + F12.

A new window will open:

Navigate to the Advanced tab:

Select Downloads in the left-hand pane:

Here you can see a list of recognized files (listed with their MIME types) and the default download folder. However you can easily set a folder of your choice. Select a file type and click the Edit button. A new window will open:

Here you can directly choose the appropriate behavior for that file, including whether to be saved, opened with Opera, opened with a plug-in, opened with an application of your choice or saved to a specific location. To set a specific location for this kind of file, simply select the Save to disk radio button, check the Do not ask for folder, but save directly to option and choose the appropriate directory:

Click OK and click OK in the Preferences window.

VN:F [1.9.18_1163]
Rating: 6.7/10 (3 votes cast)

Run cron jobs within Django using django-cron

Quite often web applications require cron-like behavior which more or less contradicts with the request-response model.

Not many host providers allow users to create a cron jobs, and even if it is possible, if your site relies on an external script it loses its integrity. It no longer is a website, it is a website relying on cron jobs.

Now at first glance, there is not much difference, but such things make migrating harder and/or may cause a lot of problems in the long run.

As we all know Django is an open source web application framework, designed for rapid development. It follows the so called DRY principle and therefore greatly emphasizes on “pluggability”. In this short tutorial we will show you how to “plug-in” a little but very useful Django application called django-cron, which allows you to easily get cron line behavior.

You can visit the project’s site in at http://code.google.com/p/django-cron

Installation is fairly easy:

  • Download the source
  • Place django_cron on your python path
  • Add “django_cron” in the list of installed apps in your settings.py:
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.admin',
    'django_cron',
)
  • In the beginning of your global urls.py file add:
import django_cron
django_cron.autodiscover()
  • Write your crons in a file named cron.py inside the application you want write crons to. Note: The application must be installed in your settings.py

A cron job is fairly easy to write.

Here is an example cron.py file which deletes old files from a fixed directory:

import os
import time
from django_cron import cronScheduler, Job

class DeleteOldFilesCron(Job):
“””A cron which deletes files older than a minute from a fixed directory”””

    run_every = 60*60*24 # run every day

    def job(self):
        path = ‘/var/www/html/media/tmp/’
        files = os.listdir(path)
        for file in files:
            if(time.time() – os.path.getmtime(path + file) > 60):
                os.remove(path + file)

cronScheduler.register(DeleteOldFilesCron)

Naturally you can have several crons in your cron.py

Note: There are some Apache specific configurations which must be taken into account. For more information visit http://code.google.com/p/django-cron/wiki/Install

VN:F [1.9.18_1163]
Rating: 3.0/10 (2 votes cast)

Fundamentals of Object Oriented Programming

This article is about my experience with Object Oriented programming.Its when I started learning java (an almost truly object oriented programming) and introduced to concept like abstract classes , interface , method overriding , some thing started to going in my mind. this blog is very basic in nature but I really hope it could help beginners on understanding things like classes, objects, abstraction , polymorphism, inheritance ,encapsulation , composition , cohesion , coupling , interface programming etc.

I am planning to write clear and concise post on each of these because I really don\”t like too much information in one shot because it never worked with me , I believe learning is gradual process and always start with most simple things which eventually turned out to be most important one.

So What is Object Oriented programming ?
simple programming which is oriented on objects :) means treat everything surrounding you as an
object.

now question comes what is Object ?
an Object is a particular concrete instance of Class and what is class ? a Class is a blueprint from
which object gets created which has attributes and behavior , we call attribute as members and behavior as methods.

ets see one example : we would like to represent a classroom into OOPS ?
so a classroom is a room , which has certain no of chairs , desks , blackboard , teacher , students etc.

in Java we will write like this.

class ClassRoom {

//members
int noOfChairs;
int noOfDesks;
Teacher currentTeacher;
Students [] students;
Blackboard blackboard;

//methods
public int getNoOfChairs(){

}

public Teacher getNoOfTeacher(){

}

…..

}

I have omitted most of the methods just to focus on concept rather than implementation , so now we know the class is blueprint which has member variable and methods and used to create object , now what is object here , any classroom in which any lecture is going on , your first lecture would be one instance , second lecture would be second instance. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

How to import data from Firefox to Google Chrome

If you have ever switched browsers before you probably know that it is tedious for two reasons. First, the navigation, shortcut keys, behavior, etc. is different. And second, your history, bookmarks, saved passwords are pretty much lost. Well… not exactly. If you are switching from Firefox to Google Chrome you are in luck because exporting data between Firefox and Chrome is a matter of a few clicks. Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

How to make Disk Cleanup run automatically on Windows 7

Without any doubt Disk Cleanup is a great utility. Whether you want to remove temporary internet files, deleted files, dump files or other unnecessary files this is the tool. So why not make Windows run it automatically?

First we will set the behavior of Disk Cleanup. Open the command prompt (open the Start, type in cmd in the search box and press Enter):
Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

How to make Firefox 3 use less memory by limiting the pages it stores in the cache

Many users think that Firefox 3 is way too slow and takes up way too much RAM. Well I partially agree with them. Still, there are certain tweaks that may modify the behavior of Firefox so it will use less memory.
For example, Firefox stores a certain number of pages in its memory (therefore in the RAM) to speed up the Back and Forward features. It is possible to modify that number. This may slow the browsing a little bit, but will limit the memory Firefox uses.

First, open Firefox and open a blank tab. Enter about:config in the Address Bar and press Enter:
Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (0 votes cast)

Changing the default file save location in MS Word 2007

MS Word 2007 stores your documents in the Documents folder (if you are using Vista or 7, and in the My Documents folder if you are using XP) by default. But as messy as it is, I still prefer to save my files on the Desktop (other users may prefer other folders). And always navigating to it when I save a file is extremely annoying. Until… I found out that I can modify that behavior and I can change the default file save location.

First, open MS Word 2007. Press the MS Office button and select Word Options:
Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.9/10 (11 votes cast)

How to manage Firefox tabs

If I have to point out the best feature of Firefox, it will be, without any doubt, the tab browsing. Never again will users be forced to open a couple of dozen windows just to check their e-mails, read the news, see the weather forecast, etc.

Tabbed browsing allows you to put all those pages in one single window. This is helpful, not only because you no longer need to have twenty browser instances on your taskbar, but because you can switch between your open pages in a blink of an eye.

Like most of the things, though, different people react to new features differently, so one should be able to modify features to suit his needs. Well modifying the behavior of tabbed browsing is as easy as it gets in Firefox .

First open Firefox, click on the Tools dropdown menu and select Options: Read the rest of this entry »

VN:F [1.9.18_1163]
Rating: 0.0/10 (10 votes cast)