Ionization Chamber - my first attempt

The simplest of all gas-filled radiation detectors is the ionization chamber, today I will describe my first attempts to build and use it, I will also say a bit about my further ideas regarding this subject. The device is presented below.

The circuit is simple, it contains 2 (3 in later version) NPN transistors in Darlington configuration, the emitter is connected to the mass, the collector and Vcc is connected to a digital voltmeter, the base is connected to an electrode that is in a metal can, the can is plugged to Vcc. Vcc=5V (12V in later version). Input resistance of the multimeter is 10MOhm. In later version I plugged a capacitor 220nF in parallel to the multimeter, it was used to filter noises.

A can, together with the electrode makes an ionization chamber, rest of the circuit is used to gain a signal from the detector.

Temperature-measuring device made from two wires

Recently I've found an article about thermocouple, a simple device that can be used to measure temperature. It uses Seebeck effect where a current in conductor is created if the conductor is heated. The amount of current depends on temperature and type of the conductor.

The thermocouple consist of two different conductors, they are in the same temperature, but they create different amount of voltage because they are different materials. A thermocouple measure difference between those voltages.

I've tried built this sensor as simple as possible, so I used iron nail and a copper wire as parts of the thermocouple. I used a multimeter to measure voltage created by the thermocouple.

Is it possible to write a program in C without using semicolons?

Yes, it's possible! In this text I will show a set of tricks to do it. I will present this on a simple program that that reads two numbers from STDIN and prints theirs sum to the STDOUT.

Normally I would start this program from declaring two variables:

int a, b;

Unfortunately, there's a semicolon at the end of the line. It can be omitted by using variables already declared for the main function:

int main(int argc, char* argv[])

I will use argc as a and argv[0] as b. Normally, next thing would be reading two values from STDIN and placing them in a and b variables. It could be like this:

scanf("%d%d", &a, &b);

Once again, there's a semicolon! This one can be skipped by using 'if' statement:

if (scanf("%d%d", &a, &b)) {}

The same trick can be used for printing to STDOUT:

if( printf("%d", a + b ) ){}

Above code compiles and works correctly, but normally the main function should return zero if everything went OK:

return 0;

This semicolon can't be avoided by using the trick with 'if' statement, but we other construction can help here:


That's all, below is full source code:

#include <stdio.h>
#include <unistd.h>

int main(int argc, char* argv[]) {
    if (scanf("%d%d", &argc, &argv[0])) {}
    if (printf("%d", argc+argv[0])) {}
    if (brk(0)) {}

Leave a comment, if you know other interesting riddles or tricks that can be used here!

A proof of concept of a simple sonar

Sonar is a ship device detecting objects in surrounding water. It analyzes sounds that propagates in the water, an active sonar uses the sounds that it produces, a passive one uses the sounds from other sources (e.g. eruptions or sounds of other ships). A wide range of frequencies can be used, from infra-sounds to ultrasounds. A simple, active sonar can be built from a couple of electronic elements and a PC computer - I will present this idea here.

fake reservoir and a floating sonar

I used a piece of Styrofoam as a ship and a bowl as a water that surrounds the ship. The bottom of the "reservoir" is modeled by a couple of floors tiles.

Breaking CAPTCHA in Python

Usually CAPTCHAs are analyzed by using neural network, it's a good approach, but it may be overcomplicated in simple cases. Presented below, much shorter algorithm can produce sufficient results for uncomplicated CAPTCHAs.

In this algorithm an image with unknown letter is compared with samples of known letters, the letter in the most similar sample is probably also the letter in analyzed image. It was implemented as a Python script, usage presented below:

captcha breaker in python, sample of usage
bash-3.2$ python test1.png 
other sample of usage of the script for breaking CAPTCHAs in Python
bash-3.2$ python test2.png 

It can't be directly used on a raw CAPTCHA, firstly small artifacts have to be removed from the CAPTCHA, secondly each letter should be stored in a separate image.

Edge Detection by using Genetic Algorithms


In this post I will present an algorithm for searching edges in images by using genetic approach.


The image is preprocessed before its usage, firstly Gaussian blur is used to remove small artifacts that could pollute the result. I could be also done by using image downsizing and upsizing as I presented in the post about breaking captcha. Secondly the image is converted to black and white version to simplify the implementation.

Original image:

input image used in edge detection based on genetic algorithm

Edges found by using a genetic algorithm (100 generations):

output image produced by genetic algorithm applied to search edges in the image

In presented version each children has only one parent, so gene change is provided only by mutation. Each specimen has two genes: X and Y that describes a location on the image. If a specimen has a good set of genes (they point to a location near the edge), then he's healthy and strong so he can breed, but if his genes are weak, then he's weak too and soon he dies. The edge is defined by a fitness function as a point that has neighbor points with different color.

Strong species breed so after couple of generations theirs children will cover the whole edge. The final result is a set of genes (each is a point on the image) in the last generation.

Virtual Machine implemented as a Domain Specific Language in Ruby


Some time ago I created a simple programming language that was compiled to its own assembly language, a file in this assembly language could be executed in a Virtual Machine or be compiled to an executable form. Today I will present an idea how to use Domain Specific Language (DSL) created in Ruby to load and execute the assembly file just as a regular Ruby script.


A sample of an assembly file is presented below, it's intuitive except the "int" mnemonic, it means "interruption", int 0 pops element from the stack and prints it on STDOUT. There aren't any registers, everything is done by using a stack.

    int 0

    call bar

    push 13
    call foo