Wednesday, February 23, 2011

How to make a pc connect to hamachi lan without login

This post contains the solutions for two main problems:
1. You have Fastweb as a provider so you can not access your computer from outside the fw network
2. You can't leave your pc turned on (but there is no one able to turn it on if they have to do "strange operations" such as.. a login under linux!)

1. The solution to the point 1 is very simple: install logmein hamachi.
Hamachi is a free software available for windows and linux that allows you to easily create a network up to 16 workstations.
You can download the linux version from the labs.

After that create a free account and a new network from your control panel on the logmein site. Take note of the network id.

Open a terminal and type
sudo hamachi attach-net yourLoginName

now return to the site and approve the request of the client (optionally you can set a identification name for the pc you are using with sudo hamachi set-nick nickname)

now with sudo hamachi you can see your status as logged in and with sudo hamachi list you can see the network.

if you make this operation on another pc you will see the two pcs with sudo hamachi list with a new ip address specified.

You can use that ip to connect for example with ssh!

2. Now if you could have a pc always turned on... but you can't.. well the best solution I found is to make the hamachi connection start before login. So you only need someone to turn on the pc to connect without anyone insert your password locally..

this is very simple to achieve.. you only need to remove networkmanager and install the more competitive wicd..
sudo apt-get remove network-manager -purge
sudo apt-get install wicd
use wicd to configure your lan/wlan.. it automatically starts before login..
hamachi autostarts before login.. that's it..

if it doesn't works try adding in /etc/rc2.d

/etc/rc2.d/S11logmein-hamachi start
after
/etc/rc.local

Tuesday, February 15, 2011

Math operations with decimals in ubuntu shell

The shell usually doesn't support operations with floating point numbers, but only with integers.

If you need to do something like 3.5*2 you will have to use a tool like bc:

echo "3.5*2" | bc


you can decide the number of decimals to use
echo "scale=2; 3.5135131*2" | bc

but there is a little bug: scale doesn't work with multiplications!!!
A little workaround is
echo "scale=2; 3.5135131*2/1" | bc

You will obtain the expected answer

Monday, February 7, 2011

How to refresh a just uploaded favicon

After uploading a new favicon for our site, Firefox will display the cached image for a while.
If you want to see immediately the new favicon visit the file in firefox (something like http://www.yoursite.com/favicon.ico) and reload the page (maybe with ctrl+f5)