Smokes your problems, coughs fresh air.

Category: Technology (Page 37 of 47)

Change in law regarding cell phone contracts

Cell phone providers in the Netherlands always try to screw you as hard as they can. The way it was, they were able to automatically extend your contract for another year. The way they screwed you here, is because when you sign up for a new contract, you often get discount. I for instance, was able to get a service worth € 17,50 per month for € 12,50 (240 minutes), the entire year. But, when the contract period would end, my contract would be extended automatically and I would pay € 17,50 per month for a year. You had to remember to call KPN before the contract would end and manually extend the contract to receive another discount.

The change in law is this: they now extend the contract one day, every day after the contract period is over. So, you can easily switch provider after you’ve seen that you suddenly pay € 17,50 instead of € 12,50, or sign up for another subscription at the same provider, or whatever you want to do.

Unfortunately, I couldn’t get the same amount of minutes (240) for € 12,50 again, but this time for € 15,00. For € 12,50 I would have gotten 130 minutes, which is too low. But luckily the guy gave me my first month for free, because I was long-time customer (or so he said), so that saves € 15,00, in other words, 6 months the difference between the 130 and 240 minutes. Yet in other words, I pay € 13.75 per month. I think this is an OK enough deal.

I could go through the hassle to see what kind of discount I get if I switch providers, because providers often give new customers more discount than existing ones, but I also hate that kind of administrative work and the risk of problems when I switch, so I’m happy now.

Setting paper size in Mozilla products

Mozilla products, firefox and thunderbird, seem to have the strange behaviour of overriding the paper size set by the operating system; it scales the page to letter and then prints it to A4.

To fix that, you need to go into about config and set the print_paper_data parameter to 9.

APC CS-500 causes USB disruption

I’m having a EM interference problem with the APC CS-500 UPS on two different locations. Those two locations are near each other and there seems to be something wrong the power grid in that area. Both UPS’s momentarily switch over to battery several times a day. Some of these times, the apcupsd daemon sends a message saying that the communication with the UPS has been restored (and therefore it had been lost at some point).

Here is the syslog of one of those computers with everything but the power failure and EMI notices filtered out:

Aug  7 06:59:10 bitler apcupsd[22622]: Power failure.
Aug  7 06:59:18 bitler apcupsd[22622]: Power failure.
Aug  7 06:59:31 bitler apcupsd[22622]: Power failure.
Aug  7 06:59:35 bitler apcupsd[22622]: Power failure.
Aug  7 13:59:19 bitler apcupsd[22622]: Power failure.
Aug  7 13:59:38 bitler apcupsd[22622]: Power failure.
Aug  7 18:59:11 bitler apcupsd[22622]: Power failure.
Aug  7 18:59:25 bitler apcupsd[22622]: Power failure.
Aug  7 18:59:28 bitler apcupsd[22622]: Power failure.
Aug  7 21:29:12 bitler apcupsd[22622]: Power failure.
Aug  7 21:29:19 bitler apcupsd[22622]: Power failure.
Aug  7 21:29:23 bitler apcupsd[22622]: Power failure.
Aug  7 21:29:51 bitler apcupsd[22622]: Power failure.
Aug  7 21:30:05 bitler apcupsd[22622]: Power failure.
Aug  7 21:30:09 bitler apcupsd[22622]: Power failure.
Aug  7 21:30:12 bitler apcupsd[22622]: Power failure.
Aug  7 21:30:14 bitler apcupsd[22622]: Power failure.
Aug  7 21:35:21 bitler apcupsd[22622]: Power failure.
Aug  7 21:35:29 bitler apcupsd[22622]: Power failure.
Aug  7 21:35:32 bitler apcupsd[22622]: Power failure.
Aug  7 21:35:38 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:11 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:22 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:31 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:35 bitler apcupsd[22622]: Power failure.
Aug  7 22:39:36 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  7 22:59:10 bitler apcupsd[22622]: Power failure.
Aug  7 22:59:25 bitler apcupsd[22622]: Power failure.
Aug  7 22:59:28 bitler apcupsd[22622]: Power failure.
Aug  7 22:59:32 bitler apcupsd[22622]: Power failure.
Aug  7 22:59:37 bitler apcupsd[22622]: Power failure.
Aug  7 23:59:32 bitler apcupsd[22622]: Power failure.
Aug  8 05:51:10 bitler apcupsd[22622]: Power failure.
Aug  8 05:51:21 bitler apcupsd[22622]: Power failure.
Aug  8 05:51:31 bitler apcupsd[22622]: Power failure.
Aug  8 05:51:35 bitler apcupsd[22622]: Power failure.
Aug  8 06:59:24 bitler apcupsd[22622]: Power failure.
Aug  8 06:59:32 bitler apcupsd[22622]: Power failure.
Aug  8 06:59:36 bitler apcupsd[22622]: Power failure.
Aug  8 11:29:11 bitler apcupsd[22622]: Power failure.
Aug  8 11:29:28 bitler apcupsd[22622]: Power failure.
Aug  8 13:59:17 bitler apcupsd[22622]: Power failure.
Aug  8 13:59:22 bitler apcupsd[22622]: Power failure.
Aug  8 13:59:23 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 14:00:19 bitler apcupsd[22622]: Power failure.
Aug  8 18:59:37 bitler apcupsd[22622]: Power failure.
Aug  8 21:27:11 bitler apcupsd[22622]: Power failure.
Aug  8 21:27:16 bitler apcupsd[22622]: Power failure.
Aug  8 21:27:17 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:27:25 bitler apcupsd[22622]: Power failure.
Aug  8 21:27:39 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:11 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:13 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:29:22 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:25 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:27 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:29:37 bitler apcupsd[22622]: Power failure.
Aug  8 21:29:38 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:30:20 bitler apcupsd[22622]: Power failure.
Aug  8 21:30:22 bitler apcupsd[22622]: Power failure.
Aug  8 21:30:24 bitler apcupsd[22622]: Power failure.
Aug  8 21:30:28 bitler apcupsd[22622]: Power failure.
Aug  8 21:30:29 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  8 21:30:37 bitler apcupsd[22622]: Power failure.
Aug  8 22:39:11 bitler apcupsd[22622]: Power failure.
Aug  8 22:39:25 bitler apcupsd[22622]: Power failure.
Aug  8 22:39:28 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:11 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:18 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:26 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:28 bitler apcupsd[22622]: Power failure.
Aug  8 22:59:40 bitler apcupsd[22622]: Power failure.
Aug  8 23:59:11 bitler apcupsd[22622]: Power failure.
Aug  8 23:59:22 bitler apcupsd[22622]: Power failure.
Aug  8 23:59:24 bitler apcupsd[22622]: Power failure.
Aug  9 05:54:10 bitler apcupsd[22622]: Power failure.
Aug  9 05:54:21 bitler apcupsd[22622]: Power failure.
Aug  9 05:54:22 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  9 05:54:39 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:10 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:17 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:19 bitler kernel: hub 5-0:1.0: port 1 disabled by hub (EMI?), re-enabling...
Aug  9 06:59:27 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:28 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:32 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:36 bitler apcupsd[22622]: Power failure.
Aug  9 06:59:39 bitler apcupsd[22622]: Power failure.
Aug  9 12:59:22 bitler apcupsd[22622]: Power failure.
Aug  9 12:59:23 bitler apcupsd[22622]: Power failure.
Aug  9 12:59:27 bitler apcupsd[22622]: Power failure.
Aug  9 13:59:24 bitler apcupsd[22622]: Power failure.
Aug  9 13:59:28 bitler apcupsd[22622]: Power failure.
Aug  9 13:59:34 bitler apcupsd[22622]: Power failure.

As you can see, all the EMI notices correspond exactly with the UPS switching over to battery; all the EMI notices are 1 or 2 seconds after the power failure notice, without exception. And no, I didn’t just show the EMI notices that suit me; these are all of them.

APC suggested it might have something to do with the 3rd party software (because they don’t support Linux themselves), but that’s ridiculous of course. The software doesn’t have the ability to command the UPS to switch over to battery, so the order of events has to be that the UPS switches and that the USB hub is disrupted by that. This is exactly the order of events the logs show.

I think this problem is common in the CS type of UPS’s and perhaps in other models as well and that just because of the frequent switching it shows more often. I still have to find out whether it’s the proximity of the UPS to the computer or if the EMI is traveling over the USB cable. Putting the UPS about a meter below the machine didn’t help, anyway.

One very big problem with this situation is that I can’t reliably connect a USB hard disk to the system for backups. The filesystem and the data on it will not take kindly to connection interrupts.

Tracking MediaWiki in a Subversion vendor branch

Vendor branches are the proper™ way of merging upstream changes in your web application installations. In Subversion, managing vendor branches isn’t so easy as it is in Git. Still, vendor branches make it much easier to track upstream.

From before I first deployed the Omega Research Wiki, I already used svn to track changes to my MediaWiki installation. However, for upgrading from one upstream release to the next, I used diff and patch. This isn’t the most reliable of methods as is exemplified by doing a diff comparing a fresh MediaWiki download with the actual files in my repo (which are supposed to belong to the same version).

What’s basically a shortcoming of svn is that I can’t just say:

svn merge http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_0/phase3/ \
http://svn.wikimedia.org/svnroot/mediawiki/tags/REL1_15_1/phase3/ .

This would have been incredibly helpful, because now I’m keeping a vendor branch not because of local modifications to upstream, but just to be able to merge cleanly.

In Subversion, maintaining a vendor branch by hand is quite some work, because you need to do a checkout first before you can import each version. (My working copy is normally a checkout of /trunk, not of /vendor/mediawiki.) Luckily, Subversion is distributed with a handy Perl script, svn_load_dirs.pl, which can do most of the heavy lifting.

Still, I didn’t feel like having to do to many manual steps, such as typing in the painfully long URLs for merging, so I decided to wrap the whole process into a nice little Bash script:

cat upgrade-mediawiki.sh
#!/bin/bash
 
svn_repo_url=file:///var/svn/wiki.omega-research.org/vendor/mediawiki/
 
merge=1 [ $# -gt 2 ] # Process extra options
    "$1"
        --no-merge)
            merge=0
            ;;
   
   
 [ $# -ne 2 ]; then
    "Usage: $0 [--no-merge] version version"
    1
 
last_version=$1
new_version=$2
 
tmp_dir=`mktemp -d` $tmp_dir
 version $*;
    "Downloading and extracting MediaWiki version $version..."
 
    [ -z `svn ls $svn_repo_url|grep $version` ];
        branch= $version |sed -e 's/\.[0-9]\+$//'`
        download_file="mediawiki-$version.tar.gz"
        download_url="http://download.wikimedia.org/mediawiki/$branch/$download_file"
 
        wget $download_url || { "Downloading $download_file failed">&2; 1; }
        tar --extract --ungzip --transform 's/^mediawiki-//' --file $download_file
        svn_load_dirs.pl $svn_repo_url -t $version current $version
   
 - [ $merge == '1' ];
    svn merge "$svn_repo_url$last_version" "$svn_repo_url$new_version" .
 0

The script only downloads and imports each specified version if that version doesn’t already exist in /vendor/mediawiki/. Also, because it has a --no-merge option, you can download all the old versions of MediaWiki that you’ve ever used, so that you can go back and compare old versions of your installation with the factory version. Of course, this is only useful if you were already tracking your installation in svn at the time, and even then not really. 😉

Anyway, the important thing is that you can use the script to download the version you’re running now and the version you want to upgrade too. I wanted to make a big jump, from 1.11.1 to 1.15.0 (I had put of the upgrade for a long time, because I first wanted to learn more about vendor branches):

Of course, as always, you need to check if the patch went well. My own results were a vivid demonstration of the unreliability of my previous method:

svn st|grep '^C'
C      languages/messages/MessagesKrj.php
C      languages/messages/MessagesWar.php
C      languages/messages/MessagesSe.php
C      languages/messages/MessagesFrc.php

Luckily, these were all files I was sure I hadn’t modified:

i `svn st|grep '^C'|sed -e 's/^C //'`; mv $i.merge-right.r32 $i; svn resolved $i;
Resolved conflicted state of 'languages/messages/MessagesKrj.php'
Resolved conflicted state of 'languages/messages/MessagesWar.php'
Resolved conflicted state of 'languages/messages/MessagesSe.php'
Resolved conflicted state of 'languages/messages/MessagesFrc.php'

Apparently, a previous upgrade hadn’t turned my MediaWiki installation exactly into 1.11.1.

TheSixtyOne, a better social music site

If you liked Last.fm, you’ll love TheSixtyOne. Discovering music is turned into a reputation game. Much like Last.fm, you can explore similar artists, genres, tags, moods and users. But, by doing so and hearting songs, you can earn reputation points and extra hearts. As your points increase, you level up, which gives you more authority. There’s an endless amount of quests to earn points faster and to make you discover all the facets of the application.

Just try it out. It’s fun and—unlike Last.fm these days–it’s free. You can choose when and how to help these starving artists! 😀

Setting up Rsync daemon

What can you do when you want to backup your entire machine to a remote location but only have non-root shell access? You use rsyncd.

On the server you need to configure a module in /etc/rsyncd.conf:

[module_name]
uid=0
gid=0
path=/path
transfer logging=no
read only=no

Then you need to rsync using a destination like user@host::module_name/

To make it work, you first need to set up a tunnel using SSH, because the rsync port (873) is not open in the firewall, most likely. So, you do this:

ssh -N -L 873:localhost:873 user@host

I wrote a script to automate this all. Perhaps I will follow-up on this post sometime and post it.

Editing Wikipedia/MediaWiki articles with VIM

Wikipedia has a number of tips for people who like to edit Wikipedia articles with VIM.

Of course, it all starts with opening an article in VIM. How I do this depends on my mood: I can open it by firing GVIM using Vimperator or I can mount the wiki with WikipediaFS. I prefer the latter.

Spell-checking

One tool that’s very convenient for editing large sections of prose is VIM’s built-in spell-checker. Example:

set textwidth=0
set spell spelllang=nl

Wrapping, matching and folding

There’s some more useful stuff that I copied to “ftplugin/mediawiki.vim” in “$HOME/.vim/“:

" Wikipedia articles often only have line-breaks at the end of each paragraph,
" a situation Vim by default doesn't handle as other text editors.
setlocal wrap linebreak
setlocal textwidth=0

" No auto-wrap at all
setlocal formatoptions-=tc formatoptions+=l
if v:version >= 602 | setlocal formatoptions-=a | endif

" Make navigation more amenable to the long wrapping lines.
noremap  k gk
noremap  j gj
noremap   gk
noremap   gj
noremap  0 g0
noremap  ^ g^
noremap  $ g$
noremap D dg$
noremap C cg$
noremap A g$a
inoremap   gk
inoremap   gj

" utf-8 should be set if not already done globally
setlocal fileencoding=utf-8
setlocal matchpairs+=<:>

" Treat lists, indented text and tables as comment lines and continue with the
" same formatting in the next line (i.e. insert the comment leader) when hitting
"  or using "o".
setlocal comments=n:#,n:*,n:\:,s:{\|,m:\|,ex:\|}
setlocal formatoptions+=roq

" match HTML tags (taken directly from $VIM/ftplugin/html.vim)
if exists("loaded_matchit")
    let b:match_ignorecase=0
    let b:match_skip = 's:Comment'
    let b:match_words = '<:>,' .
    \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
    \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
    \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
endif

" Other useful mappings
" Insert a matching = automatically while starting a new header.
inoremap   = =(getline('.')==''\|\|getline('.')=~'^=\+$')?"==\Left>":"="

" Enable folding based on ==sections==
:set foldexpr=getline(v:lnum)=~'^\\(=\\+\\)[^=]\\+\\1\\(\\s*\\)\\=\\s*$'?\">\".(len(matchstr(getline(v:lnum),'^=\\+'))-1):\"=\"
:set fdm=expr

To have this automatically executed when opening files ending in .mw:

"autocmd BufRead,BufNewFile *.mw setfiletype mediawiki" > $HOME/.vim/ftdetect/mediawiki.vim

Syntax highlighting

Additionally, if you want to have syntax highlighting for MediaWiki articles, you can save this syntax file to $HOME/.vim/syntax/mediawiki.vim.

winepath

I have all these little scripts in my $HOME/bin directory to ease the execution of Windows programs. For instance, I don’t like to type the full path to Excel Viewer every time when I need to view an Excel sheet in Linux:

#!/bin/sh
"/home/bigsmoke/.wine/drive_c/Program Files/Microsoft Office/OFFICE11/XLVIEW.EXE" "$*"

This works pretty well, except when trying to view a document that’s not in the current directory:

xlview "/tmp/Some Excel sheet sent to me by someone.xls"

To make that work, you need to use a handy utility that comes with Wine, winepath. With winepath, I can modify the script to work (the example is for wordview):

#!/bin/bash
path=`winepath --windows "$*"`
"/home/bigsmoke/.wine/drive_c/Program Files/Microsoft Office/OFFICE11/WORDVIEW.EXE" "$path"

This, together with Linux’s binfmt_misc makes executing Windows programs on Linux a breeze.

Native execution of Windows programs on Linux

When I installed this laptop last year, I was pleasantly surprised by the performance of vanilla Wine (and Gentoo’s default Wine configuration). At that time, my only memory of Wine was that getting anything useful to work took work and that your best bet to get anything working was to install CrossOver Office. Things change and in the meantime Wine has even come to version 1.0.

I want to write down what I had to do to be able to execute Windows executables as if they are Linux native. This can be done thanks to Linux’ support for misc. binaries.

First, you have to enable CONFIG_BINFMT_MISC in your kernel configuration. If it was configured as a module, run /sbin/modprobe binfmt_misc.

Then you have to register the appropriate binary formats:

':windows:M::MZ::/usr/bin/wine:' > /proc/sys/fs/binfmt_misc/register

That’s it. Of course, the .exe files need to have their executable bit set:

chmod u+x program.exe

Done.

Xerox 7232 communication failure

The Xerox 7232 color laser printer we’re leasing at work has a very vague problem causing communication failures all the time. When you boot it, it works fine. After a while it starts getting slow. And if you wait even longer, it doesn’t work at all anymore. This happens within a few minutes.

The problem seems to occur faster when you print from certain machines on the network. However, given enough time, none of them work anymore. The machines are a mix of Windows 2000 and Windows XP machines and there is no correlation between the OS and the degree of communication difficultly.

The problem has nothing to do with this existing Microsoft knowledge base item, as I will show with network traffic logs.

When the printer just starts and works fine, the communication is as follows: the client sends a [SYN] packet, the printer responds with [SYN, ACK] to which the client sends another [ACK]. At this point, the connection is established and the client starts sending data packages. After two packages the printer sends an [ACK] back. As the Microsoft’s knowledge base article states, TCP sends [ACK]’s every two packets, so this is normal. This repeats a number of times until the printer starts printing.

The following TCP/IP analysis shows it clearly (192.168.1.205 is the client, 192.168.1.103 is the printer. Don’t pay attention to the source port network name):

wireshark-screenshot-success2

When the communication problems begin, the difference is that after the first two data packets are sent, the printer doesn’t send the expected [ACK] packet. The client keeps sending retransmissions until the printer eventually sends a [RST] (reset):

wireshark-screenshot-failed2

The printer obviously doesn’t adhere to TCP/IP standards. Xerox technical support likes to claim that the problem is in our network, because the fault doesn’t (easily) happen when they connect a laptop to the printer with a crosslink cable, but this evidence clearly shows the printer is at fault. Even if it starts doing this because of some invalid data packet our client PC’s might send, it’s still faulty behavior. To such an extent even, that if any server or client machine would have this problem, it would be classified as a security risk, because it is then susceptible to denial of service attacks.

« Older posts Newer posts »

© 2024 BigSmoke

Theme by Anders NorenUp ↑