Conor Mac Aoidh
http://macaoidh.name
conor@macaoidh.name
 

Search

Archives

  • July 2010
  • June 2010
  • April 2010
  • March 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008

Spam

4,729 spam comments
blocked by
Akismet

Tag Cloud

    bt broadband CMS conor's management system conormacaoidh conor mac aoidh content management system drums fast Fedora fedora 10 furasta furasta cms furasta org gnome guide hello world HTML icsp iPhone Java javascript joomla kde Linux Mandriva mc kennas Monaghan Music mysql php repository Scratch stealing the ceiling The Dominican Affair the pot smoking pirates the strats tutorial Twitter updates web design forum webme webworks weekly tweets Windows wordpress

Ads

Furasta.Org 1.0 Pre-Alpha

Posted Dec 30th, 2009 by Conor in in CMS,Web Projects

I have been doing a lot of development on Furasta recently and the project is nearing an alpha release – I hope to have it out next week at some stage.

Below I have attached a screenshot of the new admin interface.

Furasta Pre-Alpha Screenshot

A sneak preview of what is to come in Furasta.Org 1.0

The release won’t be feature packed, but the plugin architecture should be working. Note that the SVN has not been updated in ages, but I should get around to it next week as well.

No responses yet

Mac OS X – VIM Templates

Posted Dec 24th, 2009 by Conor in in Linux,UNIX

I have always wondered if it was possible to use a template system with VIM. Whenever I used large editors it was usually because of the default template schemes they allow. I have always preferred using VIM because it’s so practical, and it’s useful to be able to execute commands in-between editing files.

Well anyway here are a few commands to configure a vim template system on UNIX (It should work on both OSX and Linux):

  • Download the template system:
    curl -C - -O http://www.vim.org/scripts/download_script.php?src_id=3747
  • Open VIM:
    sudo vim
  • Source the file you have downloaded from within VIM by typing:
    :source ./download_script.php\?src_id=3747
  • Now the VIM template system has been configured. The previous command should output the template directory so that you can create new templates, it differs depending on your OS.

That’s it if you need more info on how the system works you can visit the project homepage here.

No responses yet

Java – Drawing Squares

Posted Dec 5th, 2009 by Conor in in College,Java,Languages

This weeks ICSP assignment was to write a program which draws squares. The task was to draw squares from a set list in an array, but I opted rather to accept a command line argument in my script. To write this I had to delve back into regular expression, which I hate because I don’t understand!

The program source is below. You should execute the program from the command line giving the with and height of the square you wish to draw, for example:

java Squares 4x4

And the code:

import java.lang.String;
import java.util.regex.*;

public class Squares{
        public int dimensions[];

        public Squares(String[] args){
                if(args.length==1){
                        Pattern form=Pattern.compile("^\\S+x\\S+$");
                        Matcher fit=form.matcher(args[0]);
                        if(fit.matches()){
                                try{
                                        String[] dims=args[0].split("x");
                                        int width=Integer.parseInt(dims[0]);
                                        int height=Integer.parseInt(dims[1]);
                                        this.dimensions=new int[] {width,height};
                                }
                                catch(NumberFormatException e){
                                        System.err.println("Argument must be a string, width by height, in the form 6x6");
                                        System.exit(1);
                                }
                        }
                        else{
                                System.out.println("Argument must be a string, width by height, in the form 6x6");
                                System.exit(1);
                        }
                }
                else{
                        System.err.println("Please supply an argument, which must be a string, width by height, in the form 6x6");
                        System.exit(0);
                }
        }

        public String draw(){
                int i;
                int z;
                int width=this.dimensions[0];
                int height=this.dimensions[1];
                String square="";

                for(i=0;i<height ;i++){
                        for(z=0;z<width;z++){
                                if((i==0||i==height-1)&&(z==0||z==width-1))
                                        square+="+";
                                else if(z==0||z==width-1)
                                        square+="|";
                                else if((i==0||i==height-1))
                                        square+="-";
                                else
                                        square+=" ";
                        }
                        square+="\n";
                }

                return square;
        }

        public static void main(String[] args){
                Squares square=new Squares(args);
                String draw=square.draw();
                System.out.println(draw);
        }
}
No responses yet

Java – Calculate Taxi Fares

Posted Dec 2nd, 2009 by Conor in in College,Java,Languages

This week my ICSP assignment was to calculate taxi fares. The task was:

Using the fare table write a program that calculates the fares and test if it is correct. Upload your .java or your Scratch file. A template file for java will be provided. (Hint, only the boundary values needs to be tested. The fare table is also presented in the slides. The compile command for java should be “javac TaxiRide.java”)

Fare table
Distance (km) Cost (€)
>50 30
50-100 25, plus 9 for each km > 50
100 – 2000 190, plus 8 for each km > 100
> 2000 1800

It wasn’t the hardest task. The only thing that confused me was the Java switch syntax. In PHP you can have conditions in a switch statement such as:

<?php
switch($num){
        case ($num<10):
                // blah
        break;
        case ($num<100):
                // blah
        break;
        default:
                //blah
?>

I couldn’t get Java to accept anything other than a value for the variable bring switched. So I did it the old-fashioned way! My code is below…

public class TaxiRide{
        public int distance=0;

        public TaxiRide(String arg){
                try{
                        int distance=Integer.parseInt(arg);
                        this.distance=distance;
                }
                catch(NumberFormatException e){
                        System.err.println("Arguement must be an integer representing the distance traveled");
                        System.exit(1);
                }
        }

        public int calculateFare(){
                int distance=this.distance;
                int fare=0;
                int i=0;
                if(distance<50){
                        return 30;
                }
                if(distance%lt;100){
                        fare=25;
                        distance-=50;
                        for(i=0;i<distance;i++){
                                fare+=9;
                        }
                        return fare;
                }
                if(distance<2000){
                        fare=190;
                        distance-=100;
                        for(i=0;i<distance;i++){
                                fare+=8;
                        }
                        return fare;
                }
                return 1800;
        }

        public static void main(String[] args){
                TaxiRide taxiRide = new TaxiRide(args[0]);
                int fare=taxiRide.calculateFare();
                System.out.println("The fare is: "+fare+" euro for traveling "+taxiRide.distance+"kM\n Thank you\n");
        }
}

I feel i am learning a lot from this course. Lately I have been experimenting in a few different languages. I added a bit to the Scratch Linux installer, written in Perl, so that it added an icon in the applications menu during installation. I’ve also been messing around with bash, trying to automate some of my most common commands… was thinking of writing a small bash script that backed up my data when my external hard drive is plugged in, similar to Time Machine on OSX.

No responses yet



Conor's Blog is powered by Wordpress | Template design by Conor Mac Aoidh