Click to search Andy Jarrett.co.uk RSS feed

Loading Twitter

Fridays Joke: Second Opinion

A man runs into the vet's office carrying his dog, screaming for help. The vet rushes him back to an examination room and has him put his dog down on the examination table. The vet examines the still, limp body and after a few moments, tells the man that his dog, regrettably, is dead. The man, clearly agitated and not willing to accept this, demands a second opinion.

The vet goes into the back room and comes out with a cat and puts the cat down next to the dog's body. The cat sniffs the body, walks from head to tail, poking and sniffing the dog's body and finally looks at the vet and meows.

The vet looks at the man and says, "I'm sorry, but the cat thinks that your dog is dead, too."

The man, finally resigned to the diagnosis, thanks the vet and asks how much he owes. The vet answers, "$350."

"$350 to tell me my dog is dead?!" exclaims the man.

"Well," the vet replies, "I would only have charged you $50 for my initial diagnosis. The additional $300 was for the cat scan."

Comments Comments (0) | Print Print | Send Send | 1557 Views

Don't sell me 500mb/month limit and tell me its good

O2 are putting in a low, 500mb a month (thats around 16mb a day, don't forget that!), limit for mobile data and their excuse reason is:

"We don't think it's fair that the many should subsidise the behaviour of the few, and we think that we have a responsility to our customers to address this kind of imbalance." ... "97% of our smartphone customers currently use less than 500MB of data every month"

To me that actually says "3% of our users are causing such a strain on our network everyone needs to pay the price"

You can argue that some people might only use 200mb/month and thats fine, but thats what they are using today! As core functionality like "facetime" (which Nokia and a lot of other phones had before it was "new") and HD video become the norm this is going to go up, quickly!

Lets put 16mb per day in to context. Using typical examples from O2 this is how it breaks down:

Usage per day!
YouTube video (4.5 mins) 2 videos
Music track download low quality) 1.6 trakcs! If you use spotify premium or last.fm. BOOM!
Basic web page (100KB) 166. Facebook before you login is 86 KB
Rich web page (300KB) 50. My twitter.com page is 246KB so that is 50 page refreshes

When you look at these figure and think, "I won't look at 166 basic web pages a day" just remember you need to include all the other apps which are also using your bandwidth like emails and push services. Start going in to a app like Dropbox and pulling up that PDF then thats your daily limit gone quite quickly.

I'm not just saying "give me unlimited". I'm not stupid. "Network resources are finite. You can't offer infinite consumption of finite resources". All I am saying is find out why these 3% are using 1Gb a month (or more) and see what needs to change there. It might be as simple as the 3% are jailbreaking their phones to tether to their machines. In which case they are breaking the TOC so dump them.

I don't know the right answer here, but 500mb is the wrong one! Before we commit to anything as users we need to know some basic information:

  1. over the last 12 month have I even come close to the 500mb limit?
  2. can i put a restriction in place to physically stop me from going over the limit?
  3. how well (and accurately) will this be reported to me? (And don't say by text message as that uses the precious, buckling, network that we are trying to protect)? *there is sarcasm in there*

Update: Once you hit your limit your data speed will slow down. You will not be charged more. Which is nice!

Comments Comments (3) | Print Print | Send Send | 1663 Views

cffile in cfscript quick cheat sheet

First time for using CFFILE within cfscript so thought I should document this for myself and anyone else.

Open and close a file

view plain print about
1myFile = expandPath( "somefile.txt" );
2fileObj = fileRead( myFile );
3writeOutput(fileObj);
4// OR
5myFile = expandPath( "somefile.txt" );
6fileObj = fileOpen( myFile, "read" );
7fileClose( fileObj ); // Once a file is closed you cannot access the object

Write to a file

view plain print about
1myFile = expandPath( "somefile.txt" );
2data = "I'm going to create a file object";
3FileWrite( "fileObj", data );
4newFileObj = FileRead( "fileObj" );
5writeDump(var=newFileObj);
6// OR write direct to file
7myFile = expandPath( "somefile.txt" );
8data = "I'm going to write to direct to file";
9FileWrite(myFile, data);

Append a line to a file

view plain print about
1myFile = expandPath( "somefile.txt" );
2fileObj = FileOpen( myFile, "append");
3fileWriteLine(fileObj,"This line is new.");
4fileClose(fileObj);

Output a text file to the screen

view plain print about
1myFile = expandPath( "somefile.txt" );
2fileObj = fileOpen( myFile, "read" );
3while( NOT fileIsEOF( fileObj ) ){
4line = fileReadLine( fileObj );
5WriteOutput( "#line# <br/>" );
6}
7FileClose( fileObj );

Copy/Move and delete a file

view plain print about
1myFile = expandPath( "somefile.txt" );
2myCopyFile = expandPath( "somefile2.txt" );
3fileCopy( myFile, myCopyFile); // fileMove() works the same
4writeOutput( fileExists( myCopyFile ) ); // Check copy worked
5fileDelete( myCopyFile );
6writeOutput( fileExists( myCopyFile ) ); // Check delete worked

Comments Comments (1) | Print Print | Send Send | 1520 Views

cannot cast void to non-void

If you ever see this error it means you're trying to output a function which doesn't return a value.

For me I was playing around with fileDelete() and without looking at the docs I assumed this would pass back a boolean to tell you if it was successful or not.

Comments Comments (0) | Print Print | Send Send | 1187 Views

Subversive error because a newer version is already installed

Subversive error because a newer version is already installed

After a recent update to my Eclipse install every time I restarted the application I kept getting the following screen pop up
Subversive Connector Discovery

The issue was that it didn't matter which connector I installed I got a message stating
Cannot complete the request. See the error log for details.
"Native JavaHL XXX.XXX Implementation (Optional)" will be ignored because a newer version is already installed.
"Subversive SVN Connectors" will be ignored because a newer version is already installed.

After Google not helping me I went through the About Eclipse > Installation Details and removed all references to the connectors. In the screen shot below you can see the last couple of references highlighted
Eclipse Installation Details: Subversive Connectors

With all of them removed I restarted Eclipse and was again presented with the Subversive Connector Discovery screen but this time the selected connectors installed fine.

Comments Comments (1) | Print Print | Send Send | 1486 Views

Framework One for when you don't need a framework pt2

This post follows on from my first part and is all about using a framework for even the most simplest sites.

So our family member, Marvin Acme, has come back with the layout for his ACME gadgets to capture and kill rodents site.
Site layout

Being a family member means we're getting paid most likely with canned beer and with that in mind they are not getting me working on stylesheets!

  1. Create a new folder called layouts in the root of /acme/ and add a file called default.cfm. In there place the following snippet:
    view plain print about
    1<cfparam name="rc.pagetitle" default="A.C.M.E">
    2&lt;html>

    3<head>
    4&lt;title><cfoutput>#rc.pagetitle#</cfoutput></title>
    5&lt;style>*{font-family:"Comic Sans MS";text-align:center;}</style>
    6</head>
    7<body>
    8<cfoutput>
    9<div id="wrap">
    10<h1>A.C.M.E - Outlandish and downright dangerous products</h1>
    11<div id="nav">
    12<a href="#buildURL(framework.home)#">Home Page</a> |
    13<a href="#buildURL('main.about-us')#">About Acme</a> |
    14<a href="#buildURL('main.contact-us')#">Contact Us</a>
    15</div>
    16#body#
    17<div id="footer">A.C.M.E &copy #year(now())#</div>
    18</div>
    19</cfoutput>
    20</body>
    21</html>
    There are 3 elements in here that relate to the framework
    1. #rc.pagetitle#: the "rc" refers to the Request Context and contains all the URL and form variables from the browser which are also made available to the view directly. We can also update this variable from within a view for the default.cfm to read, in this case to update the page title
    2. buildURL simply creates the index.cfm?action= strings for us. You reference the folder name within the views/ folder (in this instance we called it main) and the file name (without the .cfm extention)
    3. #body# is where our view file will be populated in to. There is a lot more to the layouts than I need to go in to here so make sure you check out manual to see what else you can do.
  2. In views/main/ add about-us.cfm. In there put the following code:
    view plain print about
    1<cfset rc.pageTitle = "About A.C.M.E" />
    2<p>About us text coming soon</p>
  3. In views/main/ add countact-us.cfm. In there put the following code:
    view plain print about
    1<cfset rc.pageTitle = "Contact A.C.M.E" />
    2<p>Contact us text coming soon</p>
  4. In views/main/default.cfm replace the currect code with the following:
    view plain print about
    1<p>New site coming soon</p>

You should now be able to go to localhost/acme and see the following:
The site

You're done - obviously minus the content but your 3 page brouchware is setup. No XML config files, setting up debug mode, and thinking about your event names ahead of time head of time.

What is so great about this then?

  • The speed! Yes we could of used no framework and cfmodule on default.cfm, contact-us.cfm, and about-us.cfm but thats a lot of edits to do if the location of cfmodule changed or you wanted to add a required attribute. Look at what has been achieved and we spent no time setting the site up and got all the benefits of having a framework!
  • If Marvin came back and wanted a form or some kind of data displayed we have the benfit of the framework and its abiltiy in handling and passing data around.
  • And again speed! All you've done is created/edited 4 files! No more than if you would of done this without a framework!

Hopefully you've seen that there is no reason not to use a framework even in the smallest of projects. We've managed to create a site and not have to think about MVC or OO (or even XML config files) but at the same time whilst still having the power of these methodologies in the background in case we need them. Don't see this as I am against MVC or OO its just for some apps you don't need to think about these principles and convention over configuration has made this possible.

In keeping with the series I have some more posts as Marvin already has some idea posting and retrieving data and I'll look at how to grow the site.

Found out more about Framework One via:

Comments Comments (8) | Print Print | Send Send | 1179 Views

Framework One for when you don't need a framework

I've just deleted about 2 hours worth of writes and re-writes to simplify what this blog post is all about. Originally I was going to waffle about frameworks and how they can be bad for a project and how they can get in the way but they're not all-round "bad" for every project yada yada. In reallity this blog post is about 1 thing, Framework One, and how its so flexible I'm even using it for basic brouchware sites.

Sure for your big MVC/OO apps you can use FW/1 with your dumb Controllers passing data to the Service layer to request other data from the model to pass back to the view. Which is great, but what I've also enjoyed is that on the otherside it doesn't stop you from very quickly creating a 3 page brouchware site for your family member that doesn't require more core files for features you don't need i.e. dependency injection, than there are application files. Its actually because of all the corse files that in the past I would not of advocated a framework by any means for a 3 page site and it is all down to the overhead of the required CFC's. That stance has now changed and I am going to show you why you should even use Framework One for when you don't need a framework.

As with most code related samples it best to build something; so what the site spec? We are going to build a three page brochureware site (with little or no style) for our family member, Marvin Acme. Marvin wants a simple site that he will hardly be updating but is out there so he has an internet presence. He doesn't care about how we build it or anything techy like MVC and just wants the three following pages:

  1. Home page: Something short and sweet about ACME gadgets to capture and kill rodents to grab the user.
  2. About the company page: Giving background history on the company for it Wile E. Coyote kind of customers to read.
  3. A contact us page: with an address, telelphone number, and maybe even an inline Google map.

Probably not the best spec in the world (at the same time probably better than a lot of other specs we've all seen) but lets get going.

All of this is seems easy so lets clear something up now, without frameworks I'd go off and create a /tags/ folder which holds layout.cfm and for each of the 3 pages I'd use cfmodule wrapped around the contents. I might even have a Application.(cfm|cfc) for holding some site details. There is nothing wrong with that by any means and is just fine for a site this size. What I want to demonstrate to you is that you can do this just as easily with Framework one whilst:

  1. not thinking about or worrying about MVC/OO,
  2. by editing no more files than you would of if you had done this with spaghetti code without a framework,
  3. and while keeping the support of structed code just incase you ever need to add a feature later.

Begin by downloading FW/1 from github.com/seancorfield/fw1/downloads

  1. Create a new folder on your webroot called /acme/ and in there from the Framework One download copy /org/corfield/framework.cfc (directorys as well)
  2. In the FW/1 examples copy the contents of hello1 in to the /acme/ folder
  3. Your /acme/ folder should look something like the following
    Folder setup

You should now be able to go to localhost/acme and see the following:
Test acme setup

This first post is all about the setup and how we have the bare bones already created and we haven't touched a line of code yet. In the second post we are going to create our simple app for Marvin Acme and we'll build it without editing anymore than 4 files (no different than the cfmodule route) or even think about a bloated XML configuration file.

Found out more about Framework One via:

Comments Comments (0) | Print Print | Send Send | 1539 Views

Confederate money


Confederate money, originally uploaded by Andy Jarrett.

Some money my Dad has just found in a big clear-out though doesn't remember how he came across it 20 odd years ago

Comments Comments (0) | Print Print | Send Send | 1905 Views

Pomodoro timer for Chrome

I started using the Pomodoro Technique about a year or so ago and though I don't religiously follow the process in anyway or form what I have taken from it is the need to simply shut everything down and work on a single task sometimes. For those of you who don't know the Pomodoro Technique is a way to manage your time in to sizable 25 minute chunks (with 5 minute breaks) where you focus solely on the task at hand. If my high level breakdown hasn't done a good job of what the process can do for you don't worry, you can check out the site and even download the book for free to find out more.

When you start using the process though the one object you need is a good timer which fits in with your work flow, enter ChromoDoro. The Chrome browser is one program I have open all day for emails, reader, twitter etc so having a timer that works from the browser simply fits straight in with my current development setup. After installation it sits in the top bar and once set displays a countdown timer in minutes.
ChromoDoro timer

There is not much else that can be said on ChromoDoro except the current version is 1.4.0 and though not bursting with features it doesn't have to be as it does its one job really well.

Comments Comments (3) | Print Print | Send Send | 1636 Views

Fridays Joke:

A koala was sitting in a gum tree smoking a joint when a little lizard walked past, looked up and said,'Hey Koala! What are you doing?'

The koala said, 'Smoking a joint, come up and have some.'

So the little lizard climbed up and sat next to the koala where they enjoyed a few joints. After a while the little lizard said that his mouth was 'dry' and that he was going to get a drink from the river.

The little lizard was so stoned that he leaned over too far and fell into the river.

A crocodile saw this and swam over to the little lizard and helped him to the side. Then he asked the little lizard, 'What's the matter with you?'

The little lizard explained to the crocodile that he had been sitting with the koala in the tree, smoking a joint, but got too stoned and fell into the river while taking a drink.

The crocodile said that he had to check this out and walked into the rain forest, found the tree where the koala was sitting finishing a joint. The crocodile looked up and said,
'Hey you!'
And the koala looked down at him and said,
'Faaaaaaaark dude.....How much water did you drink!?'

Comments Comments (0) | Print Print | Send Send | 2318 Views

Previous Entries / More Entries

BlogCFC by Raymond Camden + Twitter @AndyJ + ColdFusion jobs + Contact Me + Snippets/Downloads + RSS .