Showing posts with label browser. Show all posts
Showing posts with label browser. Show all posts

1 Nov 2009

Firefox profile on NFS

Firefox has switched to sqlite3 for some files in the profile. this happened some time ago (AFAIKT it was with FF3). This is quiet bad if you happen to mount your home via NFS, because sqlite is not designed to work well over NFS (locking problems). The sqlite FAQ(5) has this to say about sqlite databases on NFS:

SQLite uses reader/writer locks to control access to the database. (Under Win95/98/ME which lacks support for reader/writer locks, a probabilistic simulation is used instead.) But use caution: this locking mechanism might not work correctly if the database file is kept on an NFS filesystem. ...
And indeed, it does not work for me (debian/ubuntu). The problem is, that bookmarks, history and other things will be corrupt after a network outage or a firefox crash (hello flash, i am looking at you!). I have not found a solution yet, therefore before starting firefow, I will backup all sqlite Databases:

First, you need to install the sqlite3 utility:
$ sudo apt-get install -y sqlite3


in your .profile, declare the following variables:
export PROFILE="myprofilename"
export FIREFOX_PROFILE_DIR=~/.mozilla/firefox
#export FIREFOX_PROFILE_DIR=~/.mozilla/firefox-3.5


Then use the following script to launch firefox:
#!/bin/bash

if [[ -z "$PROFILE" ]]; then
export PROFILE="default"
fi

if [[ -z "$FIREFOX_PROFILE_DIR" ]]; then
export FIREFOX_PROFILE_DIR=~/.mozilla/firefox
fi

# install sqlite 3: sudo apt-get install -y sqlite3
find=$(which find);
sqlite3=$(which sqlite3);

msg="missing or not in \$PATH, aborting";
if [[ -z "$find" ]]; then echo "find $msg"; exit 1; fi
if [[ -z "$sqlite3" ]]; then echo "sqlite3 $msg"; exit 1; fi

for d in $($find $FIREFOX_PROFILE_DIR/ -maxdepth 1 -type d); do

profile=$(echo "$d" | sed -e 's|.*/[^\.]\+\.||')

# remove this conditional statement, if you want all FF profiles backed up.
# sqlite databases in use are locked.
if [[ "$profile" != "$PROFILE" ]]; then
continue;
fi

echo "$profile | $d";

for f in $(find "$d" -iname "*.sqlite"); do
f=$(echo "$f" | sed -e 's/\.sqlite$//; s|.*/||')
if [[ -f "$d/$f.bak.sql" ]]; then rm "$d/$f.bak.sql"; fi
$sqlite3 $d/$f.sqlite .dump > $d/$f.bak.sql
done

done

firefox-3.5 -P $PROFILE

exit 0;

17 Mar 2008

Ikariam, IkaTrader

i have written some greasemonkey scripts for ikariam.de. These help to get a better overview for trading: listing incoming ships, linsting all your ships (in-/outbound).

These scripts are written for firefox 2 utilizing the greasemonkey etxtension.

More about the features and downloads for IkaTrader.

4 Nov 2007

batch conversion from svg to png

I often need icons in different sizes as raster graphics. It seems to be easier to create/maintain these graphics as vector images and the convert them in all needed sizes as raster images.

Formats
I have decided to use svg as vector format. It can be conveniently and freely be edited with inkscape. The output format is svg because I need these images in web pages. png does offer transparent gradients (in contrast to gif, which only allows one indexed color to be transparent). Internet explorer does not handle png transparency by default, you must use a filter. Dean edwards' /IE7/ remove many quirks from ie6 and lower by using clever js and css tricks. alpha transparency for png can also be enabled with /IE7/.


Batch conversion
I have been using the ImageMagick command line utilites for scripted image manipulation with a lot of joy. Unfortunately ImageMagick is only capable of manipulating raster graphics. Fortunately, though, inkscape comes with a quiet hand command line interface to get this job done. inkscape can export svg images in various png sizes (and loads more).

Example

inkscape --without-gui --file=lib/icons/scalable/apps/calc.svg \
--export-png=calc.png --export-width=48 \
--export-height=48 && eog calc.png


This command will convert an svg image (lib/icons/scalable/apps/calc.svg) into a png image (calc.png) with a size of 48*48 pixels. Wehn the conversion comamnd (inkscape) succeeds, the result is dispalyed in gnomes image viewer ( eoc calc.png).

for converting a directory structure to different sizes of png sets, I have used the following script:
#!/usr/bin/env bash

# abort if we don't have a lib directory
if [[ ! -d lib/ ]]; then
echo "Must be run from the application's main directory."
exit 1;
fi

# config
TARGET=lib/stockitems
SIZES="12 16 24 32 48 72 96";
FILES=`find ./lib/icons/scalable -name "*.svg"`;

# purge target dir
if [[ -d "$TARGET" ]]; then
rm -R "$TARGET";
fi
mkdir "$TARGET";

# convert all files to the $SIZES dimensions
for size in $SIZES; do
echo $size;
for file in $FILES; do
target="$TARGET/${size}x$size/"`echo $file | sed -e \
's/^\.\/lib\/icons\/scalable\///; s/svg$/png/'`;
parent=`dirname $target`;
if [[ ! -d "$parent" ]]; then mkdir -p "$parent"; fi
inkscape --without-gui --file=$file --export-png=$target \
--export-width=$size --export-height=$size;
done
done

exit 0;

31 May 2007

Internet Explorer Screenshot service

Web developers are struggling every day to make that website or user interface compatible with as many browsers as possible.

There are standards (I hear you say). Yes, there are! W3C is a consortium which defines recommendations. However, these recommendations are sometimes vague and most often do not cover innovative/new ideas (standards are often defined after a new technology is already in use). Therefore, browser's rendering engine's output will vary and must be tested by developers.

On windows, it is not possible to install more than one Internet Explorer version, because newer versions tend to replace older versions (IIRC it was possible to install IE4 and IE5 on the same box). This is a problem for web developers (designers and programmers) because there is often a need to support more than one version (making sure the current project works in the most used environment as well as in future/older browsers).

Linux, wine and ies4linux come in handy in this situation. combined with Xvfb and some standard *nix tools (like ImageMagick and WindowMaker) make it possible to create a web service for capturing screenshots of sites in IE 5, 5.5, 6 and 7.

Currently I am working on a appliance (VMWare image) as well as a howto on how to do this.