Wednesday, July 9, 2008

Compress / Decompress initrd files

To Decompress:

zcat initrd.gz > initrd
mount -t ext2 -o loop,rw initrd /tmp/

After the modification of the folder structure, to compress again:
gzip -c initrd > initrd.gz

Monday, May 12, 2008

Remove tabulation from an Excel file

Just a simple routine to remove "Tab characters" from an excel file:

Sub RemoveTab()
Dim MyCell As Range
For Each MyCell In Selection
Dim a As String
a = MyCell.Text
a = Replace(a, Chr(9), "")
MyCell.Value = a
Next MyCell
End Sub

Saturday, April 5, 2008

Create a manager accout

It is very usefull to create a manager account in your tomcat. In fact it will be used to access all the administration sections that you can see if you point to the root of your tomcat from a browser (e.g. http://localhost:8080/). But it is also usefull if you want to start, stop, redeploy... from the url with the tomcat manager (http://{host}:{port}/manager/{command}?{parameters}) or with ant. We have to open tomcat-users.xml (..apache-tomcat-5.5.26\conf\tomcat-users.xml). We will add the following lines:

<role rolename="manager">
...
<user username="user" password="pass" roles="manager">

So in the end we will have something like this:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager"/>
<role rolename="tomcat"/>
<role rolename="role1"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="user" password="pass" roles="manager"/>
<user username="role1" password="tomcat" roles="role1"/>
</tomcat-users>

Use tomcat through a proxy

During last days I had the necessity to access from my development tomcat the external world (e.g. access remote web services). The problem is that, inside my network, access to the external world is achieved through a proxy with autentication. The solution is to add the following line to your catalina.properties (..\apache-tomcat-5.5.26\conf\catalina.properties):

http.proxyHost=my.proxy.com
http.proxyPort=8080
http.proxyUser=user
http.proxyPassword=password

VoilĂ !

Wednesday, March 19, 2008

Hex Edit using VI

Here are some few commands to edit an hexadecimal file using vi:

vi file.hex
#now editing in vi
[esc] :%!xxd
#now editing file.hex in hex
#find some innocuous string or rcsid
#change the values on the hex side
[esc] :%!xxd -r
[esc] :wq!
#Now have a look on the file just created
hexdump file.hex

Wednesday, February 13, 2008

Setup network interfaces file

I'll just analyze how to setup a network interface. In this case it's a wireless lan with hidden essid and static ip. Let's open the interfaces file:

root@ubuntu:~# gedit /etc/network/interfaces


We will found inside something like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

Now let's add the following lines:

auto ath0
iface ath0 inet static
wireless-essid myEssid
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255

And last but not least let's restart the network:

root@ubuntu:~# /etc/init.d/networking restart



Setup network

I will just post a quick way to setup a network interface from command line. We will analyze the case of wireless lan with hidden essid and static ip address:

root@ubuntu:~# iwconfig ath0 essid "myEssid"
root@ubuntu:~# ifconfig ath0 192.168.3.3

root@ubuntu:~# route add default gw 192.168.3.1