Monday 10 December 2012

Raspberry Pi Christmas Lights

I really wish I had the time, equipment and skills to build something like this with my Pi:

   http://www.xmas4all.co.uk/index.html


Friday 12 October 2012

Setting JPEGs to open with Windows Photo and Fax Viewer

On Windows XP, for some unknown reason, sometimes sets something else other than Windows Photo and Fax Editor as the default program for opening jpeg's.

Delete all files in a folder older than x (Part 2)

I wrote a script to delete all files last modified over a certain number of days a few days ago, as mentioned here.  The purpose of the script, I later found out, was to clear old Exchange log files from the email servers, rather than interactively.  The script in the linked page asks for a folder path and number of days, so whilst may be useful for some things, is no good for the purpose we needed.

Tuesday 9 October 2012

Delete all files in a folder older than x

I spent half the day at work writing a VBScript to delete files in a folder last modified after a user specified number of days.


Monday 9 April 2012

RIP Mr. Commodore

The sad news that Jack Tramiel, founder of Commodore International, passed away was announced today:
http://www.osnews.com/story/25784/Jack_Tramiel_passed_away_age_83
Just like many, many others around my age, I spent vast amounts of my younger years staring at one of his iconic creations - the Commodore 16, then later the Commodore 64.

Sad news.

Consumables Tracker System - Part 3 - CSS Menu

This post follows on from Part 1 and Part 2, which describe how the system was designed and how the include files were created and used.  It describes how I created and edited the CSS based menu that appears on every page.

I'm not a design or CSS expert, so I made use of a handy free tool available for Mac OS to create the code for me.  The tool - CSS3Menu - is available for Windows and Mac, and has a free version, which I used, and a paid version that includes more menu templates.  I use the free version because I'm too tight to buy it. 

The tool allows you to select a template and add buttons to the menu, specifying links.  I actually tweaked the CSS code later in the project to adjust the colours but the screen shot below gives you an idea:

CSS3Menu
The tool is so simple to use that A) even I can use it and B) there's no point me explaining it - you'll all work it out no problem!

Once I'd added all the buttons I needed, I clicked on the big 'publish' button at the top and saved the created files to a folder on my desktop.  I copied the contents of this folder - another subfolder - to where the project is.  This sub-folder contains some .png files and a stylesheet that needs to be linked to when using the menu.  To link to this, I just added a line to one of the include files, it was included in all pages in the project:

The code to use to link to the stylesheet can be copied and pasted from the html file that gets created alongside the images and the stylesheet.

The code for the menu itself needs to be added to every page.  It's all been created for you, it just needs to be copied / pasted into place.  In the folder the tool saved its files to, there will be a <your_saved_name>.html file.  Open that in a text editor, and it'll show the coded menu.

I copied the code from the comments 'Start css3menu.com BODY section' to 'End css3menu.com BODY section' into my 'template.php' page under the '<div class="divMenu">' tag:



It would have been better to have put this code in an 'include' file, so if any changes needed to be made, such as adding a new menu item, it could have been changed in one place.  However, because the menu highlights the selected page, it wasn't as simple as that.  I had set the 'Home' button as active in the tool, which made the button blue, compared with the inactive buttons.  Examining the code shows that the '<a href=' part of the code for the active button adds in the code 'class="pressed"' in order to style the link differently.  On each page a different button is 'active', so this attribute needs changing on each page.  For future projects, I may consider modifying the code and adding in a javascript to work out which button should be active and set the class, but time constraints meant I didn't this time round.

When the project was almost complete I modified the colours, so changed the CSS selectors very slightly by replacing the RGB hex colours within the style sheet, hence why the screen shots above don't quite match up.  I also needed to add a few buttons after, which was just a case of copy/pasting the code from the button above and modifying it's href attributes and name.  But here's the finished menu, created with minimal coding, thanks to the developers at CSS3Menu.com:
Completed CSS Menu
Part 4 - Login System - coming soon.....

:)



Monday 2 April 2012

Consumables Tracker System - Part 2 - Include Files

This post follows on from Part 1 - Design.  To save you the effort of reading it all, it basically describes how I get my template page created and coded with CSS.

The next step in the process is to create the a template PHP page.  As many elements stay the same on each page (such as layout elements - headers, css links, etc), and I don't add some stuff into till later (Database connections), I don't want to duplicate effort by adding and editing code on each page I create. So I make full use of PHP's 'include' method.

Include files allow us to have some code written in a file (PHP, HTML, JavaScript) and then reference that code when we need to.  For example, as we have the same header on almost every page, we can place the code that creates the header into a separate file, save it as, say, header.php, and then just reference it on each page.  Then if we want to make a change to the header we can make the change in the header.php file, and the change is then replicated to all pages that use that file.

In this project, I make use of 3 include files.  To start with, I copied all the code in template.html into a new file, and saved it as template.php.  I then selected the code from the top of the document, up to the first point where the code will be different in each page, and copy this to a new file.  In the case of this project, I copied all the code from the very top of the page up to the <title> tag.  The new file was saved as 'header1.php'.  The code in template.php that was selected and copied is replaced with code to call the contents of the file.  The code to call an include file is:



My template.php page then includes the first part of the code that needs to be unique on each page - <title>Template</title>.  Then the process was repeated for the next section of code that stays the same, and saved as 'header2.php'.  In this case, I took everything up to where the side menu code is.  I could have included the menu as well, but I wanted the current page menu link to be styled slightly differently to the rest of the menu.  I'll talk about the menu system in a future post.

After the menu, I have the div that contains the page content - the middle part of the web page.  I add comments to make this really obvious as to where to add my code, and leave plenty of white space.  Then close the div, repeat the process of copying the code from the bottom of the page into another include file, saved as 'footer.php'.

This leaves us with a template page which looks like:


This gives us a fairly clean starting point for each page we create from the template page.

For the sake of completion, here's the code for each of the include files, up to this point:
header1.php


header2.php

footer.php

It's worth mentioning, when a PHP file is created in this way, it's the web server that sorts out, or 'parses' the various files to create the HTML code sent to the user.  I remember using dreamweaver years back, and that had the option to mark sections off as locked.  Changing those sections then went through each file in the project and changed the code in them.  That doesn't happen here.

The template page is then saved, and used as the starting point for most subsequent pages in the project.

Next post....  CSS Menu.... coming soon :)

Sunday 25 March 2012

Consumables Tracker System - Part 1 - Design

When creating any sort of browser based system, I tend to work in the same order each time.  It follows no professional systems analysis model that I know of, but is based loosely on user interface driven design methodologies.

My starting point tends to be a piece of A4 paper, and a pencil.  I try and draw a very rough outline of my page structure:



I'll then create a rough drawing of how I want each page to look - with a blank space in the centre for the page's content.



From here, I'll start working out what <div>'s I'll need, and create an HTML document and associated style sheet containing these <div>'s.  Nothing clever - just a page such as:

Then in the stylesheet, I just use background-color: <something_really_bright> to set each div to a different background color:

The result is a page which looks a lot like this:


The CSS is then tweaked to make the div's float to the right parts of the window, according to my page layout drawing.  For a better understanding of CSS, visit W3 Schools. 

Once I'm happy with the placement of the div's, I remove the 'background-color=' statements in the CSS file, or change them to more suitable colours.  I'll then add the page elements that stay the same on each page, such as the logo and the menu and change the CSS to set the page colour, font styles and font colours.  I originally learnt this method by following an excellent tutorial at subcide.com - one I'd certainly recommend!


Menu
To create menu's for my systems, I use a free tool called css 3 menu on my mac.  I could hand code them, but this tool allows me to quickly put together a menu which looks to much better than anything I could do, very quickly.  Then I add the style code to my CSS file, and copy and paste the HTML code into my HTML file.

This gives me an outline page which looks something like:
I save the HTML file as 'template.html'.  This becomes the base for which most other pages originate from.

Part 2 - Setting Up Include Files - coming soon....

M :)


Saturday 24 March 2012

Consumables Tracker System - Intro


Intro
Where I work, we issue a lot of toners, keyboards and mice, which works out very expensive.  In order to keep track of what is issued, I created a PHP/MySQL driven tracking system in order that we could keep tabs on what was going where, and charge back accordingly.

This series of posts describes how the tracker system works, and how it was put together.


Tasks
The system had to enable the department to record carrying out the following tasks:

  • Issue a toner, keyboard(s) and mouse / mice to rooms, and record this.
  • View a list of all stock issued, and mark as charged back.
  • Add 'on order' stock so that we can track undelivered stock and predict future stock levels
  • View and edit 'in stock' quantities, for stock checking.
Part 1 will follow soon....

Sunday 11 March 2012

Hello World

public static void main(String[]args)
          public class "HelloWorld"
          {
                        System.out.println("Hi, welcome to my blog");
           }
}

Output
Hi, Welcome to my blog

Not much here yet, but whilst you wait in anticipation of master zen-like coding hints (You'll be in for a long wait ;)  ), have a look at my 'About' page.

Maria :)