Monday, August 15, 2011

Download apache directory listings recursively

To apache directory listings recursively, use wget like below:

$ wget -r -np -nH -R index.html http://filestodownload/

where -r is for recursive retrieving, -np is for no-parent option where wget won't get the parent directory when retrieving recursively, -nH equals to no host diretories where generation of host-prefixed directories will be disabled and -R is to omit index.html.



Friday, August 5, 2011

Extract rpm without installing

Run below command:

$ rpm2cpio packagename.rpm | cpio -idmv 
where rpm2cpio will change rpm file to cpio, -i is for extract, -d is to create leading directories where needed, -m is to preserve modification time and -v is for verbose mode.

Thursday, July 28, 2011

Creating a lot of same sized files

Let's say you need to create 10 files with 100kB size. All you need to do is create a 1MB files and split it into 10 files.

$ dd if=/dev/zero of=myfile bs=1024 count=1024
$ ls -lh
-rw-rw-r--. 1 owner owner 1.0M Jul 28 15:33 myfile
where if is input file, of is output file, bs is byte size and count is the multipler of bs

and then
$ split -b 100k myfile x
$ ls -lh
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xaa
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xab
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xac
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xad
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xae
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xaf
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xag
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xah
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xai
-rw-rw-r--. 1 owner owner 100K Jul 28 15:35 xaj
-rw-rw-r--. 1 owner owner 24K Jul 28 15:35 xak
where -b is byte size, myfile is your file input name and x is your prefix.

Tuesday, June 14, 2011

Convert time to unix timestamp and vice versa

To convert current time to unix timestamp

$ date +%s
1308021863
where %s is seconds since 1970-01-01 00:00:00 UTC

To convert a unix timestamp to a readable time/date
$ date -d @1308021863
Mon Jun 13 22:24:23 CDT 2011
where -d is for displaying time described by the string after @

Wednesday, May 25, 2011

Install Al-Quran extension in openoffice

This was done in Fedora 13 with openoffice 3.2.0. Please follow below steps to install it:

1. Download the installation files

$ wget http://qioo.googlecode.com/files/QiOO-0.4b.zip

2. Extract it to somewhere
$ unzip QiOO-0.4b.zip
$ ls QiOO-0.4b
CHANGELOG QiOO-0.4b.oxt README.txt ScheherazadeRegOT.ttf

3. Copy ScheherazadeRegOT.ttf to /usr/share/fonts
$ sudo mkdir /usr/share/fonts/ScheherazadeRegOT; sudo cp -apv QiOO-0.4b/ScheherazadeRegOT.ttf /usr/share/fonts/ScheherazadeRegOT

4. Install the extension by opening openoffice writer and go to Tools > Extension Manager > Add, and search for the QiOO-0.4b.oxt plugin.

5. Activate CTL by going to Tools > Option > Language Settings > Languages > Enable For CTL(Complex Text Layout)

6. If all went well, you can see AlQuran menu in your openoffice writer's menubar like below.


That's all.