Archive

Archive for the ‘Tips 'n Tricks’ Category

OpenLaszlo and symlinks

Written on January 20th 2010, 15:01 by sYnie

I develop OpenLaszlo apps on different OL versions. But as I usually need the code to be the same, I use symlinks (symbolic links / soft links) to my apps within the tomcat server of OpenLaszlo. This leads to problems with non-lzx-files. Tomcat just doesn’t recognize other files.
There are some Sites out there, that point out a solution to this. But every time I install a new version of OpenLaszlo, I search for a minimum of 30 minutes until I found it. I think I’ve already bookmarked it, but it’s lost in thousands of OL bookmarks.
However, I thought to blog this solution. So I won’t need to search anymore in the future ;-)

So if you’re facing problems with symlinks using OpenLaszlo, just edit this file:
/path/to/openlaszlo/Server/tomcat-5.0.24/conf/LPS/localhost/lps.xml

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="../../lps-x.x.x" path="/lps-x.x.x">
...
</Context>

And apply the following changes:

<?xml version='1.0' encoding='utf-8'?>
<Context docBase="../../lps-x.x.x" path="/lps-x.x.x" allowLinking="true">
...
</Context>

That’s it.
Thanks again to the OL Forums (source)

Irssi Plugin: auto reply

Written on September 15th 2009, 16:09 by sYnie

Some days ago I wrote a small irssi plugin, which automatically replies to specific words or phrases. It’s really basic, but I thought to post it anyway, as I couldn’t find any.

It’s based on the 8-ball plugin – so thanks to Patrik Jansson.

That’s the code:

use strict;

use vars qw($VERSION %IRSSI);
use Irssi qw(command_bind signal_add);

$VERSION = '1.00';
%IRSSI = (
    authors     => 'synie',
    name        => 'auto reply',
    description => 'auto reply',
    license     => 'GPL',
);

sub own_question {
    my ($server, $msg, $target) = @_;
    question($server, $msg, "", $target);
}

sub public_question {
    my ($server, $msg, $nick, $address, $target) = @_;
    question($server, $msg, $nick, $target);
}

sub question($server, $msg, $nick, $target) {
    my ($server, $msg, $nick, $target) = @_;
    $_ = $msg;
    my $answer = "";

    // Edit this:
    if (/^how are you?/i) {
        $answer = "I'm fine, thanks.";
    } elsif (/ping/i) {
        $answer = "pong";
    } elsif (/^I hate you/i) {
        if ($nick ne "fishbot" and $nick ne "snailbot")
        {
            $server->command('kick '.$target.' '.$nick.' bye!');
            return 0;
        }
    }

    if ($answer)
    {
        $server->command('msg '.$target.' '.($nick ? $nick.': ' : '').$answer);
    }
    return 0;
}

signal_add("message public", "public_question");
signal_add("message own_public", "own_question");

Just c&p it into a file (e.g. called autoreply) located at ~/.irssi/scripts or ~/.irssi/scripts/autorun and load it via `/script load autoreply`. Make sure you edited the phrases you want to answer to automatically first – but I think this script is self-explanatory.

EeePC & OS X: W-Lan (Hackintosh)

Written on April 27th 2009, 09:04 by sYnie

I installed OS X on my little EeePC 900a. After using some different Images and also trying to Install my original copy of Leopard, I ended up with iATKOS 5i. Most of the Hardware worked out of the box. Even hotplug, what didn’t work before.
There are some things that didn’t work:

  • Display resolution
  • Ethernet
  • WiFi
  • Sound

I got it managed to make them work, by now. Well, almost ;-)
As soon as I’m finished with this OS X on EeePC, I’ll post all the things I had to do to get them running. But before this, I want to share my experience with the built in Atheros WiFi card.
Vendor ID: [168c:001c]
Subsystem: [1a3b:1026]

Different OS’ display this device with different names. But as far as I know, it’s an AR5007EG. There are various tutorials out there to get this card working. Well, at least in some way.
Have a look at this discussion:
http://www.insanelymac.com/forum/index.php?showtopic=138351
18 Pages – all about this card and different types of it. There are some ways, that really work. But you’ll need Kismac to make this device see wireless networks after every reboot. It works like this:

  • Before you shutdown your EeePC, you must turn the Airport off.
  • After booting, turn it on.
  • Run Kismac and scan for wirelless networks with Airport Extreme Passive Drivers.
  • Now your Airport will notice all the new networks.

And if you get Kernel Panics:

  • Remove Extensions.mkext* before every shutdown.

And believe me – it’s not nice to do this every boot/shutdown. I wrote scripts, that do exactly this. I still need Kismac for making the Airport notice the networks, but I’m on it. Kismac replaces the Airport drivers during scan to use it in monitor mode. I’m still finding out how everything works, and so on. But have a look into the Resources directory within Kismac. It provides all the kext files. Also there is a driver called “viha” which uses the WLanDriver.kext. Viha is an Airport driver and W-Lan utility, which also provides a shell based network stumbler. I think this is the way to go … But I’m still experimenting.

If you’re annoyed by turning on/off the Airport, removing the Extensions.kext and firing up Kismac, then use these scripts. They work for me:

1. Preparing
Open System Preferences and go to Network. Write down your Location at the top. Mine is called AON, but usually yours is named “Automatic”. Create a new one and call it “AOFF”. Within “AOFF” you’ll have to remove Airport from the list on the right side. Add another (unused) service, if you can’t remove Airport. Switch back to “Automatic”, apply and close it.
AOFF will be used to switch off the Airport. You can’t do this via shell, but you can switch those network profiles via shell. If you switch to a profile, that has no Airport service, it’ll be turned off. You can try this by switching between these networks, applying them, and looking for what happens with your Airport symbol on the top of your screen.

2. Login-/LogoutHooks:
Create two files, somewhere (Mine are located in /Library) which will be used for Airport and Extensions. I’ve called them wlankickstart and wlankickstop ;-)

wlankickstart looks like this:

#!/bin/bash
scselect Automatic

Replace “Automatic” with your default network Location, or leave it, if you’re not sure.

wlankickstop looks like this:

#!/bin/bash
scselect AOFF
rm /System/Library/Extensions.mkext*

If you don’t have random kernel panics during boot time, then remove the last line, because it causes an annoying system message during shutdown.

Make those files executable (chmod a+x filename) and store them somewhere.
Now we’re gonna make them executed while login/logout:
sudo defaults write com.apple.loginwindow LoginHook “/path/to/wlankickstart”
sudo defaults write com.apple.loginwindow LogoutHook “/path/to/wlankickstop”

Now Extensions.mkext will be beleted and Airport will be turned on/off during boot/shutdown.

3. Kismac
If you don’t have it, download and install it. Open Script Editor from /Applications/AppleScript and write a new script:

tell application “KisMAC”
activate
startScan
delay 5
stopScan
quit
end tell

Try it. It’ll run Kismac, scan for 5 secs and turn it off. Make sure, Kismac uses the Airport Extreme Passive Driver. Compile this script and save it as an Applications (without “Startup Screen”). Now Open up System Preferences, go to Accounts, select your user, go to Login Items and add the previous compiled application.

You’re done. Reboot and enjoy. Now you’ll only have to select your W-Lan Network after a reboot instead of doing this process by your own.
It works? Give me a comment ;-)

Sockets/IRC using Flash/Openlaszlo without server side proxy

Written on January 22nd 2009, 02:01 by sYnie

some weeks ago I’ve been playing around with the possibility of flash of using sockets. I tried to connect to various services, but unless there is any crossdomain.xml on the server it is just impossible. Well, there is a way to use a server side proxy to create such connections, as it’s allowed to open sockets from the flash client to the same domain, but this isn’t always the best solution. For example if you want to connect to an IRC server, you will be limited to a few connections. Besides that, not everybody has the possibility to run a proxy server for such services.
After some hours of experiments, I got a solution. It’s not very nice and it’s questionable whether this could ever be used in productive environments – but it’s pretty nice to play with ;-)

In this example I used OpenLaszlo to do the flash part – but it can be easily reproduced with actionscript. Furthermore I decided to explain it with an IRC network and as for that (to keep it simple) I used a library to do the protocol stuff. But you can extend this to any service, that uses network connections.
It’s pretty simple:

  • First we create a Java Applet, which does all the socket stuff
  • This Applet will be signed to be able to open connections outside of its sandbox
  • Then the Flash Client will be designed
  • And after all that, a small set of Javascript Functions are needed to make them communicate

This is the example. It’s quick’n'dirty, but it works. You have to accept the Certificate. If you don’t the network connections won’t work.

Keep on reading for examples …
Read more…

Hibernate on EeePC 900A

Written on October 18th 2008, 00:10 by sYnie

Before I start to talk about hibernate, I want to mention a very strange behavior of the 900A. The internal SSD is named sda OR sdb, depending on whether there is a card in the card reader at the system startup. So if there is a card plugged in, the internal SSD will be flagged as sdb. If there is no card, it will be sda. WTF? I really have no idea what this is caused by. But I think this causes a problem with hibernation.

At first, I didn’t even realize, that the internal SSD changes its device name. I use Ubuntu eee and during the installation, the fstab and menu.lst were filled with UUID’s instead of the device names – So there is no problem with booting and mounting them.

Anyway, I tried to get hibernation aka suspend to disk to work using this tutorial:
http://www.ubuntu-eee.com/wiki/index.php5?title=Fix:_hibernate

Everything seemed to work. s2disk caused the notebook to hibernate (as long as i didn’t insert/remove a card), but the wakeup ended in a ordinary boot, without resuming the written image. After hours, I got it work. Just do exactly the same, as it’s described in the tutorial, except for one step.
When you’re asked to change the /etc/uswsusp.conf, don’t use any device names in it. Do it, as Ubuntu did it during the installation: Use UUID’s.
To get to know the UUID of the internal SSD, we have to find out, how it’s labeled:

mount

This will return something like this:

/dev/sdb1 on / type ext3 (rw,noatime,errors=remount-ro)
proc on /pro....

Now, we know our SSD is /dev/sdXX (sdb1 in my case), because it’s mounted to /. In the next step, we’ll get to know the UUID:

sudo vol_id /dev/sdXX |grep UUID=

This will return the UUID. In my case:

ID_FS_UUID=16fa07c8-8416-5f10-85c6-a8410fad510

And now we’ll use this UUID instead of the device name in /etc/uswsusp.conf:

# /etc/uswsusp.conf(8) -- Configuration file for s2disk/s2both
resume device = /dev/disk/by-uuid/16fa07c8-8416-5f10-85c6-a8410fad510
compress = y
early writeout = y
image size = 0
RSA key file = /etc/uswsusp.key
shutdown method = platform
resume offset = XXX

If you’ve found this site after you already tried the tutorial mentioned above, then just do the changes and run this at the end:

sudo update-initramfs -k `uname -r` -u

Otherwise hibernate will create the image but it won’t be booted.

And now, for me, it works *woohoo*
I hope this will help ;-)

Linux on USB

Written on November 30th 2006, 13:11 by sYnie

Once this was a very detailed post about which distribution to use on a USB stick and how to get that managed. As I just translated it for devl.net, I keep it short.

I have used Slax in order to install it on a USB stick. Just plug it into any (new) computer, and it’ll boot from it (as long as the mainboard is able to do this and as long as it’s activated in the BIOS). Every Linux user will know the benefits of a full OS on a USB stick.

This is a short how-to about installing Slax on a USB stick:

  1. Plug in the stick and type `dmesg |tail` in order to get to know how the stick is named. Usually it’s sda or the partition sda1, which I’m also using furtheron. (Use your own device name instead of sda)
  2. Create partition table: `cfdisk /dev/sda`. Format the whole stick as Fat32 (Type 0B). Also give it a “Bootable Flag”. After writing, it should look something like this: sda1 Boot Primary W95 FAT32 [ ] 1022.92
  3. Format: `mkdosfs -F 16 /dev/sda1` creates a Fat16 partition, which can be also read by windows.
  4. Create a directory called “usb” (or whatever) in /mnt and mount /dev/sda to it: `mkdir /mnt/usb && mount /dev/sda1 /mnt/usb`
  5. Download Slax. It’s not important which version you use. I downloaded Slax Popcorn Edition.
  6. Open a shell and go to the directory where you have downloaded slax to  (`cd /home/you/whereever/downloads`) and create a directory called ‘usbslax’ by typing `mkdir usbslax`.
  7. Mount the iso to the just created directory: `mount -o loop slax-*.iso usbslax`.
  8. `cp -r slax/* /mnt/usb` will copy all the data to the USB stick.
  9. Go to the stick (`cd /mnt/usb`)
  10. copy isolinux.cfg to syslinux.cfg, as we want to use syslinux: `mv isolinux.cfg syslinux.cfg`
  11. Copy the kernel and initrd to the root directory of the stick, as it won’t be a live CD: `cp boot/vmlinuz boot/initrd.gz ./`
  12. Open syslinux.cfg in a any text edit tool (e.g. `vim syslinux.cfg`) change every  ‘/boot/vmlinuz’ to ‘vmlinuz’ and ‘/boot/initrd.gz’ to ‘initrd.gz’.
  13. Unmount: `cd .. && umount /dev/sda1`
  14. Install Lilo to the stick: `lilo -M /dev/sda` [grub didn't work for me]
  15. Make it bootable: `syslinux -s /dev/sda1`
  16. Reboot and enjoy: `sudo reboot`