<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technical Diary</title>
	<atom:link href="http://andriigrytsenko.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Wed, 28 Jul 2010 09:02:46 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Software RAID level 1 behavior</title>
		<link>http://andriigrytsenko.net/2010/07/software-raid-level-1-behavior/</link>
		<comments>http://andriigrytsenko.net/2010/07/software-raid-level-1-behavior/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 17:47:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[fs]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[raid]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=827</guid>
		<description><![CDATA[Here I will try to describe behavior of SW RAID level 1 in case of crash.

There will be two scenario:

 Delete partition by fdisk and restart the computer.
 Delete and create empty partition by fdisk and restart the computer.
 Delete whole storage device from the system and restart computer.
 Delete and create whole storage device [...]]]></description>
			<content:encoded><![CDATA[<p>Here I will try to describe behavior of SW RAID level 1 in case of crash.<br />
<span id="more-827"></span></p>
<p>There will be two scenario:</p>
<ol>
<li> Delete partition by <strong>fdisk</strong> and restart the computer.</li>
<li> Delete and create empty partition by <strong>fdisk</strong> and restart the computer.</li>
<li> Delete whole storage device from the system and restart computer.</li>
<li> Delete and create whole storage device from the system and restart computer.</li>
</ol>
<h3 style="text-align: center;"><strong>1.  Delete partition by fdisk and restart the computer.</strong></h3>
<p>First, I gotta create the <em>raid</em> device:</p>
<pre>[root@node1 ~]# mdadm -C /dev/md0 -n 2 -l 1 /dev/hdd1 /dev/hdb8
mdadm: largest drive (/dev/hdb8) exceed size (476160K) by more than 1%
Continue creating array? y
mdadm: array /dev/md0 started.</pre>
<p>and build <strong>ext3</strong> file system on the device:</p>
<pre>[root@node1 ~]# mke2fs -j /dev/md0</pre>
<p>Edit <em>/etc/fstab</em> according to the changes:</p>
<pre>/dev/md0                /test                   ext3    defaults        0 0</pre>
<p>and mount everything is contained at <strong>/etc/fstab</strong>:</p>
<pre>[root@node1 ~]#mount -a</pre>
<p>Copy some files to <strong>/test</strong>(to be able to check files integrity in the future):</p>
<pre>[root@node1 ~]# cp -rfv /var/* /test/</pre>
<p>Now, delete <strong>/dev/hdd1</strong> through <strong>fdisk</strong>:</p>
<pre>[root@node1 ~]# fdisk  /dev/hdd

The number of cylinders for this disk is set to 8322.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): d
Selected partition 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.</pre>
<p>and restart computer:</p>
<pre>[root@node1 ~]# reboot</pre>
<p>During the system booting I got next error(the same I got when try to manually mount <strong>md0</strong>):</p>
<pre>mount: wrong fs type, bad option, bad superblock on /dev/md0,
       missing codepage or other error
       (could this be the IDE device where you in fact use
       ide-scsi so that sr0 or sda or so is needed?)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so</pre>
<p><strong>/proc/mdstat</strong> doesn&#8217;t see any  local raid devices:</p>
<pre>[root@node1 ~]# cat /proc/mdstat
Personalities :
unused devices:</pre>
<p>Let&#8217;s create new <strong>mdadm.conf</strong> :</p>
<pre>[root@node1 ~]#  mdadm --examine --scan  /dev/hdb8 &gt; /etc/mdadm.conf

[root@node1 ~]# cat /etc/mdadm.conf
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=c1ce0c10:035aa2a3:829450b6:84b7a236</pre>
<p>And active everything from mdadm.conf:</p>
<pre>[root@node1 ~]#  mdadm -A -s
mdadm: /dev/md0 has been started with 1 drive (out of 2).</pre>
<p>The <strong>md0</strong> was activated, but only with one disk:</p>
<pre>[root@node1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 hdb8[1]
      476160 blocks [2/1] [_U]</pre>
<p><strong>Conclusion:</strong> If it was a root partition your system wouldn&#8217;t boot at all. And you would have to dance with boot disk to make you system alive.</p>
<h3 style="text-align: center;"><strong>2. Delete and create empty partition by fdisk and restart the computer.</strong></h3>
<p>The same actions as above and additional create partition <strong>/dev/hdd1</strong> in <strong>fdisk</strong>.<br />
After system booted. None of raid&#8217;s are active :</p>
<p></strong></p>
<pre>[root@node1 ~]# cat /proc/mdstat
Personalities :
unused devices:</pre>
<p>But after restore procedure system is going to work in full-fledged mode(with 2 disks):</p>
<pre>[root@node1 ~]#  mdadm --examine --scan  /dev/hdb8 &gt; /etc/mdadm.conf
[root@node1 ~]# mdadm -A -s
mdadm: /dev/md0 has been started with 2 drives.
[root@node1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 hdd1[0] hdb8[1]
475136 blocks [2/2] [UU]</pre>
<p>The new device has no influence on system behavior at all. Result is similar to previous one.</p>
<h3 style="text-align: center;"><strong>3. Delete whole storage device from the system and restart computer.</strong></h3>
<p>During this test the <strong>md0</strong> was restored and mounted during system boot without any problem or delays. Also next notice message were generated and put into the syslog facility <strong>kernel</strong>:</p>
<pre>kernel: raid1: raid set md0 active with 1 out of 2 mirrors</pre>
<h3 style="text-align: center;"><strong>4. Delete and create whole storage device from the system and restart computer.</h3>
<p></strong><br />
During boot raid wasn&#8217;t rebuilt by itself: </p>
<pre>
[root@node1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 hdb8[1]
      475136 blocks [2/1] [_U]
</pre>
<p>And has to be re-built manually :</p>
<pre>
[root@node1 ~]# mdadm -a /dev/md0 /dev/hdd1
mdadm: re-added /dev/hdd1
</pre>
<p>Still recovering :) : </p>
<pre>
[root@node1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 hdd1[0] hdb8[1]
      475136 blocks [2/1] [_U]
      [====>................]  recovery = 21.5% (103296/475136) finish=0.4min speed=12912K/sec
</pre>
<p><strong>NOTE: partition type for new partition should be set to &#8216;Linux raid autodetect&#8217; (FD in a hex code). Frankly speaking I didn&#8217;t test whether it works without that, that&#8217;s why it may be or may _not_ useless procedure. My advice is: just do it! </strong></p>
<pre>
[root@node1 ~]# fdisk -l /dev/hdd

Disk /dev/hdd: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdd1               1         943      475240+  fd  Linux raid autodetect
</pre>
<h3><strong>P.S. System information:</strong></h3>
<p>Tests were performed at virtual machine:<br />
<strong>virtualbox-2.1.4<br />
virtualbox-ose-guest-modules-2.6.26-1-686</strong><br />
Software installed inside VM:<br />
<strong>CentOS(kernel-2.6.18-128.el5)<br />
mdadm-2.6.9-2.el5</strong></p>
<p></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/07/software-raid-level-1-behavior/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trick: DOC to PDF on Linux</title>
		<link>http://andriigrytsenko.net/2010/07/trick-doc-to-pdf-on-linux/</link>
		<comments>http://andriigrytsenko.net/2010/07/trick-doc-to-pdf-on-linux/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 12:07:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=814</guid>
		<description><![CDATA[Here is little trick how to convert *.doc files into the *.pdf on Linux.

PRE-REQUIREMENTS: 
oowriter has to be already installed. It is provided by Open Office system(for Debian its openoffice.org-writer package).
Unfortunately, I can&#8217;t remember the source where this macros is came from. Anyway here my script:
#!/bin/bash
# Written by Andrii Grytsenko
# pp: AndriiGrytsenko.net

if [ $# -lt [...]]]></description>
			<content:encoded><![CDATA[<p>Here is little trick how to convert *.doc files into the *.pdf on Linux.</p>
<p><span id="more-814"></span></p>
<p><span style="color: #ff0000;">PRE-REQUIREMENTS: </p>
<p><strong>oowriter</strong> has to be already installed. It is provided by Open Office system(for Debian its <strong>openoffice.org-writer</strong> package).</span></p>
<p>Unfortunately, I can&#8217;t remember the source where this macros is came from. Anyway here my script:</p>
<pre>#!/bin/bash
# Written by Andrii Grytsenko
# pp: AndriiGrytsenko.net

if [ $# -lt 1 ]; then
    echo "Example: pdf2doc [doc_file] [output_dir]"
    echo "in case output_dir is missing generate into current dir"
fi

DOCDIR=$(dirname $1)
DOCFILE=$(basename $1)
PDFFILE=$(echo $DOCFILE | sed -e 's/\.doc$/\.pdf/g')
CURRENT_DIR=$(pwd)
OUT_DIR=$2

# if output_dir is missing set current
if [ -z $OUT_DIR ]; then
    OUT_DIR=$CURRENT_DIR
fi

if  echo $DOCDIR | grep -E "^\.$" &gt; /dev/null; then
        DOCDIR=$CURRENT_DIR
elif ! echo $DOCDIR | grep -E "^/" &gt; /dev/null; then
        DOCDIR=$CURRENT_DIR/$DOCDIR
fi

cd $DOCDIR
/usr/bin/oowriter -invisible "macro:///Standard.Module1.ConvertWordToPDF($DOCDIR/$DOCFILE)"
sleep 2 # for big files generation can take more time
mv $PDFFILE $OUT_DIR/
cd $CURRENT_DIR</pre>
<p>Put file into the catalog from PATH env variable, into the /usr/bin for example. And call doc2pdf.</p>
<p>To generate question.pdf from question.doc and put it into the /tmp, run this:</p>
<pre>doc2pdf ~/tmp2/questions.doc /tmp/</pre>
<p><span style="color: #ff0000;"><strong>PROFIT:</strong></span><span style="color: #ff0000;"><strong> </strong></span></p>
<pre>andrii@agrytsenko:~$ ls -l /tmp/questions.pdf
-rw-r--r-- 1 andrii vboxusers 53226 Jul 16 14:17 /tmp/questions.pdf</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/07/trick-doc-to-pdf-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl and cookies auth</title>
		<link>http://andriigrytsenko.net/2010/06/perl-and-cookies-auth/</link>
		<comments>http://andriigrytsenko.net/2010/06/perl-and-cookies-auth/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 12:05:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=794</guid>
		<description><![CDATA[I made little overview how to make http authorization through the PERL.

I&#8217;m not gonna describe how to make HTML form and  how to parse input data from html. I leave these as you your homework ;). As storage for HTTP sessions I chose database(specifically MYSQL).
Here is my table with sessions :
desc mc_sessions;
+-----------------+--------------+------+-----+---------+-------+
&#124; Field  [...]]]></description>
			<content:encoded><![CDATA[<p>I made little overview how to make http authorization through the PERL.</p>
<p><span id="more-794"></span></p>
<p>I&#8217;m not gonna describe <a href="http://www.google.com.ua/search?hl=en&amp;source=hp&amp;q=html+form&amp;aq=f&amp;aqi=g10&amp;aql=&amp;oq=&amp;gs_rfai=">how to make HTML form</a> and <a href="http://www.google.com.ua/search?hl=en&amp;q=how+to+parse+input+data+from+html+in+perl&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai="> how to parse input data from html</a>. I leave these as you your homework ;). As storage for HTTP sessions I chose database(specifically MYSQL).</p>
<p>Here is my table with sessions :</p>
<pre>desc mc_sessions;
+-----------------+--------------+------+-----+---------+-------+
| Field           | Type         | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+-------+
| user_name       | varchar(50)  | YES  |     | NULL    |       |
| session_id      | varchar(255) | NO   | PRI | NULL    |       |
| expiration_time | int(11)      | YES  |     | NULL    |       |
+-----------------+--------------+------+-----+---------+-------+</pre>
<pre>
use CGI qw/:standard/;
use CGI::Cookie;

sub set_cookies {.
    my ($db,$user_name,$user_passwd) = @_;

    my $exp_time = time() + 259200; #(3 days)
    my $session_id = md5_hex($user_id.''.$user_name.''.$user_passwd.''.$exp_time);

    my $sth = $dbh-&gt;prepare("INSERT INTO $table (user_name,session_id,expiration_time) VALUES (?,?,?)");
    $sth-&gt;execute($user_name,$session_id,$exp_time);

    my $cookie1 = new CGI::Cookie(-name=&gt;'SessionID',-value=&gt;"$session_id");
    my $cookie2 = new CGI::Cookie(-name=&gt;'ExpirationTime',-value=&gt;"$exp_time");

    print header(-cookie=&gt;[$cookie1,$cookie2]);

    return 1;
}

sub check_auth {
    my ($dbh) = @_;

    my %cookies = fetch CGI::Cookie;
    my %cook_hash;

    foreach my $key (sort keys %cookies) {
        $cookies{$key} =~ /=(.*);/;
        $cook_hash{$key} = $1;
    }

    return -1 if (!defined($cook_hash{SessionID}));

    my $user_name = is_session_valid($dbh,$cook_hash{SessionID});

    return -1 if ($user_name == -1);

    return $user_name;
}

sub is_session_valid {
    my ($dbh,$session_id) = @_;

    my ($exp_time);

    my $sth = $dbh-&gt;prepare("SELECT * FROM sessions WHERE session_id=? and expiration_time &gt; ?");
    $sth-&gt;execute($session_id,time());

    while ( my @array = $sth-&gt;fetchrow_array ) {
            ($user_name,$session_id,$exp_time) = @array;
    }

    return $user_name if (defined($user_name) and $exp_time &gt; time());

    return -1;
}
</pre>
<p>As result we have 3 functions.</p>
<ol>
<li><span style="color: #000000;"><strong>set_cookies</strong></span><span style="color: #000000;"> &#8211; this function generate, put in database and send cookies to user&#8217;s browser.</span></li>
<li><strong>check_auth</strong> &#8211; check if user has already have some cookies from server if yes call <em>is_session_valid</em> for future checking.</li>
<li><strong>is_session_valid</strong> &#8211; look about user&#8217;s  session id  and check whether this session was expired or not.</li>
</ol>
<p><span style="color: #ff0000;"><strong><span style="text-decoration: underline;">Pay attention:</span></strong></span></p>
<p><span style="color: #ff0000;"><strong></strong></span><span style="color: #ff6600;"><span style="color: #ff0000;">Each function receives variable </span><strong><span style="color: #ff0000;">$dbh</span></strong><span style="color: #ff0000;"> it&#8217;s </span><a href="http://search.cpan.org/~timb/DBI-1.611/DBI.pm#Outline_Usage"><span style="color: #ff0000;">database connection identificator</span></a><span style="color: #ff0000;"> and should be created before function run.</span></span></p>
<h2 style="text-align: center;">How does it use?</h2>
<p>Edit you CGI code. And take care that all pages checks sessions id.<br />
Put this function call after authorization by password to send cookies to user:</p>
<pre>
set_cookies($dbh,$username,$password);
</pre>
<p>And these in all remains site&#8217;s pages to prevent site from unauthorized actions:</p>
<pre>
my $user_name = check_auth($dbh);

if ( $user_id == -1 ) {
        some action[s]
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/06/perl-and-cookies-auth/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MYSQL quick overview</title>
		<link>http://andriigrytsenko.net/2010/05/mysql-quick-overview/</link>
		<comments>http://andriigrytsenko.net/2010/05/mysql-quick-overview/#comments</comments>
		<pubDate>Tue, 18 May 2010 11:10:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=762</guid>
		<description><![CDATA[Here I systematized some of my MYSQL knowledges.

First I decide to make some test database to do everything step-by-step. This will be companies database contains information about all employers, projects and departments.
CREATE DATABASE company
Go in:
USE company
And make 4 tables.


Employers


employer_id
int primary key


name
varchar(15)


surname
varchar(25)


hire_date
date


department_id
int


fired
int





projects


project_id
int primary key


name
varchar(255)





departments


department_id
int primary key


name
varchar(255)



This table consists relation between employer and projects:


project_involved


employer_id
int


project_id
int



Let&#8217;s create its in [...]]]></description>
			<content:encoded><![CDATA[<p>Here I systematized some of my MYSQL knowledges.<br />
<span id="more-762"></span></p>
<p>First I decide to make some test database to do everything step-by-step. This will be companies database contains information about all employers, projects and departments.</p>
<pre>CREATE DATABASE company</pre>
<p>Go in:</p>
<pre>USE company</pre>
<p>And make 4 tables.</p>
<table border="1">
<tbody></tbody>
<caption style="text-align: center;"><strong>Employers</strong></caption>
<tbody>
<tr>
<td>employer_id</td>
<td>int primary key</td>
</tr>
<tr>
<td>name</td>
<td>varchar(15)</td>
</tr>
<tr>
<td>surname</td>
<td>varchar(25)</td>
</tr>
<tr>
<td>hire_date</td>
<td>date</td>
</tr>
<tr>
<td>department_id</td>
<td>int</td>
</tr>
<tr>
<td>fired</td>
<td>int</td>
</tr>
</tbody>
</table>
<table border="1">
<tbody></tbody>
<caption style="text-align: center;"><strong>projects</strong></caption>
<tbody>
<tr>
<td>project_id</td>
<td>int primary key</td>
</tr>
<tr>
<td>name</td>
<td>varchar(255)</td>
</tr>
</tbody>
</table>
<table border="1">
<tbody></tbody>
<caption style="text-align: center;"><strong>departments</strong></caption>
<tbody>
<tr>
<td>department_id</td>
<td>int primary key</td>
</tr>
<tr>
<td>name</td>
<td>varchar(255)</td>
</tr>
</tbody>
</table>
<p>This table consists relation between employer and projects:</p>
<table border="1">
<tbody></tbody>
<caption><strong>project_involved</strong></caption>
<tbody>
<tr>
<td>employer_id</td>
<td>int</td>
</tr>
<tr>
<td>project_id</td>
<td>int</td>
</tr>
</tbody>
</table>
<p>Let&#8217;s create its in DB:</p>
<pre>CREATE TABLE employers (
employer_id int primary key auto_increment,
name varchar(15),
surname varchar(25),
hire_date date,
department_id int,
fired int);</pre>
<pre>CREATE TABLE projects (
project_id int primary key auto_increment,
name varchar(255));</pre>
<pre>CRETE TABLE departments (
department_id int primary key auto_increment,
name varchar(255));</pre>
<pre>CREATE TABLE project_involved (
employer_id int,
project_id int);</pre>
<p>And insert some data into them. I will show you only few of them:</p>
<pre>INSERT INTO projects (departments) VALUES ('General Project');</pre>
<p>In this insert I use <a href="http://dev.mysql.com/doc/refman/5.0/en/subqueries.html">subquery</a>:</p>
<pre>INSERT INTO employers
(name,surname,hire_date,department_id,fired)
VALUES ('Jonh','Smith','2007-10-30',
(SELECT department_id FROM departments WHERE name='Department A'),
0);</pre>
<p>Format of date should be the next:</p>
<p><strong><span style="color: #ff0000;">YYYY-MM-DD</span></strong></p>
<p>There is also some example of <strong>SELECT</strong> query in the <strong>UPDATE</strong> statement:</p>
<pre>INSERT INTO projects (name) VALUES ('General Project');</pre>
<pre>INSERT INTO project_involved (employer_id,project_id)
VALUES (
(SELECT employer_id FROM employers WHERE name='Jonh' AND surname='Smith'),
(SELECT project_id FROM projects WHERE name='General Project')
);</pre>
<p>In the ending of filling db up I&#8217;ve got next results:</p>
<pre>SELECT * FROM employers;
+-------------+------+---------+------------+---------------+-------+
| employer_id | name | surname | hire_date  | department_id | fired |
+-------------+------+---------+------------+---------------+-------+
|           1 | Jonh | Smith   | 2007-10-30 |             1 |     0 |
|           2 | Yan  | Brown   | 2008-11-23 |             2 |     0 |
+-------------+------+---------+------------+---------------+-------+
2 rows in set (0.00 sec)</pre>
<pre>SELECT * FROM project_involved;
+-------------+------------+
| employer_id | project_id |
+-------------+------------+
|           1 |          1 |
|        NULL |          2 |
+-------------+------------+
2 rows in set (0.00 sec)</pre>
<pre>SELECT * FROM projects;
+------------+-----------------+
| project_id | name            |
+------------+-----------------+
|          1 | General Project |
|          2 | Second Project  |
+------------+-----------------+
2 rows in set (0.00 sec)</pre>
<pre>SELECT * FROM departments;
+---------------+---------------+
| department_id | name          |
+---------------+---------------+
|             1 | departament A |
|             2 | departament B |
+---------------+---------------+
2 rows in set (0.00 sec)</pre>
<p>If you need to to remove something from your table(<em><span style="text-decoration: underline;">Department D</span></em> from <em><span style="text-decoration: underline;">departments</span></em> for example):</p>
<pre>DELETE FROM departments WHERE name='Department D';</pre>
<p>I&#8217;ve totally forgot about some column should be at <em><span style="text-decoration: underline;">employers</span></em> table. Column <span style="text-decoration: underline;"><em>position</em></span> has to be added. To change the structure of the table use <strong>ALTER</strong>:</p>
<pre>ALTER TABLE employers
ADD COLUMN position varchar(255) AFTER surname;</pre>
<p>in the same way you can remove needed column from the table:</p>
<pre>ALTER TABLE employers DROP COLUMN position;</pre>
<p>To rename column name run:</p>
<pre>ALTER TABLE table_name CHANGE old_name new_name INTEGER</pre>
<p>Now update the data:</p>
<pre>UPDATE employers SET position='system engineer'
WHERE surname='Smith' AND name='Jonh';</pre>
<p>There are few examples with subqueries. If you need to select all data from <em><span style="text-decoration: underline;">emloyers</span></em> table and resolve department name from <em><span style="text-decoration: underline;">departments</span></em> table. Run:</p>
<pre>SELECT employers.name, employers.surname, employers.hire_date, departments.name
FROM employers INNER JOIN departments USING (department_id);</pre>
<p>To simplify a query use <a href="http://www.google.com.ua/search?hl=en&amp;source=hp&amp;q=mysql+alias&amp;aq=f&amp;aqi=g10&amp;aql=&amp;oq=&amp;gs_rfai=">alias</a>:</p>
<pre>SELECT <span style="color: #ff0000;">e</span>.name, <span style="color: #ff0000;">e</span>.surname, <span style="color: #ff0000;">e</span>.hire_date, <span style="color: #ff0000;">d</span>.name FROM employers <span style="color: #ff0000;">e</span>
INNER JOIN departments <span style="color: #ff0000;">d</span> USING (department_id);
+------+---------+------------+---------------+
| name | surname | hire_date  | name          |
+------+---------+------------+---------------+
| Jonh | Smith   | 2007-10-30 | departament A |
| Yan  | Brown   | 2008-11-23 | departament C |
+------+---------+------------+---------------+
2 rows in set (0.00 sec)</pre>
<p>Here is more complex query which is involves all 4 tables:</p>
<pre>SELECT e.name, e.surname, e.position, e.hire_date, d.name department, p.name project
FROM projects p
INNER JOIN project_involved USING (project_id)
INNER JOIN employers e USING (employer_id)
INNER JOIN departments d USING (department_id);
+------+---------+-----------------+------------+---------------+-----------------+
| name | surname | position        | hire_date  | department    | project         |
+------+---------+-----------------+------------+---------------+-----------------+
| Jonh | Smith   | system engineer | 2007-10-30 | departament A | General Project |
| Jonh | Smith   | system engineer | 2007-10-30 | departament A | Second Project  |
+------+---------+-----------------+------------+---------------+-----------------+
2 rows in set (0.00 sec)</pre>
<p>To remove database or table use <strong>DROP</strong>:</p>
<pre>DROP [database|table]</pre>
<p>For example:</p>
<pre>DROP employers;</pre>
<p>To see database or table structure use <strong>SHOW CREATE</strong>:</p>
<pre>SHOW CREATE TABLE table;</pre>
<pre>SHOW CREATE DATABASE company;</pre>
<pre>SHOW CREATE DATABASE company;
+----------+--------------------------------------------------------------------+
| Database | Create Database                                                    |
+----------+--------------------------------------------------------------------+
| company  | CREATE DATABASE `company` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+--------------------------------------------------------------------+</pre>
<h3 style="text-align: center;"><strong>BACKUPS</strong></h3>
<p>To make backups of your database use <strong>mysqldump</strong> :</p>
<pre>mysqldump -u root -p --database company &gt; company.sql</pre>
<p>To restores from backups :</p>
<pre>mysql -u root -p -e 'source company.sql' company</pre>
<p style="text-align: center;"><strong>CREATE USER</strong></p>
<pre>GRANT [privileges] ON [resource] TO [identity]</pre>
<p>In example I create user <em><span style="text-decoration: underline;">company_admin</span></em> which has  all privileges on all tables in database <span style="text-decoration: underline;"><em>company</em></span> from host <em><span style="text-decoration: underline;">localhost</span></em> with password <em><span style="text-decoration: underline;">secret-password</span></em>:</p>
<pre>GRANT ALL PRIVILEGES ON company.* TO company_admin@localhost
IDENTIFIED BY 'secret_password';</pre>
<p>There are some of the privileges, almost all of them is self-explained:</p>
<p><em>ALTER<br />
CREATE<br />
DELETE<br />
DROP<br />
GRANT<br />
INSERT<br />
SELECT<br />
UPDATE</em></p>
<p>For more details concerning <strong>GRANT</strong> go to <a href="http://dev.mysql.com/doc/refman/5.0/en/grant.html">ofdocs</a>.</p>
<p style="text-align: center"><strong>MYISAM VS INNODB</strong></p>
<p>InnoDB is set by default. And it&#8217;s speed and mature way to store simple data.</p>
<p>Advantages of InnoDB:</p>
<ol>
<li>transaction support</li>
<li>row-level locking</li>
<li>foreign key constraints</li>
</ol>
<p>To disadvantages we can attribute the next:</p>
<ol>
<li>don&#8217;t support full-text searching</li>
<li>some troubles with AUTO_INCREMENT columns</li>
</ol>
<p>To change of the table engine run:</p>
<pre>ALTER TABLE table ENGINE=[engine]</pre>
<pre>ALTER TABLE employers ENGINE=InnoDB</pre>
<p style="text-align: center;"><strong>FOREIGN KEY</strong></p>
<p>This feature help you to prevent your data from human mistake and keep it integrity.<br />
First, you need to convert your tables into InnoDB:</p>
<pre>ALTER TABLE table ENGINE=InnoDB;</pre>
<p>and set dependency:</p>
<pre>ALTER TABLE employers ADD CONSTRAINT dep_id_cons
FOREIGN KEY (department_id) REFERENCES departments (department_id);</pre>
<p>Now when we try to set employers.department_id which is not at departments.department_id. As result changes is not committed and we get an error:</p>
<pre>INSERT INTO employers (name,surname,department_id)
VALUES ('test','test','123');
ERROR 1452 (23000): Cannot add or update a child row:
a foreign key constraint fails (`company/employers`,
CONSTRAINT `dep_id_cons` FOREIGN KEY (`department_id`)
REFERENCES `departments` (`department_id`))</pre>
<p>To delete foreign key run:</p>
<pre>ALTER TABLE employers DROP FOREIGN KEY dep_id_cons;</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/05/mysql-quick-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UA-IX checker</title>
		<link>http://andriigrytsenko.net/2010/04/ua-ix-checker/</link>
		<comments>http://andriigrytsenko.net/2010/04/ua-ix-checker/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 08:31:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=737</guid>
		<description><![CDATA[Based on this post I have decided make some program which able to detect weather IP is a part of some network (in this case UA-IX network) or not.

Speaking about UA-IX, from wikipedia we know: 
The Ukrainian traffic exchange network (UA-IX) (Ukrainian: Українська мережа обміну інтернет-трафіком) is an Internet exchange point that was established in [...]]]></description>
			<content:encoded><![CDATA[<p>Based on <a href="http://andriigrytsenko.net/2010/03/ipcalc-on-perl/">this post</a> I have decided make some program which able to detect weather IP is a part of some network (in this case UA-IX network) or not.<br />
<span id="more-737"></span></p>
<p>Speaking about UA-IX, from <a href="http://en.wikipedia.org/wiki/Ukrainian_Internet_Exchange_Network">wikipedia</a> we know: </p>
<blockquote><p>The Ukrainian traffic exchange network (UA-IX) (Ukrainian: Українська мережа обміну інтернет-трафіком) is an Internet exchange point that was established in Kiev, the capital of Ukraine, on July 2000 and is the daughter company of Ukrainian Internet Association. Companies that established Ukrainian traffic exchange network are major Ukrainian businesses that work expanding Ukrainian Internet market.</p></blockquote>
<p>Here the <a href="http://noc.ix.net.ua/ua-list.txt">list</a> of all networks which belongs to UA-IX net. Download it to your machine and save as <em>ua-list.txt</em>.</p>
<p>Content of file. We have some networks list here:</p>
<pre>$ head -3 ua-list.txt
8.8.4.0/24
8.8.8.0/24
62.16.0.0/19
</pre>
<p>Here is the script:</p>
<pre>$cat uaix.pl
#!/usr/local/bin/perl
# Written by Andrii Grytsenko 2010
# PP: http://andriigrytsenko.net     

use POSIX;
use strict;

sub dec2bin {
   my $hex = shift;
   my $pack = unpack("B32",pack("N",$hex));
   my $pack = substr($pack,-8);
   return $pack;
}

my $bin_ip;
$bin_ip .= dec2bin($_) foreach (split(/\./,$ARGV[0]));

open(IP, "<$ARGV[1]");
while(<IP>){
    chomp();
    my ($ip,$net_mask) = split(/\//,$_);
    $net_mask = 24 if (!defined($net_mask));
    my $bin_network;
    $bin_network .= dec2bin($_) foreach (split(/\./,$ip));
    my $net_net_part = substr($bin_network,0,$net_mask);
    my $net_ip_part  = substr($bin_ip,0,$net_mask);
    if ( $net_net_part == $net_ip_part) {
        print "IP $ARGV[0] belong to network $_\n";
        exit;
    }
}

print "IP $ARGV[0] is not part of UA-IX\n";
close(IP);</pre>
<p>To run the script: </p>
<pre>$ perl uaix.pl [ip_addr] [path/to/ua-list.txt]</pre>
<p>For example: </p>
<pre>$ perl uaix.pl 72.14.228.156 ua-list.txt
IP 72.14.228.156 belong to network 72.14.192.0/18</pre>
<p>There is also some ways to use script on your own&#8230; You can use your list of networks to detect ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/04/ua-ix-checker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPCalc on Perl</title>
		<link>http://andriigrytsenko.net/2010/03/ipcalc-on-perl/</link>
		<comments>http://andriigrytsenko.net/2010/03/ipcalc-on-perl/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 18:52:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=720</guid>
		<description><![CDATA[Today I decided to make my own IPCalc program. I had two reason for that. First to learn perl&#8217;s binary operations and second one to make some IP calculation points more clear for me.

There is some listing of my script I hope this example help you to understand some fundamental points in IP math.

#!/usr/local/bin/perl
# Written [...]]]></description>
			<content:encoded><![CDATA[<p>Today I decided to make my own IPCalc program. I had two reason for that. First to learn perl&#8217;s binary operations and second one to make some IP calculation points more clear for me.<br />
<span id="more-720"></span></p>
<p>There is some listing of my script I hope this example help you to understand some fundamental points in IP math.</p>
<pre>
#!/usr/local/bin/perl
# Written by Andrii Grytsenko 2010
# PP: http://andriigrytsenko.net    

use POSIX;

sub hex2bin {
   my $hex = shift;
   my $pack = unpack("B32",pack("N",$hex));
   my $pack = substr($pack,-8);
   return $pack;
}                                          

sub bin2hex {
   my $bin = shift;
   return unpack("N", pack("B32", substr("0" x 32 . $bin, -32)))
}                                                               

sub bin2ip {
    my $bin = shift;
    my $type = shift;
    my $ip;
    $ip .= bin2hex(substr($bin,0,8)) ."\.";
    $ip .= bin2hex(substr($bin,8,8)) ."\.";
    $ip .= bin2hex(substr($bin,16,8)) ."\.";
    if ( $type eq 'first') {
        $ip .= bin2hex(substr($bin,24,8)) + 1 ;
    } elsif ($type eq 'broad') {
        $ip .= bin2hex(substr($bin,24,8)) - 1 ;
    } else {
        $ip .= bin2hex(substr($bin,24,8));
    }
    return $ip;
}

sub normalization {
    my $line = shift;
    my ($ip,$mask) = split(/\//,$line);
    return($ip,$mask);
}

my ($ip,$net_mask) = normalization(@ARGV[0]);

my $host_mask = 32-$net_mask;
my $max_host = POSIX::pow(2,$host_mask)-2;
my $bin_mask = "1" x $net_mask . "0" x $host_mask;

my $bin_ip ;
$bin_ip .= hex2bin($_) foreach (split(/\./,$ip));

my $min = $bin_ip &#038; $bin_mask;
my $max_mask = "0" x $net_mask . "1" x $host_mask;
my $max = $bin_ip  | $max_mask;

my $min_ip = bin2ip($min);
my $min_host_ip = bin2ip($min,'first');
my $max_ip = bin2ip($max);
my $max_host_ip = bin2ip($max,'broad');

print \<\< EOF
IP ADDRESS:\t $ip\t $bin_ip
NETWORK MASK:\t \/$net_mask\t\t $bin_mask
WILDCARD:\t \/$host_mask\t\t $max_mask
NETWORK IP:\t $min_ip\/$net_mask\t $min
BROADCAST ADDR:\t $max_ip\t $max
FIRST ADDR:\t $min_host_ip
LAST ADDR:\t $max_host_ip
MAX HOSTS\t $max_host
EOF
</pre>
<p>Run scripts with one argument ip/netmask... Unfortunately, you can use only short network mask type :</p>
<pre>./ipcalc 192.157.9.3/21</pre>
<p>the output looks like this:</p>
<pre>
IP ADDRESS:      192.157.9.3     11000000100111010000100100000011
NETWORK MASK:    /21             11111111111111111111100000000000
WILDCARD:        /11             00000000000000000000011111111111
NETWORK IP:      192.157.8.0/21  11000000100111010000100000000000
BROADCAST ADDR:  192.157.15.255  11000000100111010000111111111111
FIRST ADDR:      192.157.8.1
LAST ADDR:       192.157.15.254
MAX HOSTS        2046
</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/03/ipcalc-on-perl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Clean up the shared memory in Solaris</title>
		<link>http://andriigrytsenko.net/2010/03/clean-up-the-shared-memory-in-solaris/</link>
		<comments>http://andriigrytsenko.net/2010/03/clean-up-the-shared-memory-in-solaris/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 15:44:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[solaris]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=713</guid>
		<description><![CDATA[Here is short trick how to clean the shared memory up in Solaris OS. 

Here is short info about the host(solaris 5.9, arch sparc):
uname -a
SunOS hostname1 5.9 Generic_118558-25 sun4u sparc SUNW,Sun-Fire-V890 Solaris

To see all shared memory segment, use ipcs

user1@~>ipcs -m -a
IPC status from  as of Wed Mar 10 16:26:20 CET 2010
T    [...]]]></description>
			<content:encoded><![CDATA[<p>Here is short trick how to clean the shared memory up in Solaris OS. </p>
<p><span id="more-713"></span></p>
<p>Here is short info about the host(solaris 5.9, arch sparc):</p>
<pre>uname -a
SunOS hostname1 5.9 Generic_118558-25 sun4u sparc SUNW,Sun-Fire-V890 Solaris
</pre>
<p>To see all shared memory segment, use <em>ipcs</em></p>
<pre>
user1@~>ipcs -m -a
IPC status from <running system> as of Wed Mar 10 16:26:20 CET 2010
T         ID      KEY        MODE        OWNER    GROUP  CREATOR   CGROUP NATTCH      SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
Shared Memory:
m       4608   0x5efaa728 --rw-r-----   oracle oinstall   oracle oinstall     23 3992993792  5720 18925 16:24:47 16:24:47 11:59:42
m    5246977   0x517b6233 --rw-r--r-- user1   os_int user1   os_int     32    7352048 10685 16417 16:21:26 16:21:26 16:13:35
m    1969154   0x22b80b3e --rw-r--r-- user1   os_int user1   os_int      3   72552448 10689 11443 16:14:19 16:13:51 16:13:37
m    1967619   0x1b68b6e6 --rw-r--r-- user1   os_int user1   os_int      8  438326272 10689 16417 16:21:26 16:21:26 16:13:38
m    1966084   0x5724f977 --rw-r--r-- user1   os_int user1   os_int     14  212926464 10689 11379 16:14:27 16:13:50 16:13:40
m    1966085   0x534aab2a --rw-r--r-- user1   os_int user1   os_int     10  216572928 10689 11442 16:14:38 16:13:51 16:13:42
m   11391045   0x7bfc552e --rw-r--r-- user2   os_int user2   os_int      0    7352048  8047  9445 14:43:22 14:43:40 13:41:22
m   10461766   0x63fcba9b --rw-r--r-- user2   os_int user2   os_int      0   72552448  8114  9457 14:43:22 14:43:38 13:41:25
m    9721415   0x5cad6643 --rw-r--r-- user2   os_int user2   os_int      0  583097344  8114  9459 14:43:22 14:43:38 13:41:27
m    9655368   0x1869a8d4 --rw-r--r-- user2   os_int user2   os_int      0  212926464  8114  9466 14:43:22 14:43:38 13:41:29
m    9753673   0x148f5a87 --rw-r--r-- user2   os_int user2   os_int      0  216572928  8114  9473 14:43:22 14:43:38 13:41:31
</pre>
<p>To delete/destroy/remove any segment of the shared memory, use <em>ipcrm</em>. You can specify segment by  <em>shmkey</em>(3-rd field in ipcs output) or by <em>shmid</em>(2-nd field) use <strong>-M</strong> and <strong>-m</strong> accordingly . Like : </p>
<pre>ipcrm -m 4608</pre>
<p>or </p>
<pre>ipcrm -M 0x5efaa728</pre>
<p>To remove all segment in shared memory where owner is <em>user1</em>, run </p>
<pre>ipcs -m -a | awk '{if($5 ~ /user1/ &#038;&#038; $1 ~ /m/) print "ipcrm -m "$2;}' | bash</pre>
<p>END.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/03/clean-up-the-shared-memory-in-solaris/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Perl performance optimization</title>
		<link>http://andriigrytsenko.net/2010/03/perl-performance-optimization/</link>
		<comments>http://andriigrytsenko.net/2010/03/perl-performance-optimization/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 18:05:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=671</guid>
		<description><![CDATA[I&#8217;d like to describe my own experience with perl optimization. There several common way to make you code works more faster.

I used perl module Benchmark to make measurements. Rules:
1. If you can use single quotes instead of double quote, do it. In most cases it will be executed more faster because of string in single [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to describe my own experience with perl optimization. There several common way to make you code works more faster.<br />
<span id="more-671"></span></p>
<p>I used perl module Benchmark to make measurements. Rules:</p>
<p>1. If you can use single quotes instead of double quote, do it. In most cases it will be executed more faster because of string in single quotes is not going to concatenate. </p>
<p>2. Use compiled regexps in case you have loops. It can brings huge performance: </p>
<pre>
use Benchmark;

sub qwe {
    my $re = shift;
    my $line = "wer";
    foreach my $reg (@$re){
        if ( $line =~ /$reg/) {
            my $l=0;
        }
    }
}

my $line = "sdfsdfsdfsdf";
my $ref = ".*";
my @arr = qw(qwe sdf wer); #plaine regexps
my @c_re;
foreach my $p_re (@arr) { # compile it and put in to the @c_re
    my $re = qr/\b$p_re\b/i ;
    push(@c_re,$re);
}

Benchmark::cmpthese(100000, {
    'Compiled' => sub { qwe(\@c_re) },
    'Not_compiled' => sub { qwe(\@arr) },
});</pre>
<p>As result:</p>
<pre>
                 Rate Not_compiled     Compiled
Not_compiled  36232/s           --         -79%
Compiled     169492/s         368%           --</pre>
<p>3. Extract values from string with <em>substr</em> if you can. There are three well knows ways to do such kind of operation: regular expressions, split and substr. Let&#8217;s compare it:</p>
<pre>sub mksplit {
    my ($line) = @_;
    my ($fst,$snd) = split(/-/,$line);
    return($fst,$snd);
}

sub mkregexp {
    my ($line,$re) = @_;
    $line =~ m/$re/;
    return($1,$2);
}

sub mkstr {
    my ($line) = @_;
    my $pos = index($line,'-');
    my $fst = substr($line,0,$pos);
    my $snd = substr($line,$pos+1);
    return($fst,$snd);
}

my $line = "12-34";
my $n_comp_re = '(\d+)-(\d+)';
my $comp_re = qr/\b$n_comp_re\b/i ;

Benchmark::cmpthese(1000000, {
    'Compiled' => sub { mkregexp($line,$comp_re) },
    'Not_compiled' => sub { mkregexp($line,$n_comp_re) },
    'STR' => sub { mkstr($line) },
    'Split' => sub { mksplit($line) },
});

Benchmark::timethese(1000000, {
    'Compiled' => sub { mkregexp($line,$comp_re) },
    'Not_compiled' => sub { mkregexp($line,$n_comp_re) },
    'STR' => sub { mkstr($line) },
    'Split' => sub { mksplit($line) },
});
</pre>
<p>Where <em>compiled</em> and <em>not_compiles</em>  we use when talk about regular expression.</p>
<pre>
                 Rate        Split     Compiled Not_compiled          STR
Split        297619/s           --          -9%         -12%         -25%
Compiled     327869/s          10%           --          -4%         -17%
Not_compiled 340136/s          14%           4%           --         -14%
STR          396825/s          33%          21%          17%           --
Benchmark: timing 1000000 iterations of Compiled, Not_compiled, STR, Split...
  Compiled:  4 wallclock secs ( 3.14 usr +  0.00 sys =  3.14 CPU) @ 318471.34/s (n=1000000)
Not_compiled:  3 wallclock secs ( 2.91 usr +  0.00 sys =  2.91 CPU) @ 343642.61/s (n=1000000)
       STR:  2 wallclock secs ( 2.53 usr +  0.00 sys =  2.53 CPU) @ 395256.92/s (n=1000000)
     Split:  3 wallclock secs ( 3.19 usr +  0.00 sys =  3.19 CPU) @ 313479.62/s (n=1000000)
</pre>
<p>As you can see from output the more faster way to exract values from string is <em>substr</em>, next is split and regular expressions is the most slower. I don&#8217;t know why compiled regexps is more slow than regular one in this case. I guess its because of 1 iteration. </p>
<p>4. Don&#8217;t use sort in hash loops if there is no necessity. The most faster way to through over the hash is <em>keys</em> statement: </p>
<pre>
sub mkeach {
    my $hash = shift;
    my %hash2;
    while ( my($key,$value) = each(%$hash)){
        $hash2{$key} = $value;
    }
    return(\%hash2);
}

sub mkkeys {
    my $hash = shift;
    my %hash2;
    for my $key (keys(%$hash)){
        $hash2{$key} = $hash->{$key};
    }
    return(\%hash2);
}

sub mksort {
    my $hash = shift;
    my %hash2;
    foreach my $key (sort keys %$hash) {
        $hash2{$key} = $hash->{$key};
    }
    return(\%hash2);
}

my %hash = (name => 'name1', surname => 'surname1', address => 'address', var => 'var1', var2 => 'var2');

Benchmark::cmpthese(1000000, {
    'Keys' => sub { mkkeys(\%hash) },
    'Each' => sub { mkeach(\%hash) },
    'Sort' => sub { mksort(\%hash) },
});

Benchmark::timethese(1000000, {
    'Keys' => sub { mkkeys(\%hash) },
    'Each' => sub { mkeach(\%hash) },
    'Sort' => sub { mksort(\%hash) },
});
</pre>
<pre>
        Rate Each Sort Keys
Each 66800/s   --  -3% -14%
Sort 68681/s   3%   -- -11%
Keys 77459/s  16%  13%   --
Benchmark: timing 1000000 iterations of Each, Keys, Sort...
      Each: 16 wallclock secs (14.92 usr +  0.00 sys = 14.92 CPU) @ 67024.13/s (n=1000000)
      Keys: 12 wallclock secs (12.91 usr +  0.00 sys = 12.91 CPU) @ 77459.33/s (n=1000000)
      Sort: 15 wallclock secs (14.62 usr +  0.00 sys = 14.62 CPU) @ 68399.45/s (n=1000000)
</pre>
<p>That&#8217;s all for now, but I&#8217;ll continue to optimize my code so I think there will be an updates soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/03/perl-performance-optimization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check if the perl module is installed</title>
		<link>http://andriigrytsenko.net/2010/02/check-if-the-perl-module-is-installed/</link>
		<comments>http://andriigrytsenko.net/2010/02/check-if-the-perl-module-is-installed/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 15:40:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=665</guid>
		<description><![CDATA[Under cover you can find some trick and script to check perl module installation.

To figure out whether perl module is installed at the system. Run:
perl -M&#60;module_name&#62; -e 1
if command return an error or NOT 0(zero) then module is not installed at the moment.
Here is also perl script which help you check a lot of modules:
#!/usr/local/bin/perl

my [...]]]></description>
			<content:encoded><![CDATA[<p>Under cover you can find some trick and script to check perl module installation.<br />
<span id="more-665"></span></p>
<p>To figure out whether perl module is installed at the system. Run:</p>
<pre>perl -M&lt;module_name&gt; -e 1</pre>
<p>if command return an error or NOT 0(zero) then module is not installed at the moment.</p>
<p>Here is also perl script which help you check a lot of modules:</p>
<pre>#!/usr/local/bin/perl

my @modules = qw (put your modules here separated by space without any quotes);

foreach my $module (@modules){
print $module,"\t";
my $result=system("perl -M$module -e 1");
print "Installed" if (!$result);
print "\n";
}</pre>
<p>EOF</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/02/check-if-the-perl-module-is-installed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Dbmail mailbox quota notification script</title>
		<link>http://andriigrytsenko.net/2010/02/dbmail-mailbox-quota-notification-script/</link>
		<comments>http://andriigrytsenko.net/2010/02/dbmail-mailbox-quota-notification-script/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 16:41:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=652</guid>
		<description><![CDATA[Here is the script which check quota limits in the dbmail and in case of exceeding, script send mail to user and postmaster.

Get script mail_quota.pl and mail_quota.conf configuration file at first.
To make script work fine two cpan modules should be installed:
cpan -i Mail::Send
and 
cpan -i DBD::Pg
This is dbmail table dbmail_users description:
dbmail=# \d dbmail_users
Table "public.dbmail_users"
Column  [...]]]></description>
			<content:encoded><![CDATA[<p>Here is the script which check quota limits in the dbmail and in case of exceeding, script send mail to user and postmaster.<br />
<span id="more-652"></span></p>
<p>Get script <a href="http://andriigrytsenko.net/files/mail_quota.txt">mail_quota.pl</a> and <a href="http://andriigrytsenko.net/files/mail_quota.conf">mail_quota.conf</a> configuration file at first.</p>
<p>To make script work fine two <a href="http://www.cpan.org/">cpan</a> modules should be installed:</p>
<pre>cpan -i Mail::Send</pre>
<p>and </p>
<pre>cpan -i DBD::Pg</pre>
<p>This is dbmail table <em>dbmail_users</em> description:</p>
<pre>dbmail=# \d dbmail_users
Table "public.dbmail_users"
Column      |            Type             |                              Modifiers
-----------------+-----------------------------+---------------------------------------------------------------------
user_idnr       | bigint                      | not null default nextval('dbmail_user_idnr_seq'::regclass)
userid          | character varying(100)      | not null
passwd          | character varying(34)       | not null
client_idnr     | bigint                      | not null default 0::bigint
maxmail_size    | bigint                      | not null default 0::bigint
curmail_size    | bigint                      | not null default 0::bigint
maxsieve_size   | bigint                      | not null default 0::bigint
cursieve_size   | bigint                      | not null default 0::bigint
encryption_type | character varying(20)       | not null default ''::character varying
last_login      | timestamp without time zone | not null default '1979-11-03 22:05:58'::timestamp without time zone
</pre>
<p>There is configuration:</p>
<pre>cat mail_quota.conf:
user=user
host=localhost
port=5432
dbname=db
password=pass
min_thre=80
max_thre=90
admin_mail=admin@domain.com</pre>
<p>No comment in the configuration file is permitted. First 4 lines describe database connection.<br />
<em>min_thre</em>/<em>max_thre</em> &#8211; minimum and maximum threshold for notification measure is percent. If minimum threshold will be reached user receive mail about quota exceeding. In case of maximum reaching, mail also will be sent to administrator. </p>
<p>To make checking on regular basis add it into the crontab file. </p>
<pre>crontab -l
# m h  dom mon dow   command
59 23 * * *     /path/to/mail_quota.pl /path/to/mail_quota.conf</pre>
<p>Below we check mail quota every day at 23.59. </p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/02/dbmail-mailbox-quota-notification-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Network bandwidth script</title>
		<link>http://andriigrytsenko.net/2010/02/network-bandwidth-script/</link>
		<comments>http://andriigrytsenko.net/2010/02/network-bandwidth-script/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 17:35:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=634</guid>
		<description><![CDATA[I spent several hours to find suitable script which help me figure out my network speed between two servers. But it was fruitlessly. So, I decided to make my own script with blackjack and hoockers. (c)

My Perl script require several things :

Perl interpreter of course
IO::Socket perl module
Getopt::Long perl module

I will tell you nothing about first [...]]]></description>
			<content:encoded><![CDATA[<p>I spent several hours to find suitable script which help me figure out my network speed between two servers. But it was fruitlessly. So, I decided to make my own script with blackjack and hoockers. (c)</p>
<p><span id="more-634"></span></p>
<p>My Perl script require several things :</p>
<ol>
<li>Perl interpreter of course</li>
<li>IO::Socket perl module</li>
<li>Getopt::Long perl module</li>
</ol>
<p>I will tell you nothing about first one. To install perl modules run <em>cpan</em> as root:</p>
<pre>cpan -i Getopt::Long</pre>
<p>and</p>
<pre>cpan -i IO::Socket</pre>
<p>When installation will be finished. Download <a href="http://andriigrytsenko.net/files/bandtest_pl.txt">bandtest.pl</a> and save it at 1-st server.</p>
<p>Now go to the second one and run <em>netcat</em>(please make sure you have this package installed):</p>
<pre>server02# nc -4tl 7777 &gt; /dev/null</pre>
<p>You can use any free port instead port 7777.</p>
<p>Back to first server and run <em>bandtest.pl</em>, but before make sure there is no any firewalls rules which hamper in connection between to hosts on port 7777.</p>
<p>Use <em>telnet</em> to check connection:</p>
<pre>server01# telnet server02 7777
Connected to kivras01.
Escape character is '^]'.</pre>
<p>This output means connection is successfully opened, so you can continue.</p>
<p>Make file with size for example 100Mb(I advice you to don&#8217;t use very big files, 100Mb is fit size which doesn&#8217;t fill your memory out and enough for proper results.  I intentionally put file into memory before sending the data&#8217;s. This allow me delete any I/O operation during the network connection and as result prevent any result distortion.):</p>
<pre>server01# dd if=/dev/zero of=/tmp/test bs=1024 count=1000000
100000+0 records in
100000+0 records out
102400000 bytes (102 MB) copied, 1.20234 s, 85.2 MB/s</pre>
<p>Run <em>bandtest.pl</em> to get a results:</p>
<pre>server01$ ./bandtest.pl -h server02 -p 7777 -f /tmp/test
Bytes were transfered 102.40 MB
Seconds taken: 8
Average speed 12.80 MB
</pre>
<p>EOF.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/02/network-bandwidth-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get system temperature in Linux</title>
		<link>http://andriigrytsenko.net/2010/01/get-system-temperature-in-linux/</link>
		<comments>http://andriigrytsenko.net/2010/01/get-system-temperature-in-linux/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 13:17:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=624</guid>
		<description><![CDATA[How to get online temperature status on your linux box.

There is one good package which allow you to control and check your computer temperature in online mode. To install  For debian:
apt-get install lm-sensors
for CentOS or RH:
yum install lm-sensors
Next software should discover all sensors in your PC, run sensors-detect:
agrytsenko:~# sensors-detect
# sensors-detect revision 5729 (2009-06-02 15:51:29 [...]]]></description>
			<content:encoded><![CDATA[<p>How to get online temperature status on your linux box.<br />
<span id="more-624"></span></p>
<p>There is one good package which allow you to control and check your computer temperature in online mode. To install  For debian:</p>
<pre>apt-get install lm-sensors</pre>
<p>for CentOS or RH:</p>
<pre>yum install lm-sensors</pre>
<p>Next software should discover all sensors in your PC, run <em>sensors-detect</em>:</p>
<pre>agrytsenko:~# sensors-detect
# sensors-detect revision 5729 (2009-06-02 15:51:29 +0200)
# System: Hewlett-Packard HP Compaq 6510b (GB866EA#ACB) (laptop)
# Board: Hewlett-Packard 30C0                                   

This program will help you determine which kernel modules you need
to load to use lm_sensors most effectively. It is generally safe
and recommended to accept the default answers to all questions,
unless you know what you're doing.                                

Some south bridges, CPUs or memory controllers contain embedded sensors.
Do you want to scan for them? This is totally safe. (YES/no):
Silicon Integrated Systems SIS5595...                       No
VIA VT82C686 Integrated Sensors...                          No
VIA VT8231 Integrated Sensors...                            No
AMD K8 thermal sensors...                                   No
AMD K10 thermal sensors...                                  No
Intel Core family thermal sensor...                         Success!
    (driver `coretemp')
Intel AMB FB-DIMM thermal sensor...                         No
VIA C7 thermal and voltage sensors...                       No          

Some Super I/O chips contain embedded sensors. We have to write to
standard I/O ports to probe them. This is usually safe.
Do you want to scan for Super I/O sensors? (YES/no):
Probing for Super-I/O at 0x2e/0x2f
Trying family `National Semiconductor'...                   No
Trying family `SMSC'...                                     Yes
Found unknown chip with ID 0x3600
Probing for Super-I/O at 0x4e/0x4f
Trying family `National Semiconductor'...                   No
Trying family `SMSC'...                                     Yes
Found unknown non-standard chip with ID 0x7a                      

Some hardware monitoring chips are accessible through the ISA I/O ports.
We have to write to arbitrary I/O ports to probe them. This is usually
safe though. Yes, you do have ISA I/O ports even if you do not have any
ISA slots! Do you want to scan the ISA I/O ports? (YES/no):
Probing for `National Semiconductor LM78' at 0x290...       No
Probing for `National Semiconductor LM79' at 0x290...       No
Probing for `Winbond W83781D' at 0x290...                   No
Probing for `Winbond W83782D' at 0x290...                   No          

Lastly, we can probe the I2C/SMBus adapters for connected hardware
monitoring devices. This is the most risky part, and while it works
reasonably well on most systems, it has been reported to cause trouble
on some systems.
Do you want to probe the I2C/SMBus adapters now? (YES/no):
Sorry, no supported PCI bus adapters found.
Module i2c-dev loaded successfully.

Now follows a summary of the probes I have just done.
Just press ENTER to continue:

Driver `coretemp':
  * Chip `Intel Core family thermal sensor' (confidence: 9)

To load everything that is needed, add this to /etc/modules:
#----cut here----
# Chip drivers
coretemp
#----cut here----
If you have some drivers built into your kernel, the list above will
contain too many modules. Skip the appropriate ones!

Do you want to add these lines automatically to /etc/modules? (yes/NO)yes
Successful!

Monitoring programs won't work until the needed modules are
loaded. You may want to run '/etc/init.d/module-init-tools start'
to load them.

Unloading i2c-dev... OK</pre>
<p>If you have choosen &#8220;yes&#8221; on last question then all needed kernel modules were added to your module config file. In my case only one module is found, here is it:</p>
<pre>agrytsenko:~# grep temp /etc/modules
coretemp</pre>
<p>To get sensors status and data run <em>sensors</em>:</p>
<pre>agrytsenko:~# sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:       +60.0°C  (crit = +256.0°C)
temp2:       +58.0°C  (crit = +108.0°C)
temp3:       +45.0°C  (crit = +105.0°C)
temp4:       +32.5°C  (crit = +108.0°C)
temp5:       +65.0°C  (crit = +110.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Core 0:      +59.0°C  (high = +100.0°C, crit = +100.0°C)

coretemp-isa-0001
Adapter: ISA adapter
Core 1:      +61.0°C  (high = +100.0°C, crit = +100.0°C)
</pre>
<p>The output depends on your hardware sensors. This output from my another PC:</p>
<pre>w83627hf-isa-0290
Adapter: ISA adapter
VCore 1:   +1.47 V  (min =  +1.30 V, max =  +1.71 V)
VCore 2:   +1.82 V  (min =  +1.30 V, max =  +1.71 V)       ALARM
+3.3V:     +3.25 V  (min =  +2.82 V, max =  +3.79 V)
+5V:       +4.89 V  (min =  +4.06 V, max =  +5.70 V)
+12V:     +12.28 V  (min =  +7.24 V, max =  +9.97 V)       ALARM
-12V:     -11.95 V  (min =  +4.58 V, max = -11.87 V)       ALARM
-5V:       -5.20 V  (min =  +2.09 V, max =  -4.39 V)       ALARM
V5SB:      +5.46 V  (min =  +5.99 V, max =  +5.19 V)       ALARM
VBat:      +2.85 V  (min =  +3.54 V, max =  +3.49 V)       ALARM
fan1:        0 RPM  (min = 10887 RPM, div = 2)              ALARM
fan2:        0 RPM  (min = 3947 RPM, div = 2)              ALARM
fan3:        0 RPM  (min = 4411 RPM, div = 2)              ALARM
temp1:       +28 C  (high =   +68 C, hyst =   +48 C)   sensor = thermistor
temp2:     +43.0 C  (high =   +70 C, hyst =   +65 C)   sensor = diode(beep)
temp3:      -1.5 C  (high =   +70 C, hyst =   +65 C)   sensor = diode
vid:      +1.500 V  (VRM Version 8.5)
alarms:
beep_enable:
          Sound alarm enabled
</pre>
<p>Now you can do with these info whatever you want, for instance put into the file as plain text or excel document or even storage in RDBMS. I prefer to store these data&#8217;s in Round Robin Database and draw nice graphs by <strong>rrdtool</strong> util.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/01/get-system-temperature-in-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google maps API to show users location</title>
		<link>http://andriigrytsenko.net/2010/01/google-maps-api/</link>
		<comments>http://andriigrytsenko.net/2010/01/google-maps-api/#comments</comments>
		<pubDate>Sun, 17 Jan 2010 20:18:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=605</guid>
		<description><![CDATA[I will show you how to use google maps to print location of your site visitors.

First of all you need to get Google KEY, to do this you should have google account. If you have it visit google key page to generate the map key.
After you&#8217;ve done it -&#62; you will be ready for next [...]]]></description>
			<content:encoded><![CDATA[<p>I will show you how to use google maps to print location of your site visitors.<br />
<span id="more-605"></span></p>
<p>First of all you need to get Google KEY, to do this you should have google account. If you have it visit <a href="http://code.google.com/apis/maps/signup.html">google key page</a> to generate the map key.</p>
<p>After you&#8217;ve done it -&gt; you will be ready for next steps.</p>
<p>Below the script should be downloaded in your html directory as location.cgi for example:</p>
<pre>#!/usr/bin/perl                                              

use strict;
use LWP;   

sub GetCode {
 my ($map_key,$lat,$long,$zoom)=@_;

 my $head = &lt;&lt;HEAD;
 &lt;title&gt;Your current location&lt;/title&gt;
 &lt;script src="http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;sensor=false&amp;amp;key=$map_key"
 type="text/javascript"&gt;&lt;/script&gt;
 &lt;script type="text/javascript"&gt;
 function initialize() {
 if (GBrowserIsCompatible()) {
 var map = new GMap2(document.getElementById("map_canvas"));
 map.setCenter(new GLatLng($lat, $long), $zoom);
 map.setUIToDefault();
 }
 }
 &lt;/script&gt;
HEAD
 my $body= &lt;&lt;BODY;
 &lt;body onload="initialize()" onunload="GUnload()"&gt;
 Your current location is $ENV{REMOTE_ADDR}:&lt;br&gt;
 &lt;div id="map_canvas" style="width: 500px; height: 300px"&gt;&lt;/div&gt;
 &lt;/body&gt;
BODY
return($head,$body);
}                                                                                                

sub GetHTMLCode {
 my ($head,$body)=@_;
 my $html = &lt;&lt;HTML;
 &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
 &lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"&gt;
 &lt;head&gt;
 &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/&gt;
 $head
 &lt;/head&gt;
 $body
HTML
 return $html;
}

sub GetCoordinates {
 my $ip = shift;
 my ($lat,$long);
 my $ua = new LWP::UserAgent;
 $ua-&gt;agent("Opera/9.0 " . $ua-&gt;agent);
 $ua-&gt;timeout("5");

 my $req = new HTTP::Request( GET =&gt; "http://www.geobytes.com/IpLocator.htm?GetLocation&amp;template=php3.txt&amp;IpAddress=$ip");
 my $res = $ua-&gt;request($req);
 if (! $res-&gt;is_success) {
 die "can't get acccess to server \n";
 }
 my $content=$res-&gt;content;
 foreach my $str (split(/\n/,$content)){
 $lat = $1 if ($str =~ /meta name=.latitude. content=.(\d+\.\d+)./);
 $long = $1 if ($str =~ /meta name=.longitude. content=.(\d+\.\d+)./);
 }
 return($long,$lat);
}
my $map_key="";
my $zoom="10";
my $ip_addr=$ENV{REMOTE_ADDR};
my ($long,$lat)=GetCoordinates($ip_addr);
my ($head,$body)=GetCode($map_key,$lat,$long,$zoom);
my $html = GetHTMLCode($head,$body);
print "Content-type: text/html\n\n";
print $html;</pre>
<p>This script also available by this <a href="http://andriigrytsenko.net/files/location.txt">link</a>.<br />
Your google key should be defined as variable <strong>map_key</strong> in the code.</p>
<p>Function <strong>GetCode</strong> &#8211; return two values:</p>
<ol>
<li><em>$head</em> &#8211; this block should be put into the &lt;head&gt; section of your html code.</li>
<li><em>$body</em> &#8211; into the &lt;body&gt; section.</li>
</ol>
<p>Function <strong>GetCoordinates</strong> return <em>longitude</em> and <em>latitude </em>of got ip.</p>
<p>Function  <strong>GetHTMLCode </strong>was used<strong> </strong>to generate example html code.</p>
<p>You also can implement these functions into your page as module. Download <a href="http://andriigrytsenko.net/files/google_map.pm">google_map.pm</a> and save it in your perl modules directory or do it as describe in this  <a href="http://andriigrytsenko.net/2009/11/use-perl-module-without-root-access/">post</a>. After, you can easily call this functions from your code as show below:</p>
<pre>#!/usr/bin/perl

use lib "path/to/directory/where/you/save/google_map.pm";
require google_map;

my $map_key="your_map_key_was_described_below";
my $zoom="10";
my $ip_addr=$ENV{REMOTE_ADDR};
my ($long,$lat)=google_map::GetCoordinates($ip_addr);
my ($head,$body)=google_map::GetCode($map_key,$lat,$long,$zoom);
my $html = google_map::GetHTMLCode($head,$body);
print "Content-type: text/html\n\n";
print $html;</pre>
<p>To see how it work check this <a href="http://andriigrytsenko.net/google_map.cgi">link</a> out.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/01/google-maps-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>D-link dwa-110 on Debian Box</title>
		<link>http://andriigrytsenko.net/2009/12/d-link-dwa-110-on-debian-box/</link>
		<comments>http://andriigrytsenko.net/2009/12/d-link-dwa-110-on-debian-box/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 12:23:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=524</guid>
		<description><![CDATA[Here some manual how to set up wireless usb stick(D-link dwa-110) on Debian Linux box step-by-step.

First you need to get Windows drivers from your drivers CD(you can find this stuff in your modem&#8217;s box). Also you need to install ndiswrapper.
Put directory with drivers to /root/Drivers/ and install ndiswrapper:
apt-get install ndiswrapper-common ndiswrapper-utils-1.9 rt73-common
Make ndiswrapper work with [...]]]></description>
			<content:encoded><![CDATA[<p>Here some manual how to set up wireless usb stick(D-link dwa-110) on Debian Linux box step-by-step.</p>
<p><span id="more-524"></span></p>
<p>First you need to get Windows drivers from your drivers CD(you can find this stuff in your modem&#8217;s box). Also you need to install <em>ndiswrapper</em>.</p>
<p>Put directory with drivers to /root/Drivers/ and install ndiswrapper:</p>
<pre>apt-get install ndiswrapper-common ndiswrapper-utils-1.9 rt73-common</pre>
<p>Make ndiswrapper work with your windows driver:</p>
<pre>ndiswrapper -i /root/Drivers/WinXP_2K_9X/Dr71WU.inf</pre>
<p>in case of previous step was successfully done, generate new configuration for modprobe:</p>
<pre>ndiswrapper -m</pre>
<p>Try to determine what name has you wireless interface:</p>
<pre>ifconfig -a</pre>
<p>By default it&#8217;s <em>wlan0</em> , but in my case it&#8217;s <em>wlan1</em>. Let&#8217;s bring it up:</p>
<pre>ifconfig wlan1 up</pre>
<p>Add interface configuration to your <em>/etc/network/interfaces</em>. In case you have no dhcpd server inside the network set your settings statically :</p>
<pre>auto wlan1
allow-hotplug wlan1
iface wlan1 inet static
    address 192.168.0.3
    network 192.168.0.0
    gateway 192.168.0.1
    netmask 255.255.255.0
    wireless-essid Homeee
    wireless-mode Managed
    wireless-key DFFB9E2CC1</pre>
<p>Or if you have dynamic server inside:</p>
<pre>auto wlan1
iface wlan1 inet dhcp
    wireless-essid amber
    wireless-mode managed
    wireless-key 6170-706C-65
    wireless-rate 54M</pre>
<p>Restart your computer and enjoy. Or at least run :</p>
<pre>/etc/init.d/networking restart</pre>
<p>Also below some tips how to make manual configuration:</p>
<pre>ifconfig wlan1 192.168.0.1 netmask 255.255.255.0 up</pre>
<p>- bring network up with defined ip and net mask.</p>
<pre>iwconfig wlan1 essid "name of network"</pre>
<p>- to set network name</p>
<pre>iwconfig wlan1 mode "new_mode"</pre>
<p>- set mode there is 7 modes are present. See <em>man iwconfig</em> to get more details.</p>
<pre>iwconfig wlan1 key "key string"</pre>
<p>- to set key up</p>
<p>or</p>
<pre>iwconfig wlan1 key "s:key_string"</pre>
<p>- to WEP ascii key.</p>
<pre>iwconfig wlan1 rate 54M</pre>
<p>- to set up spesific transfer date speed</p>
<pre>iwlist wlan1 scan</pre>
<p>- to get all available networks and its parameters.</p>
<p>UPDATE:<br />
You can create little script which will be able restart ot start you wifi connection.</p>
<pre>cat &gt; /bin/wifi-restart </pre>
<pre>#!/bin/bash

ifconfig wlan1 down
sleep 5
iwconfig wlan1 essid amber
iwconfig wlan1 key s:apple
iwconfig wlan1 rate 54M
ifconfig wlan1 up
dhclient3 wlan1</pre>
<p>Now set executable  bit on it:</p>
<pre>chmod +x /bin/wifi-restart</pre>
<p>To start or restart wifi, run it: </p>
<pre>wifi-restart</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/12/d-link-dwa-110-on-debian-box/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl debug</title>
		<link>http://andriigrytsenko.net/2009/12/perl-debug/</link>
		<comments>http://andriigrytsenko.net/2009/12/perl-debug/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 12:13:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=535</guid>
		<description><![CDATA[One of the perl debug way.

Perl module  PadWalker is require. Install it over cpan util:
cpan -i PadWalker 
Let&#8217;s create simple script:
$cat ./hello.pl
#!/usr/bin/perl
sub say_hello {
my $what=shift;
print "Hello $what\n";
}

my $var1="var1";
my $var2="var2";
say_hello("you");
my $var3="var3";

And try to debug it:
$ perl -dF hello.pl
Loading DB routines from perl5db.pl version 1.31
Editor support available.Enter h or `h h' for help, or `man perldebug' [...]]]></description>
			<content:encoded><![CDATA[<p>One of the perl debug way.<br />
<span id="more-535"></span></p>
<h4>Perl module  <em>PadWalker</em> is require. Install it over <em>cpan</em> util:</h4>
<pre><code>cpan -i PadWalker </code></pre>
<h4>Let&#8217;s create simple script:</h4>
<pre><code>$cat ./hello.pl</code></pre>
<pre>#!/usr/bin/perl
sub say_hello {
my $what=shift;
print "Hello $what\n";
}

my $var1="var1";
my $var2="var2";
say_hello("you");
my $var3="var3";
</pre>
<h4>And try to debug it:</h4>
<pre><code>$ perl -dF hello.pl</code></pre>
<pre>Loading DB routines from perl5db.pl version 1.31
Editor support available.Enter h or `h h' for help, or `man perldebug' for more help.main::(hello.pl:8):     say_hello("you");
DB&lt;1&gt;
</pre>
<h4>type <strong>&#8220;h&#8221;</strong> to get help.  To list  a function use <strong>&#8220;l function_name&#8221;</strong>:<br />
</h4>
<pre> DB&lt;1&gt; l say_hello
3       sub say_hello {
4:              my $what=shift;
5:              print "Hello $what\n";
6       }</pre>
<h4>To make step without entry to function use <strong>&#8220;n&#8221;</strong>. To  go through function <strong>&#8220;s&#8221;</strong></h4>
<pre> DB&lt;2&gt; s
main::say_hello(hello.pl:4):            my $what=shift;
</pre>
<h4>To return from subroutine use <strong>&#8220;r&#8221;</strong>.</h4>
<h4> use <strong>&#8220;y&#8221;</strong> to print all variables and their values or use <strong>&#8220;y variable&#8221;</strong> to print specific.</h4>
<pre> DB&lt;1&gt; y
$var1 = 'var1'
$var2 = 'var2'</pre>
<h4>and</h4>
<pre>DB&lt;1&gt; y var1
$var1 = 'var1'
</pre>
<h4> Options <strong>&#8220;M&#8221;</strong> print all used modules and path to them:</h4>
<pre> DB&lt;2&gt; M
'AutoLoader.pm' =&gt; '5.67 from /usr/local/lib/perl5/5.8.9/AutoLoader.pm'
'Carp.pm' =&gt; '1.10 from /usr/local/lib/perl5/5.8.9/Carp.pm'
...</pre>
<h4> <strong>&#8220;R&#8221;</strong> &#8211; restart the scripts.<br />
</h4>
<h4> <strong>&#8220;V&#8221;</strong> &#8211; list variables<br />
</h4>
<h4> <strong>&#8220;S&#8221;</strong> &#8211; list subroutine<br />
</h4>
<h4> <strong>&#8220;q&#8221;</strong> &#8211; for exit </h4>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/12/perl-debug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wireless connection issue</title>
		<link>http://andriigrytsenko.net/2009/12/wireless-connection-issue/</link>
		<comments>http://andriigrytsenko.net/2009/12/wireless-connection-issue/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 11:10:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[wifi]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=529</guid>
		<description><![CDATA[Recently I have faced with the next problem-&#62; my wireless connection time-to-time became unavailable.

I was starting investigation and figure out that my problem was the same as this. There is also workaround solution was found. First, let me describe my hardware and symptom data.
I have usb wireless adapter  D-link  DWA-110.
#lsusb
....
Bus 002 Device 004: [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have faced with the next problem-&gt; my wireless connection time-to-time became unavailable.</p>
<p><span id="more-529"></span></p>
<p>I was starting investigation and figure out that my problem was the same as <a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/200500">this</a>. There is also workaround solution was found. First, let me describe my hardware and symptom data.</p>
<p>I have usb wireless adapter  D-link  DWA-110.</p>
<pre>#lsusb
....
Bus 002 Device 004: ID 07d1:3c07 D-Link System Wireless G DWA-110 Adapter </pre>
<p>Linux kernel:</p>
<pre># uname -r
2.6.30-1-686</pre>
<p>Sometimes I observed that my network going to hung. In my logs I observer such messages:</p>
<pre>Dec 22 21:45:36 agrytsenko kernel: [52190.300066] wlan1: no probe response from AP 00:26:5a:95:8b:cc - disassociating
Dec 22 21:46:56 agrytsenko kernel: [52269.860040] wlan1: direct probe to AP 00:26:5a:95:8b:cc try 1
Dec 22 21:46:56 agrytsenko kernel: [52270.060080] wlan1: direct probe to AP 00:26:5a:95:8b:cc try 2</pre>
<p>I have written little script which restart my network:</p>
<pre>#!/bin/bash
ifconfig wlan1 down
sleep 5
iwconfig wlan1 essid amber
iwconfig wlan1 key s:apple
iwconfig wlan1 rate 54M
ifconfig wlan1 up
dhclient3 wlan1
</pre>
<p>But this way is not good idea at all. So after googling I find next solution(it&#8217;s also not complete solution, but quite better then my previous). This solution involve kernel sources. Therefore you should download it. After downloading you need to compile and install new kernel. Here is good <a href="http://andriigrytsenko.net/2009/07/linux-kernel-from-sources-for-debian/">how to</a> for Debian users.</p>
<p>Before you begin to compile new kernel and after unpacking the sources you should change one line in your sources. First, try to find it:</p>
<pre>cd /usr/src/linux
# grep -r IEEE80211_MONITORING_INTERVAL *
debian/linux-image-2.6.30/lib/modules/2.6.30/build/net/mac80211/mlme.c:#define IEEE80211_MONITORING_INTERVAL (2 * HZ)
.......</pre>
<p>So our line is found. Go there and set value to 100. Ex.:<br />
from</p>
<pre>#define IEEE80211_MONITORING_INTERVAL (2 * HZ)</pre>
<p>to</p>
<pre>#define IEEE80211_MONITORING_INTERVAL (100 * HZ)</pre>
<p>After new kernel installed and loaded my problem disappeared.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/12/wireless-connection-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use perl module without root access</title>
		<link>http://andriigrytsenko.net/2009/11/use-perl-module-without-root-access/</link>
		<comments>http://andriigrytsenko.net/2009/11/use-perl-module-without-root-access/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 14:46:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=512</guid>
		<description><![CDATA[Take this simple instruction if you need to include module (which is not installed at your system) to your perl script.


Get module and install it to directory where you have write permission (For example: /home/user1/libs).
Go to your script and add new library path to your INC array:
use lib '/home/user1/libs';
to check that it was successfully put [...]]]></description>
			<content:encoded><![CDATA[<p>Take this simple instruction if you need to include module (which is not installed at your system) to your perl script.<br />
<span id="more-512"></span></p>
<ol>
<li>Get module and install it to directory where you have write permission (For example: <em>/home/user1/libs</em>).</li>
<li>Go to your script and add new library path to your INC array:</li>
<pre>use lib '/home/user1/libs';</pre>
<p>to check that it was successfully put in INC array, print it out</p>
<pre>print "\@INC = @INC\n";</pre>
<li>Include it to your script with &#8220;<em>require</em>&#8221; or &#8220;<em>use</em>&#8221; directives.</li>
<pre>require "test.pm";</pre>
<p>or</p>
<pre>use "test.pm";</pre>
</ol>
<p style="text-align: center;"><strong>SAMPLE</strong></p>
<p>Here is some little sample how it&#8217;s work. <strong></strong></p>
<p><strong>Our module:</strong></p>
<pre>user1@agrytsenko:~/tmp2$ cat lib/test.pm
package test;

use strict;

sub say {
my $word=shift;
my $str="Hello my $word world\n";
return($str);
}
1;
__END__</pre>
<p><strong>Our script:</strong></p>
<pre>user1@agrytsenko:~/tmp2$ cat bin/test.pl
#!/usr/bin/perl

use lib '/home/user1/tmp2/lib';
require 'test.pm';

my $string=test::say("good");
print $string, "\n";</pre>
<p><strong>Our running result:</strong></p>
<pre>sheva@agrytsenko:~/tmp2/bin$ ./test.pl
Hello my good world
</pre>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/11/use-perl-module-without-root-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wireless internet AP based on RedHat linux</title>
		<link>http://andriigrytsenko.net/2009/11/wireless-internet-ap-based-on-linux/</link>
		<comments>http://andriigrytsenko.net/2009/11/wireless-internet-ap-based-on-linux/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 02:36:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=498</guid>
		<description><![CDATA[I will try to describe how to make own home wireless access point based on RedHat linux machine.

This post include 2 part. In first one I&#8217;ll describe step which should be taken on linux machine and in second one step for windows client.
Linux(server side)
We use this host to share internet connection between users over wireless [...]]]></description>
			<content:encoded><![CDATA[<p>I will try to describe how to make own home wireless access point based on RedHat linux machine.</p>
<p><span id="more-498"></span></p>
<p>This post include 2 part. In first one I&#8217;ll describe step which should be taken on linux machine and in second one step for windows client.</p>
<h2 style="text-align: center;">Linux(server side)</h2>
<p>We use this host to share internet connection between users over wireless network, so the machine has to have at least two connection:</p>
<ol>
<li>Internet ( regular ethernet connection)</li>
<li>Wireless connection( provided by wi-fi card)</li>
</ol>
<p>I will skip how to setup your Internet connection, therefore make sure its work properly.<br />
If you mounted your wi-fi card to pci slot use <em>lspci</em> to check it out:</p>
<pre>[root@localhost ~]# lspci  | grep -i wireless
02:01.0 Ethernet controller: Atheros Communications Inc. Atheros AR5001X+ Wireless Network Adapter (rev 01)</pre>
<p>For this card kernel module <em>ath5k</em> should be loaded into the kernel. Check it:</p>
<pre>lsmod | grep ath5k</pre>
<p>Use <em>modprobe</em> unless module is not loaded.</p>
<pre>modprobe ath5k</pre>
<p>If you done it without any problem I will able to set up the wi-fi card. Here is network configuration file for interface wlan0 with some comments:</p>
<pre>[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-wlan0# Atheros Communications Inc. Atheros AR5001X+ Wireless Network Adapter
DEVICE=wlan0
ONBOOT=yes
IPADDR=192.168.0.1
NETMASK=255.255.255.0
HWADDR=00:17:9a:b7:d6:01
TYPE=Wireless
MODE=Ad-Hoc  # set this mode if want to make this card as access point
ESSID=homeee # the name of this connection which will be displayed for users
KEY=dffb9e2cc2 # secret key for connection</pre>
<p>To generate connection key run:</p>
<pre>dd if=/dev/random bs=1 count=5| xxd -ps</pre>
<p>Now restart the network service:</p>
<pre>service network restart</pre>
<p>and verify:</p>
<pre>iwconfig wlan0</pre>
<p>and</p>
<pre>ifconfig wlan0</pre>
<p>So 50% of linux part is done. Tune your kernel to make it forward ip traffic:</p>
<pre>vi /etc/sysctl.conf</pre>
<p>and set
<pre>net.ipv4.ip_forward</pre>
<p> to 1:<br />
<em>net.ipv4.ip_forward = <strong>1</strong></em><br />
Make changes affected:</p>
<pre>sysctl -p /etc/sysctl.conf</pre>
<p>Verify:</p>
<pre>sysctl -a | grep all.forwarding | grep ipv4</pre>
<p>And last but very important step. Its firewall and nat settings:<br />
!!! Be careful because this command flush all your rules in OUTPUT chain</p>
<pre>iptables -F OUTPUT</pre>
<p>turn masquerading on:</p>
<pre> iptables -t nat -I POSTROUTING -s 192.168.0.2/32 -o eth0 -j MASQUERADE</pre>
<p>where <em>eth0</em> your interface for share.<br />
save it all:</p>
<pre>service iptables save</pre>
<p>The linux router is ready on all 100%.</p>
<h2 style="text-align: center;">Windows(client side)</h2>
<p>I use windows Vista for this, but this steps can be used to Windows XP as well. Go to:<br />
<em>Start-&gt;Control Panel-&gt;Network and Internet-&gt; Network and Sharing center -&gt;  manage network connections </em><br />
Click right button on your <em>Wireless Network Connection</em> and choose <em>Properties</em>.<br />
Make double click on <em>Internet Protocol Version 4</em>.<br />
When new window is appear fill it up:<br />
<em>Ip address: 192.168.0.2<br />
Subnet mask: 255.255.255.0<br />
Default gateway: 192.168.0.1</em><br />
Also you need to specify you DNS server. Put the ip address of DNS server provided by your ISP.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/11/wireless-internet-ap-based-on-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Local Cent-OS repository step-by-step</title>
		<link>http://andriigrytsenko.net/2009/10/local-cent-os-repository-step-by-step/</link>
		<comments>http://andriigrytsenko.net/2009/10/local-cent-os-repository-step-by-step/#comments</comments>
		<pubDate>Wed, 21 Oct 2009 14:28:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=486</guid>
		<description><![CDATA[There is some instruction how to make centralized repository for CentOS software.

As repository I have used my own Debian machine. Firstly, I have installed createrepo. This program generate some metadata which is necessary for RPM repository. Run
apt-get install createrepo
to install it from yum repository.  Create two directories in the DocumentRoot environment. In my case [...]]]></description>
			<content:encoded><![CDATA[<p>There is some instruction how to make centralized repository for CentOS software.</p>
<p><span id="more-486"></span></p>
<p>As repository I have used my own Debian machine. Firstly, I have installed <em>createrepo</em>. This program generate some metadata which is necessary for RPM repository. Run</p>
<pre>apt-get install createrepo</pre>
<p>to install it from yum repository.  Create two directories in the <em>DocumentRoot</em> environment. In my case its <em>/var/www/html/</em> :</p>
<pre>mkdir -pv /var/www/html/centos/5/{os,updates}/i386</pre>
<p>Now  copy packages from your CD/DVD installation disk to <em>./centos/5/os/i386</em> directory.<br />
As I have an image file I should mount it first:</p>
<pre>mount -o loop ~/CentOS-5.3-i386-bin-DVD.iso /mnt/dvd/</pre>
<p>Only after you may start to copy:</p>
<pre>cp /mnt/dvd/CentOS/* /var/www/html/centos/5/os/i386/</pre>
<p>Its can take a while.<br />
Also you need to get updates for your repository:</p>
<pre>rsync -avrt rsync://mirror.web-ster.com/centos/5/updates/i386  --exclude=debug/</pre>
<p>Take a look about more suitable rsync mirror for you <a href="http://www.centos.org/modules/tinycontent/index.php?id=30">here</a>. It&#8217;s good idea to keep this directory updated all the time via cron. </p>
<p>Generate metadata for both directories.</p>
<pre>cd /var/www/html/centos/5/os/i386/ &#038;&#038; createrepo . </pre>
<pre>cd /var/www/html/centos/5/updates/i386/ &#038;&#038; createrepo . </pre>
<p>For server side is done. Please pay attention that your web-server should be run to keep the repository available. </p>
<h3>Client side:</h3>
<p>Backup your *.repo files in your <em>/etc/yum.repos.d</em>: </p>
<pre>for i in *.repo; do mv $i $i.bak; done</pre>
<p>And new one <em>CentOS-Base.repo</em> config with next context:</p>
<pre>[base]
name=CentOS-$releasever - Base
baseurl=http://{IP address of your server}/centos/$releasever/os/$basearch/
gpgcheck=0
[update]
name=CentOS-$releasever - Updates
baseurl=http://{IP address of your server}/centos/$releasever/updates/$basearch/
gpgcheck=0</pre>
<p>This steps should be repeated for each client machine.  </p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/10/local-cent-os-repository-step-by-step/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux hard reboot and System Request Key</title>
		<link>http://andriigrytsenko.net/2009/10/linux-hard-reboot-and-system-request-key/</link>
		<comments>http://andriigrytsenko.net/2009/10/linux-hard-reboot-and-system-request-key/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 12:14:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=482</guid>
		<description><![CDATA[Sometimes we need to reboot remote machine. But all we get an error in console.

The most popular reason of this disk problems. To perform force rebooting turn on SRK feature in the kernel via proc VFS:
# sysctl -w kernel.sysrq=1 
and send command to kernel to reboot the system without unmounting file systems:
echo b > /proc/sysrq-trigger
Here [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes we need to reboot remote machine. But all we get an error in console.<br />
<span id="more-482"></span><br />
The most popular reason of this disk problems. To perform force rebooting turn on SRK feature in the kernel via proc VFS:</p>
<pre># sysctl -w kernel.sysrq=1 </pre>
<p>and send command to kernel to reboot the system without unmounting file systems:</p>
<pre>echo b > /proc/sysrq-trigger</pre>
<p>Here is some additional SRK features:<br />
• <strong>r</strong> — Disables raw mode for the keyboard and sets it to XLATE (a limited keyboard mode which<br />
  does not recognize modifiers such as Alt, Ctrl, or Shift for all keys).<br />
• <strong>k</strong> — Kills all processes active in a virtual console. Also called Secure Access Key (SAK), it is<br />
  often used to verify that the login prompt is spawned from init and not a trojan copy designed to<br />
  capture usernames and passwords.<br />
• <strong>b</strong> — Reboots the kernel without first unmounting file systems or syncing disks attached to the<br />
  system.<br />
• <strong>c</strong> — Crashes the system without first unmounting file systems or syncing disks attached to the<br />
  system.<br />
• <strong>o</strong> — Shuts off the system.<br />
• <strong>s</strong> — Attempts to sync disks attached to the system.<br />
• <strong>u</strong> — Attempts to unmount and remount all file systems as read-only.<br />
• <strong>p</strong> — Outputs all flags and registers to the console.<br />
• <strong>t</strong> — Outputs a list of processes to the console.<br />
• <strong>m</strong> — Outputs memory statistics to the console.<br />
• <strong>0-9</strong> — Sets the log level for the console.<br />
• <strong>i</strong> — Kills all processes except init using SIGKILL.<br />
• <strong>l</strong> — Kills all processes using SIGKILL (including init). The system is unusable after issuing this SR Key pre.<br />
• <strong>h</strong> — Displays help text.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/10/linux-hard-reboot-and-system-request-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
