четвъртък, 1 ноември 2007 г.

Разменяне на две променливи без помощта на трета:

a=a+b;
b=a-b;
a=a-b;

a=a+b-(b=a);

a=b-a+(b=a);

a=a*b/(b=a);

a = a^b; b =a^b; a =a^b;

a ^= b ^= a ^= b;

//for strings
a=a.concat(b);
b=a.substr(0, a.length-b.length);

петък, 14 септември 2007 г.

"Инсталиране" на Eclipse под Linux

Слагаме Java на компа (стари версии могат да се намерят на http://java.sun.com/products/archive).
Нека вземем малко по-свежа Джавичка от http://java.sun.com/javase/downloads/index_jdk5.jsp, преместваме я в /usr/local
mv jdk-1_5_0_12-linux-i586.bin /usr/local
отиваме в нейната директория,
cd /usr/local
chmod u+x или a+x jdk-1_5_0_12-linux-i586.bin
./jdk-1_5_0_12-linux-i586.bin /usr/local (./ ако се намираме в същата директория).
След като се е разархивирал бина можем със спокойна съвест да го забършем, освен ако не си колекционираме Джави.
rm -f jdk-1_5_0_12-linux-i586.bin (-f форсира изтриване без допълнително запитване)
Остана да добавим в PATH
export PATH=/usr/local/jdk1.5.0_12/bin:$PATH
До тук настроихме Джавата, изтегляме желания Eclipse от http://download.eclipse.org/eclipse/downloads/, разархивираме го
tar -zxvf eclipse-SDK-3.2.1-linux-gtk.tar.gz и стартираме Eclipse.

Java Installation



Пускане на джава:
http://java.sun.com/j2se/1.4.2/install-linux.html

Installation of Self-Extracting Binary

Use these instructions if you want to use the self-extracting binary file to install the Java 2 SDK. If you want to install RPM packages instead, see Installation of RPM File.

1. Download and check the download file size to ensure that you have downloaded the full, uncorrupted software bundle.

You can download to any directory you choose; it does not have to be the directory where you want to install the Java 2 SDK.

Before you download the file, notice its byte size provided on the download page on the web site. Once the download has completed, compare that file size to the size of the downloaded file to make sure they are equal.

2. Make sure that execute permissions are set on the self-extracting binary.
Run this command:
chmod +x j2sdk-1_4_2_-linux-i586.bin

3. Change directory to the location where you would like the files to be installed.

The next step installs the Java 2 SDK into the current directory.

4. Run the self-extracting binary.

Execute the downloaded file, prepended by the path to it. For example, if the file is in the current directory, prepend it with "./" (necessary if "." is not in the PATH environment variable):

./j2sdk-1_4_2_-linux-i586.bin

The binary code license is displayed, and you are prompted to agree to its terms.

The Java 2 SDK files are installed in a directory called j2sdk1.4.2_ in the current directory. Follow this link to see its directory structure. The Java 2 SDK documentation is a separate download.

Note about Root Access: Unbundling the software automatically creates a directory called j2sdk1.4.2_. Note that if you choose to install the Java 2 SDK into system-wide location such as /usr/local, you must first become root to gain the necessary permissions. If you do not have root access, simply install the Java 2 SDK into your home directory, or a subdirectory that you have permission to write to.

Note about Overwriting Files: If you unpack the software in a directory that contains a subdirectory named j2sdk1.4.2_, the new software overwrites files of the same name in that j2sdk1.4.2_ directory. Please be careful to rename the old directory if it contains files you would like to keep.

Note about System Preferences: By default, the installation script configures the system such that the backing store for system preferences is created inside the Java 2 SDK's installation directory. If the SDK is installed on a network-mounted drive, it and the system preferences can be exported for sharing with Java runtime environments on other machines. As an alternative, root users can use the -localinstall option when running the installation script, as in this example:

j2sdk-1_4_2_-linux-i586.bin -localinstall
This option causes the system preferences to be stored in the /etc directory from which they can be shared only by VMs running on the local machine. You must be root user for the -localinstall option to work.

See the Preferences API documentation for more information about preferences in the Java platform.

Installation of RPM File

Use these instructions if you want to install Java 2 SDK in the form of RPM packages. If you want to use the self-extracting binary file instead, see Installation of Self-Extracting Binary.

1. Download and check the file size.

You can download to any directory you choose.

Before you download the file, notice its byte size provided on the download page on the web site. Once the download has completed, compare that file size to the size of the downloaded file to make sure they are equal.

2. Extract the contents of the downloaded file.

Change directory to where the downloaded file is located and run these commands to first set the executable permissions and then run the binary to extract the RPM file:

chmod a+x j2sdk-1_4_2_-linux-i586-rpm.bin

./j2sdk-1_4_2_-linux-i586-rpm.bin

Note that the initial "./" is required if you do not have "." in your PATH environment variable.

The script displays a binary license agreement, which you are asked to agree to before installation can proceed. Once you have agreed to the license, the install script creates the file j2sdk-1_4_2_-linux-i586.rpm in the current directory.

3. Become root by running the su command and entering the super-user password.

4. Run the rpm command to install the packages that comprise the Java 2 SDK:

rpm -iv j2sdk-1_4_2_-linux-i586.rpm 
5. Delete the bin and rpm file if you want to save disk space.

6. Exit the root shell.

петък, 31 август 2007 г.

За малко пак да отида на translit.ru за да ползвам удобната транслитерация. Просто забравих, че токущо си бутнах xorg.conf-a и сега мога да пиша на БГ фонетична.
Използвах стаията от http://www.linux-bg.org/cgi-bin/y/index.pl?page=article&id=advices&key=377466040, която сложих тук.


Писане на кирилица в графична среда

Вариант, който действа под абсолютно всички графични среди.

Отваряте '/etc/X11/xorg.conf'* с някой текстов редактор и търсите секцията:

Section "InputDevice"

Там добавяте/редактирате следните редове:

Option "XkbLayout" "us,bg"
Option "XkbVariant" ",phonetic"

Това ще ви позволи да пишете на английски и български фонетичен. Ако предпочитате БДС, използвайте следния вариант:

Option "XkbLayout" "us,bg"
Option "XkbVariant" ",bds"

За да използвате клавишни комбинации, добавяте следния ред:

Option "XkbOptions" "grp:ctrl_shift_toggle,grp:lwin_switch,grp_led:scroll"

Така ще можете да превключвате между различните езици чрез Control+Shift, a лампичката Skroll Lock на клавиатурата ще свети, когато сте на кирилица. Ако искате временно да смените на различен език, ще можете да направите това, като натиснете и задържите левия win клавиш.

KDE си има свои собствени настройки на клавиатурните подредби в Контрол центъра, които препоръчвам да бъдат изключени, за да се използват настройките в xorg.conf. Можете да инсталирате програмката KKBSwitch за да ви показва флагчето на езика, на който пишете.

След редакцията на /etc/X11/xorg.conf е необходимо рестартиране на графичната среда, за да влязат в сила новите настройки. Може да я рестартирате като натиснете едновременно: Ctrl+Alt+Backspace

* за да редактирате xorg.conf, трябва да имате правата на su/root

четвъртък, 30 август 2007 г.

Добро място от което да почна да чета за VNC: http://digg.com/linux_unix/Remote_Desktop_for_Linux,
http://blog.lxpages.com/2007/03/13/remote-desktop-for-linux/.

сряда, 29 август 2007 г.

Исках да подкарам licq на Сузето си (Оупън Сузе 10.2) и понеже още нямах C компилатори, намерих rpm на http://rpmseek.com; http://fr.rpmfind.net/.

четвъртък, 23 август 2007 г.



Наскоро видях много полезна и безплатна услуга за хостинг на UNIX + KDE:
cosmopod.com
http://linuxrevolution.blogspot.com/2006/02/cosmopod-free-remote-kde-desktop.html

сряда, 22 август 2007 г.

QEMU




Като типичен Уиндоус потребител понякога се плаша от UNIX like системите. ( Срам ме е:) )
Отдавна видях новина за QEMU, но някак досега не съм го пробвал, оказа се доста просто особенно ако не правиш нищо екзотично. Реших да пусна едно UBUNTU на QEMU-то под WINDOWS XP (този ползвам вкъщи:)).
Отидох на официалния сайт http://fabrice.bellard.free.fr/qemu/ (документация http://fabrice.bellard.free.fr/qemu/user-doc.html -> Quick Start -> http://kidsquid.com/cgi-bin/moin.cgi/QuickStartGuide -> http://calamari.reverse-dns.net:980/cgi-bin/moin.cgi/QemuOnWindows), от там ме припратиха на уиндоуския сайт на кю ему: http://www.h7.dion.ne.jp/~qemu-win/ и от там изтеглих http://www.h6.dion.ne.jp/~kazuw/qemu-win/qemu-0.9.0-windows.zip
Разархивирах зипа в Drive:/bin/qemu и изпробвах Drive:\bin\qemu> qemu -L . -hda linux.img .
Нещо се показа и се зарадвах:)
Създадох имидж qemu-img.exe create -f qcow hda.img 3G
И после qemu.exe -L . -cdrom ubuntu-7.04-desktop-i386.iso -hda hda.img -m 256 -boot d
И тръгна... Изпаднах в лека еуфория:) Очичките ми светнаха като видях готиния дизайн на UBUNTU инсталатора:)

Послепис:
Както можеше да се очаква в света на конзолите не всичко тръгва идеално, оказа се че не съм си сложил акселератор:) Could not open '\\.\kqemu' - QEMU acceleration layer not activated.