/usr/portage

Corporate Blogging 0

Ich versuche das jetzt auch mal mit der kommerziellen Bloggerei. Und zwar im Schokokeks-Weblog. Sogar mit Hackagotchi, wie sich das gehört.

Filed under , , , , , & no comments & no trackbacks

»sleep« for special purposes 2

I have a problem which occurs every evening: often I started a video using realplayer before going to bed. Realplayer does not close itself at the end of the video, which is correct in general but in my case not the best practice. Realplayer is a proprietary tool and uses Open Sound System (OSS), which is a bit antiquated nowadays. Also OSS was blocking the sound device when playing sounds. The crap Enlightment Sound Daemon (ESD) was a result of that issue. Back to my topic. Often when I go to bed I want to watch a video, but always want my Banshee to wake me up in the morning. But Banshee cannot play any sound, if the device is blocked by realplayer. So I need to kill realplayer once the video is done or a bit later but before the next morning. So I do something like sleep 3600 ; kill <pid> which works pretty fine. If I’m drunken, which takes place naturally rarely, I have the problem that I do not remember how big the integer after my sleep must be. And, especially when I’m drunken, I hate it to have my video quitting before it is done or I felt asleep. So I need a sleep-replacement which is more convenient and usable when being drunken. In fact I need a sleep replacement which can handle strings like »2m«, »2h«, »60*60*2« etc. pp. Download it! And now I can go to bed.

Filed under , , , & two comments & no trackbacks

Release early, release often 0

I’ve written a replacement for the well-known locate on Unix-plattforms. It is designed to act in a client/server model (currently not implemented) and should do auto-updating via inotify (currently also not implemented, first of all I need to fix the Ruby-bindings for inotify) but it does indexing and searching and this works relatively well. Some speed improvements are needed but I’ve just spent something around two hours from the idea to the implementation. If you want to give it a try, just check out http://svn.usrportage.de/rblocate/trunk/ and create a SQLite3-database in the same directory where you script is.

$ sqlite3 files.db
SQLite version 3.3.6
Enter ".help" for instructions
sqlite> CREATE TABLE files (id INTEGER PRIMARY KEY AUTOINCREMENT, path VARCHAR(1024) UNIQUE);
sqlite> .quit

Now run ./search.rb --index <dir> and after that just ./search.rb --search <term>. Have fun!

Filed under , , & no comments & no trackbacks

Ein Wunder 0

gnu.org ist jetzt im Jahre 1999 angekommen.

Filed under , , & no comments & no trackbacks

Wer kennt ein Rechenzentrum? 6

Angenommen ich will perspektivisch auf zwei Jahre ca. fünf Server haben und erstmal mit drei Stück anfangen, die ruhig etwas besser sein dürfen, also genug Arbeitsspeicher haben dürfen und ruhig auch Dual Cores verbaut haben können, mindestens aber so 64bit Athlon-Zeugs, und wenn ich diese Hardware noch nichtmal unbedingt selbst kaufen will, sondern gerne auch ein Rechenzentrum nehme, dass so Hardware rumfliegen hat und vermietet, dafür aber halt Ausfälle ersetzt, und wenn ich dann noch will, dass die Rechner am gleichen Switch hängen, ne serielle Konsole haben, bitte auch redundante Netzwerkkarten (ja, so hübsche Gigabit-Intels) und dann noch jeweils ne doppelte SATA-Platte drinnen und dann will ich noch ein bisschen rund-um-glücklich-Support, welcher Server-Housing-Anbieter etc. ist dann was für mich? Ich dachte, ich gestalte das Weblog mal ein bisschen interaktiv.

Filed under , , , , & six comments & no trackbacks

Hatte ich das erwähnt? 5

Nein, ich glaube nicht. Seit Mitte September habe ich ja die Abteilung gewechselt. Das heißt bei Nu2M: 5 Meter Abstand zum alten Büro. Zuvor hatte ich ein Jahr lang an Blogg.de, Blogmonitor und solchen Projekten gearbeitet. Nun bin ich zum Neu.de-Team gewechselt, das gerade am Relaunch des – vorsichtig gesprochen – etwas ergrauten, aktuellen Neu.de-Portals arbeitet. Bisher läuft alles sehr cool – auch weil man von Leuten wie bbobb und kaib ganz gut was lernen kann – und somit ist außer, dass Kollege M. ab und an mit sich selbst spricht und mich beim Nasepopeln unterbricht, alles super. Wenn jetzt PHP noch ordentlich skaliert, sind wir alle glücklich. Begeistert bin ich jetzt schon von der ultimativen Suchmöglichkeit, sich die akut sexuell Frustrierten einer Stadt ausgeben zu lassen. Das wird hoffentlich sowas wie die Real-Life-Variante von PornoTube (Vorsicht: FSK 18, Jörn, Finger weg!). Und bevor ich nochmal eine ähnlich dämliche Überschrift wählen muss, es gibt jetzt auch einen Beta vom neuen Neu.de. Nicht, dass euch das was nutzen würde, denn anmelden kann man sich nicht. Aber der neue Volkssport ist ja eh, massenweise Betascreens zu beglotzen.

Filed under , , , & five comments & no trackbacks

RAM austauschen 4

Ich bin ja nun bekanntermaßen eher nicht so der Hardware-Bastler, aber RAM-Riegel einbauen geht dann doch noch. Normalerweise ist das ja so, man schraubt eine Kiste auf, das dauert maximal zehn Minuten, dann zieht man die alten RAM-Riegel raus, das dauert fünf Minuten, weil man nochmal einen guten Schluck Kaffee zu sich nimmt. Nun nimmt man die neuen Riegel und schiebt die rein, was, großzügig gerechnet, zehn Minuten dauert, weil man nebenbei noch genüsslich in der Nase bohrt. Dann bastelt man das Gehäuse wieder drauf und nocheinmal vergehen fünf Minuten. So würde ich mir das normalerweise vorstellen. Gestern allerdings hat 1&1 dafür fast einen ganzen Tag gebraucht, weswegen Schokokeks.org deutlich zu lange down war. Entschuldigt bitte.

Filed under , , , & four comments & no trackbacks

Die Konkurrenz hat gewonnen – vorläufig 5

Im Kölner Rheinhafen gibt es wunderschöne Büros mit Rheinblick und großen Fenstern. Zwischen Gustav-Heinemann-Ufer und dem Bayenturm, in unmittelbarer Nähe zur Südstadt, also kulinarisch nicht zu verachten, niemand wäre gezwungen zweimal in der Woche das gleiche Fast-Food-Restaurant aufzusuchen. Eben der optimale Ort für eine innovative Web 2.0 Company. Leider hat sich nun die Konkurrenz die Büros geschnappt. Ich sehe schon die frisch entlassenen Manager durch die U-Bahn-Abteile wanken: »Haben sie Interesse an einem Obdachlosen-Office oder auch vielleicht eine kleine Spende?«. Eine kleine Spende, gerne. Leider wird das mit den Büros im Rheinhafen nicht lange klappen, da bekanntlich Vista ein Misserfolg wird und Linux mit XGL, Composite-Extension und GNOME endgültig die ganze Welt rockt.
via

Filed under , , , , & five comments & no trackbacks

To spread or not to spread 3

A few days ago, SpreadGNOME has been launched. While it is a good idea to split developer-pages and marketing-pages, as like Mozilla does it with mozilla.org and SpreadFirefox, pages like SpreadGNOME should have the appeal of a marketing-page. There should be funky screenshots, big headings, concise texts – the page should give the visitor the impression of cool people, writing sexy software which is much better than the thing he currently uses. Just ask yourself: is this the impression you get when you visit SpreadGNOME?

Update

There is a new design but this does not look like a »The most important thing you miss in your life is using GNOME«-page, sorry. Putting links to a tech-orientated news-portal, a wiki-page for developers and gnome.org is not that imaginative.

As they are calling for suggestions, they could have them:

Filed under , , & three comments & one trackback

Verbraucherinformationen 2

Ich hatte Herrn Olbertz versprochen, auf seinen Blog-Counter hinzuweisen. Ist auch überaus sinnvoll, denn dort findet man eine sehr lustige Webapplikation mit allerhand Features, von denen ich bisher nie gedacht hatte, dass ich sie brauchen würde. Meine Damen und Heren, gehen Sie weiter, hier gibt es nichts zu sehen. Schauen Sie sich lieber den Blogcounter an. Ein Problem dabei ist, dass man jetzt sieht, dass ich von keiner Sau gelesen werde.

Filed under , & two comments & no trackbacks

Die Welt ist schlecht 1

... und erst ihr Code:

    /* WAS IST DAS ???
    //ich weiss es auchnicht aber es ist schon lange auskommentiert glaube ich
    $db->Execute("UPDATE weblogs SET title='$_POST[blog_title]', info='$_POST[blog_desc]',name='$_POST[blog_name]',template='$_POST[blog_template]' WHERE id = ".$_SESSION['weblog']['id']);
    $db->Execute("UPDATE weblogs SET aktiv='$_POST[blog_aktiv]' WHERE id = ".$_SESSION['weblog']['id']);
    */

Filed under , , , & one comment & no trackbacks

Next generation? 4

Am Wochenende war der Lieblingsbruder zu Besuch. Jenseits dessen, dass er hier bei »Paint it Black« abgeräumt hat und er gezwungen wurde, am Programm für musikalische Früherziehung teilzunehmen, sich also das »van Cleef«-Festival reinziehen musste, bleibt es ja nun doch nicht aus, dass man sich unterhält. Er ist gar nicht so viel jünger, genauer gesagt, drei Jahre jünger und so älter wir werden, umso mehr nivellieren sich die Unterschiede. Wenn der Kleine (und dieser Titel ist, einmal vergeben, für die Ewigkeit) aber über seine Internet-Gewohnheiten erzählt, wird einem schummrig. Offensichtlich wächst da die Generation der heute 16, 17-Jährigen heran, die – wie selbstverständlich – das Internet als Möglichkeitserweiterung begreifen, ihr »richtiges Leben« (jaja, bisher ist’s kein Richtiges, schon gut) mit anderen Mitteln fortzuführen. Da wird social software ganz normales Mittel der Distinktion, die virtuelle Identitäten sind austauschbar wie die Sonstigen. Und das mit einer engen Rückkopplung an die Wirklichkeit, die all die Steinzeitängste vergessen lassen. Stellt sich mein Umfeld noch regelmäßig die Frage, ob es wirklich cool ist, Frauen via Internetz kennen zu lernen und würde ich es niemals zugeben, das jemals getan zu haben, so ist das einfach egal. Just another place. Sehr lehrreich, so ein Gespräch. Die Frage »wieviel Computer für’s Kind« gibt sich langsam selbst der Lächerlichkeit preis. Haben Eltern schon längst den Überblick verloren, was ihre Kids da so im Netz treiben, so wird diese digitale Kluft immer größer. Filesharing, Youtube-Videos gucken, bloggen, Mails schreiben, chatten, Foren benutzen, social software wie MySpace, Kwick, o.ä und vor allem deren Kombination ist an ganz schön vielen Leuten vorbeigezogen. An mir im Übrigen im Endeffekt auch. Sich mit zwanzig alt fühlen, wenn der Kleine erzählt – der reality crash zum Wochenende.

Filed under , , & four comments & no trackbacks

Question of the day 7

Why does nobody develop Gstreamer-bindings for PHP?

Filed under , , , , & seven comments & no trackbacks

Multithreaded TCP-server in Ruby 0

Hopefully on Wednesday Blogmonitor, a new project of Interdings will be open for the public. In the last days and hours I was working on the API-components. An XML/RPC-interface, an REST-service and as a nice goodie a multithreaded TCP-server where you can watch all the incoming pings when they occur. The concept is the following: when an incoming ping occurs, the encapsulated class Blogmonitor::Pingservice::Ping sends a notification to the TCP-component, which waits for incoming connections on a custom port and serves the snippet to all of the connected clients. This is invented as really simple interface and has nothing to do with more standartized technologies like »Publish & Subscribe«, also the logic would be similiar.


What does Ruby already provide?


Ruby ships an example of a multihreaded server implementation which is called GServer. It provides the possibility to create a child-class of it, overload the serve()-method and be happy. That’s really a good beginning and the concept of having patterns seems to succeed again: don’t code things twice.


Example I, first working snippet


<ol><li>require 'gserver'</li><li>class MyServer < GServer</li><li>  def serve( io )</li><li>    io.puts( "Hello world" )</li><li>  end</li><li>end</li><li></li><li>s = MyServer.new 1234</li><li>s.start</li><li>s.join</li></ol>

The code should be more or less self-explaining: load the pattern, extend the class GServer and overload the method server(), which provides an IO-object. The method puts() of the IO-object writes »Hello world« to connected client.
Just create an instance, start() the server, join().
Connect with telnet to localhost and port 1234:

telnet localhost 1234
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
<strong>Hello World</strong>
Connection closed by foreign host.

Now you have a simple TCP-Server. But we miss a few things: on the one-hand the backend notification is not implemented and the connection is not persistent. If a client connects, it should not be disconnected just to receive a stream of incoming weblogs. First of all: implement the streaming thingy. Have a look at the lines 3-5 of example I: the serve()-method is executed on a new connection and disconnects the client when it method is called. But we want to have it persistant. A dirty solution would be to write the io-code in an endless loop, which works pretty fine.


Example II, persistant server


<ol><li>require 'gserver'</li><li>class MyServer < GServer</li><li>  def serve( io )</li><li>    loop do</li><li>      io.puts( "Hello World" )</li><li>    end</li><li>  end</li><li>end</li><li></li><li>s = MyServer.new 1234</li><li>s.start</li><li>s.join</li></ol>


Let’s implement the backend thingy. During my implementation I ran into a number of problems: I had a working example on my Linux-box there and after putting it on our development-system, which is a Solaris-driven T1000 from Sun I saw that from strange reason the implementation of sockets in Ruby seems not to work on Solaris, which is pretty annoying but in the end I’m happy it did not work with sockets. The next idea was to use just TCP with non-blocking connections to send packages from the ping-interface to the Live-monitor-component, but sadly Ruby on Solaris does sadly also not support non-blocking connections. The thing I’d stuck with was UDP. Good old UDP but I think it is pretty ok for this uncritical task. To send some message, you also have a pattern called UDPSocket which can be utilized to do this task.


Example III, UDP-server


<ol><li>require 'socket'</li><li>u = UDPSocket.new</li><li>u.bind( "127.0.0.1", 1357 )</li><li>message = u.recvfrom( 512 )[0]</li><li>puts message</li></ol>

Example IV, UDP-client

<ol><li>require 'socket'</li><li>s = UDPSocket.new</li><li>s.connect( "localhost", 1357 )</li><li>s.send( "Hello world", 0 )</li><li>s.close</li></ol>


The next problem is to make sure all listening TCP-clients get notified. So we need to have something like an IO-heap, where we store all the existing IO-objects and iterate through them to notify everyone. So we modify the serve()-method as it follows:

  1. def serve( io )
  2. io_heap << io</li><li> loop do; end</li><li>end</li></ol></pre> <p>But who sends the snippet to all the objects? We also overload the constructor of our MyServer class to start a notification thread which does the following tasks:<ul><li>Start the UDP-server</li> <li>Iterate to our heap of IO-objects to notify them all</li></ul></p> <h3>Example V, the complete component</h3> <pre><ol><li>require 'gserver'</li><li></li><li>class MyServer < GServer</li><li> def initialize( port, *args )</li><li> io_heap = []
  3. udp = Thread.fork do</li><li> udp_socket = UDPSocket.new
  4. udp_socket.bind( "localhost", 1357 )</li><li> loop do</li><li> payload = udp_socket.recvfrom( 512 )[0]
  5. unless payload.empty?
  6. io_heap.each do |io|</li><li> begin</li><li> io.puts payload</li><li> rescue Errno::EPIPE => error</li><li> io_heap.delete io
  7. end
  8. end
  9. end
  10. end
  11. end
  12. super(port, *args)
  13. end
  14. def serve( io )
  15. @io_heap << io
  16. loop do; end
  17. end
  18. end
  19. server = MyServer.new( 1234, host=“localhost” )
  20. server.start
  21. server.join

Isn’t it really, really short?

Filed under , , , , , , & no comments & no trackbacks

What to do? 0

During my daily work I often heard discussions about how to handle charset properly. What a server must provide to handle charsets correctly, which configuration for Apache is needed, what options must be set in php.ini to make PHP correctly working, which functions should be avoided when using PHP, which locales must be used and so on. So I want to give a short overview how to sail around common problems in a LAMP-setup.

Kernel

Just to make sure the option CONFIG_NLS_UTF8 is set to y.

Environment

To make sure, newly created filenames are there in UTF-8 and in general VT-input is handled correctly, you have to choose a charset, which comes with an .UTF-8-suffix. For german feel free to choose de_DE.UTF-8. Make sure your glibc is provides this locales. To convert current names of files you can just use convmv. For a desktop you must also adjust the font and set a correct TTY-font but this could be ignored for a server which is just administrated via remote shell.

Webservers in general – focus on Apache

To make sure, the users input is UTF-8, the server has to deliver the correct Content-Type-header. Take a look at the output of wget -S http://usrportage.de, my weblog, which is hosted on Schokokeks.org, a properly configured server (sure!):
wget -S usrportage.de
—21:00:33— http://usrportage.de/ => `index.html’
Resolving usrportage.de… 87.106.4.7
Connecting to usrportage.de|87.106.4.7|:80… connected.
HTTP request sent, awaiting response… HTTP/1.1 200 OK Date: Thu, 13 Jul 2006 19:00:27 GMT Server: Apache X-Powered-By: PHP/5.1.4-pl0-gentoo with Hardening-Patch X-Blog: Serendipity Set-Cookie: PHPSESSID=9da2ded6522851ef8ddc3ebe7590b354; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache X-Serendipity-InterfaceLang: de X-FreeTag-Count: Array Connection: close Content-Type: text/html; charset=UTF-8
Length: unspecified [text/html]

[ <=> ] 65,557 250.71K/s

21:00:33 (250.19 KB/s) – `index.html’ saved [65557]


You see the header Content-Type: text/html; charset=UTF-8. (You can also the a bug in S9Y, which poorly casts an array, but anyway.) So your browser is notified, that it should send UTF-8 encoded data. That’s the whole secret. To configure Apache properly, make sure the directive AddDefaultCharset is set to UTF-8.

One thing at last: if you’re using AJAX-functions from Prototype for JavaScript-purposes, you have to reencode the string delivered by the AJAX-call. In PHP the following would work:
$string = utf8_encode( $_POST[‘key’] );

MySQL

Before transacting any data, make sure your connection charset is set to UTF-8:
SET NAMES utf8;
By the way: have I ever mentioned you should ever use mysql_real_escape_string() instead of mysql_escape_string()?

PHP

Just two rules: use mb_string-functions whereever it is possible, set the INI-setting default_charset to UTF-8 and – anyway – don’t use functions from the ereg-family also they have an mb_-Prefix. They aren’t binary-safe, that’s all you need to know.
Also make sure, your sources are UTF-8 encoded. Use iconv to correct those who are not.

Update


I forgot to mention, that the functions htmlentities(), html_entity_decode() and htmlspecialchars() does not reflect PHPs default_charset-directive but assumes iso-8859-15 as the default charset, which is pretty annoying and should be considered as a bug, from my point of view. So you need to pass UTF-8 as the third parameter to the function to make sure it will work properly with Unicode.

Filed under , , , , , , , & no comments & no trackbacks

↖ Older Entries Newer Entries ↘