SQL tip: How to bind NULL with PHP and Oracle

Neat little trick to bind a null value without using an if clause.

How often have you done something like this when a variable might be null:

$sql = "SELECT * FROM someTable WHERE col1 = :firstVar";
if ($secondVar !== null) {
   $sql.= " AND col2 = :secondVar";
}
...
oci_bind_by_name($stmt, ':firstVar', $firstVar);
if ($secondVar !== null) {
   oci_bind_by_name($stmt, ':secondVar', $secondVar);
}

Then checkout this, which is quite a bit shorter and a lot easier to read:

$sql = "SELECT * FROM someTable WHERE col1 = :firstVar
   AND (col2 = :secondVar OR :secondVar IS NULL)";
...
oci_bind_by_name($stmt, ':firstVar', $firstVar);
oci_bind_by_name($stmt, ':secondVar', $secondVar);

How to recharge your camera batteries in the Amazonian jungle

I’m going on a photo expedition into the jungle of Guyana up the Rewa river. I’m planning on bringing my Nikon D800 camera and the D300 as a backup. In order to be able to recharge the batteries, I had to come up with a solar solution since there is not going to be any electricity. Therefore I purchased the waterproof and flexible solarpanel CHEPRE by SIStech Switzerland. It weights only 530gr, but is powerful enough to recharge both batteries, the EN-EL15 for the Nikon D800 and the EN-EL3e for the Nikon D300.

CHEPRE solar panel charging battery for the Nikon D800/D300
Charging an EN-EL3e battery for the Nikon D300 with the solar panel CHEPRE. Next to the charger the exchangeable plate for the battery EN-EL15 for Nikon D800 (this is not in Guyana yet, but still in Switzerland).

Solar panels produce only direct current (DC), but the standard battery chargers expect alternating current (AC), so no luck using the standard chargers that come with the camera. Furthermore, both camera use a different type of battery, which would mean to bring two cradles, one for each. Fortunately, there is a smart solution of a universal battery charger with exchangeable plates which can be connected directly to the panel or to any standard 12v cigarette lighter plug. It is advisable though to use a powertank as a buffer to be independent of sunlight.

I successfully loaded both batteries within a few hours even on slightly over casted days. I was also capable of charging the Ultrabook ASUS Zenbook UX31A via the powertank.

 

 

Nikon D800 examples of bird photos with high ISO settings

Here are some examples of bird photos taken with the Nikon D800 and the 600mm or 300mm lens in Finland. The weather and light conditions were very poor, so high ISO settings between 1600 – 3200 were necessary.

Photo of a female Great Grey Owl on the nest.
Photo of a female Great Grey Owl (Strix nebulosa) taken with f4.5, 1/250 and ISO 3200 late in the evening (5575 x 3721 pixels).

Continue reading “Nikon D800 examples of bird photos with high ISO settings”

What’s the fastest way to transfer photos from the Nikon D800?

I did some quick and unscientific comparing of different ways to transfer photos from my Nikon D800 camera to my PC. I also looked at the D800’s internal copying versus copying with a card reader.

Setup

Setup1: The Nikon D800 camera is used as the card reader and connected directly via cable to different USB ports on the computer including the multicard reader’s own USB3 port.

Setup 2: Using the Icy Box IB-865 card reader directly.

Transfer: Copying 291 photos (12GB) from the memory card to the PC’s hard drive (SSD):

Results

Transfer from the SDHC card

card reader           connected to         time
Nikon D800            PC USB2 front       10m 48s
Nikon D800            PC USB3 front r      4m 44s
Nikon D800            PC USB3 back         4m 11s
Nikon D800            PC USB3 front l      3m 48s
Nikon D800            PC USB3 Icy Box      4m 00s
Raidsonic Icy Box                          2m 34s

 

Transfer from the CF card

card reader           connected to         time
Nikon D800            PC USB3 Icy Box      4m 27s
Raidsonic Icy Box                          2m 22s

 

Direct copy from SD card to CF card

Nikon D800            Nikon D800           8m 00s
Raidsonic Icy Box     Icy Box              6m 28s

 

The clear winner is the multi card reader connected to the internal USB3 port on the motherboard. Transfer is almost 5 times faster than the slowest connection via USB2.

Technical Details

Desktop PC:
Processor: Intel Core i7-2600K, 3.4GHz
Memory (RAM): 16GB
Motherboard: ASUS P8P67 Deluxe
System OS: Windows 7 Professional 64bit
Harddrive: Crucial SSD C300 128GB SATA 6GB/s

Camera: Nikon D800

Storage media:
SanDisk Extreme Pro SDHC 16 GB 95MB/s
SanDisk Extreme Pro Compact Flash 90MB/s 32 GB

Card reader:
Raidsonic Icy Box IB-865 USB3 Multi Card Reader hooked up to the motherboard’s internal USB3 20pin connector replacing the ASUS frontpanel USB3 ports.

Changing cursor to wait while request is in progress

Switching cursor to ‘wait’ and back to ‘default’ is tricky since some elements such as link, input or button have a different default style. Setting it back to ‘auto’ does not work in Firefox, but to an empty string works. Here’s how you would do it with dojo:

require(['dojo/_base/connect', 'dojo/query'], function(connect, query) {
	// change cursor on first ajax request
	connect.subscribe("/dojo/io/start", function() {
		query('*').style('cursor', 'wait'); // also when mouse is over buttons or inputs
	});
	// change cursor back on last ajax request
	connect.subscribe("/dojo/io/stop", function() {
		window.setTimeout(function() { // seems to fix FF not always setting cursor back to auto on some elements
			query('*').style('cursor', ''); // in FF auto would set default cursor, use '' instead
		}, 50);
	});
});

Using Nikon D800 for flying birds

Over the last three weeks, I’ve been using the Nikon D800 to shoot birds on my vacation in Florida. Here are my unscientific and personal findings for shooting birds in flight from tripod and hand-held with some example photos below:

  • Auto ISO sensitivity control is bliss if you don’t use manual exposure mode. For birds in flight or any other wildlife in fast action, I normally have it set to: ISO sensitivity 100 (= minimum), Maximum sensitivity 1600, Minimum shutter speed 1/1600-1/2000. For slower moving or more static animals, 1/640 seconds seems to give good and sharp results. Of course if you have enough light go as fast as possible.
  • When using CF a general AF problem is that the focus point is often not on the eye. This is not specific to the D4/D800’s new AF system (Advanced Multi-CAM 3500FX). So just shoot and hope for the best.
  • The new AF system seems to be very fast and hunt less than the previous one, especially when the background is the sky.
  • With the new AF system I don’t need to overexpose +1 or +2 when shooting flying birds against the blue sky as with the old AF (Multi-CAM 3500DX).
  • You don’t need more than 4fps to capture wildlife in action (I already knew this before and couldn’t understand all the fuss about it being slow).
  • Having so many pixels at hand is really helpful, since it is easier to catch a bird in flight when it is further away, then just crop to get the right detail. This is a huge advantage over the D4 and I think far more relevant than the 4fps versus 10fps.
  • If you only want photos that are sharp down to pixel level, be prepared to have to throw away many of your shots (Be aware that this makes sense only if you plan to crop or print in gigantic dimensions).

Photos of flying birds using a tripod

All photos below were taken with the Nikkor 600mm/f4 VR mounted on a Gitzo Tripod GT5541LS with a head by Dietmar Nill.

Flying Great Egret (Ardea alba) with fish in beak
Flying Great Egret (Ardea alba) with a little fish in its beak. Taken at f5.6, 1/1600, ISO 640

Continue reading “Using Nikon D800 for flying birds”

Nikon D800: Beware of the 36 Megapixels

Have you ever laughed at the TV shows where they use a photo to investigate a crime and with the use of some piece of software they just can press the enhance button and then suddenly some detail appears magically out of nowhere?

Laugh no longer.

Below is just an innocent photo of a bird.

Photo of an Anhinga (Anhinga anhinga)
Portrait of an Anhinga (Anhinga anhinga) 7360 x 4912 pixels shot hand-held at f4.5, 1/640, ISO 800 using Nikkor 105mm/2.8

Continue reading “Nikon D800: Beware of the 36 Megapixels”

My First (Bird) Photos with Nikon D800 and 600mm f4

Only few talked about it being good for wildlife, most said it’s only for landscape, architecture or studio. Many would have preferred a lower pixel count and questioned whether it’s going to be of any use. But when shooting birds, especially small song birds, you never get close enough or can have enough pixels. So I didn’t listen, took the risk and pre-ordered mine on the day it was announced, the new Nikon D800.

In the meantime its sensor got tested by DxOMark and became their new king. Two days ago mine came by mail. I took some test shots to see if some of my lenses needed AF fine tuning, already that revealed how good the camera will perform. It also showed what an incredibly sharp lens the 600mm f4 VR is (see photos further down on page). Yesterday and today I went out to test it and came back with a few shots of a male and female Goosander (Mergus merganser). After looking at the results, pixel peeping included,  I am a very, very happy and excited new Nikon D800 owner. But see and peep for yourself:

Photo of a female Goosander (Mergus merganser) taken with the new Nikon D800
Uncropped photo of Merganser (Mergus merganser) taken with the new Nikon D800 and the 600mm VR f4. You have 7360 x 4912 pixels available for cropping!

Continue reading “My First (Bird) Photos with Nikon D800 and 600mm f4”

REST with dojo and PHP: Notes on using dgrid with a caching store

I would like to share some (personal) pitfalls I came across when creating the demo REST with dojo and PHP: Demo of a dgrid observing changes to the JsonRest store:

  • dojo/store/Observable only works correctly when the object has an id. Unfortunately, dojo/store/Memory.add(object) does not add the id to the object when creating it (as of 1.7.1) .  See bugs #12835 and #14281. For a fix see changeset #27072
  • Observable does only work correctly with a store, that provides a queryEngine. dojo/store/JsonRest does not have a queryEngine by default, so you will have to provide your own. If you are using a cache, observe the dojo/store/Memory directly. Upate 29.06.2012: For a fix see changeset #29069.
  • As stated in the docs, but easily missed: dojo/store/Cache automatically adds all returned objects from get() and query() calls to the cache, but only get() uses the cache, whereas query() directly uses the master store. If you want the query to come from the cache, directly call query() on the caching store, e.g. dojo/store/Memory.
  • In the demo, the PHP script responds to the GET 2 by returning a Json object with id 2 and to a GET 2/ by returning an array of objects with parent id 2. If you want to query the Memory store for 2’s children, you have to provide an object as an argument, e.g. storeMemory.query({parId: 2}), whereas the JsonRest store expects a string e.g. storeJsonRest.query(‘2/’);
  • JsonRest store’s methods do not return the same types as Memory store, which can be confusing…
    storeMemory.add(newObject) returns the id
    storeJsonRest.add(newObject) returns the response from the server (or rather a Deferred providing it)
    …, but makes sense, because it can save an extra round trip to the server.

Also see dojo/store/Observable and dojo/store/Cache more info.

 

Canon vs. Nikon Telephoto Lenses: If weight plays a major role

The table (sortable) and charts on this page may help you decide which telephoto lens to buy if the weight plays a major role.

It is kind of frustrating that the Canon lenses are about half to a full kilo lighter than the Nikon ones if you are an owner of Nikon equipment. For the weight of a Nikon 500mm you get a Canon 600mm…