RSSAmplifier

Blog

Code intoxicated

Recent content on Code intoxicated

cristian.ioRSS feed ↗27 posts

Latest posts

Annotated examples of paperd.ink programs

A couple of weeks I got a paperd.ink display. I must confess I bought it on impulse. I am a sucker for EInk tech. But upon receiving it I realized I just don’t know how to code for it. So I decided to embark on a masochistic journey through the world of embedded programming, mainly by reading the source code of the few examples available. As I was going through that, I thought it would be…

paperd.ink - notes from a non-expert

I am a sucker for E Ink displays. So when I saw https://paperd.ink/ I joined the waiting list immediately, even though I don’t know much about hardware. I got my dev kit yesterday and so far managed to run some sample apps, and learned some things along the way. This post is a note to myself aiming at reinforcing the lessons learned, but might be useful to others new to this.

Blender Texture

A post for myself. Something I forget to do everytime. Not anymore: Here’s a step by step of how to apply a texture to a 3d model using Blender. 0. Create model or import STL 1. Remesh Open the Object Data Properties menu, then Remesh, choose the appropriate Voxel Size, and click Voxel Remesh. To check if this worked, go to Edit mode (Tab), and zoom into the model. You should see it has…

macondo: making Docker-wrapped applications easier to run

I found this article and it reminded me of a tool I wrote a couple of months ago called macondo. In this post, I will try to explain what it is, why I wrote it and some of the drawbacks I’ve found. I am not trying to justify its existence of it or even suggesting this is the right way of doing things. I haven’t decided whether I like it or not.

Kotlin's .copy() gotcha... when Java is better

Kotlin’s data classes are cool. They are the recommended way of replacing POJOs and it is usually recommended to use them with vals so the classes are immutable. They come with a handy copy() method that “clones” the data class, which can also be parameterized with any named argument, so the new object has all the fields of the original class + the overridden fields. So far so…

Tools I use

It should be no mystery that tooling is a big part of anyone working with computers. They can make a huge impact on your workflow and productivity. I decided to maintain a list of the tools I feel define my workflow, focusing on the tools that I don’t see used as much by my peers (e.g. I don’t list my browser or anything commonplace): NixOS I used macOS heavily for at least 7 years.

YouTube flagged me so I built a Telegram bot to proxy/watch videos

TLDR; I use ad blockers. YouTube flagged my account and devices. I can only watch around 1 in 4 videos. So I wrote a Telegram bot that receives YouTube URLs and replies back with the video. The problem I use adblockers to have a semi-decent experience on the Internet. I mainly use UBlock Origin plus some DNS ones. One nice feature of UBlock Origin is that it does block ads from YouTube videos.

Automatic work session recordings with OBS Studio + TaskWarrior + TimeWarrior + YouTube

Hacker News discussion Not long ago I read a comment on Hacker News about tips to improve one’s performance as a developer; it recommended a system of recording oneself while working and someone suggested uploading the videos to YouTube (as private or unlisted) for future revision and as a backup. I liked the idea so I wanted to give it a try myself. Of course, like most of the stuff I do,…

Include versions in published POM file when using Gradle platforms (BOM)

Gradle platforms are a nice feature introduced back in Gradle 5. They allow you to align the versions of the dependencies across multiple projects by declaring them explicitly in a “platform module”. This is no more than Gradle implementing Maven’s BOM (bill of materials) pattern. This post is not intended to sell you the idea of Gradle platforms. In fact, it assumes familiarity…

Mentorship

I enjoy mentoring too. If you need need some engineering mentoring, especially around Java (and other JVM languages), data engineering (Flink, Presto, etc.), backend engineering, infra (Kubernetes, Docker, etc.), please send me an email or contact me via telegram at https://t.me/casidiablo. Sessions price can vary depending on the topic, but it goes for around 80USD/hr.

[RedisConf 2018] Slides of my presentation on ReBloom

You can download the slides here: Leaveraing Bloom Filters on Redis

Connect to VPN using Pritunl + auto 2FA

At work we use Pritunl to connect to the office VPN. This process involves entering a password and a two factor authentication token. Tired of manually connecting using the graphical user interface and pulling my phone to get a new 2FA every time, I went ahead and tried to automate the process. It turns out that, in Linux, Pritunl offers two clients: CLI and GTK. Using the CLI one, once you have…

Idempotence layer on bloom filters

TLDR: we run several applications consuming multiple real-time streams. These applications implement idempotence using Redis sets. In this post I describe our journey moving to bloom filters (using the ReBloom module), which brought down our memory usage by almost 10x. Let’s briefly define idempotence: An operation is said to be idempotent when applying it multiple times has the same effect.…

So... I have an album on Spotify

First of all, let me clarify something: I’m not a musician. I don’t even know the difference between DO and RE. I’m a human just like you (unless you are some future alien reading this, in which case all I can say is: cool), so I like music. And using a synthesizer is rather easy to create your own, so I did it, and it’s live and feels great.

Find self-references in (possibly nested) collections

I found a nice trick reading part of the ElasticSearch client for Java. Say you are given an object (could be a map, a list, an array or anything) and you need to make sure the same reference does not show up in any of the children objects (or theirs). Here is how this the ElasticSearch guys solved this problem: static void ensureNoSelfReferences(Object value) { ensureNoSelfReferences(value,…

Mutability and Java 8's method references

Method references is a nice feature introduced in Java 8. It lets you make your lambdas even more concise: // from... someStream .map(item -> obj.someMethod(item)) .moreStuff... // to... someStream .map(obj::someMethod) .moreStuff... Some linting tools will even suggest you replace your lambdas with method references but, watch out, that sometimes have some unadverted consequences. For instance,…

Merge multi-project test coverage: Gradle + Jacoco + Sonarqube

I’m assuming you got here because you are using Gradle with Jacoco and noticed that integrating it with Sonarqube does not work perfectly out of the box. Specifically, when your project has multiple modules, you might have seen that Sonarqube’s coverage report ignores code in module A covered by tests in module B. In fact, this is a problem that you will find even if you are not using…

Send Flink's logs to ElasticSearch using Log4j

Flink uses slf4j as its logging façade, and log4j as the default logging framework (they support logback too). Logs are accessible via Flink’s UI in the JobManager tab which is good for short-lived jobs but unusable for long-lived, streaming applications. You probably want your logs out of there somewhere else; here’s how you can send them to ElasticSearch so you can access them, say,…

Paste multi-line commands in Scala's REPL

Use :paste scala> :paste // Entering paste mode (ctrl-D to finish)

Shuffle or pick random lines from a file

There comes a day in the life a developer when one needs to choose random lines from a text file. This is useful for a myriad of reasons, like taking a random sample of a CSV file, or shuffling the code of your coworkers, just for fun. There are multiple tools in the UNIX toolbox to solve this problem, but the shuf utility is by far the most elegant: # shuffles a file and prints to stdout shuf…

Customizing pyspark app start up script

A nice feature of pyspark applications is that you don’t have to use spark-submit manually. Instead, when you instantiate a SparkContext instance, it will take care of running spark-submit ... pyspark-shell for you. Sometimes, however, you may want to customize that launch a bit. For instance, it is useful to tell spark-submit to include specific libraries in the classpath; which is in and…

JVM notes

A class file consists of bytecode and a symbol table There are two kinds of types: primitives and references Reference types can be either a dynamically allocated class instance or an array. There is no way to distinguish primitive types within bytecode except for the operands used to manipulate them. Each operand has a different version depending on the type: e.g.: iadd, ladd, fadd and dadd are…

the incident 'might' make an agreeable break to the routine of the day

Min 39, sec 48

Plantasia

A piece of art from Mort Garson. A good companion for when you need to go there. Happy trip!

Estimate Gas when using Oraclize

Ethereum transactions require you to pay a fee that is measured with gas. Every instruction executed by the EVM costs a certain amount of gas, so before queuing your transaction, you have to specify a gas limit and a gas price. That gas is paid in ether, so for example, if your transaction has a gas limit of 82470 and your gas price is, say, 1 Gwei (0.000000001 ΞTH), then the cost of the…

God bless Kovan (and Parity)

Learning a new technology is always a daunting task, specially when in its early stages. Ethereum is one of such technologies and, soon enough, after starting your journey you get a lot of new terminology/projects thrown at you: Solidity, MetaMask, Mist, Serpent, Rinkeby, Ropsten, Kovan, Parity, Truffle, Geth, etc, etc. As you start wrapping your head around some of those new concepts it is common…

The Rabbit Hole

It seems like no matter how much experience I gain as a developer, and as a human being, time to time I end up going deep into some rabbit hole. This time, in one of those deadly spirals of random clicking on the net I ended up learning about Ethereum. How did I get from there to creating Hugo-based blog hosted on the InterPlanetary File System? I thought I was done with blogging.