RSSAmplifier

Blog

Tadas Sasnauskas

tadas-s.github.ioRSS feed ↗36 posts

Latest posts

DIY Roland JV-1080 expansion card

Recently I restored a Roland XP-60 synth for a friend. It’s a digital sample based synth with possibility of expanding sample set with up to 4 expansion cards. And, while looking at service manual I got carried away a little… Those expansion cards have a pretty straightforward interface - 8 bit data bus, 20 bit address bus, a few chip enable pins. Looked like something very DIYable. Result of the…

Demystifying BMW Eccentric Shaft Sensor

Introduction So I recently got into the impractical hobby of owning a relatively old and high mileage BMW. And apart of numerous leaks of various fluids I’m now having trouble with this weird and wonderful BMW’s Valvetronic “thing”. And one of key components of it is the eccentric shaft sensor: BMW OEM part number: 11377527016 It’s located at the top of the engine and measures angle of this…

Creating custom SELinux policy for a small network service

Introduction From RedHat article about SELinux : Security-Enhanced Linux (SELinux) is a security architecture for Linux® systems that allows administrators to have more control over who can access the system. In this article I will try to show how a small custom network service can be hardened with help of SELinux policies. Note that this article is not an introduction to SELinux and assumes some…

Avoid ActiveRecord queries starting with model class

When writing a Rails resource controller code it’s quite common to start with querying from model class itself: Model.find , Model.find_by , Model.where , etc.. After all for simplicity sake it is what’s given in some Rails guides examples : class ArticlesController < ApplicationController def index @articles = Article . all end def show @article = Article . find ( params [ :id ]) end def new…

Developer friendly multi-mode Docker image entrypoint

Context Most reusable Docker images from Docker Hub or similar repositories are designed to run a single process (e.g. database, web server, cache storage). Expectation is that you can run it with reasonable defaults using docker run <image>:latest . And most of customisation is done through environment variables. That default mode command most of the time will be configured through ENTRYPOINT .…

Avoid ActiveRecord model self-save

I’ve seen this, what I’d call anti-pattern, number of times in pretty much every code base I worked with. When controller action updates 1-2 model attributes it is tempting to move #save call into the model itself. Say we have an article section in some private knowledge base. It started with a generated article scaffold. Here’s the controller code: class ArticlesController < ApplicationController…

Quick Jira search

An average tech company nowadays usually uses Jira for issue/project tracking, Confluence as knowledge base and GitHub for source code repositories. Depending on company size and age, this trio may contain an extensive body of knowledge. But searching it can be daunting: visiting all three and typing your search keywords is not that quick. For that I have one of my favourite “office life” hacks:…

SSH Authentication using Lithuanian Personal Identity Card

!!! 2026-01-01 Update PWPW S.A are on their way out and being replaced by MaskTech International GmbH produced cards and software. So this article is somewhat outdated. Disclaimer I have absolutely no idea what I am doing. Smartcards, PKCS 11 and other related technology is greek to me. Do not try this in any kind of serious setting, this is for test and entertainment purposes only. Background…

My first Rails contribution - no_store HTTP cache directive

Rails is generally a feature rich framework and I rarely find anything really missing when developing applications with it. However I recently discovered that current Rails HTTP caching header facilities do not provide a method to set Cache-Control: no-store header. And it’s a popular way to prevent browsers from rendering a possibly stale web page view when browser’s “Return” button is used. This…

Devise serialize into session trick

I always thought Devise is a great example of a remarkably flexible and modular behaviour implementation. To a level it is not fully documentable. Instead, after you got started with the basics, its source code serves best as documentation (and is a good read overall). One of the many extension points which has attracted my attention before is serialize_into_session / serialize_from_session…

Extending ActiveRecord associations

Ever found yourself having difficulty to decide if method belongs to parent or child model? Let’s say we have a Blogger and Article models. And profile section of our “blogging platform” displays list of articles published this current month. Our option 1 is doing it in Blogger model: class Blogger < ApplicationRecord has_many :articles def articles_this_month articles . where ( 'created_at > ?' ,…

Adding delays to reduce ESP8266 power consumption

I’m currently working on a small ESP8266 gadget which runs UDP server and does some actions based on packets received. Main loop goes a bit like this (note: I’m using Arduino core): void loop () { size_t size = udp . parsePacket (); if ( size > 0 ) { // handle the packet } } Looks fine until you remember that ESP8266 is a 32bit micro running at pretty whopping (for $1 price) 80Mhz frequency. So…

Aisler - new KiCad friendly PCB prototyping service

So I’ve been raving about OSH Park and how good they are for about a year now. However there’s one tiny issue with them - cheapest service turnaround (from upload to PCBs arriving by post) is roughly 3 weeks if you live in EU. From this year’s FOSDEM “KiCad project status” talk I learned that there’s new player in this - AISLER . They support manufacturing PCBs directly from KiCad’s ‘.kicad_pcb’…

(Not so) interesting I2C PWM RGB led driver NCP5623

I was looking to something that could offload doing PWM from microcontroller + save precious I/O pins and found NCP5623 : Triple Output I2C Controlled RGB LED Driver The NCP5623 mixed analog circuit is a triple output LED driver dedicated to the RGB illumination or backlight LCD display. Sounds great, by my TL/DR of the datasheet would be: 5 bit PWM resolution is not enough if you plan doing artsy…

First board from Oshpark

Expectation (the amazing KiCad 3D preview): Reality:

ESP8266 OSC to MIDI WiFi bridge for TouchOSC: laying out the PCB

Finally found some time and inspiration to continue working on this small project and prepared the schematic + PCB layout using KiCad EDA . And before I get my first PCBs (from Oshpark ) to actually build and test it, I wanted to share some thoughts about KiCad as a newbie who barely did any EDA work before. For starters - schematic capture is easy and straightforward. Most generic components come…

ESP8266 Strava running stats display (again)

Since ESP8266 is cheap as chips (quite literally - less than £2 a pop) I got a handful and started re-building previous breadboard mockups. Excuse my savage ways of building stuff, but here’s my second iteration of the Strava running stats display : Mildly interesting: most of hobbyist friendly through-hole regulated power supply ICs cost more than ESP8266 ESP-12E.

ESP8266 OSC to MIDI WiFi bridge for TouchOSC

One more quick & dirty ESP8266 mockup: Open Sound Control to MIDI bridge. And this time ESP8266 runs as a WiFi access point to your mobile device (phone or tablet) sending the OSC messages (with TouchOSC for example): Source code available on GitHub: https://github.com/tadas-s/OSC2Midi Combined with TouchOSC this can provide an additional very configurable control surface for one or more…

ESP8266 based Strava running stats display

After a few evenings of messing around with ESP8266 I managed to produce a very simple display of my Strava running stats. For now it only fetches my public profile and extracts two figures: total and current month’s killometrage I ran with the tracker. Nothing terribly useful and definitely nothing complicated, but it’s a fun start. For now it simply connects to my WiFi network and starts…

ESP8266 Flashing Jig

Woo! ESP8266 Flashing jig is ready: Works great with Arduino IDE + ESP8266 board “plugin” + PL2303 USB to serial cable .

ESP8266 WiFi module

It seems I’ve been living under a rock for past couple years not to learn about ESP8266 WiFi module . Long story short: last time I checked embedded WiFi options for hobbyists it was mostly $50-$150 boards or Arduino shields. And now there’s this tiny 10x25mm module for ~3 dollars (literally costs peanuts). Low power, but with fairly quick MCU, 1x ADC, 16x GPIO pins, WEP/WPA/WPA2 encryption, can…

RC2014 update: now in enclosure

My RC2014 is now in a nice sturdy enclosure: Front panel: power button, reset button, power led. Rear panel: FTDI serial cable connection, power jack.

Web MIDI API is surprisingly easy

So I bumped into this neat CodePen snippet “Musical Chord Progression Arpeggiator” by Jake Albaugh . I never really tried to get any formal music theory training so for me this demo seemed to be rather impressive. And I thought it’d be even more fun if I could feed that to my MicroKorg synth. After poking for couple hours with Web MIDI API spec I managed to produce this snippet with section to…

RC2014 retro computer kit

I finally found a DIY retro computer kit that I always wanted: RC2014 (available as a kit on Tindie marketplace ). According to the author himself: RC2014 is a simple 8 bit Z80 based modular computer. It is inspired by the home built computers of the late 70s and computer revolution of the early 80s. It is not a clone of anything specific, but there are ideas of the ZX81, UK101, S100 and Apple I…

DRY up your API integration specs

Once we established that our API code is correctly wired to a component like Doorkeeper then there’s no point in repeating the fact that every request needs to include one or another kind of token header, for example: it '...' do get '/me' , nil , { 'Authorization' => "Bearer #{ token . token } " } # ... rest of the testcase end For request/integration specs this could be easily replaced by:…

ngResource class and instance methods

One not really obvious ngResource trick is adding custom instance methods. Say we have a user resource: module . factory ( ' User ' , function ( $resource ) { return $resource ( ' /me ' ); } ngResource generates some static ( get for example) and instance ( $get , $save , $delete ) methods for us which is great. But what if we need something more? First of all, start with declaring resource in wee…

Taking screenshots of failed Protractor test cases on Travis CI

So. You got a Protractor test suite doing amazing tricks via browser running under xvfb . And then it ocassionally fails, on remote environment like Travis CI only. Now what? Take a screenshot! Protractor uses Jasmine and it has a quick and easy reporter API. Which you can define and add within protractor.conf.js : { // ... rest of Protractor conf ... onPrepare : function () { var…

Learning something new: Rust programming language

New programming languages lately have been popping up almost monthly but one has really caught my eye: Rust . While everyone else is mostly doing new interpreted, garbage collected languages, Rust is quite a bit different. Key points of interest for me are: Rust is compiled systems language allowing to go as low as C Unique memory model – guaranteed memory safety Non garbage collected but it kind…

Why I *love* Linux

One tool fails with message about failed child process. No further details. No verbose mode / no debug logs. strace to the rescue: strace -ostrace.txt -f -e trace=process grunt test:e2e Result? One of many lines in strace output: 9713 execve("/usr/local/bin/java", ["java", "-jar", "/vagrant/node_modules/protractor"..., "-port", "4444", "-Dwebdriver.chrome.driver=/vagra"...], [/* 30 vars */]) = -1…

Kickstart your Vagrant

A couple night adventure in building custom kickstarted CentOS install disks and then Vagrant base boxes from that. It’s rather satisfying to make it work without any interactions from start to end.

Learn Python the hard and *fun* way

learnpythonthehardway.org is a good resource but.. It can be bland and tedious for an experienced developer. I think I might have found and answer for this… (drumroll) Bioinformatics Algorithms (Part 1) course at Coursera. Why? It’s all about searching / scanning and manipulating lots of very long strings ;) You cannot avoid learning core Python data structures and it’s properties, loops, map,…

Couple awesome git tricks

For easier conflict resolution use diff3 format. This guy did a good job explaining it . Found something possibly obsolete but you are not entirely sure if it’s true? Search history for mentions of keyword using the -S flag: git log -S "keyword" This will display log entries of commits that have “keyword” added or removed from the repository.

Learning Python

Why Python is the way it is? Most of my questions were answered in this nice blog post Python and the Principle of Least Astonishment .

Jenkins, xvfb-run and responsive designs

There’s a gotcha if you’re doing responsive designs (which rely on max-device-width) and running tests via xvfb-run: by default xvfb-run launches 640x480px server. Depending on your mobile optimization strategy this might cause mobile stylesheets to kick-in. In our case this hid some miscellaneous sign-up forms and as a result some tests failed. Just use xvfb-run -s “-screen 0 1600x1200x24″ to…

Frontend development with heavy backend API

Frontend development can get bit frustrating when working with heavy slow backend. In my case it’s an API served via HTTP. Solution? Throw in Varnish cache in between with a simple/dumb cache-all config: backend default { .host = "127.0.0.2"; .port = "80"; } sub vcl_recv { set req.backend = default; return(lookup); } sub vcl_miss { return(fetch); } sub vcl_hit { return(deliver); } sub vcl_fetch {…

Compiling Gearman on Centos 5.9

Centos ships with rather old version of Gearman which also prevents installing latest Gearman PHP module via Pecl. Ideally you would want to build rpm with latest version, but in case you want to go the easy (and bit dirty) way here’s a gist I wrote about it .