Merging PDF files on Ubuntu

October 13, 2010 Leave a comment

gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf in3.pdf …

or

use pdftk: http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
examples: http://www.accesspdf.com/article.php/20041129175231241

Categories: Ubuntu Tags: , , ,

Restoring GRUB2 on Ubuntu

September 8, 2010 Leave a comment

https://help.ubuntu.com/community/Grub2#Reinstalling%20from%20LiveCD

METHOD 3 – CHROOT

This method of installation uses the chroot command to gain access to the broken system’s files. Once the chroot command is issued, the LiveCD treats the broken system’s / as its own. Commands run in a chroot environment will affect the broken systems filesystems and not those of the LiveCD.

1. Boot to the LiveCD Desktop (Ubuntu 9.10 or later). Please note that the Live CD must be the same as the system you are fixing – either 32-bit or 64-bit (if not then the chroot will fail).
2. Open a terminal – Applications, Accessories, Terminal.
3. Determine your normal system partition – (the switch is a lowercase “L”)
sudo fdisk -l
* If you aren’t sure, run
df -Th. Look for the correct disk size and ext3 or ext4 format.
4. Mount your normal system partition:
* Substitute the correct partition: sda1, sdb5, etc.
sudo mount /dev/sdXX /mnt # Example: sudo mount /dev/sda1 /mnt
5. Only if you have a separate boot partition:
* sdYY is the /boot partition designation (for example sdb3)
* sudo mount /dev/sdYY /mnt/boot
6. Mount the critical virtual filesystems:
sudo mount –bind /dev /mnt/dev
sudo mount –bind /dev/pts /mnt/dev/pts
sudo mount –bind /proc /mnt/proc
sudo mount –bind /sys /mnt/sys
7. Chroot into your normal system device:
sudo chroot /mnt
8. If there is no /boot/grub/grub.cfg or it’s not correct, create one using
update-grub
9. Reinstall GRUB 2:
* Substitute the correct device – sda, sdb, etc. Do not specify a partition number.
grub-install /dev/sdX
10. Verify the install (use the correct device, for example sda. Do not specify a partition):
sudo grub-install –recheck /dev/sdX
11. Exit chroot: CTRL-D on keyboard
12. Unmount virtual filesystems:
sudo umount /mnt/dev/pts
sudo umount /mnt/dev
sudo umount /mnt/proc
sudo umount /mnt/sys
* If you mounted a separate /boot partition:
sudo umount /mnt/boot
13. Unmount the LiveCD’s /usr directory:
sudo umount /mnt/usr
14. Unmount last device:
sudo umount /mnt
15. Reboot.
sudo reboot

Categories: Linux, Ubuntu Tags: , ,

Using GMP with Eclipse on Ubuntu C/C++

Install GMP
sudo apt-get install libgmp3-dev libgmp3-doc libgmp3c2

On Eclipse
Project->Properties
C/C++ Build->Settings
GCC C Linker->Miscellaneous
Linker flags: -lgmp -lgmpxx

Categories: C/C++, Eclipse, GMP, Ubuntu Tags: , , , ,

Comparing Arrays in Java

When comparing to array == operator won’t do the job. Because using == operator only compares the objects whether they are the same object or not. That means operator won’t check the objects data.

for example
byte[] a = “Test”.getBytes();
byte[] b = “Test”.getBytes();

(a == b) –> false
Arrays.equals(a,b) –> true

Categories: Java Tags: ,

Install MySql Server on FreeBSD

cd /usr/ports/databases/mysql50-server
make install clean
cp /usr/local/share/mysql/my-small.cnf /usr/local/etc/my.cnf
echo “mysql_enable=\”YES\”" >> /etc/rc.conf
mysql_install_db
chown -R mysql:mysql /var/db/mysql

Categories: FreeBSD Tags: ,

Install vulnerable ports on FreeBSD

While installing ports portaudit may stop installation becasue of vulnerabilities of ports. In order to ignore vulnerability reports use -DDISABLE_VULNERABILITIES parameter in your make command.

make -DDISABLE_VULNERABILITIES install clean

Categories: FreeBSD Tags: , ,

Install Php for Apache22 on FreeBSD

Install php5
cd /usr/ports/lang/php5
make install clean

Note: portaudit may stop installation because of vulnarabilities of php5 port. In order to solve this problem give following command.
make -DDISABLE_VULNERABILITIES install clean

Install php5 extras

cd /usr/ports/databases/php5-mysql
make install clean

cd /usr/ports/www/php5-session
make install clean

cd /usr/ports/graphics/php5-gd
make install clean

Append following lines to httpd.conf file.
nano -w /usr/local/etc/apache22/httpd.conf

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Update DirectoryIndex
DirectoryIndex index.php index.html index.htm

Copy php.ini-dist as php.ini
cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

Restart Apache22
/usr/local/etc/rc.d/apache22 restart

Test Php
echo “” >> /usr/local/www/apache22/data/test.php

Categories: FreeBSD Tags: , ,

How to enable/disable IP Packet Forwarding in Windows 2000/NT/XP

Open registry by typing

regedit

in Run Dialog ( Win + R ), then find system key

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]

Set the value of “IPEnableRouter” 0 to disable or 1 to enable IP Packet Forwarding. You must restart your computer.

Categories: Windows Tags: ,

Disable Beep/Bell Sound on FreeBSD

This command would disable the hardware beep/bell sound for the current session.

sysctl hw.syscons.bell=0

If you want to disable the beep/bell sound persistently you should add the “hw.syscons.bell=0″ entry to /etc/sysctl.conf file by giving the following command;

echo “hw.syscons.bell=0″ >> /etc/sysctl.conf

Categories: FreeBSD Tags:

.Net Oracle Connection String Sorunu

C# ile Oracle Express 10g bağlanmak için kullanılan connection stringlerde dikkat edilmesi gereken husus, eğer sisteminiz türkçe ise; connection string diye tabir edilen bağlantı özelliklerinin “anahtar=değer;” şeklindeki ikililer ile belirtildiği değişken içersinde türkçe karakter olmaması gerekmektedir.

Öte yandan anahtarlar işlenirken küçültülür değerler ise büyültülür yani “user id=linq;” yazdığımız zaman oracle üzerinde linq kullanıcısının tanımlı olmasına karşın bağlantı girişimimiz de oturum açma işleminin başarısız olacağını görürüz bunun temel sebebi kullanıcı adı oracle’a gönderilirken tamamı büyük harf  olur ve sistemimiz türkçe karakterleri desteklediği için oracle giden kullanıcı adı “LİNQ” olur. halbuki tanımlı kullanıcımız “LINQ” dur.

“anahtar” değerlere gelirsek yine “user id=linq;” örneği üzerinden gidelim. Madem oracle değerleri büyültüyor o zaman tüm ikilileri büyük harfle yazalım “USER ID=LINQ;”. Bir bağlantı açmak istediğimize tekrar sorun ile karşılaşacağız bu seferki sorunumuz ise geçersiz olan anahtar kelimesidir. Çünkü anahtarlar işlenmeden önce küçültülür ve “USER ID” “user ıd” olur ki yine işletim sistemimizin Türkçe olmasından kaynaklanmaktadır.

Özetle Connection stringlerinizin “anahtar=DEGER;” şeklinde olmasını tavsiye ediyorum.

Categories: .Net, Oracle Tags: , , , ,
Follow

Get every new post delivered to your Inbox.