Archive for 'Programming'

Writing Python with PSPad

PSPad is a great editor for programmers. Instead of using a dedicated Python IDE, PSPad can be tweaked to compile and run scripts directly. Here’s how: -

  • Go to Settings -> Highlighters Settings
  • Select “Python” in the left hand pane (if its not selected already)
  • Select the “Compiler” tab
  • In the “compiler” text box, enter or browse to the location of the Python compiler (e.g. C:\Program Files\Python26\python.exe)
  • In the “parameters” text box, enter “%File%” (note the double quotes)
  • Put a tick box in the “Capture Program Output Window” option
  • In the “LOG parser” text box, enter *file %F *line %L*

PSPad Python Settings

Once this is set up correctly, you will be able to run .py files directly from PSPad by going to File -> Compile or using the shortcut (Ctrl+F9).

Updating twitter from python

Just looking into posting twitter updates from python. I’ve found three methods so far: -

Hmmm, more investigation required…

Backup of all MySQL databases

To backup all MySQL databases on a machine, use the following command: -

mysqldump -u root -psecret –all-databases > backup.sql

To restore all databases, use the following command: -

mysql -u root -psecret < backup.sql

To restore a single database (from a cpanel backup etc), use the following command: -

mysql -u user -psecret dbname < dbbackup.sql

AJAX Libraries API

The “AJAX Libraries API” is a google-sponsored initiative that hosts key javascript libraries: -

It handles the cache headers etc, and more importantly saves your bandwidth!

To use them, simply refer to them in your HTML. For example, to load Prototype version 1.6.0.2, place the following in your HTML:

<script src=”http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js”></script>

Graphs and Charts

Open Flash Chart is a great way to include fancy graphs and charts on your web site. There are plenty of examples and tutorials on the site – it’s really easy to use.

Web Page Backgrounds

Sometimes, you just need a simple background for a web page. BgPatterns is a great free website that allows you to create your own tiled/repeating backgrounds – ideal for web pages or desktops.