Archive for February 2015

Linux server remembering last used folder

I’m administrating many servers – usually each for different purpose.

When I log to a server very often I need to work at last folder where I was last time – 80% cases. But Linux kicks me to my home directory, which is the last one where I want to be.

Following script will remember where you was and after login it will move you back to that folder. Put it into ~/.bashrc or /etc/bashrc

function mycd() {
 cd $1
 pwd > ~/.pwd
}
alias switch="cd $(cat ~/.pwd)"
switch
alias cd='mycd'

 

How it works:

1) function mycd must be defined at bashrc file to so the command cd will apply to your shell. If you will create small script and call it, it will not work.

2) at the function mycd you execute cd and the you store actual path to file ~/.pwd

3) at the start of the bash, you first restore your path by loading content of ~/.pwd and then you replace cd command with mycd.

 

It’s so simple, but it saves time.

 

Rotation of Image from UPS in PHP

I was recently implementing UPS API for PHP.

I found those two great sources from Gabriel Bull or simple one from Alex Fraundhof.

When I ask to get the shipping Label by

$Response = $ShipperObj->createLabel($params);

the result is label that is rotated by 90 degrees to the right.

view_order

I didn’t found any parameter to get the label rotated as I want.

Read more