Posts

Using konqueror to navigate through man pages

Image
If you are a KDE user you can use Konqueror for MAN pages navigation, just add "man:" prefix before interested command. For instance enter  man:ssh-copy-id to Konqueror's address bar and enjoy nicely rendered MAN page entry and all browser's features like search results highlighting, hyperlinks to the related MAN entries (yay!). I wrote simple bash script that utilizes man binary functionality but displays MAN page in Konqueror. Put this code to the /usr/local/bin/kman file: #!/bin/sh #Su'ed root console support if [ $UID = 0 ]; then     su - $LOGNAME -c "env DISPLAY=:0 konqueror man:$@" 2>/dev/null & else      konqueror man:$@ 2>/dev/null & fi For autocompletion support add this to the /etc/bash.bashrc.local file: #konqueror man complete ${_def} -F _man_ ${_file} kman Run  kman   ssh-copy-id and have a fun. Tested only in Opensuse.

PHP associative arrays or hashes: in-depth look

Image
Before you start reading i warn you: this article won't help you in every day PHP developing in any way. But if you are naturally interested, like me, in how things work you're welcome to spend your precious time on reading and understanding this article. Still here? Great. Lets try to stay sane after all this low level mumbo-jumbo and start. PHP array or in other terms hash is a combination of the data storing methods called "vector" and "linked list". Vector is a nice aligned structure in the memory, simplest and fastest way to store and access linked pieces of the data because accessing vector offsets functionality is baked right into the modern CPU's. I'm referring to the assembler's offset calculating functionality like MOV [BASE+OFFSET], DATA. Think of the vectors as a numerically indexed PHP array. If you need to access array member you just pass offset to it like this: $array = array("a", "b", "c"); ...

PHP extension development with Linux and Eclipse CDT. Building your environment

Image
It is hard to start with PHP extensions development in Unix environment. It is not enough to be familiar with C programming language also you need at least basic knowledge in packaging, GNU build tools and of course PHP internals. If your desktop is beautified by Linux - there is a good news for you: you don't need to setup and build everything by yourself! You just need to know how to use already configured package for your distribution. Don't even ask what to do if your desktop is crippled by Windows - play minesweeper. This post is intended to give you a good place to start. Everything is shown on example of the Opensuse 11.4, but other distributions are suitable as well. First of all we need to obtain PHP source code. Raw PHP source from php.net can be used but you will need to take care of PHP configuring and all external symbols. Delete stripped php binaries first: # zypper rm php5 next # zypper si php5 this command will download source R...

Curl multi hangs, connection timeout. Asynchronous DNS support

The problem. Curl is a nice library that takes advantage of asynchronous loading. Many developers use CURL in high level languages to load multiple web pages simultaneously. I use curl_multi functions very heavily in my PHP scripts too. But recently i discovered very awkward problem: CURL loads web pages asynchronously but DNS resolution is single threaded! This means that if one of the CURL handles hangs on DNS resolving other handles will hang too and wait for their turn in resolving queue! And if you set curl option "connection timeout" and DNS resolving takes more than timeout you set - all requests will fail! The solution. Starting from version 7.20.0 CURL can handle async DNS resolution using libcares. But cares support isn't enabled by default (at least in Opensuse packages and FreeBSD ports). To take advantage of async DNS resolution rebuild libcurl with --enable-ares option. If your copy of the libcurl is already compiled with async DNS support PHP will repor...

Opensuse linux and D-link DWA-525 (RaLink 3060 based)

Recently i've upgraded wifi network card to D-link DWA-525 based on RaLink 3060 chipset which is wifi-N capable. But my Opensuse 11.4 wasn't able to detect it. There is two ways to solve this problem - first is to download chipset driver from ralink's site ( http://www.ralinktech.com/en/04_support/support.php?sn=501 ), setup, compile it and use. But it seems to be in a beta state because after installation it spams your logs with debug messages (can be disabled by removing -DDBG from config.mk but anyway i don't trust drivers with debug mode turned on by default). Second and proper way in my opinion is to install ralink drivers from repositories. Search for the "ralink-firmware" on  http://software.opensuse.org/search?q=ralink-firmware  and "one click install" will do all the job for you.

Ip addresses and subnets calculation

Many people do not clearly understand how IPv4 CIDR notation actually works. Let me explain it for you in binary arithmetic. Let's take a very common class C ip address: 192.168.1.1 Its binary representation is:  11000000.10101000.00000001.00000001 IP address actually consists of 32 bits. Those dots are splitting 32 bit value in 4 chunks: 192 -  11000000 168 - 10101000 1 - 00000001 1 - 00000001 Easy, huh? Now let's take the subnet 192.168.1.0/24. So what does /24 actually mean? It means that 24 bits  used to identify network and all other bits (8 in this case) are used to identify IP address. Binary representation of 192.168.1.0 is 11000000.10101000.00000001 .00000000 As I've mentioned above 24 bits are used to identify network (they are marked in bold). 8 bits are left to represent IP address and maximum value is 11111111 - 255 in decimal. Last IP address is reserved as broadcast. So network consists of 254 hosts. More confusing example: 211.240.192...