Software Woes

Rants, tips and tricks



Saturday, July 11, 2009



CodeIgniter woes

I started using CodeIgniter some time ago, and here are the problems I'm having:

- nuking of $_GET does sound reasonable, but it makes problems when you want to integrate with some other service like RPX for example. I "fixed" this by writing a small php script outside of framework to take the GET request and turn it into URL acceptable by CI

- The settings for Apache rewrite rule you'll find first is soo wrong. I mean, it is correct, but it creates a hell of a lot of problems when you want to do something outside of the box. Basically, you have to "allow" anything outside of CI (even images, javascript and css) to be accessible. The alternative snippet I found is much better (it basically says: if it's a real file, fetch it, if not, route through CI):

RewriteEngine on
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]


...more coming as I build my first serious CI-powered application.



Friday, July 03, 2009



Staying up to date with slackware-current

Here's a nice script I use (I did not write it myself):

#!/bin/bash
#
# Check slackware-current
#

# Where to download from
# should script it so that the different sources can be listed and
# selected from the command line
SOURCE="rsync://slackware.mirrors.tds.net/slackware/slackware64-current"
# Change as necessary
OPTIONS="-avzP --delete --delete-after"

EXCLUDE="--exclude=pasture --exclude=kdei \
--exclude=zipslack"

DEST="/home/milanb/arhiva/install/distre/slackware/current64/download/"

case "$1" in

"-c" )
echo "Checking..."
/usr/bin/rsync $OPTIONS $EXCLUDE --dry-run $SOURCE $DEST
;;

"-d" )
echo "Downloading..."
/usr/bin/rsync $OPTIONS $EXCLUDE $SOURCE $DEST
;;

* )
echo "Usage: `basename $0` {-c|-d}"
echo -e "\t-c : Check for updates"
echo -e "\t-d : Download updates"
exit
;;

esac

######################################################



Thursday, June 25, 2009



Setting up wireless on Slackware

Setting up wireless on a public unrestricted hotspot has always been mystery to me. I didn't really need it often, and when I did I did not have Internet access to google a way to do it. Well, today I was with a friend so I used his laptop to find out how to set it up.

It's really simple once you do it. What's important:

1. start up wireless card
2. scan for networks
3. pick a network and connect to it

Starting up a wireless card might require that you load a kernel module manually. Some modules have option to turn on the LED indicator:

# /sbin/modprobe iwl3945

Once you start it up, open the Wireless section in KDE Control Center, and click "Activate" button.

Now, run /sbin/ifconfig to see all the interfaces. You should see something like wlan0. Then, use this interface name to scan the area for networks:

iwlist wlan0 scan

As a result, you'll get each wireless network and it's ESSID. Let's assume ESSID is MyHotSpot and connect to it:

iwconfig wlan0 essid MyHotSpot

In case you need to supply username and password, look into wpa_supplicant and it's config file (I haven't tried this). And start wpa_supplicant:

wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf &

Once you're done, use dhcpcd to get an IP address, default route, and DNS server information:

dhcpcd wlan0

...and that's it.

Update: there is a very nice and simple to use tool that automates all this and wraps it into a GUI. It's called wicd, and you can find it in /extra in the newest Slackware, or fetch it from the project page and compile it yourself (no special dependencies needed):

http://wicd.sourceforge.net



Thursday, June 18, 2009



X11 forwarding on Slackware

Many times I wanted X11 forwarding to be as simple as ssh -x host; run program.

Until today, that never worked for me. But today I was in the mood to try to make it work somehow.

It turns out, it can be made to work that way, and it's super easy. The thing is that X11 forwarding via SSH is disabled by default (which is very reasonable setting, BTW). To enable it, just open /etc/ssh/sshd_config on the remote host (where you want to run the applications) and make sure it contains the following lines (uncommented):

AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

Once you save the file, restart sshd to pick up the new config:

/etc/rc.d/rc.sshd restart

And you're done. On your local host, just run ssh with -X or -Y parameter. The difference is this:

-X Enables X11 forwarding.
-Y Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.

Gosh, think about all the times I've done things in much more frustrating way (via VNC for example).



Friday, June 12, 2009



Firefox 3 printing on Linux

Printing from Firefox has been greatly improved in version 3, but there are still some minor quicks. The most annoying one is that the print dialog does not remember settings.

And some of the settings have annoying defaults. Firefox developers should really know that people are not just using web browser to browse the Internet and occasionally print some web pages. Developers all over the world are developing web applications for both Internet and intranet and printing is very important.


The main problem I have, is that Header and Footer settings are not remembered. So, for each page I want to print, I have to go to that tab, set all six fields to "--blank--" and then print. Each time I want to print anything.

I mean, how hard could it be to save those settings somewhere in ~/.mozilla/firefox and add a nice "Reset" button for people how change the settings so much they get lost.



Wednesday, April 08, 2009



Local search engines to try

Sphinder: PHP + MySQL backend for storage
http://www.sphider.eu/

Xapian: Perl + any database
http://xapian.org/

Apache Solr: Java/Tomcat for web interface, web layer on Lucene
http://lucene.apache.org/solr/
http://www.ibm.com/developerworks/library/os-php-apachesolr/index.html



Saturday, February 21, 2009



Setting up Git offline work via USB memory stick

I have a home laptop and an office desktop computer. When I leave office, everything is shut down, so there is no way to access the git repository online. Since I didn't want to drag my notebook to work everyday, I got the idea to have a git repository on my USB memory stick.

One of the requirements was that it is a bare repository so it does not take too much space. I had a lot of trouble figuring out this one, and finally I got the right way when I understood how git is meant to be used.

I created a big file on my FAT filesystem, and formatted in in ext2 with something like:

dd if=/dev/null of=/mnt/stick/repos.ext2 bs=1024 count=500000
mkfs.ext2 /mnt/stick/repos.ext2

Then I mounted it and created a bare copy of my repos:

mount -o loop /mnt/stick/repos /mnt/repos
cd /mnt/repos
git clone /home/milanb/repos repos

When I go home, I repeat the mount on my laptop and pull the changes into local development repository:

mount -o loop /mnt/stick/repos /mnt/repos
cd ~/devel/repos
git pull /mnt/repos/repos master

After I commit the changes, just push it back to stick:

git push /mnt/repos/repos

Now, the tricky part, when I go back to the office, I was (stupid) to try to push the changes from the stick to local repository. There are ways to make this work, but quite awkward and error prone. Git is not meant to be used that way. The rules are simple, if you do everything right:

- you should never need to pull/fetch into bare repos
- you should never need to push into non-bare repos

So, what I really needed to do is just to reverse the logic and pull changes from stick into my local repository:

git pull /mnt/repos/repos master

It merges (unless there's confict) and everything is fine. To prevent from typing all those long paths, you can define aliases (remotes) via git-remote command:

git remote add /mnt/repos/repos stick

And later just do these to pull and push:

git pull stick master
git push stick

All that time I used SVN and CVS just got that centralized way of thinking into me. Finally I'm free ;)

All I can say is: Git simply rocks!