Pointless Batch File Exercise

January 25th, 2012

Create a new text file.

Name it “implode.bat”.

Open it in a text editor.

Type the following:

DEL "%~f0"

Save the file and close your text editor.

Locate the file in your browser.

Double click on it.

Haha! Now you’ll have to start again. Sucker.

New Tools for the Indecisive TV Viewer

January 23rd, 2012

More news from Chimpcom.

Not long ago I added the reddwarf command which displayed the name of a random episode, to help you pick on to watch.

I briefly considered creating a complex algorithm to take into account which episodes you’d already seen. I could also implement ratings – per-user and cloud-sourced average – and weight the probabilities based on that.

I may well do that but not quite yet.

In the meantime I’ve generalised the command and given it a new name: choose. “Why?” you ask, “what does that achieve?” Well…

Now, if I type “choose reddwarf” (the series’ name must be one word at the moment…I’m working on that) you will get a random episode name, along with some extra info.

But the bonus is you can now type “choose 24″ or “choose bigbangtheory” or “choose fastshow” or any one of over 6000 other TV shows.

Of course, even though it’s not case-sensitive and there is some fuzziness to the searching, the names aren’t going to be quite how you type them on your first go. To make this a bit more straight-forward I’ve added the shows command.

For a full list of shows type “shows”. To search for a show name, type e.g. “shows dwarf” to find the Red Dwarf. Only one search word is currently allowed.

Handy hint: if you only get one result when you use the shows command, you can use your search term with the choose command. E.g. “shows dwarf” finds only Red Dwarf. Therefore “choose dwarf” would pick an episode of Red Dwarf. However “choose red” would pick a random episode from the first show that matches the word “red” – whatever that is – which probably isn’t what you want.

Listings are provided by epguides.com/.

Next on the list is tab-completion. Watch this space.

Pointless Function is Pointless

December 14th, 2011
Syntax
UnitAbbr$( unit_name )
unit_name is a string representing a standard MapInfo Professional unit name (for example, “km”).
Return Value
String expression, representing an abbreviated unit name (for example, “km”)

So you put in “km” and you get back “km”. How did I survive without this function?!

[Ok, so I think it's supposed to be for converting the English version of a unit to another language. They could have used a better example though.]

Knife Fork Spoon – The Full Story

December 5th, 2011

One three-panel comic. How far can I take the puns. In script for for no very good reason.

 

 

INT. ROOM – NIGHT

TONY lies on the sofa flipping a coin and trying to catch it on his nose. FRANK enters with a harassed expression.

FRANK

Dave’s been knifed!

TONY leaps up, throws the coin through the window and kicks the cat at the fridge.

TONY

Knifed?! That’s forking terrible!

FRANK stares in disbelief.

TONY

[looking concerned]

What, too spoon?

FRANK shakes his head as if to say “what the fuck is wrong with you”.

FRANK

What the fuck is wrong with you?

TONY

Well, what happened? Did they mug him?

FRANK strides away, and launches into the story]

FRANK

Yeah, they just… Wait.

He stops and turns around. TONY’s grinning like a cunt.

FRANK

That was another pun, wasn’t it.

TONY’s smile instantly disappears and he looks concerned.

TONY

No, I just…

[He tails off and sighs in exasperation]

Look, did you call the cups?

FRANK

[starting to lose it]

I’m serious! They almost got me, too!

TONY

Well, were you mugged? You know I always told him you you should just wok away.

FRANK

Do you want me to fucking punch you?

TONY

That’s a whisk I’m willing to take.

FRANK

He’s dead, Tony!

TONY

Oh. Shit! Well…I guess I’ll mark the day on my colander.

FRANK

For fuck’s sake, man-

TONY

Sorry, I’m just…

[he searches for the word]

…bowled over, you know. It’s not a pretty pitcher.

FRANK

Fuck you.

[He storms out]

TONY

Ladle.

PDF Font Embedding

November 14th, 2011

I thought that the idea of PDF – standing, as it does, for Portable Document Format and with portable in this context basically meaning that it should be the same under a variety of circumstances – would look the same whenever it is viewed. This is not the case.

I have also recently learned that as well as the original PDF format there are five subsets:
PDF/X – PDF for exchange
PDF/A – PDF for archive
PDF/E – PDF for engineering
PDF/VT – PDF for exchange of variable data and transactional (VT) printing
PDF/UA – PDF for universal access.

There’s also the non-standard PDF/H – PDF for healthcare – which presumably nurses you back to sanity after you’ve been dealing with PDF files.

Most of the time you won’t need to know or care about the above but sometimes you’ll be in a position – as I was last Thursday – when you send your document to the printers and they come back to you saying that the fonts need to be embedded. Which is odd when the only font being used is Arial.

The trick – at least in my case – is to force your PDF exporter to use PDF/X or PDF/A. because /A and /X are designed for exchange and archiving respectively they require fonts to be embedded. This is usually a case of checking a box in your export/print dialogue. Mine is in a section called “Standards” with the label “PDF/A-1b (Acrobat 5.0 Compatible)”. Yours may be slightly different, but just look for PDF/A, PDF/X or ISO Standard.

Moving Split Access Database Back Ends

November 9th, 2011

So you split your Microsoft Access database into front-end and back-end. Then someone went and moved your back-end database, or renamed the folder. Bastards.

Well, not really. If you set up your database right this shouldn’t matter. Or at least it should prompt you for the new location.

So you open up your front end database. Open up your list of tables and right-click on one and open the “Linked table manager”.

What you should have done to start with is select the “always prompt for a new location” checkbox before you start using the database. Check it now. Also click “select all” and then ok. Access will then prompt you to find your back end database. Which you will do and everything will be alright again. Until next time.

PHP: Public vs Private vs Protected

November 8th, 2011

Here’s a bunch of code exploring the difference between Public, Private and Protected methods and members in classes in PHP.

<?php
// Don't expect this code to run. It's designed to fail.

class Original {
  protected $base_extend = 'base class';

  public $public_var     = 'public variable';
  public $private_var    = 'private variable';
  public $protected_var  = 'protected variable ';

  public function publicMethod() {
    echo 'publicMethod() called from '.$this->base_extend.'.<br>';

    // From here - inside the base class - we can call see all the
    // methods and members.
    $this->privateMethod();             // All
    $this->protectedMethod();           // of
    echo $this->public_var . '<br>';    // these
    echo $this->private_var . '<br>';   // will
    echo $this->protected_var . '<br>'; // work
  }

  private function privateMethod() {
    echo 'Private method called from '.$this->base_extend.'.<br>';
  }

  protected function protectedMethod() {
    echo 'Protected method called from '.$this->base_extend.'.<br>';
  }
}

class Extend extends Original {
  protected $base_extend = 'extended class';

  public function publicMethod2() {
    echo 'publicMethod2() called from.'.$this->base_extend.'<br>';
    $this->privateMethod();             // Fatal error
    $this->protectedMethod();           // Works
    echo $this->public_var  . '<br>';   // Works
    echo $this->private_var . '<br>';   // Works
    echo $this->protected_var . '<br>'; // Works
  }

  /**
   * If we wanted to we could re-define the private method
   * and variable inside the extended class. This way we
   * would be able to see them from within the extended class.
   * As it is, we can only see them from within the base class.
   *
   * private $private_var = 'private';
   *
   * private function privateMethod() {
   *  echo 'privateMethod called from extend.<br>';
   * }
   *
   */
}

$base = new Original();

$base->publicMethod();    // Works
$base->privateMethod();   // Fatal error
$base->protectedMethod(); // Fatal error

$ext = new extend();

$ext->publicMethod();       // Works
$ext->publicMethod2();      // Works
$ext->privateMethod();      // Fatal error
$ext->protectedMethod();    // Fatal error

So, to sum up:

Public methods:
CAN be seen from anywhere, from inside and outside the class. Used for things that should be available to anyone using the class as a “black box”. Anything public should probably be mentioned in the documentation. E.g. $object->doSomethingUseful();

Protected methods:
CANNOT be seen from outside the class. CAN be seen from inside the class and CAN be seen from inside extensions of the class where it was defined. Should be used for things that should not be obvious to “black box” users but are available in extensions of the class where they are defined. E.g. $this->getSomeVariable();

Private methods:
CAN only be seen from inside the class. CANNOT be seen from outside the class and CANNOT be seen from extensions of the class it is defined in. Used for things that should not be messed with – i.e. the hidden inner workings of your base class. You might not even want to mention these in your documentation. E.g. $this->tediousComplexHiddenLogic()

Spam

November 8th, 2011

I’ve just been looking through the spam that has been filtered from the comments on this blog. Some are worth mentioning.

A philosophical one:

If the decision makers aren’t dead yet, then Jesus didn’t do a good enough job. Therefore the people itself should take charge! Simply ignore all the decisions that you know is wrong.

Happy customer with generic praise:

Almost all of what you articulate happens to be astonishingly precise and it makes me wonder why I had not looked at this with this light previously. This article really did switch the light on for me personally as far as this particular issue goes. But there is actually one particular issue I am not really too cozy with and while I try to reconcile that with the actual core theme of the issue, let me see exactly what the rest of the visitors have to say.Well done.

From this post which is one of the least enlightening posts I’ve written.

Generic Praise 2:

This website is my breathing in, rattling great layout and perfect content material .

Generic Criticism:

very radical. Nonetheless, I appologize, but I do not subscribe to your entire idea, all be it exciting none the less. It would seem to everybody that your commentary are not totally validated and in actuality you are your self not wholly convinced of the argument. In any case I did take pleasure in looking at it.

Generic Criticism 2:

You’ve indisputably made some excellent aspects right here. I namely admire the manner you’ve been ready to stick lots thought into a somewhat quick put up (comparitively) which makes it an thoughtful put up on your topic. IMHO you put a whole lot of great knowledge in this put up with out the complete filler that most bloggers use just to make their posts seem longer, that is supreme for a gal like me who doesn’t have plenty time cause I’m normally throughout the go. I normally get so pissed off with so loads of from the outcomes contained in the principal SE’s since they generally seem to largely be crammed with filler content material that usually shouldn’t be reasonably good. In the event you don’t thoughts I will add this submit and your weblog to my mouthwatering favorites so I can share it with my family. I will be back, you could be sure of that so sustain the nice blogging.

Legal Advice:

A legislation business business might be a organization entity formed by any particular person or a lot a lot much more lawyers to interact within of demo of legislation

Indeed.

Damning with bizarre praise:

Hi! I am ofttimes to blogging and i rattling realise your volume. The article has rattling peaks my occupy. I am achievement to bookmark your position and record checking for new collection

Ok, this one’s going in my header. What’s with the word “rattling”? It seems to come up a lot. *googles* Apparently “rattling” is synonymous with “extraordinary” and “energetic”. I did not know that.

SQLite

October 20th, 2011

I’ve copied one file, entered three lines in a terminal and written six lines of code and I’m already getting output. I’m liking this!

Edit: I’m doing this in Python so this is a joy compared to the day it took me to make Python and MySQL speak to each other.

Nelson House Bristol

October 18th, 2011

My Half Life 2 / Left 4 Dead map “Halls of Resistance” is on the first page of Google image search results for “nelson house bristol”. And more if you search for “nelson house halls of residence”. Hah!

Come to Bristol! We’re on fire! And there are headcrabs!