Skip to content


Notes on docker.io and lightweight php (i.e. for wordpress)

So I moved a couple of sites from a friend’s FreeBSD server to a linux one and decided to learn to use Docker along the way. Once I’ve created an image (based on debian/jessie) and added required dependencies, php applications started to run, except for their mail functionality. Even after installing sendmail it would not work. Fortunately, it makes little sense to run SMTP stack inside of a docker container (since the host probably has it anyway), so here comes ssmtp to the rescue. ssmtp needs to be configured with the corrent mailhub to receive the emails. And here comes the interesting part — how do you know the hostname (or IP address) of the host, when inside of a container?

In short, you don’t. There are some workarounds for sure, but they are not ideal. I decided to “fix” the IP address of a docker host by using --bip option in /etc/defaults/docker.io like this:

DOCKER_OPTS="--bip 172.17.42.1/16"

So the base docker Dockerfile for php projects looks like:

FROM debian:jessie

RUN apt-get update && apt-get install -y \
php5-fpm \
php5-cgi \
ssmtp \
vim-tiny \
locales

RUN dpkg-reconfigure locales && \
locale-gen C.UTF-8 && \
/usr/sbin/update-locale LANG=C.UTF-8

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN echo mailhub=172.17.42.1 >> /etc/ssmtp/ssmtp.conf

ENV LC_ALL C.UTF-8

Nice, but not as clean as I’d like it to be.

Posted in general, software.


BleedingEdge 2012 – recap

Wow! Totalno presenečen sem bil nad obiskom predavanja, ki je vsaj po mojem občutku teklo gladko. Veliko zanimanja je požel projekt Weinre, mislim pa da je bilo poslušalstvo navdušeno tudi nad PhoneGap/Cordova ogrodjem. Se priporočam za kakšen feedback in pa seveda tudi za demonstracijo vaših produktov, ki bodo temeljili na tej tehnologiji. Ob začetku predavanja sem imel kar nekaj težav: najprej Win7 niso hoteli dati iz sebe na projektor več kot 640×480. Očitno so ga nekako napačno prepoznali. Tako da sem uporabil sposojen notebook, na katerem sem odprl Remote Desktop na moj notebook. Druga prepreka pa je bila konfiguracija omrežja, ki je preprečevala da bi iz mobilnega telefona lahko prišel do računalnika in demonstriral Weinre v praksi in v aplikaciji. No, pa drugič, ko bo official Weinre build deloval tudi na Windows Phone.

Posted in Uncategorized.


Bleeding Edge 2012 – Razvoj “native” mobilnih aplikacij za različne platforme

V priponki je na voljo predavanje kot tudi izvorna koda uporabljena in demonstrirana na predavanju. Uporabljeno je ogrodje Apache Cordova (verzija 2.2.0rc1), prikazuje pa urnik konference BleedingEdge 2012.

Posted in Uncategorized.


Ntk2012 – prezentacija in demo

V prilogi je tako prezentacija kot demo koda, ki je bila uporabljena na predavanju. Enjoy!

Posted in Uncategorized.


Android and stack traces

While doing native development for the Android platform, native segmentation faults happen. And they are not very descriptive to the usual developer (which includes me, of course). You would see something along those lines: Continued…

Posted in Uncategorized.


O negibnem dojemanju

Pod roke mi je prišel tekst, ki se mi zdi vreden objave v širšem kontekstu. Gre za Takuanovo pismo Yagiu Tajima-no-Kami. Morda gre v tekstu za pomoto in gre dejansko za pisma Yagyū Munenori, kar pa zares ni toliko pomembno kot dejanska vsebina.

Budistični nauk razlikuje dvainpetdeset stopenj duhovnega razvoja. Eno izmed stopenj imenuje zastoj, ko se človek prilepi na eno samo mesto ne more več naprej. S tvojim mečevanjem je nekaj podobnega: če nasprotnik udari po tebi in so vsi čuti zbrani na njegovem meču, tedaj si pod njegovim vplivom in nisi več gospodar lastnih gibov. Temu pravimo zastoj, ker obstaneš pripeljen na eno samo mesto.

Celoten tekst je na voljo v PDF zapisu.

Posted in general.


Oh really? Password too long?

We are in 2011 after all, so seeing an error message that a password is too long is… well embarasing.

So, given that passwords shouldn’t or should I say must not be saved in a way that enables anyone (even administrators) to retrieve the plaintext version of a password, we’re talking about some sort of hashing. Whether hashing algorithm it is MD5 (avoid) os SHA1 (and in order to avoid precomputed hashes of passwords (known also as rainbow tables) you should use salting techniques with hashing algorithms), the length of a calculated hash does not depend on the length of the plain text password.

So, why is the length of the password limited to 16 characters? Beats me.

Of course, I recommend developers to use bcrypt instead of SHA or MD5. Bcrypt is very slow (compared to SHA or MD5), which is a good property to have for checking passwords — you don’t want to have a super-fast hashing/crypting algorithm thus effectively preventing brute force attacks.

Posted in general, software.

Tagged with , , .


Airport Extreme and PPTP

I was having issues with VPN connection (PPTP to be exact) to my customer. I was connecting with Mac OS X and Windows (tried Windows 7 and Windows XP sp3) and could not make it work. All computers are behind Airport Extreme. When I connected to internet directly (not through Airport), everything worked fine. While googling around, I found many posts referring to a lengthy post describing to enable the default host on Airport base station. I had that configured already, so I was looking for solution elsewhere, since I just could not get the clients to connect. The error I was getting was “PPTP received unexpected message type = 6699“. And that error was printed in the log file after several sent [LCP ConfReq id=0x1 ] messages.
Airport-extreme-config
Since “Default host” setting is sort of dangerous (if don’t use a firewall), I decided to turn it off and to check with tcpdump what goes on on the wire (maybe the /var/log/ppp.log isn’t telling me everything).
To my surprise, PPTP connection was established successfully, so there is a hint for you: if you have problems establishing PPTP connection, try disabling the “Enable default host at” in your Airport configuration.

Posted in general, OS X.

Tagged with , .


Netduino – the beginning

netduino
I’ve received Netduino Plus yesterday. After playing with the on-board LED and button switch, I tried something else today. Since I don’t have a background in electronics, I googled a bit, asked around and connected LED, a couple of resistors and a transistor (BC108C) to control the external LED with the digital output of a Netduino.
The project goal is simple enough for a seasoned electronics guy, but for me, it is quite a challenge:

  • Function as a regular thermostat
  • Which can be controlled remotely via SMS as well:
    • to check current temperature on location
    • to set desired temperature on location
    • to switch power on or off for the oil boiler (heating furnace) and water pumps
    • to alert via SMS when the temperature drops below a defined threshold

The Netduino/Arduino boards are amazing in that they offer a high level language to control them and create your stuff. You can develop & debug with Visual Studio in case of Netduino boards using the familiar interface and software development skills. There are tons of shields (addons, plugins) available for those boards as well. I’m planning on integrating real time clock, digital temperature sensor and a cellular shield (GSM functionality) and a graphical LCD next. Baby steps.

So, how did I wire the external LED?

First, I had to learn some basics:

  1. You have to limit current for the LED, otherwise it will burn
  2. You have to drop the voltage, or the LED will burn

You can limit current by using resistors. I used the 5V pin on the Netduino, and LED needs only 2.5V, so I had to halve the voltage and limit current at the same time. You can do this simply by using two resistors. Smart people call this voltage divider. First, I calculated the maximum current that is allowed for the LED, and that is 20mA. Given the 5V voltage and formula V = R*I, the resistor comes out to 5V / 0.02A = 250Ω (Ohm). Given that, I now needed to lower the voltage, which in my case is simple. The formula for voltage divider is Vout = Vin * R1 / (R1 + R2). Now that I know that R1 + R2 should be 250Ω it is easy to calculate that R1 = R2 = 125 Ohm. I actually used 120Ω resistors as I didn’t have 125Ω ones.
So, the LED was lit, but I wanted to control it via software, so I needed a “switching” mechanism. I asked around used NPN transistor for that. I connected the LED output to collector of a transistor, and connected the emitor part of the transistor to ground. Now, we need to tell the transistor to “open up”. I figured I’ll just connect the digital output to base of transistor, but friendly guys on a Slovenian electronics forum suggested that I use a resistor in between. So I did.
The end result? A program, which turns the LED on whenever I press the button. The final schema looks something like this:
Blinking netduino with external LED
This image was made with Fritzing which looks like a very promising project as well.

Posted in general, Netduino, software.

Tagged with , , , .


Bleeding Edge 2010

Že tretja Bleeding Edge konferenca je za nami. V prilogah najdete tako prezentacijo, ko tudi demo aplikacijo (ki zahteva VS2010 ter nameščen ASP.NET MVC 3 preview 1) ki demonstrira določene tehnike predstavljene med samim predavanjem.

Vesel sem, da ste se odzvali v tako velikem številu in upam, da bo naslednjič tudi tako.

Posted in software.