30 December, 2009

How to use CodeIgniters template parser

This little tutorials shows how you can use CodeIgniters template parser. I like to use this utility to make my HTML code more readable and keep PHP code out of design files. It's also easier to write documents based on this.

28 December, 2009

How to build .deb package from source

Instructions for building a .deb file from source files. Most errors you get while compiling is that you might have to install some packages from aptitude.

Copy files to temp:

cp -r '/dir/of/the/source/files' /tmp

Go to the copied files:

cd /tmp/source-dir-name

While doing dh_make press "s" for the first question and "enter" for the second one:

dh_make --createorig

Build the package:

dpkg-buildpackage -rfakeroot

.deb file should appear into your /tmp directory if building was successful.

27 December, 2009

GoonZu classes guide

Made by: rappwr
              Luminary has six different weapon classes to choose among. Three of classes are melee and other three are ranged. Axer, spearman, swordsman belong to melee group and bowman, caner, gunner belong to ranged group. Each weapon class has its 19 different weapons of its kind from level 0 to level 110 kind of weapon.

26 December, 2009

Archive using linux terminal.

Just some commands about archiving for command line. Should work on all Linux distributions.

Make .zip archive:

zip -r name_for_the_zip_file.zip file/or/dir/i/want/to/zip

Extract .zip archive:

unzip dir/to/the/file.zip

Make .rar archive:

rar a name_for_the_rar_file.rar file/or/dir/i/want/to/rar

Extract .rar archive:

rar e dir/to/the/file.rar

Make .tar archive:

tar cf name_for_the_zip_file.tar file/or/dir/i/want/to/tar

Extract .tar archive:

tar xf dir/to/the/file.tar

Make .tar.gz archive:

tar czf name_for_the_zip_file.tar.gz file/or/dir/i/want/to/gzip

Extract .tar.gz archive:

tar xzf dir/to/the/file.tar.gz

Make .tar.bz2 archive:

tar cjf name_for_the_zip_file.tar.bz2 file/or/dir/i/want/to/bzip

Extract .tar.bz2 archive:

tar xjf dir/to/the/file.tar.bz2

22 December, 2009

How to install ssh with sftp server?

I wanted to install ftp server on my little home server. So I googled it. I found out that it would be safer to use sftp instead of ftp, which would be file transfer for ssh. It's also easier you can just type ssh://username@www.example_domain.com in your nautilus and if you see your files then you have successfully logged in. You can easily make new users and give them permissions through ssh configuration files.

To enable it you need ssh server, if you don't have it:

sudo apt-get install openssh-server

Then you have to change a row in your OpenSSH server configuration file:

sudo nano /etc/ssh/sshd_config

Replace the line:

Subsystem sftp /usr/lib/openssh/sftp-server

with:
Subsystem sftp internal-sftp


NB: This works on Debian and all distributions based on it, like Ubuntu. The default port is 22 for ssh so you probably want it to be opened, if you want to access your sftp outside lan.

14 November, 2009

How to mount ftp to directory

If you are using Thunar on Xubuntu(xfce) and you would prefer to use file browser instead of external ftp client. It should work on every Linux distribution.

1) Download curlftpfs:

sudo apt-get install curlftpfs


2) How to use curlftpfs:

curlftpfs ftp://username:password@your.domanin.com/ /location/where/to/mount


For more information: curlftpfs homepage

08 November, 2009

Consider adjusting the PKG_CONFIG_PATH environment variable...

This is the error I got while compiling:
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables GTK_CFLAGS
and GTK_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.


Installing "gnome-core-devel" was the solution for my problem:
sudo apt-get install gnome-core-devel

01 November, 2009

How to use diff and patch in bash script

Diff and patch commands can be used to compare differences of files and change the content based on that. You can see something similar in SVN or wikis.

How to make and use .patch script:

You have to have the original version of file and the edited version of the same file. Then you can make .patch file about the differences with this command:
diff -u /original/file/location /edited/file/location > patch_file_name.patch

You can use the created .patch file on any file with this command:
patch /file/that/will/be/patched < location/of/patch/file.patch



Original Post

How to get self directory in bash script

This makes variable $SELF_DIR where is location of that script:
SELF_DIR=$(cd $(dirname $0); pwd -P)

This does the same thing as the first one but it adds the script file name to the variable:
SELF_DIR=$(cd $(dirname $0); pwd -P)/$(basename $0)


Original Post

15 March, 2009

Differences between echo and print

There are 2 commands called echo and print. Both do practically the same thing. There are some differences. Print behaves like function and echo is a bit faster.

Display string:

1 <php
2 //Echo displays this line faster.
3 echo 'This will be displayed.';
4 //Print is a bit slower.
5 print 'This will be displayed.';
6 ?>



Difference between ''(single quotes) and ""(double quotes):

1 <?php
2 $string = 'dog';
3 //This prints: This is a $string.
4 echo 'This is a $string.';
5 //This prints: This is a dog.
6 echo "This is a $string.";
7 //This prints: This is a dog.
8 echo 'This is a ' . $string . '.';
9 ?>
There is no point to use double quotes if you dont have any string in it, it just makes the code a bit slower.


Display html code with echo or print:

1 <?php
2 //The right way
3 echo '<img src="picture.png" border="0" />';
4 //The wrong way
5 echo "<img src='picture.png' border='0' />";
6 ?>



Parameters:

1 <?php
2 //Echo can take multiple parameters
3 echo 'parameter1', 'parameter2', 'parameter...';
4 //Print can't take multipleparameters
5 print 'No multiple parameters possible, because I behave like a function';
6 ?>


Some day here will be some examples, about prints function like behaviour being a useful thing.

11 March, 2009

Add user to a role using CreateUserWizard.

It's mutch simpler than you might thought. Just double click on your CreateUserWizard and add a line between the lines what appeared.

1 protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
2 {
3 Roles.AddUserToRole(CreateUserWizard1.UserName, "Role name as string");
4 }

How to install Flash Player 9 for Epiphany

By copying this code line by line you can install installing Flash Player 9 for Epiphany. This have worked for me on Ubuntu and Debian.

cd
wget http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_9_linux.tar.gz
tar zxf install_flash_player_9_linux.tar.gz
cd install_flash_player_9_linux
sudo cp libflashplayer.so /usr/lib/epiphany/2.14/plugins
cd
rm -Rf install_flash_player_9_linux