Website Tile on the Windows 8 Start Screen

In Windows 8 there is an option in the tile interface to pin a shortcut to the Start screen as a tile.
Detecting Photo Orientation in PHP via EXIF
Cheat sheet.
Vertical photos shot in portrait mode on Android and iPhone are saved as horizontal images, but the photo orientation is written into EXIF.
If you output the value of this command:
$exif = exif_read_data( $existingFilePath, 0, true);
Then among the array values you will see:
array
(
...
[IFD0] => Array
(
[Make] => Sony
[Model] => LT25i
[Orientation] => 6
[XResolution] => 72/1
[YResolution] => 72/1
[ResolutionUnit] => 2
[Software] => 9.1.A.1.145_58_f100
[DateTime] => 2013:07:26 17:00:01
[YCbCrPositioning] => 1
[Exif_IFD_Pointer] => 214
[GPS_IFD_Pointer] => 626
)
...
)
In this case it means that when this photo is displayed, the app showing it must rotate the image by 90 degrees because the photo is in portrait orientation.
To avoid problems when uploading images to the server and processing them (creating a reduced copy, creating a thumbnail), you can detect such photos with this code:
<?php
imagecopyresampled( $resultImage, $sourceImage, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
$exif = exif_read_data( $existingFilePath, 0, true);
if( false === empty( $exif['IFD0']['Orientation'] ) ) {
switch( $exif['IFD0']['Orientation'] ) {
case 8:
$resultImage = imagerotate( $resultImage, 90, 0 );
break;
case 3:
$resultImage = imagerotate( $resultImage,180,0);
break;
case 6:
$resultImage = imagerotate( $resultImage,-90,0);
break;
}
}
Interestingly, Windows Phone saves a portrait photo as a vertical image.
Creating SSH Aliases for Terminal in Mac OS X
Cheat sheet.
Everything is the same as in Linux, only on macOS there is no ssh-copy-id command. To make it available:
brew install ssh-copy-id
Further it is exactly like in Linux:
To connect to host 192.168.1.2 not via ssh root@192.168.1.2 but via ssh myhost, do the following:
Create the ~/.ssh/config file, and put this in it:
Host myhost
HostName 192.168.1.2
User root
Port 22
Next, to avoid entering the password every time, generate your keys
ssh-keygen -t rsa
And copy the public key to the server
ssh-copy-id myhost
Update the keys:
ssh-add ~/.ssh/id_rsa
Samui in 4 minutes
While I was on Samui I shot a video — a full circle around the island. About 50 km. I sped it up to 4 minutes. This is what came out :)
Detecting When the Map Stops in Google Maps SDK for iOS
An addition to this post. There I mentioned among the problems that Google Maps only provides the event mapView: didChangeCameraPosition:, which fires at every tiny movement of the map, even while the finger is still on the screen. If you move your finger slowly across the map and some markers are supposed to appear via external HTTP requests, it manages to send 10-15 requests per second. That is of course unacceptable, especially on mobile internet.
But you can handle this yourself, more specifically with UIPanGestureRecognizer.
Code cheat sheet:
// где-то в коде проекта
panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(mapDidChange:)];
[panRecognizer setMinimumNumberOfTouches:1];
[panRecognizer setMaximumNumberOfTouches:1];
// GoogleMapsView это гуглокарта, класс GMSMapView
GoogleMapsView.gestureRecognizers = @[panRecognizer];
//.. метод, реагирующий на отпускание касания
-(void)mapDidChange:(UIPanGestureRecognizer *)pan {
if ( panRecognizer.state == UIGestureRecognizerStateBegan ) {
// ничего не делать, но можно и что-нибудь делать
}
if ( panRecognizer.state == UIGestureRecognizerStateEnded ) {
// палец отпущен, можно делать то, что нужно, например:
[self sendMapRequest];
}
}
That is it: you attach the gesture recognizer to the Google map. When the finger is released, you perform the required actions. Theoretically this can even replace mapView: didChangeCameraPosition: if needed.
Replacing UIDevice uniqueIdentifier
Since uniqueIdentifier is now deprecated (back from the iOS 5 days) and Apple no longer accepts apps that use this method (the latest Xcode, it seems, does not even build a project that uses this function).
I googled what to replace it with and assembled one solution from several different ones:
NSString *uuid = @"";
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
// This is will run if it is iOS6 or later
uuid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
} else {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
id uuidId = [defaults objectForKey:@"deviceUuid"];
if (uuidId)
uuid = (NSString *)uuidId;
else {
// Create universally unique identifier (object)
CFUUIDRef uuidObject = CFUUIDCreate(kCFAllocatorDefault);
// Get the string representation of CFUUID object.
uuid = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuidObject);
CFRelease(uuidObject);
[defaults setObject:uuid forKey:@"deviceUuid"];
}
}
Apple now suggests using the identifierForVendor method. This identifier will be unique for each device, but the same across all of your apps on that device. That is, if you install 2 apps from one vendor on the same phone, this id will be the same in both apps. It appeared in iOS 6 and, as far as I understood, on iOS 6 it changes if the app is deleted and installed again. In iOS 7, judging by what people write, it will already be tied to the MAC address and will always stay the same.
The identifierForVendor method had a bug in iOS 6.0: on devices updated over the air it returned a value full of zeros. In 6.0.1 and later that was fixed.
identifierForVendor appeared only in iOS 6, so if you support iOS 5 you need something else. This is where CFUUIDCreate comes in handy. An ID created with it will also change after the app is removed and installed again if you store it somewhere like NSUserDefaults, as in the code above. If you store it in KeyChain, you can avoid it changing after installation. Although how necessary that is is not very clear to me personally. But once generated, the identifier has to be stored somewhere, otherwise this code will generate a different one every time.
That is the cheat sheet.
Thailand, February 2013, video
I finally edited the video from my February vacation in Thailand.