Chris Tate-Davies

An archive of helpful tit bits of information for development, and probably some stuff that is incomplete, wrong or boring…

Message: [Syntax Error] Expected PlainValue, got ”’ at position x in property {model}

Posted on | December 14, 2011 | No Comments

Was getting the above error in my Doctrine project, turned out I had used a single quote in the ORM Annotations:

    /**
     * @ORM\Column(type='integer', name='row_number')
     * @var int
     */
    protected $rowNumber;

Your ORM Annotations must be double quotes ” to allow the read ahead to read ahead…

 

VPNetMon – close programs when VPN drops

Posted on | December 10, 2011 | No Comments

If you are using a VPN to securely download files, whether it be for anomynous reasons or anything else, if the VPN connection gets dropped, your PC may revert to an unsecured connection to continue the operation.

VPNetMon is an application that montors your VPN connection and if it drops, the application can be configured to close certain apps.

So if you are using a BitTorrent client and using an anonymous VPN connection to download content this will make you feel much more secure indeed.

You can get it at http://vpnetmon.webs.com/

God, Windows is sloooooow

Posted on | November 30, 2011 | No Comments

I am assisting a colleague today check out a rather large feature branch. I showed him the branch address and he started checking it out using Tortoise SVN on Windows 7.

Upon returning to my desk (Ubuntu 11.10), I decided to merge the branch with the major trunk. I checked out a brand new copy of the branch, merged it (for the first time in several months) and then re-committed the pages.

Guess what, he’s still checking out the original!!!

Do yourselves a favour guys, make it Linux this Christmas…

HEX colour chart with RGB reference

Posted on | November 30, 2011 | No Comments

I need this quite often so I thought I would put it on my site. Nothing more, nothing less. (Click it to make it bigger)

HEX colour chart

 

 

 

 

 

 

 

 

 

 

CSS properties direction (padding, margins, etc)

Posted on | November 25, 2011 | 3 Comments

You’ll have no doubt seen:

padding: 5px 10px 5px 10px;

in a CSS file. Do you ever wonder which of the properties are which?

Just start at the top and move clockwise until you reach the left side.

Top Right Bottom Left

It saves doing this:-

padding-top: 5px;
padding-right: 10px;
padding-bottom: 5px;
padding-left: 10px;

Just a simple one that I’m sure 99.9% of people knew.

Ubuntu, Thunderbird always maximised

Posted on | November 23, 2011 | No Comments

I recently switched from Linux Mint back to the old trusty Ubuntu (11.10)

One major problem was Unity, but I got round this by installing Xfce and use that as a shell instead. Much better.

Now, my Thunderbird is proper maximised. Like full screen, so I can’t switch to any applications unless I use ALT TAB. Found help on the net.

1) Close Thunderbird

2) Locate your localstore.rdf file, mine was in:

~/.thunderbird/ftfxbq7f.default$

3) Edit the file, and find the section that looks a little like this:

<RDF:Description RDF:about="chrome://messenger/content/messenger.xul#messengerWindow"
                   width="1024"
                   height="1024"
                   screenX="344"
                   screenY="113"
                   sizemode="fullscreen" />

And change it to:

<rdf:Description RDF:about="chrome://messenger/content/messenger.xul#messengerWindow"
                   width="800"
                   height="600"
                   sizemode="normal"
                   screenX="5"
                   screenY="5" />

Then, once restarted, Thunderbird should be all nice and accessible again. Thanks to Greg for this one!

A-Z list of CSS features

Posted on | November 20, 2011 | No Comments

Found this great list of CSS features.

https://developer.mozilla.org/en/CSS/CSS_Reference

Javascript Hoisting

Posted on | November 18, 2011 | No Comments

When using JavaScript, you declare a variable using the var keyword.

var myvariable = "a value";

These variables are globally accessible unless they are defined within a function. Javascript performs an operation known as “hoisting” when it compiles which draws all the declarations to the top of the page.

Here is a piece of code:

var test = "my test";
alert(test);

When run, the above will display “my test” in an alert, as you would expect.

Consider this:

var test = "my test";
alert(test);

function testMe() {
    alert(test);
    var test = "another test";
    alert(test);
}

testMe();

The above will display “my test” and then an “undefined” error and then “another test” in an alert. This is because we have declared a function variable within the function testMe function and this overrides the global state.

If we refactor the code as so:

var test = "my test";
alert(test);

function testMe() {
    alert(test);
    test = "another test";
    alert(test);
}

testMe();

Because we have not used the var keyword, the variable exists throughout, and the alerts you get will be “my test” and then “my test” and finally, “another test”

Its very important to remember this, as when you have some large functions, you could be getting obscure results you could be looking for a long time to find the issue.

 

 

 

Accessing controller data from a partial viewscript

Posted on | November 17, 2011 | No Comments

When using an inline partial viewscript in my form, I sometimes need access to data. I can accomplish this by using a setter and getter with a public function in my form. We’ll use the action “guinness” as the controller action in this example.

application\modules\project\forms\guinness\base.php

protected $_id;

public function setId($id)
{
    $this->_id = $id;
    return $this;
}

public function getId()
{
    return $this->_id;
}

public function getPintCount()
{
    $model = new PubModel();
    return $model->countPints(this->getId());
}

application\modules\project\views\scripts\guinness\page.phtml

<?=$this->render('_partial.phtml');?>

application\modules\project\controllers\GuinnessController.php

<?php
$form = new SomeForm();
$form->setId(123);
?>

application\modules\projects\views\scripts\guinness\_partial.phtml

<?=$this->element->getPintCount();?>

 

This way I can get the content view my connected partials which in essence are a copy of the viewscript.

Seems a long way round, but it keeps everything nicely separated.

 

 

 

Viewing events attached to elements via JavaScript

Posted on | September 27, 2011 | 2 Comments

If like myself, you often attach functions to elements using jQuery, for example:

$('.btnName').live('click', function() {
    //do something
});

There is a nice little browser extension that will show all the elements on the page with a little bubble outlining the attached events/functions.

It is written by Allan Jardine, and you can get it from http://www.sprymedia.co.uk/article/Visual+Event

 

 

keep looking »
  • Chris Tate-Davies

    Hello there. This is my little "repository" on the world wide web. Its for nothing more than documenting things that I might need again in the future. You could describe it as an extension to my memory.

    Also an online collaboration of my thoughts through the day. I'll try to keep the real random stuff out and keep the blog on course.

    Thanks for stopping by... Hope you find what you're looking for...

  • Tags