Orebro Slott (Taken with instagram)
First time my grandparents meet the great grand kids (Taken with instagram)
Just landed in Chicago, 4 more hours and we’ll be on our way to Sweden (Taken with instagram)
Tonight I am taking my family for a month long adventure across Europe. We are flying in to Stockholm, Sweden, where we will spend some time visiting friends and family. Then we will travel to Aix en Provence, France, for a few days to enjoy good food and company. Then on to Italy for some good Italian food. Then we will fly to Crete to meet up with my parents. Then finally back to Sweden for a few last days before heading back home.
I’m so excited. It’s going to be a ton of fun and this will be the first time that as a family we can pull away and go on vacation outside the country.
[video]
The other day I was working on a project where I needed to crop and resize images, so I wrote this quick PHP function that uses the GD2 library. Enjoy.
function cropImage($image,$image_w=120,$image_h=120) {
if ($image['size'] == 0) {
return(false);
}
if ($image['error'] > 0) {
return(false);
}
if ($image['type'] == "image/gif") {
$source_img = @imagecreatefromgif($image['tmp_name']);
}
else if (($image['type'] == "image/jpeg") || ($image['type'] == "image/pjpeg")) {
$source_img = @imagecreatefromjpeg($image['tmp_name']);
}
else if (($image['type'] == "image/png") || ($image['type'] == "image/x-png")) {
$source_img = @imagecreatefrompng($image['tmp_name']);
}
else {
return(false);
}
if (!$source_img) {
return(false);
}
$orig_w = imagesx($source_img);
$orig_h = imagesy($source_img);
$w_ratio = ($image_w / $orig_w);
$h_ratio = ($image_h / $orig_h);
if ($orig_w > $orig_h ) { // wider
$crop_w = round($orig_w * $h_ratio);
$crop_h = $image_h;
$src_x = ceil( ( $orig_w - $orig_h ) / 2 );
$src_y = 0;
} elseif ($orig_w < $orig_h ) { // taller
$crop_h = round($orig_h * $w_ratio);
$crop_w = $image_w;
$src_x = 0;
$src_y = ceil( ( $orig_h - $orig_w ) / 2 );
} else { // square
$crop_w = $image_w;
$crop_h = $image_h;
$src_x = 0;
$src_y = 0;
}
$dest_img = imagecreatetruecolor($image_w,$image_h);
imagecopyresampled($dest_img, $source_img, 0 , 0 , $src_x, $src_y, $crop_w, $crop_h, $orig_w, $orig_h);
return($dest_img);
}
[video]
It is now official. I will be joining the ServiceNow family starting on March 19th 2012. It has been a wonderful experience working at MIR3. I have grown both as a developer and as a person, and I am so thankful for the time I’ve had working with the wonderful people at MIR3. But I feel I have come to a fork in the road and it is time to move on.
I will be working at ServiceNow as a Developer, where I will be designing and developing business applications on top of the ServiceNow platform.
For those not familiar with ServiceNow, here is the official description from their website:
Born in the cloud, ServiceNow makes IT more accessible, intuitive and social. ServiceNow creates a single system of record for all IT processes within a company. This system brings together IT strategy, design, transition and operation on a powerfully simple cloud platform that just works.
ServiceNow is built to be a productivity tool for all types of business users including the CIO, service desk staff, application developers, IT finance, IT operations and business people. ServiceNow applications are built on a single platform as a service. The platform offers a consistent and intuitive user experience through the entire IT Infrastructure Library (ITIL) service lifecycle.
[video]
I was looking at some of the different ways of reversing a string in PHP and in JavaScript. There are so many ways of accomplishing such a simple task but I wanted to compare some of the different ways.
PHP
$string = “This is a test”;
$string = strrev($string);This is almost cheating because PHP has a built in function… but this is the easiest way for sure
$string = implode('',array_reverse(str_split($string)));
$string = str_split($string);
for ($i=count($string)-1; $i>=0; $i--) {
$newstring .= $string[$i];
}
$string = $newstring;
JavaScript
var string = “This is a test”;
string = string.split('').reverse().join('');
var newString = [];
for (i=(string.length)-1; i>=0; i--) {
newString.push(string[i]);
}
string=newString.join('');