2011/10/10 12:52

FNC v1.02 release - The file created date time information is available for those cameras providing incorrect EXIF data


Today following feature is added for Sony HX5V digial camera user.

- User can set file created date time as file name. This feature is useful to Sony HX5V digital camera user that the camera store inaccurate date time information as EXIF in digital photo file sometimes.

The above feature won’t be necessary for the usual digial camera users, but if you think the date time information is incorrect and the file created date time is much better accurate, please set above red rectangulared area for applying correct information to generate file name.

Another posts included in "Software"

FNC v1.01 release (2)2009/08/21
FNC v1.0 release (0)2009/08/20
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.

2011/07/01 16:28

How to set AUTO_INCREMENT ID in mySQL ?


In case that you need to set AUTO_INCREMENT ID manually, you can set it as below:

ALTER TABLE tbl AUTO_INCREMENT = 1000
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.

2011/05/26 21:56

How to create private URL on S3/CloudFront with time-limit ?


For security reason, many companies may require one time temporary or Private URL with time-limit. Some people call this as private or signed URL. Below URL is based on PHP and contains S3 Signed URL generation function and CloudFront Signed URL generation function.

The implementation method both S3 and CloudFront is totally different. Please refer below.

<?
// below is for generating temporary URL based on AWS S3, and CloudFront.
//
// Programmed 2011 by Kurapa Chunun Kang (kurapa@kurapa.com)

// reference:
//    https://forums.aws.amazon.com/thread.jspa?messageID=112693

function get_s3_signed_url($bucket, $resource, $AWS_S3_KEY, $AWS_s3_secret_key, $expire_seconds)
{
 $expires = time()+$expire_seconds;

  // S3 Signed URL creation
  $string_to_sign = "GET\n\n\n{$expires}\n/".str_replace(".s3.amazonAWS.com","", $bucket)."/$resource";
 $signature = urlencode(base64_encode((hash_hmac("sha1", utf8_encode($string_to_sign), $AWS_s3_secret_key, TRUE))));

 $authentication_params = "AWSAccessKeyId=".$AWS_S3_KEY;
 $authentication_params.= "&Expires={$expires}";
 $authentication_params.= "&Signature={$signature}";
   
  return $link = "http://{$bucket}/{$resource}?{$authentication_params}";
}

function get_cloudfront_signed_url($cloudfront, $resource, $expires, $key)
{
  // you can get your private key at below url
  //    https://aws-portal.amazon.com/gp/aws/developer/account/index.html?ie=UTF8&action=access-key
  //    it must be stored at server side in order to create signed URL.
  //
  // after log in, change tab to key-pairs for cloudfront url signing
 
  $priv_key = file_get_contents('AWS.pem');
  $pkeyid = openssl_get_privatekey($priv_key);
  $policy_str = '{"Statement":[{"Resource":"'.$resource.'","Condition":{"DateLessThan":{"AWS:EpochTime":'.$expires.'}}}]}';
  $policy_str = trim( preg_replace( '/\s+/', '', $policy_str ) );
  $res = openssl_sign($policy_str, $signature, $pkeyid, OPENSSL_ALGO_SHA1);
  $signature_base64 = (base64_encode($signature));

  $repl = array('+' => '-','=' => '_','/' => '~');
  $signature_base64 = strtr($signature_base64,$repl);

  $url = "http://{$cloudfront}/{$resource}?Expires={$expires}&Signature={$signature_base64}&Key-Pair-Id={$key}";

  return $url;
}

$AWS_access_key_id = "your_AWS_access_key_id";
$AWS_s3_secret = "your_AWS_s3_secret";
$AWS_cloudfront_key_pair_id= "your_AWS_cloudfront_pub_key";

echo "<a href=" . get_s3_signed_url( "blahblah.s3.amazonAWS.com", "test.jpg", $AWS_access_key_id, $AWS_s3_secret, 30) . " target=_blank>s3</a><br>";
echo "<a href=" . get_cloudfront_signed_url( "blahblah.cloudfront.net", "test.jpg", 30, $AWS_cloudfront_key_pair_id) . " target=_blank>cloudfront</a><br>";

?>


In case that your PHP treat openssl_sign() as undefined function, you can use it by adding below function on the top of the program.
<?php
// $data is assumed to contain the data to be signed

// fetch private key from file and ready it
$fp = fopen("/src/openssl-0.9.6/demos/sign/key.pem", "r");
$priv_key = fread($fp, 8192);
fclose($fp);
$pkeyid = openssl_get_privatekey($priv_key);

// compute signature
openssl_sign($data, $signature, $pkeyid);

// free the key from memory
openssl_free_key($pkeyid);
?>

In addition, you need to install Open SSL software on your server.
Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.

2011/04/29 10:02

The Delphi function to get My Videos folder


In order to get My Videos folder, you need to call SHGetSpecialFolderPath(). But I recommend you to use below wrapper for easy control.

function GetSpecialFolderPath(Folder: Integer; CanCreate: Boolean): string;
// Gets path of special system folders
//
// Call this routine as follows:
// GetSpecialFolderPath (CSIDL_PERSONAL, false)
//        returns folder as result
//
var
   FilePath: array [0..255] of char;

begin
 SHGetSpecialFolderPath(0, @FilePath[0], FOLDER, CanCreate);
 Result := FilePath;
end;


What you want is simply 'My Videos' folder, you can get it as below way.

m_directory.Text := GetSpecialFolderPath(CSIDL_MYVIDEO, True);

In case that you need to get other special folders like My Musics, My Pictures, or something like that, below information will be helpful for you.

  CSIDL_DESKTOP                       = $0000; { <desktop> }
  CSIDL_INTERNET                      = $0001; { Internet Explorer (icon on desktop) }
  CSIDL_PROGRAMS                      = $0002; { Start Menu\Programs }
  CSIDL_CONTROLS                      = $0003; { My Computer\Control Panel }
  CSIDL_PRINTERS                      = $0004; { My Computer\Printers }
  CSIDL_PERSONAL                      = $0005; { My Documents.  This is equivalent to CSIDL_MYDOCUMENTS in XP and above }
  CSIDL_FAVORITES                     = $0006; { <user name>\Favorites }
  CSIDL_STARTUP                       = $0007; { Start Menu\Programs\Startup }
  CSIDL_RECENT                        = $0008; { <user name>\Recent }
  CSIDL_SENDTO                        = $0009; { <user name>\SendTo }
  CSIDL_BITBUCKET                     = $000a; { <desktop>\Recycle Bin }
  CSIDL_STARTMENU                     = $000b; { <user name>\Start Menu }
  CSIDL_MYDOCUMENTS                   = $000c; { logical "My Documents" desktop icon }
  CSIDL_MYMUSIC                       = $000d; { "My Music" folder }
  CSIDL_MYVIDEO                       = $000e; { "My Video" folder }
  CSIDL_DESKTOPDIRECTORY              = $0010; { <user name>\Desktop }
  CSIDL_DRIVES                        = $0011; { My Computer }
  CSIDL_NETWORK                       = $0012; { Network Neighborhood (My Network Places) }
  CSIDL_NETHOOD                       = $0013; { <user name>\nethood }
  CSIDL_FONTS                         = $0014; { windows\fonts }
  CSIDL_TEMPLATES                     = $0015;
  CSIDL_COMMON_STARTMENU              = $0016; { All Users\Start Menu }
  CSIDL_COMMON_PROGRAMS               = $0017; { All Users\Start Menu\Programs }
  CSIDL_COMMON_STARTUP                = $0018; { All Users\Startup }
  CSIDL_COMMON_DESKTOPDIRECTORY       = $0019; { All Users\Desktop }
  CSIDL_APPDATA                       = $001a; { <user name>\Application Data }
  CSIDL_PRINTHOOD                     = $001b; { <user name>\PrintHood }
  CSIDL_LOCAL_APPDATA                 = $001c; { <user name>\Local Settings\Application Data (non roaming) }
  CSIDL_ALTSTARTUP                    = $001d; { non localized startup }
  CSIDL_COMMON_ALTSTARTUP             = $001e; { non localized common startup }
  CSIDL_COMMON_FAVORITES              = $001f;
  CSIDL_INTERNET_CACHE                = $0020;
  CSIDL_COOKIES                       = $0021;
  CSIDL_HISTORY                       = $0022;
  CSIDL_COMMON_APPDATA                = $0023; { All Users\Application Data }
  CSIDL_WINDOWS                       = $0024; { GetWindowsDirectory() }
  CSIDL_SYSTEM                        = $0025; { GetSystemDirectory() }
  CSIDL_PROGRAM_FILES                 = $0026; { C:\Program Files }
  CSIDL_MYPICTURES                    = $0027; { C:\Program Files\My Pictures }
  CSIDL_PROFILE                       = $0028; { USERPROFILE }
  CSIDL_SYSTEMX86                     = $0029; { x86 system directory on RISC }
  CSIDL_PROGRAM_FILESX86              = $002a; { x86 C:\Program Files on RISC }
  CSIDL_PROGRAM_FILES_COMMON          = $002b; { C:\Program Files\Common }
  CSIDL_PROGRAM_FILES_COMMONX86       = $002c; { x86 C:\Program Files\Common on RISC }
  CSIDL_COMMON_TEMPLATES              = $002d; { All Users\Templates }
  CSIDL_COMMON_DOCUMENTS              = $002e; { All Users\Documents }
  CSIDL_COMMON_ADMINTOOLS             = $002f; { All Users\Start Menu\Programs\Administrative Tools }
  CSIDL_ADMINTOOLS                    = $0030; { <user name>\Start Menu\Programs\Administrative Tools }
  CSIDL_CONNECTIONS                   = $0031; { Network and Dial-up Connections }
  CSIDL_COMMON_MUSIC                  = $0035; { All Users\My Music }
  CSIDL_COMMON_PICTURES               = $0036; { All Users\My Pictures }
  CSIDL_COMMON_VIDEO                  = $0037; { All Users\My Video }
  CSIDL_RESOURCES                     = $0038; { Resource Directory }
  CSIDL_RESOURCES_LOCALIZED           = $0039; { Localized Resource Directory }
  CSIDL_COMMON_OEM_LINKS              = $003a; { Links to All Users OEM specific apps }
  CSIDL_CDBURN_AREA                   = $003b; { USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning }
  CSIDL_COMPUTERSNEARME               = $003d; { Computers Near Me (computered from Workgroup membership) }
  CSIDL_PROFILES                      = $003e;


Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.

2011/04/29 09:32

Get Application Data Path on Delphi


In case of getting Application Data Path on delphi like C:\Documents and Settings\[username]\Application Data\', you can use following function.

uses SysUtils;

Edit2.Text := GetEnvironmentVariable('TEMP');

Trackback 0 Comment 0

Trackback : Cannot send a trackbact to this post.