ryu's blog just a few lines of code

13Oct/110

HOWTO Compile Objective-C in Ubuntu (11.04)

To compile Objective-C code in Ubutnu, just install gcc, gobjc, gnustep and clang.
The actual compile process for a file eg. called code.m starts with the following line:

# gcc -o code code.m -I /usr/include/GNUstep/ -L /usr/lib/GNUstep/ -lgnustep-base -fconstant-string-class=NSConstantString

But, in my case there was an error: 'error: #error The current setting for native-objc-exceptions does not match that of gnustep-base ... please correct this.'
To solve this problem, do the following:

# vim /usr/include/GNUstep/GNUstepBase/GSConfig.h

:set nu

Go to line number (in my case) 221, or search for:

#define BASE_NATIVE_OBJC_EXCEPTIONS 1

Replace the line with:

#define BASE_NATIVE_OBJC_EXCEPTIONS 0

Now the compiler should work without problems! :)

21Sep/110

HOWTO: Install PHP Memcache on Ubuntu

Update, install new software an restart Apache:

# apt-get update && apt-get upgrade

# apt-get install memcached php5-memcache

# /etc/init.d/apache2 restart

Now test it. Start a new memcache instance:

# memcached -u root -d -m 24 -l 127.0.0.1 -p 11211

This instance starts as root user using 24 MB as maximum cache size, listening on port 11211.
On my system, I have this process running now:

13919 ? Sl 0:00 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1

We can test our running memcache process by connecting via Telnet:

# telnet 127.0.0.1 11211

An overview of the availiable commands, you can find here: http://lzone.de/articles/memcached.htm
If you like to change your default memcached configuration, do the following:

# vim /etc/memcached.conf

Don't forget to restart memcached afterwards:

# /etc/init.d/memcached restart

At this point you would have to start all memcached instances manually. That's a thing I wouldn't like to worry about. So move the commands to rc.local:

# vim /etc/rc.local

Add lines like this before 'exit 0':

memcached -u your-user-name -d -m 16 -l 127.0.0.1 -p 11211

Make sure every instance listens on a different port. For example: 11211, 11212, 11213... etc.

16Jun/110

Fully functional Flash Player on Ubuntu (Firefox/Chrome)

Replace libflashplayer.so in /usr/lib/flashplugin-installer/ with the file you can download here:
http://labs.adobe.com/downloads/flashplayer10_square.html

Why? - For example youtube.com worked for me, but grooveshark.com or livestation.com didn't. - Now everything works fine!

6May/113

Skype logo missing on Gnome Panel in Ubuntu 11 with Classic Desktop

How so solve this problem? - Just do the following:

Press ALT+F2, and enter:

gconftool --recursive-unset /apps/panel

After the system being busy for a moment, press ALT+F1.
Your Skype icon should be visible again!

Tagged as: , , 3 Comments
15Apr/111

Replace a string in a file in CLI (Command Line), Linux

For instance, you would like to replace 'abc' with 'def' everywhere in your file, do the following:

cat file1.txt | sed -e 's/abc/def/' > file2.txt

15Mar/110

HOWTO: Install ImageMagick (IMagick) for PHP on Ubuntu

If you don't have it installed already, install PEAR:

# sudo apt-get install php-pear

Install the Imagick packets:

# sudo apt-get install imagemagick libmagickwand-dev

If you don't have the PHP5 development packet on your server, you maybe also need to install the following packet:

# sudo apt-get install php5-dev

Now we can install Imagick via PECL:

# sudo pecl install imagick

At this point we have to tell PHP to use Imagick. We can achieve this by putting the following line in the php.ini config file. Just put it at the end of the file. Mine is located at /etc/php5/apache2/php.ini.

extension=imagick.so

We're nearly done. Restart your Apache2 server now:

/etc/init.d/apache2 restart

That's it! ;)

30Mar/100

Make Nagiosgrapher graphs availiable in Nagios3 web interface on Ubuntu

Change or insert the following lines in /etc/nagios3/nagios.cfg

process_performance_data=1
service_perfdata_command=ngraph-process-service-perfdata-pipe

12Mar/100

Check CPU virtualization capability on Linux

egrep '(vmx|svm)' --color=always /proc/cpuinfo

21Jan/100

Select Java version to be used on Ubuntu

sudo update-alternatives --config java

Tagged as: , No Comments
29Jun/094

HOWTO: Install the latest version of rTorrent, Ubuntu

Be sure you are root or have sudo rights. At first we try to clean the system, if there's any older version installed from repository. You can try this:

# sudo apt-get remove rtorrent libtorrent7

On newer systems, like my Ubuntu 9.04 you could try this:

# sudo apt-get remove rtorrent libtorrent11

After this we need to install some packet dependencies and compiling tools.

libTorrent's README says:

libsigc++ 2.0 (deb: libsigc++-2.0-dev)
g++ >= 3.3

rTorrents README says:

libcurl >= 7.12.0
ncurses

So we try to install the following packets. Maybe they differ at your system version.

# sudo apt-get install build-essential libsigc++-2.0-dev pkg-config comerr-dev libcurl4-openssl-dev libidn11-dev libkadm55 libkrb5-dev libssl-dev zlib1g-dev libncurses5 libncurses5-dev

If you got some old packets, which are useless, you can clean them up using this command:

# apt-get autoremove

Go to your home directory or another directory you like.

# cd ~

Now we download the lastest stable release of libTorrent and rTorrent. You can find them here.

# wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.4.tar.gz && wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.4.tar.gz

Now we have to extract the files.

# tar -xvvzf libtorrent-0.12.4.tar.gz && tar -xvvzf rtorrent-0.8.4.tar.gz

Configure, Compile & Install:

# cd libtorrent-0.12.4
# ./configure && make && make install
# cd ../rtorrent-0.8.4
# ./configure && make && make install

If there are no errors, we got rTorrent successfully installed. At this point we need a configuration file, a session directory and a torrent directory.

We change to a normal user.

# su your-user-name

We change to his home directory.

# cd ~

Now we create a torrent directory.

# mkdir torrent

In this directory we create a session directory. I make it invisible because we don't have to access it in the future.

# cd torrent
# mkdir .session

Now we have to create a configuration file. Change to your home directory.

# cd ~
# touch .rtorrent.rc

You can get a default configuration file here. Copy the lines into your configuration file and edit the following two:

directory = /home/your-user-name/torrent
session = /home/your-user-name/.session

Save the file. Now we are finished. You can start rtorrent using this command:

# rtorrent