newspaint

Documenting Problems That Were Difficult To Find The Answer To

Monthly Archives: Dec 2014

The Perl Hash Assignment Gotcha

Question: what do you get if you run the following Perl script?

use warnings;

my %hash => (
    'name' => 'Jimmy',
);

Answer: you get the message:

Useless use of a constant (name) in void context at hashtest.pl line 3.
Useless use of a constant (Jimmy) in void context at hashtest.pl line 3.

So what went wrong? The answer is simple enough but very easy to miss. You probably wanted to assign to the hash variable – but used the comma operator (=>) instead.

To fix merely use an equals sign only after declaring the hash variable:

use warnings;

my %hash = (
    'name' => 'Jimmy',
);

Nissan Primera P12 2.0 Diagnostic Tricks

No responsibility is taken from any problems that may occur from following any advice in any part of this post.


Programming Key Fobs

This is necessary after putting a new battery in a key fob.

Switch ignition-switch exactly six times from the “LOCK” to the “ON” position within 10 seconds and return the ignition switch to the “LOCK” position, key may be removed from the ignition. After 2 seconds the hazard lights will flash twice!

For each key: Press and hold the unlock button (black) while pressing the lock button (red) 3 times. Then release the unlock button. The hazards should flash once! Do the same for the second fob.

Turn the ignition switch to the “ON” position. The hazards should flash twice! The only keys the car will accept are those you just programmed.


Getting into Maintenance Mode

SELF DIAGNOSIS and CONFIRMATION/ADJUSTMENT MODE

  • START ENGINE
  • TURN AUDIO SYSTEM OFF
  • WHILE PRESSING THE INFO SWITCH,TURN THE VOL CONTROL 30 CLICKS OR MORE (dosen’t matter which way)

When self diag and conf/adj mode is started a short “beep” will be heard.

  • Select CONFIRM/ADJUSTMENT
  • Select SERVICE

You should be able to reset and make any adjustments on the screen displayed. If you need to go back a screen at any stage, use the “PREV” button.


Obtaining ECU Engine Codes

  • make sure your foot is off the accelerator pedal
  • twist ignition key to engine on (but don’t actually start engine)
  • wait 3 seconds
  • press the accelerator pedal to the floor and all the way back up 5 times in quick succession
  • wait 7 seconds
  • push pedal to the floor, count to 10 (by the time you get to 10 the engine light should come on), release the pedal when you see the engine light on the dash

The engine light will communicate error codes. It will flash n times for a digit of n (10 times for a zero). The slow flashes indicate the first digit. The rapid flashes will be for the 2nd, 3rd, and 4th digits of a code.

Credits

Information taken from www.nissanhelp.com.


How to Remember What Flashing Lights Mean When Locking

When you press “lock” on your key fob the indicators flash one long time. When you press “unlock” on your key fob the indicators flash twice.

What’s a good trick to remember whether two flashes means lock or unlock?

Say the word as the indicators flash. Lock has one syllable. One flash. Unlock has two syllables. Two flashes.

“Lock” (flash)

“Un…” (flash) “…lock…” (flash)

Easy!

Change Keyboard Layout for Citrix Receiver for Linux

So you’re using Linux with a certain type of keyboard (in my case, US). And you’re using Citrix Receiver for Linux (Citrix client) running a Windows Remote Access Desktop – but inside your Windows sessions it appears that keys are not being mapped correctly – perhaps the CTRL and ALT keys aren’t being detected, perhaps your double quote is swapped with your at symbol.

To fix: you need to explicitly tell Citrix what type of keyboard you are using by editing
  ~/.ICAClient/wfclient.ini
and changing:

KeyboardLayout = (User Profile)

to

KeyboardLayout = US

or whatever keyboard you have from this list at support.citrix.com.

Those options are (in case the list is ever removed from the Citrix site):

  • (Server Default)
  • Albanian Belarusian
  • Belgian Dutch
  • Belgian French
  • Brazilian (ABNT)
  • British
  • Bulgarian (Latin)
  • Bulgarian
  • Canadian English (Multilingual)
  • Canadian French (Multilingual)
  • Canadian French
  • Croatian
  • Czech (QWERTY)
  • Czech
  • Danish
  • Dutch
  • Estonian
  • Finnish
  • French
  • German (IBM)
  • German
  • Greek (220) Latin
  • Greek (220)
  • Greek (319) Latin
  • Greek (319)
  • Greek Latin
  • Greek
  • Hungarian 101-Key
  • Hungarian
  • Icelandic
  • Irish
  • Italian (142)
  • Italian
  • Japanese (client and server IME)
  • Japanese (client IME only)
  • Japanese (server IME only)
  • Korean Latin American
  • Latvian (QWERTY)
  • Latvian
  • Lithuanian
  • Norwegian
  • Polish (214)
  • Polish (Programmers)
  • Portuguese
  • Romanian
  • Russian (Typewriter)
  • Russian
  • Serbian (Cyrillic)
  • Serbian (Latin)
  • Slovak (QWERTY)
  • Slovak
  • Slovenian
  • Spanish Variation
  • Spanish
  • Swedish
  • Swiss French
  • Swiss German
  • Taiwan
  • Turkish (F)
  • Turkish (Q)
  • Ukrainian
  • United Kingdom
  • US
  • US-Dvorak for Right hand
  • US-Dvorak for left hand
  • US-Dvorak
  • US-International

Old Math Riddle/Joke Explained

In Season 5 Episode 1 of “Highway to Heaven” an old math riddle was quoted:

Three sailors check into a motel. At the front desk the clerk charges them $10 each for a total of $30.

The clerk later realises the room price was $25 and gives a bellhop $5 to take back to the sailors as a refund.

On the way to the room the bellhop decides to pocket $2 for himself – and hands each of the sailors $1 each.

Now each sailor had effectively paid $9 each ($10 minus the $1 refund). Three times nine is twenty-seven – $27. The bellhop had the other $2. That makes $29.

Where did the other dollar go?

Mentally it seems like a real puzzle – the men spent $27 on the room. And the bellhop had $2. If you add the two numbers it does result in $29.

The problem is the sign. Spending is the opposite of receiving. Which is why you can’t just add the two numbers. If somebody receives $2 (as the bellhop did) then they technically spent negative $2. So the sailors spent $27 and the bellhop spent $-2 making a total spending of $25.

Let’s do it with algebra:

let sailor’s original $10 spend be s s = 10
original spend on room 3s = 30
refund of $5 3s – 5 = 30 – 5
bellhop keeps $2 3s – (3 + b) = 25
bellhop b=2 3(s – 1) – b = 25
rearrange formula 3(s – 1) = 25 + b
substitute constants 3(10 – 1) = 25 + 2
finalise 27 = 27

There’s no imbalance.

Smart Computers Are No Threat

Stephen Hawking, in an article dated 2 December 2014, stated that artificial intelligence could end mankind.

Now in all likelihood Mr Hawking is considerably more intelligent than I. However I do not believe that there is anything to be worried about with intelligent computers.

Society has a small number of more intelligent beings than the rest of the population. Yet they are of no threat to the existence of the less intelligent. Why is this so?

It’s All About Power

I believe wars and nature have shown us that the threat to existence is solely attributable to power. Humans have wiped out other animal species not out of intent but because they had the power to do so and didn’t restrain themselves.

Our national leaders are rarely the most intelligent of people – again they are often from wealthy families and get where they are because of the networks they have and the people who would benefit from their compliance.

In the school yard intelligent people are routinely targeted for physical assault by those with more raw strength.

Society often demonstrates power against intelligence in the form of strike action by unions who can disrupt society through coordinated action.

And gangs can change/destroy lives through the use of sheer force.

So What Can a Smart Computer Do?

Not a lot! Humans can pull the plug.

Of course if you network a large number of computers and attach them to electrical sources they control along with physically strong mechanical systems – perhaps portable systems (e.g. robotic drones) – then you have a realistic power threat.

But nobody will be that stupid, right?

Is Intelligence Then No Value?

Intelligence does have value. But, by itself, is not a replacement for raw physical or political power. Intelligence helps gain a slight advantage where two parties have equal power. But intelligence is not enough to wipe out or control another.

How Can You Be Sure?

I’m not. This is a personal theory with no scientific evidence to back it up.