My first prosody module!

July 24th, 2010

I have recently written two XMPP related things. The first is a prosody module called mod_post_msg which accepts messages in a HTTP POST, using HTTP authentication. It was inspired by this ejabberd module by skeltoac, but it takes full stanzas, whereas mine just takes a plain text message body.

The second is a sendxmpp like Bash script based on cURL which works with the module. It is supposed to work like sendxmpp, but doesn’t support all of it’s options. You can get sendxmpp-curl here.

This allows you to post simple XMPP messages from CLI (like sendxmpp), with less round trips than a full XMPP session would require (At least I hope so).

“sudo gedit” must die!

July 23rd, 2010

Why is it that so many Ubuntu guides tell you to do sudo gedit /path/to/somefile when there is a sudoedit command? An editor, like Gedit, doesn’t need to run as root, ever.

This is so much better and safer:

SUDO_EDITOR=gedit sudo -e /path/to/somefile

This will …

  1. Copy the file to /tmp/
  2. Invoke gedit as your user
  3. Update the original file if you changed the temporary file

It would of course be really useful if gksudo had this built in already, and could be used in a nice way by nautilus-gksu.

PAE

June 16th, 2010

PAE på en burk med 192M RAM är nog rätt ovärt.

Stuff

May 5th, 2010

Random stuff jag borde blagat om men inte orkat, i till synes omvänd kronologisk ordning.

Rösträkning med Bash

January 18th, 2010

Piratpartiets primärval är avslutat. 1300 röster registrerades av partiets ca 48 tusen medlemmar, dvs ca 2.7%.

Grattis till Norrbotten som hade överlägset högst valdeltagande

Här är ett stycke Bash-magi som ger dig en votes.txt med antal röster och på vem, sorterad fallande efter antal röster. Paketen curl, grep, sed och coreutils behövs om de inte är installerade, iaf i Ubuntu och förmodligen de flesta Debian-baserade distributionerna.

Notera att detta endast visar hur många röster som kandidaterna fått.

#!/bin/bash

curl -s "http://data.piratpartiet.se/Data/DisplayInternalPollVotes.aspx?PollId=2" |
    sed -r 's/\s$|^\s*//g' | # tar bort blanktecken
    grep -E '^[A-Z0-9]{12}\b' | # endast röster
    sed -r 's/^[A-Z0-9]{12}\s*//' | # ta bort röst-id
    sed -r 's/\s+/\n/g' | # dela upp i en kandidat per rad
    grep -E '^[0-9]' | # tar bort tomma rader
    sort | uniq -c | sort -nr > votes.txt # räkna och sortera

# Detta hämtar och byter ut medlems-nr mot namn.
curl -s "http://www.piratpartiet.se/primarvalskandidater" |
    grep -Eo '<span[^>]*SpanCandidateName[^>]*>[^<]*' | cut -d\> -f2 |
    sed -r 's/^(.*)\s+\(#([0-9]+)\)$/sed -i "s,\\b\2\\$,\1," votes.txt;/' | sh

De faktiska ska som jag förstått det viktas efter hur högt man placerat kandidater, eventuell kvotering samt hur fördelningen mellan distrikt ser ut. Så, 16:00 idag presenteras de färdiga listorna. Frågan är; vad gör vi nu?

Liferea vs tiny screen

December 14th, 2009

I use Liferea for RSS-feeds. I also have a craptop with a tiny screen (1024×576px).

Liferea - Normal view

Liferea - Normal view

I think there is room for optimizing this, more spatial perhaps?

Liferea - wide view

Liferea - wide view

This could use some miller-columnification.

Optimally, I would like to have this:

  • Single pane
  • Oldest unread post first
  • Headlines which expand when clicked

Damn you Ctrl+W

November 4th, 2009

Don’t know how many times I accidentally pressed Ctrl+W when I wanted to delete a word in some non-terminal app, instead closing it and losing all the text I’ve written. Now I found out you can do this:

gconftool --set /desktop/gnome/interface/gtk_key_theme \
  --type string Emacs

Then Ctrl+W does what it should!

Trac + Evolution?

October 26th, 2009

Imagine having your assigned tasks from Trac in Evolutions ToDo-list and beeing able to . Like this but with Trac as backend.

Idea for Application menu

September 14th, 2009

Navigating menus with a touchpad isn’t my idea of awesome. But imagine something like Global menu combined with Gnome Do or dmenu.

  1. Press magic keybinding, like Super + Menu
  2. You get some selection thing with all menu items
  3. You type in what you want to do, filtering as you type
  4. ???
  5. PROFIT!

Some IRCin’

<zash_> a do-like application-menu-thing would be handy
<kholerabbi> Which is a pleasure
<kholerabbi> what do you mean?
<zash_> kholerabbi: something that lets you navigate app-menus by keyboard
<zash_> since not everything has proper keybindings
<kholerabbi> zash_: that's actually kind of interesting...
<zash_> and navigating gigantic menu trees with touchpad is a pain
<kholerabbi> you can already use the keyboard (arrow kets etc.)
<zash_> kholerabbi: yes, but arrows and alt+underlined char only does so
        much
<kholerabbi> agreed
<zash_> label-matching ala gnome-do would be faster
<kholerabbi> so you'd press a shortcut (super+menu) then type 'about' or
             'new'...
<zash_> precisly
<kholerabbi> You should mock it up. If it's really a good idea it will
             catch on. Consider large menus like the gimp and inkscape in
             your designs
<kholerabbi> ok
<kholerabbi> I need sleep, but think on it and maybe talk to the global
             menu people
 * zash_ needs moar coffee!

Some bash testing

grep MenuItem some_window.glade -A 3 | \
grep -E '<property[^>]+name="label"' | \
grep -Eo '>[^<>]+' | sed 's/^>//g' | \
sed s/_// | dmenu -b -i

Om Skype

August 23rd, 2009

Piratpartiets mål är att förändra lagstiftningen på en global skala för att gynna framväxten av informationssamhället, präglat av mångfald och öppenhet.

Nice!

Principprogram version 3.3

Den offentliga sektorn ska arkivera och göra dokument tillgängliga i öppna format. Det ska gå att kommunicera med myndigheter utan att vara bunden till en viss leverantör av programvara. Användningen av öppen källkod i den offentliga sektorn, inklusive skolor, ska stimuleras.

Öppna format och öppen källkod ska uppmuntras.

Men, varför;

Webbstrategi- och utvecklingsgruppen som syftar till att förena alla som vill vara med och bidra med utveckling och strategier runt all möjlig mjukvara som rör sig inom PP. Vill du hjälpa till så är det enklast att lägga till antingen Daniel .. eller Mikael .. på skype så bjuder vi in er i chatgruppen.

Meh.

Skype uses a proprietary Internet telephony (VoIP) network, called the Skype protocol. The protocol has not been made publicly available by Skype and official applications using the protocol are closed-source.

Skype has taken extreme measures to obfuscate their traffic and functioning of their program.

This makes me a saaad panda.

Men, vad kan man göra åt det?