Programming conversations

April 6, 2014

BitTorrent Sync

A month ago I wrote about File Transfer for mobile phones. There I wrote how I think a solution for file transfer should work. A few days later I found Bittorrent Sync. Problem solved!

December 29, 2013

Use ZeroMQ to control a receipt printer

A customer needed a solution to the following problem. There are multiple web POS systems that need to print to a receipt printer. The web server is not in the same place as the POS terminals, but they are connected to a network. To solve the problem I used ZeroMQ to connect the web server to the receipt printers. The current solution consists of four parts. Web app Web server (connects a PUSH socket to a PULL socket) ZeroMQ device (a multiplexer receives from a PULL socket and sends these to a PUB socket) Computer with receipt printer (a sink that receives on a SUB socket subscribed to its own address) First a user in a browser clicks the button to print a receipt....

November 20, 2013

File transfers for mobile phones

Sometimes I need to copy a file from my computer to my phone. That’s should be really easy. But it’s not. I would like it to work like this: I put a file in a folder. If my phone is on the same network, the file should be copied from the computer to my phone, without further actions from me. And that’s it. The file shouldn’t be copied to a server somewhere else....

November 17, 2013

Redis queue design choices

In a previous post I wrote about simple job queue in Redis. In this post I like to write a bit about the design choices. I think these choices illustrate a point about design. Job handle The job handle in the code is create by the client (with help from the Redis server). This job handle is passed to the queue in Redis and picked up on the other side by the worker....

September 6, 2013

I rewrote my blog software in Perl

In the last few weeks I have rewritten my blog software in Perl. The old version used Ruby. I wrote that version, because I wanted to try out Ruby. The software is about as old as the blog itself. The new software is written Perl. I use many new modules in Perl. For example Moo, Path::Tiny and Carton. Moo is an OO library for Perl. It allows me to write OO code in Perl without any boilerplate....

September 2, 2013

Simple queue in Redis with Perl

Sometimes you need to have a asynchronous worker written in Perl. The small script here takes a job from the queue and executes the code. It only takes a few lines of Perl. use Redis; my $redis = Redis->new(encoding => undef); my $queue_name = 'q'; my $timeout = 10; for (;;) { my ($queue, $job_id) = $redis->blpop(join(':', $queue_name, 'queue'), $timeout); if ($job_id) { my %data = $redis->hgetall($job_id); # do something with data....

September 2, 2013

Dockerfile for Pinto server

Yesterday I created Pinto server on a server with Debian. Today I did the same but with Docker. Docker is way to run processes in their own sandbox. Docker uses a Dockerfile to create an image that run a certain process. The Dockerfile that I used to run pintod looks like this: FROM ubuntu RUN apt-get -y install curl perl build-essential RUN curl -L http://getpinto.stratopan.com | bash RUN mkdir /var/pinto VOLUME /var/pinto EXPOSE 3111 RUN adduser --system --home /opt/local/pinto --shell /bin/false --disabled-login --group pinto ENV PINTO_HOME /opt/local/pinto ENV PINTO_REPOSITORY_ROOT /var/pinto RUN /opt/local/pinto/bin/pinto init CMD /opt/local/pinto/bin/pintod I created a volume for /var/pinto that contains the repository....

July 24, 2013

Dist Milla and Pinto

Today I was working on a private module that I use to write web applications. A few weeks ago I found out about Milla. Milla is a plugin bundle for Dist::Zilla, which makes it easy to create Perl modules. When you’re ready Milla automatically releases your new module to PAUSE. This is really useful for public modules, but not that useful for private modules. Pinto is like CPAN in a way....

July 23, 2013

Create your own YouTube playlists

A few days ago Mindcrack Ultra Hardcore season 11 started. In Ultra Hardcore the play by special rules, that are different from vanilla Minecraft. The biggest difference is that players don’t regenerate health automatically. They need to eat golden apples to increaes their health. These apples are harder to make, because you need golden ingots instead of golden nuggets. Each season players record videos of their perspective of the match and post these videos to their YouTube channel....

June 9, 2013