Let’s talk a bit about memory management

So after almost finishing my class on operating systems and memory management (at the easy and superficial stuff) i’ve always wondered how one can put all the theorems in a touchable context, and right after i went into the bathtub it hit me.

I’m not talking about memory management methods right now, just if you have no idea about it, think of all the methods you COULD use to fill an array or slice (talking golang now) with other arrays or slices.

The thought is rather easy, let’s say you have an empty slice with len(s) = 32 and you need to fill it with an amount of other slices that are filled with whatever, some random data. The first iteration of data would be pretty straight forward, just putting them at the first free position (concerning it doesn’t exceed the length of the array, in this case 32) – otherwise it should either be rejected or enqueued. Now the fun part begins when you delete random slices from within the slices (e.g., s[0..7] and s[11..14]) and then try to put new data in there.

Now if you’ve got two slices enqeued with len(q[0]) = 4 and len(q[1]) = 8. In case you just put the data in the first fitting (Hint: That’s a keyword) place, there’s no more room for q[1].

This is easily adaptable without even having to get on a lower level of memory management on the OS abstraction level. You can play with this idea – if you’ve got sample implementations of this “problem” (I wouldn’t call it problems, but make of it whatever you want), hit me up so i can link them here πŸ™‚

UPDATE: I did some untested stuff in a go playground, you can play with it. https://play.golang.org/p/ei5QgXBh_7S

Let’s talk a bit about memory management


The last few nights seriously took my energy level to a new low. Maybe part of that problem is the fact that since I’ve build this depression I’ve been watching Twitch-Streams to sleep in. Bad, bad, baaaad idea. So now i want to get rid of that and instead listen to soothing music when i get to bed. Not that hard, but somehow i don’t want my phone to be responsible for that. And my laptop? Way too loud, too much energy drain, etc.

So what do we do?

Easy peasy, let’s build an AlarmPi – and now that we’re on it: Let’s use it as an alarm as well. And now that we’re on it: Let’s build a mobile App so we can change all the settings. So, in my terrible sleepless idea-digging I figured i need the following things:

  • A playlist with soothing music (YouTube?)
  • A playlist with music to wake up to (YouTube?)
  • The possibility to set volumes, etc.
  • A neat web interface
  • A randomizing-button so we don’t get up to the same shit
  • A mobile app to control the neat web interface
  • Alarm Clocks (more than one?)
  • If more than one alarm: different playlists for different occasions?
  • Maybe some timers on when to start the soothing music and when to stop?

Looks reasonable, eh? So the Raspberry Pi is sitting on my desk, now let me get a few appointments out of the way (math exams, hooray.) and we’re off to go.

I’m still wondering if Go is the right language for that or whether i want to try something new. Suggestions?


PiDioder Tutorial

Hey folks, i finally found all the old links and descriptions and images for this tutorial, will probably update it in the next few weeks (As of Feb 20th).


The Materials you need:

  • Voltmeter
  • Some cables
  • Soldering Gun (and accessories)

if you know how to use it, you should always try to measure the voltage between the mass/ground and the source you’re working on, i will add the voltages that are expected
in this tutorial.

the hardware part

Step 1

2013-12-08 12.40.53

open the box with a screwdriver, you can damage it, but i would strongly suggest you be careful – cause you might want to use it later on

2013-12-08 12.41.26

this is what the box looks like if you opened it without damaging it. you can easily pull out the circuit board now.

Step 2

now you should mount it on a stand or somewhere similar to have a solid working base that doesn’t move while you’re working. this is how the UNCHANGED circuit board looks like.

2013-12-08 18.20.01

now you need to disconnect the existing connections between the mosfets and the potentiometer wheel-thingy (help me out, what is this thing called?) (thanks to /u/CastleSeven for giving me the right name).


click on the image to view it in full size. on this i already cut the connections between the mosfets and the potentiometer. i’d recommend you to scratch off the first layer first to make the copper-connections visible and then disconnect them at the exact positions i marked on the image. otherwise you’ll have problems soldering your new wires on it.

Step 3

2013-12-08 18.23.46

now you need four wires (one for each channel and one for the mass), try to keep them the same length. it will help you in the end.

Step 4

voltages between the mass (blue cable on the bottom) and the connections before the mosfets (the three big black blocks) should be 0V right now. if it’s not zero, you need to scratch a bit more.


the mass wire! you need to solder one of your four wires to the blue wire on the bottom of the image (the one that has the description “-” on the circuit board). hint: paint the other end of the wire in some color so you know it’s the mass wire, it will come in handy.

you need to skin the ends of the new wires, whirl them up and solder them to the three points i marked with the numbers “1”, “2” and “3” – beware! the wires for point 2 and 3 should not touch each other!
the three numbers represent a color in the RGB color space, i’m not sure which mosfet is in charge of which color. if you figured it out (mine is already finished and i can’t access the board anymore) please let me know.

2013-12-08 20.20.42

this is what your board could/should look like after you’ve soldered all the wires and probably did some fixation of the wires.

Step 5

2013-12-11 02.00.54

i used a 26 pin socket connector to connect the wires to the corresponding pins of the gpio outs. take a look at the pinout scheme for the pi on this page: http://modes.io/raspberry-pi-serial-communication-for-fomophobia/

for software reasons we need the following pins:

  • Ground (Mass), which should be connected to the mass wire
  • GPIO 4
  • GPIO 17
  • GPIO 18

i will explain what this is about in the software part of this tutorial.

2013-12-11 02.01.33

i used a Ferm CTM1010 to cut a hole in the case i got for the pi for the wires. simultaneously i widened the hole for the power cord on the original case of the circuit board. then i closed the whole thing with some bandage tape

Step 6

actually you should be done with the hardware part right now. to the software part!

the software part

we are going to make use of sarfatas pi-blaster library – which enables PWM (pulse wide modulation) on some GPIO pins. now you know why we used some specific pins. all credits belong to his awesome work!

Step 1

as i’m not going to tell you how to install an operating system on your pi we start by following the how to from the pi-blaster github page

Step 2

check if everything is working correctly by typing echo "0=1" > /dev/pi-blaster into a terminal. mark the color you see and then undo it by typing echo "0=0" > /dev/pi-blaster you will need the numbers of all three colors, so do the same with 1=1 and 2=1

Step 3

if every color works and you know the number of the color, clone my small go-pidioder project on github and run it (you need go for it to work). take a look at the main.go file and change the consts to the values you wrote down. start the server by typing go run main.go and wait for it to start. it simply starts a small webserver on port 1337. if you can open the website and click one of the buttons, you’re done! have fun!

help me help you

I’d love to make a video tutorial for the pidioder as well as update the information concerning newer versions of the IKEA Dioder and the piblaster library. but sadly i currently can’t afford anything (being a student seems to have its drawbacks i guess) – so if you’re interested in helping me create updated versions i’d kindly ask you to make a small donation πŸ™‚

in action

this is just a small thing i hacked together to show some “random disco mode”.


big thanks to nemo for figuring out the technical stuff

feel free to contact me for any further information or if you think something is missing in the tutorial.