Planet DokuWiki



March 21, 2010

Retirando o amarelado de plásticos com o Retrobright.

Retirando o amarelado de plásticos com o Retrobright.

Neste final de semana assumi o papel de homem da casa e partir para consertar algumas coisas, entre elas a fiação do telefone e do cabo de tv e internet. Aí que eu notei que minha fiel secretária eletrônica, com mais de 10 anos parecia com hepatite. Resolvi tentar o experimento Retrobright. Eu usei a seguinte fórmula: 1 vidro de 70 ml de água oxigenada 40 volumes, meia colher de chá de Vanish líquido (o pessoal usa o em pó) e uma colher de gel de glicerina para limpar plásticos de carro. Fora a água oxigenada, o resto eu tinha em casa, inclusive a luz negra eletrônica de 26W. Eu esqueci de tirar foto da secretária montada, mas depois de desmontada e lavada com detergente, ficou assim:

Eu misturei tudo e apliquei usando um pincel. Eu notei que o enbranquecimento foi mais rápido quando coloquei a lâmpada bem próxima, mas tomando cuidado de não aquecer as peças. De vez em quando dava umas pinceladas extras, pois o gel parecia secar, devido à glicerina. Deixei de 19:00 às 10:00, e o resultado final foi este: secretariawhite.jpg

Embora a máquina reflita o flash, podemos comparar com a parede branca ao lado (é quase o tom do mármore na primeira foto). Note que a tinta dos impressos também foi retirada parcialmente, e o botão azul também sujou o pincel.

Da próxima, vou tentar a mistura com maizena e Vanish em pó, que está neste link do Flickr. O cara ainda usou água oxigenada 10 volumes. No wiki original, a recomendação é qualquer coisa de 20 para cima.

Em resumo: funciona!!

by tjpp at March 21, 2010 05:23 PM

March 19, 2010

Using the Gtags source code tag system with vim


The GNU Global source code tagging system is a utility that allows you to index all functions, global variable definitions, macros, etc... in a source code for easy navigation. The utility generates an index that can be used to easily locate the definition or references to a given symbol. The Gnu Global/Gtags system is very useful for hacking a large project containing many subdirectories. This article is a how-to guide for using Gtags with vim.

by CodeAlias at March 19, 2010 01:35 AM

March 18, 2010

Como uma mancha cresce

Como uma mancha cresce

Eu já comentei aqui, o problema do caminho aleatório (Random Walk). Falei no post do O azeite bêbado e fiz algumas simulações com o Processing.js, disponíveis na página do curso de Física Estatística que estou ministrando neste semestre. A experiência que eu quero realizar é medir como o diâmetro de uma mancha de tinta em uma folha de papel varia com o tempo. Vale ressaltar que este probleminha é inspirado em um outro que mostrou que átomos existem, ou comportamentos em mercados de ações, como um gás venenoso se espalha pelo ar, etc.

O que eu fiz foi o seguinte: filmei uma gota de tinta que cai no papel.

Agora eu retiro frames do vídeo, em intervalos regulares. O vídeo foi gravado a 30 fps, com uma câmera digital comum. O problema que eu enfrentei é que eu não quero todos os frames (são 7 segundos de filme, com 30 por segundo seriam 210 para analisar e eu queria por volta 15). Os programas que havia testado ou retiravam todos os frames ou só faziam snapshots de 1 em 1 segundo. A dica para resolver isto foi passada pelo Armando M. Baratti, na lista do Arch Linux. O que devemos fazer pelo ffmpeg é o seguinte: ele só tira frames de 1 em 1s, mas podemos mudar a velocidade do filme. Se repassarmos o filme em 15 fps por segundo, então 0.5s do filme original vai ser 1s do filme repassado. A sintaxe então é simples:

ffmpeg -i mvi_6484.avi -r 10 -ss 00:00:04 -t 00:00:06 extracted_images/images%03d.png
que faz o seguinte: pega o arquivo mvi_6484.avi, a partir do quarto segundo, com duração de seis segundos e tira 10 fotos por segundo. As fotos são salvas no diretório extracted_images, e com um rótulo que indica a ordem do frame. Eu pego cada foto e uso o Gimp para medir o tamanho da mancha. Depois uso o Gnuplot para medir o tamanho em função do número do frame (nem precisa saber quanto tempo em unidades tradicionais como minuto ou segundo). O resultado está no gráfico abaixo do tamanho em pixels versus o índice do frame

Observe que a gota não cresce com velocidade constante, mas é mais lenta à medida que o tempo passa. Na verdade, o raio da gota cresce com a raiz quadrada do tempo (como mostrado por Einstein em 1905). Eu não vou dar detalhes aqui pois isto é um trabalho para os estudantes da disciplina :) . Prometo que depois eu conto o resto.

by tjpp at March 18, 2010 01:04 AM

Using vim file buffers


Vim has a feature called “file buffers” that works as follows : During a vim session, each time a file is opened, vim keeps an entry for the file in what could be called a “recently opened files” list. This entry is called buffer. This buffer list can server as a file navigation tool that facilitates the editing of multiple files during the same vim session. When you need to work on a file that you previously opened, you can open the buffer list, locate your file by its name then use th…

by CodeAlias at March 18, 2010 12:41 AM

March 15, 2010

Emails from Strangers

Emails from Strangers

Having your name in the credits of an popular Open Source tool has strange side effects. One of them is getting emails that were clearly not meant for me.

Today it got really bizarre, because multiple people where involved. I only got one mail, but it contained a whole message history which I provide here for your amusement education.

It all started with Monika from Austria who tried to look up the opening times of a Lidl supermarket on the net. For some reason however, she did not find their official website. Instead she found a wiki that collects opening times for various stores. The story could have ended there.

Unfortunately, the information was wrong and poor Monika had to wait half an hour in the cold. When she came home she was angry and wrote a mail to the Lidl customer service1):

From: Monika
To: Lidl Customer Service

The internet states about opening hours: 7:30 for saturday

http://www.kfn.at/wiki/doku.php?id=lidl 

but lidl triesterstraße opens only at 8 o'clock.
what did I do, that I have to freeze while waiting?
in the store they then just look at you... with a shrug.
not a very friendly customer service.

monika

This came to the hands of the friendly Theresia from the supermarket's customer service. She had a look at the link and wondered what to do. Instead of registering at the wiki and changing the info, she decided to forward the whole thing to her colleague in the marketing department:

From: Theresia
To: Walter

That page isn't ours....can we somehow forward this?

asking you for a short reply

Of course Walter had no clue either. But he spent a few more seconds looking around and somehow found my email address:

From: Walter
To: Andreas Gohr

Dear Mr. Gohr,

please go on www.lidl.at and use our correct opening-hours

Yours
Walter

This was clearly never meant for me. Walter probably just found my email somewhere in the DokuWiki credits linked from the mentioned wiki site.

I'm not surprised that Monika couldn't tell the difference between some random website and the Lidl's official homepage. We all know at least since the Read Write Web Facebook login story that end user's often have no idea about how the web works.

I am somewhat surprised that Walter took time enough to dig through the site to somehow find my email address, but then did not realize that it is the not the site owner's one. But he's a real marketing pro by asking me to visit his website to update the times, instead of sending the correct times right away ;-)

The real surprising thing is, that I now have Monika's email address which is really none of my business. Yes, as I said: the whole mail history was in that forwarded mail, including the customers email address!

So here are the lessons to be learned today:

  • site owners:
    1. provide an easy and obvious way to contact you!
  • customer service people:
    1. get a clue about the web!
    2. never ever give your customer's email addresses to a stranger!
Tags:
customers,
email,
web,
rant
Similar posts:
1) I still wonder how she found the correct mail address, after she failed to find the correct website in the first place

Add or read comments to this article »»

Copyright © 2010 Andreas Gohr
This feed is for personal, non commercial use in the subscriber's feedreader only.
All contents (especially texts and images) are protected by copyright law and may not be republished outside of splitbrain.org or planet.dokuwiki.org without prior consent. Texts may be quoted in extracts under fair use policy. [digital fingerprint: sb97741286f601b4a0d496dc8bae242e6d]

by Andi at March 15, 2010 10:07 PM

March 14, 2010

Moved

Yay, I moved again. I still live in Munich though ;-). This weekend I managed to finish my living-/hacking-/music room and thought I might share some pictures (yeah, they're a little dark I know ;-), light still sucks).

farm3.static.flickr.com_2688_4431538273_dfd43aa188_b.jpg

Notice the new chair 8-)!!

farm5.static.flickr.com_4029_4431549299_2ec9ff4e9a_b.jpg

Still lots of work to do. The walls need some love (pictures - I dunno) and I need at least another two weekends painting the kitchen and the toilet, buy some good lamps (anyone got experience with LED stuff?) etc. etc..

This blog post was created on 2010-03-14 at 15:58 and last modified on 2010-03-14 at 15:59 by Michael Klier. It is tagged with moved.

March 14, 2010 02:58 PM

March 05, 2010

Sightseeing in Northern Sudan

Pyramids of MeroeToday, I finally got to visit a small part of Sudan outside of Khartoum. The drive was long, but made more bearable by an overcast sky - which somewhat cleared during the day. Instead of 40º it maxed around 35-36.

My day started at 7.15 and finished around 8pm. Still an hour after getting home, I am just about rehydrated - despite easily consuming 3 bottles of water, a guava juice, a cup of tea, two bowls of chicken soup and a glass of milk during the day (so far). Other food consistered of some savouries from the Burj, grilled Nile perch on the bank of the Nile, and chicken, chips and salad in a Khartoum restaurant.

The first stop in the journey was the pyramids at Meroë. This is a collection of around 200 pyramids - mostly in poor condition - where there are very few other tourists or vendors. This makes it a very pleasant place to visit.

The pyramid is an iconic building design, and set against some very golden yellow sand and a bright blue sky - the overall effect becomes hard to describe. Photographically it is almost too good to be true and ends up looking like a film set.

Next up was Royal City, which was nothing to write home about - a lot of stones but with very little left. The temple at Naga gave a better insight into the building and carving style of the people.

Finally we visited the 6th Cataract in the Nile. Here we took a boat ride and had lunch. The Nile is a very impressive river, but the cataract (essentially a small rapid) is only really a minor geographical feature. Nile perch is a very bony fish and ours tasted a little undercooked. Still it was clearly fresh as it had just been caught, so the chance of any bacteria is remote.

Read or add comments to this article

This feed is not for use on commercial web sites.
© Monjo.com

by monjo at March 05, 2010 12:59 PM

March 03, 2010

Google about Privacy

Attention: Satirical content lurking right around the corner :)

While admitting that security measures need to improve, Google officials also claimed that everyone makes mistakes, be it storing confidential data indefinitely or, say, “having a few too many drinks on the evening of Jan. 23, driving home in a haze, striking a pedestrian on the corner of Mercer and Cavendish, speeding off, and then desperately searching online for hit and run laws, right, Karen?”

“Americans have every right to be angry at us,” Google spokesperson Janet Kemper told reporters. “Though perhaps Dale Gilbert should just take a few deep breaths and go sit in his car and relax, like they tell him to do at the anger management classes he attends over at St. Francis Church every Tuesday night.”

Read all of it here: http://www.theonion.com/content/news/google_responds_to_privacy

by xarumanx at March 03, 2010 07:39 PM

Prisoner of War

Berated and cajoled
Lacerated and mauled
He lays, chained to a fence
Completely naked, lacking defence.

Was this how it was meant to be?
A definition of freedom and liberty?

Poked with sticks, prodded with a gun
Guards standing over, all making fun.
captured they are, prisoners of war
What is the reason, what was it for?

Was this how it was meant to be?
No justification, no reason that I can see.

Just water and bread, that’s all he is fed
Battered and bruised, from his toes to his head.
Dead is his family, dead are his friends
Killed by a stray bomb, he was making amends!

Was this how it was meant to be?
And what was it for?
And why this lack of morality?
All in the name of war.

Read or add comments to this article

This feed is not for use on commercial web sites.
© Monjo.com

by monjo at March 03, 2010 07:04 PM

March 02, 2010

Bye Bye Data-Retention

Zumindest in ihrer derzeitigen Umsetzung wurde die Vorratsdatenspeicherung in Deutschland für Verfassungswidrig erklärt. Da hat sich die Arbeit des CCC wirklich ausgezahlt, die dem Richtergremium bereits am 15.12.2009 äußerst plakativ darlegten, dass nicht belegbar ist, was mit den eigenen Daten die nach der Vorratsdatenspeicherungsrichtlinie gespeichert wurden passiert.

Ich hoffe doch mal die Österreichische (und auch andere Europäische) Regierung(en) nehmen sich ein Beispiel daran bevor sie blindlings etwas Umsetzen das hauptsächlich einen weiteren Schritt in Richtung 1984 macht.

by xarumanx at March 02, 2010 11:52 AM

German Adventure Games

German Adventure Games

I recently played through two point'n'click adventure games by German publishers and was positively surprised. It seems the adventure genre is back.

I have no idea on the availability of these games outside of Germany. Amazon.com seems not to carry them currently, which is a pity. Additionally keep in mind that I played the games in German – English dubs might be not as good as the German version.

The Book of Unwritten Tales

“The Book of Unwritten Tales” is set in a fantasy world filled with orcs, dwarfs, elves, gnomes and mages. You play different characters that will only meet later in the game. Your task is to find some magical item and use it to end a long running war between good and evil and finally bring back peace to the kingdom.

The game features beautiful graphics and well executed voices and soundtrack. The game's tasks and riddles are always logical1). I never came to a point where I didn't know what I had to achieve next. Not that I immediately knew how to solve the task, but I never felt lost.

What I enjoyed most were the little homages to popular movies, books and other adventure games. And talking to the mummy in an archeologist's home made me literally laugh out loud – a really “Monkey Island”-esque moment.

I highly recommend to get this game.

HMH Interactive
Windows Vista
EUR 17,48

The Whispered World

“The Whispered World” is set in a medieval fantasy world, too. You're playing Sadwick, a young clown in a traveling circus group. Sadwick hates to be a clown. In fact he is annoyed by pretty much everything and believes the whole world is always turning against him.

Nonetheless he sets out to rescue the world of being destroyed, when the task arises. He's accompanied by his little pet caterpillar named Spot. Spot plays an important role in the puzzles as he can transform himself into various forms with different abilities. Using Spot in his correct form is the key to solve many puzzles.

Unfortunately the game isn't as logical as the Unwritten Tales. I often had to rely on a walkthrough to find my way out. What bugged me most was that certain puzzles involved indirectly manipulating parts of the screen that you couldn't highlight. I expect the things I can interact with (even indirectly) to be at least examinable.

Graphics, voices and soundtrack where as good as in the Unwritten Tales. Unfortunately voices and sounds did not always match the animations.

Despite it's shortcomings, “The Whispered World” is a solid adventure game. And the somewhat surprising ending is so touching I had tears in my eyes.

Koch Media GmbH
Windows Vista
EUR 24,90
Tags:
adventure,
games,
review
Similar posts:
1) well, at least for a seasoned adventure gamer who knows to look for a cooking pot when a helmet is needed

Add or read comments to this article »»

Copyright © 2010 Andreas Gohr
This feed is for personal, non commercial use in the subscriber's feedreader only.
All contents (especially texts and images) are protected by copyright law and may not be republished outside of splitbrain.org or planet.dokuwiki.org without prior consent. Texts may be quoted in extracts under fair use policy. [digital fingerprint: sb97741286f601b4a0d496dc8bae242e6d]

by Andi at March 02, 2010 07:34 AM

February 28, 2010

Another Ad Network: Ad Bard

Another Ad Network: Ad Bard

You might have noticed, there are new ads here1). They are powered by Ad Bard.

They describe themselves as “the ad network for ethical computing” and are currently in beta.

The Ad Bard Network is the only advertising network designed specifically for reaching the developers, architects, users and influencers in the free software community, allowing advertisers to directly communicate with the key customers in this exciting new area.

Only websites that focus on free software can join the network to become publishers. And similar criteria are applied to advertisers.

In theory that should be a perfect match for this site. If it works out in reality (eg. payments) will be an interesting thing to see.

Tags:
advertising,
ads,
adbard
Similar posts:
1) RSS Users click through ;-)
AdBlock users just ignore this post

Add or read comments to this article »»

Copyright © 2010 Andreas Gohr
This feed is for personal, non commercial use in the subscriber's feedreader only.
All contents (especially texts and images) are protected by copyright law and may not be republished outside of splitbrain.org or planet.dokuwiki.org without prior consent. Texts may be quoted in extracts under fair use policy. [digital fingerprint: sb97741286f601b4a0d496dc8bae242e6d]

by Andi at February 28, 2010 12:20 PM

February 26, 2010

Microscópio USB XingLing

Microscópio USB XingLing

Este microscópio foi minha primeira experiência com o site chinês dealextreme. O site é cheio de bugigangas inúteis mas incrivelmente atraentes (ok, algumas são úteis). O legal do site é o frete grátis para qualquer compra. Você pode até sugerir produtos para que sejam vendidos no site.

Eu comprei um microscópio USB, cujas especificações importantes são: 200x, 8 leds para iluminação e 1.3M pixels de resolução (1280×1024). A encomenda chegou cerca de 5 semanas depois da compra (no meio destas, teve Natal e Ano Novo): comprei no início de dezembro e recebi na metade de janeiro. Fiz outras compras (ímas Nd) na semana passada e espero que seja mais rápido. O microscópio é mesmo um brinquedo: todo de plástico e com foco manual meio duro de ajustar. Não dá para confiar na haste que sustenta o microscópio e mexer no foco significa tirar o objeto do foco do microscópio. Tem algumas fotos do brinquedo em http://www.dealextreme.com/photogallery.dx/sku.26764~seQ.3. Veio com um mini-cd.

A instalação no Linux (Arch Linux) é assim: pegue o mini-cd e coloque uma tulipa de cerveja gelada em cima. Plugue o cabo em uma porta USB. Vai ser carregado automaticamente o módulo uvcvideo. Carregue o cheese e bata fotos ou filme. Tome um gole de cerveja entre uma foto e outra. Vou colocar umas amostras para que vocês tenham ideia da qualidade de imagem (clique para ver na resolução 1280×1024):

Pele da mão. Pessoas no microscópio parecem 80 anos mais velhas.

pele.jpg

Olha o sorriso ! Na verdade é a unha do polegar (não, não faço “francesinha”).

sorriso.jpg

Neurônios ??? Não, é um destes chamados jogos americanos (de colocar prato em cima), de plástico.

neuronios.jpg

Gostou e quer comprar mas a patroa não deixa ? Diga que é um moderno localizador de cravos

cravos.jpg

A limitação mais séria é que, apesar do aumento de 200 vezes anunciado, você não tem controle da ampliação (não é até 200x, mas 200x e pronto). Portanto o microscópio é só uma webcam com umas lentes a mais. Para coisas um pouco mais sérias, é melhor comprar um microscópio baratinho (lá tem também) e bolar um esquema de acoplamento tipo tubo de PVC e fita isolante para acoplar uma webcam. O botão de captura de imagem funciona no cheese e o botão on-off é para controlar os leds (veja como a foto dos neurônios falsos ficou brilhante, ficaria melhor com os leds desligados).

Uma coisa chata no cheese, é que eu tive que desligar a webcam para poder ver o microscópio: eu poderia mexer no gstreamer-properties, mas usar um outro programa para escolher o device é contra-producente. Eu vi alguns relatos dizendo que o gstremaer-properties não funcionaria para dois devices, se um é v4l1 e o outro v4l2 (que não é o meu caso, ambas são v4l2).

Em resumo, é mais um brinquedo quase inútil e interessante, ideal para períodos de dólar baixo.

by tjpp at February 26, 2010 01:25 PM

February 24, 2010

Multifuncional Wireless no Arch Linux

Multifuncional Wireless no Arch Linux

Depois do post do Augusto no Efetividade.net resolvi trocar minha multifuncional por uma wireless HP Photosmart. Não vou repetir o post dele, portanto visitem-o para maiores informações sobre a impressora em si. Comprei no Mania Virtual, pagando R$ 369,00, sem ter que devolver a antiga/quase nova (HP Trade-in). Como sempre, a entrega foi pontual: comprei sexta à noite e recebi ontem.

Só aí é que eu reli o post do Augusto sobre a instalação no Linux e ele fala em uma impressora pré-configurada para a rede :( As impressoras laser HP da Física permitem configuração de rede na própria impressora, esta multifuncional, não. Como eu uso Linux há alguns anos, eu procuro ler antes de instalar… nem deveria.

O procedimento é o seguinte: eu já tinha o hplip instalado pois tenho uma laser 1005 para trabalhos grandes - se é a última versão? Gente, isto é ArchLinux. Ligue a impressora e o cabo USB (esqueça o aviso de só ligar a USB quando o computador pedir). Carregue o hp-setup:

Escolha o último, como na figura acima. O quadro seguinte é só informativo:

Achou!!

Achou!!

Um passo a mais

Configurou!!

A impressora tem um servidorzinho web embutido que permite configurar tudo pelo browser agora:

Eu fiz um passo a mais. Entrei em http://localhost:631 (interface do CUPS) e testei os dois drivers disponíveis: hpijs e hpcups. O hpcups deu quase um centímetro a mais no final da folha. Não notei diferença na qualidade, pelo menos na página de teste.

Foi difícil ??

by tjpp at February 24, 2010 11:46 AM

February 21, 2010

Dresden Weekend

Dresden Weekend

Kaddi and I where in Dresden for a prolonged weekend. I really needed a vacation and even though it was a short one, I enjoyed it very much. As usual, here are some of the photos we took.

Tags:
vacation,
photos,
dresden
Similar posts:

Add or read comments to this article »»

Copyright © 2010 Andreas Gohr
This feed is for personal, non commercial use in the subscriber's feedreader only.
All contents (especially texts and images) are protected by copyright law and may not be republished outside of splitbrain.org or planet.dokuwiki.org without prior consent. Texts may be quoted in extracts under fair use policy. [digital fingerprint: sb97741286f601b4a0d496dc8bae242e6d]

by Andi at February 21, 2010 08:59 PM

February 18, 2010

Python Webservice, part 2 : a twistd integration

yann.hodique@gmail.com

Twistd

In my previous post I've explained how to generate a SOAP service from a WSDL file, and how to implement the required methods properly. A solution to run such a service is to use the Twisted Daemon, aka twistd. Though not needed, strictly speaking, it provides a nice set of features aimed at easing complex applications development.

In particular, it allows to write so-called plugins that make it possible to just launch services in the following way:

$ twistd echo

To achieve that, one has to create a file twisted/plugins/echo.py accessible somewhere from the python path (that is, the twisted directory should be a subdir of an element of the path).

Manhole

Twisted offers a nice service, that can be used to provide an inspection/debug interface for your main application. This is called manhole and provides a python interpreter interface. This way you can just telnet/ssh the manhole, and execute appropriate commands to introspect the current state of the application, or put it in the desired state.

A nice example of a really useful function to run from the manhole service is the rebuild one. It tries very hard to provide in-place reloading of code (and corresponding objects). Don't expect any wonder here, it will fail in some corner cases. Still, it proves really useful most of the time, and helps a lot not restarting the server every now and then.

Example

Here is a fully working example of a twistd plugin for the Echo service, with a functional manhole service in addition.

from zope.interface import implements
from twisted.python import usage
from twisted.python.rebuild import rebuild
from twisted.plugin import IPlugin
from twisted.application.service import IServiceMaker, MultiService
from twisted.application.internet import TCPServer
from twisted.web.server import Site
from twisted.web.resource import Resource
from twisted.conch.manhole_tap import makeService as makeConsoleService
 
from EchoImpl import EchoService
 
class EchoOptions(usage.Options):
    optParameters = [["port", "p", 8080, "main port", int],
                     ["service-port", "s", 8081, "service port", int],
                     ["service-users", "u", "/etc/passwd",
                      "The path to a passwd-like authentication file"]]
 
class EchoServiceMaker(object):
    implements(IServiceMaker, IPlugin)
    tapname = "echo"
    description = "Sample Echo service"
    options = EchoOptions
 
    def makeService(self, options):
        # Create Service
        srv = EchoService()
 
        root = Resource()
        # we'll serve Echo at http://<ip>:<port>/echo
        root.putChild('echo', srv)
        siteFactory = Site(root)
 
        echo_service = TCPServer(options['port'], siteFactory)
        console_service = makeConsoleService(
            {"telnetPort": str(options['service-port']),
             "sshPort": None,
             "namespace": {"service": srv,
                           "rebuild": rebuild},
             "passwd": options['service-users']})
 
        svc = MultiService()
        echo_service.setServiceParent(svc)
        console_service.setServiceParent(svc)
 
        return svc
 
serviceMaker = EchoServiceMaker()

The code is hopefully rather straightforward. It should be noted that the manhole service (created by the makeConsoleService() call) needs to know about a set of objects (the “namespace” key). Those objects are the roots for everything accessible from the service. Here, the main service object (the srv object) is available to the manhole under the name service. Here is how it can be used:

$ telnet localhost 8081
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Username: yann
Password: x
 
>>> print service
<EchoImpl.EchoService object at 0x2fc8c10>
>>>

Hint: the password is really 'x', as I'm using /etc/passwd by default, which contains 'x' for every “password” field, since the real passwords are in /etc/shadow. Convenient for a dev deployment ;)

Read or add comments to this article

by Yann Hodique at February 18, 2010 11:01 PM

February 17, 2010

Reunited

Reunited

LEGO was my favourite toy when I was a kid. When I moved out, I left my LEGO box at my mum's place. Last week I asked her to bring it with her when she visited and now I'm finally reunited with my LEGO bricks :-).

I'm as happy as a kid. There were even a few old manuals and LEGO catalogs so I could add a few more sets to my list at Brickset, still not complete though.

Tags:
lego,
toys

Add or read comments to this article »»

Copyright © 2010 Andreas Gohr
This feed is for personal, non commercial use in the subscriber's feedreader only.
All contents (especially texts and images) are protected by copyright law and may not be republished outside of splitbrain.org or planet.dokuwiki.org without prior consent. Texts may be quoted in extracts under fair use policy. [digital fingerprint: sb97741286f601b4a0d496dc8bae242e6d]

by Andi at February 17, 2010 08:39 PM

Python Webservice, part 1 : a Twisted solution

yann.hodique@gmail.com

As mentioned previously I've been spending some time recently working on a SOAP server mock. For this I've used Python Twisted and ZSI. Since the interaction between the 2 seems rather poorly documented (even Google doesn't know much about it), I thought I'd share what I've investigated and done.

Disclaimer: you should be familiar with SOAP and Python Twisted. I'll not cover anything in these areas.

For the sake of simplicity, I'll take a classical minimal server: an Echo service.

Let's start from the definition of such a service, as a WSDL. This one was randomly picked from there Anyway the implementation details are not so important here.

<?xml version="1.0" encoding="UTF-8"?>
<definitions
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="urn:ZSI"
    targetNamespace="urn:ZSI" >
  <types>
    <xsd:schema elementFormDefault="qualified" targetNamespace="urn:ZSI">
      <xsd:element name="Echo">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="value" type="xsd:anyType"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
  </types>
 
  <message name="EchoRequest">
    <part name="parameters" element="tns:Echo" />
  </message>
 
  <message name="EchoResponse">
    <part name="parameters" element="tns:Echo"/>
  </message>
  <portType name="EchoServer">
    <operation name="Echo">
      <input message="tns:EchoRequest"/>
      <output message="tns:EchoResponse"/>
    </operation>
  </portType>
 
  <binding name="EchoServer" type="tns:EchoServer">
    <soap:binding style="document"
                  transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="Echo">
      <soap:operation soapAction="Echo"/>
      <input>
        <soap:body use="literal"/>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
    </operation>
  </binding>
 
  <service name="EchoServer">
    <port name="EchoServer" binding="tns:EchoServer">
      <soap:address location="http://localhost:8080/echo"/>
    </port>
  </service>
 
</definitions>

So really nothing fancy here. Just the definitions and shape of the messages/operations (only trivial ones).

ZSI offers the wsdl2py tool, that can process such WSDL files, and produce client bindings and server stub. In this article, the server part is what we want. (note the -w flag will trigger Twisted code generation)

$ wsdl2py -w echo.wsdl

EchoServer_server.py now contains the code for the service stub. Not much in there, the main part being the following method:

def soap_Echo(self, ps, **kw):
    request = ps.Parse(EchoRequest.typecode)
    return request,EchoResponse()

This is the one we should implement to make the service concrete. Here is a first attempt:

class EchoService(EchoServer):
 
    def __init__(self):
        EchoServer.__init__(self)
 
    def soap_Echo(self, ps, **kw):
        request, _ = EchoServer.soap_Echo(self, ps, **kw)
        return request, request

That will work. If you register this Service as a Twisted Resource, it will provide a functional SOAP Echo service, on which you can execute the following.

$ POST http://localhost:8080/echo
Please enter content (application/x-www-form-urlencoded) to be POSTed:
<soapenv:Envelope 
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body xmlns:ns1="urn:ZSI">
    <ns1:Echo>
      <ns1:value xsi:type="xsd:string">plop</ns1:value>
    </ns1:Echo>
  </soapenv:Body>
</soapenv:Envelope>
^D
<soapenv:Envelope xmlns:ZSI="http://www.zolera.com/schemas/ZSI/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header></soapenv:Header><soapenv:Body xmlns:ns1="urn:ZSI"><ns1:Echo><ns1:value xsi:type="xsd:string">plop</ns1:value></ns1:Echo></soapenv:Body></soapenv:Envelope>

Still, this is not very Twisted… I mean we don't take advantage of the asynchronous framework here, as the only method we wrote is definitely synchronous and we treat each call after one another. Would the soap_Echo() take time for whatever reason, that would introduce unacceptable delays for the user. Of course, there is no magic in the Deferred objects, which means than simply returning a Deferred in soap_Echo() will absolutely not work.

Digging a bit more in the ZSI Twisted glue, one can find a promising piece of code, appropriately named DeferHandlerChain. This is an alternative to the DefaultHandlerChain that's used (by default) by WSresource objects (hence EchoServer ones). The nice property of this handler chain is to put in place a callback chain from processRequest() to processResponse(), actually supporting Deferred objects returned by soap methods. In a word, what we need…

The code can become something like:

class EchoDeferHandlerChainFactory:
    protocol = DeferHandlerChain
 
    @classmethod
    def newInstance(cls):
        return cls.protocol(DefaultCallbackHandler, DataHandler)
 
class EchoService(EchoServer):
 
    def __init__(self):
        EchoServer.__init__(self)
        EchoServer.factory = EchoDeferHandlerChainFactory
 
    def soap_Echo(self, ps, **kw):
        request, _ = EchoServer.soap_Echo(self, ps, **kw)
 
        def _answer():
            return request
 
        # yeah, we have a very busy echo service... 5 seconds delay !
        d = deferLater(reactor, 5, _answer)
        return request, d

You can now try triggering several parallel Echo calls, and see that they will not be treated in sequence !

Read or add comments to this article

by Yann Hodique at February 17, 2010 07:20 PM

February 15, 2010

It's Been Quiet Here

Not because I'm not doing anything worth telling the intertubes, but because I put a lot on hold at the moment (including this blog). Mostly because I'm moving (again). In three weeks from today I'll be in my new flat, with a hopefully ready to use Internet uplink1) and plenty of free time to work on interesting/funny/musical/nerdy stuff again :-) (I have big plans - as always ;-)).

Until then I'll waste my free time relaxing and playing Eve Online (the first game in month which I still enjoy after playing it for more than a day).

1) this thime I told my ISP 6 weeks in advance, lets see how that works out

This blog post was created on 2010-02-15 at 11:10 and last modified on 2010-02-15 at 12:08 by Michael Klier. It is tagged with moving.

February 15, 2010 10:10 AM

February 14, 2010

Creating ePub files from webpages

As my newest gadget (well, it's already more than one and a half months old) is an eBook reader device my interest for ePub files has grown as ePub is basically the format that works best for my device and probably generally small eInk devices.

Basically, an ePub file is a xhtml file with some additional information (e.g. a table of contents) zipped together into a handy file. So saving a webpage into an ePub document seems to be quite easy. Nevertheless there are some things the tool has to pay attention too as e.g. the xhtml in a epub file has to be valid xhtml 1.1. For further details on the file format I suggest reading this guide on ePub file creation.

Of course one could do that manually for every single page one wants to read, but I thought there has to be something more handy. Calibre is a great software for creating content for eBook reader devices and it can even process RSS feeds (though skimming through content as I do during reading my feeds is not exactly what you can do best with an eBook reader device). Nevertheless I wanted something more integrated into my favorite browser, Firefox. Surprisingly I couldn't find a single addon for Firefox that fits this purpose.

Finally I managed finding three web services that can create ePub files from webpages:

Web2FB2

The most simple one is Web2FB2, although it's name may suggest something different that service also creates ePub files. I said it's simple because it really just takes the webpage and creates an ePub file. It doesn't try to detect the main text or use RSS feeds or remove the navigation, but at least it includes all images. It seems to me that it ignores printing stylesheets, too. So it depends on the webpage and which parts of it you are interested in how well the result is usable.

zinepal.com

The probably most sophisticated service I've found is zinepal.com - it's basically intended for creating newspapers from webpages, feeds or Google news or blog search results. You can add up to 5 (25 in the pro version) webpages to a so-called „Zine“ for which you can then choose several options and get it as PDF or ePub. When you are pro-user (which are you automatically for the first month of usage) you can even add your own logo or introductory section. You can also select which fonts shall be used and as pro user you can add advertisement (which of course is more intended for republishing the result than for personal use ;)). Besides that it creates quite useful ePubs (and PDFs) from the specified pages and feeds, it removes almost everything but the actual content, the only negative point is it doesn't add a table of contents for the included pages.

Instapaper

Instapaper is „A simple tool to save web pages for reading later.“. Nevertheless it looks really interesting to me as it is indeed quite simple, you even don't need a password for your account when you don't want one (but it still supports multiple folders, starring pages, iPhone apps…). With a simple bookmarklet you can save pages for later reading. And the best is: you can create an ePub of all your unread pages. As zinepal.com Instapaper most of the time removes everything but the essential text (and unfortunately like zinepal.com also most/all? images…), but as a big plus it adds a table of contents so you can quickly jump between the included pages.

Thus Instapaper looks exactly like what I've been looking for - a tool to make it easy to read all that stuff I find online but want to read in a quiet (or noisy) moment on my sofa (or on the train). I can collect the stuff I want to include and then when I want to get something to read I simply click the epub link and save the ePub file on my reader (switching between files is one of the slower operations, thus having it all in one file is also a big plus). And for the Amazon Kindle there would even be an auto-delivery option. The only thing I'm missing a bit are the images in the webpages, I hope that the algorithm for extracting the text will be improved, but of course I understand that such an algorithm is hard to create and always includes a lot of guessing.

If you should have discovered other ways for getting the web (or at least some parts of it ;))into an ePub file, please let me know!

Read or add comments to this article

by Michael Hamann at February 14, 2010 10:24 PM


Subscriptions

Subscribe: planet feed

About

This planet aggregates feeds from blogs powered by DokuWiki. Posts are not necessarily about DokuWiki but reflect the diversity of DokuWiki users.

Do you blog using DokuWiki? Send me a mail and I'll add you to the planet.