January 20, 2020

Aggregate Multiple Outputs with Named Pipes

Sometimes I want to make multiple outputs from multiple processes into one single output. Let's say we have to aggregate K8s pod logs from a deployment. We could do that by redirecting each output to a file and follow the file by tail -f like below. tempfile=$(mktemp /tmp/rip-example.XXXXXXXXXX) trap "rm \"$tempfile\"" EXIT pods=$(kubectl get pods | grep Running | grep -oe "app-[a-z0-9\-]\+") for pod in $pods do kubectl logs -f "$pod" >> "$tempfile" & done tail -f "$tempfile" However, that method consumes disk spaces. Read more

October 8, 2019

Using Docker for RubyGems projects

Sometimes I want to create a new gem or modify existing gems to extend/fix them. However, I do not want to install tons of additional development tools on my host machine for that. Recently, I created a shell script which creates an instant development environment on Docker for that. #!/bin/sh -e exec docker run --rm -it \ --workdir=/work \ -v $(pwd):/work \ -v=$HOME/.gitconfig:/root/.gitconfig \ -v=$HOME/.ssh:/root/.ssh \ -v=$HOME/. Read more

October 3, 2019

Creating an Active Job Adapter

Active Job adapter interface I've created an Active Job adapter to run my background jobs on Google Cloud Run via Google Cloud Tasks. Although it is the first time for me to create an adapter for Active Job, this is working very well so far. https://github.com/esminc/activejob-google_cloud_tasks-http Creating an Active Job adapter itself is not so hard. You can see that by exploring the repository above. In fact, Active Job adapters are required to implement only two methods: enqueue and enqueue_at. Read more

September 27, 2019

Sending FCM Push Notifications with Andpush Gem

Recently, I had migrated from GCM (Google Cloud Messaging) to FCM (Firebase Cloud Messaging) because GCM was ending its life. At first, I found fcm gem which supports FCM. I changed my application code to use the gem and I deployed the new version since it was working nicely on the staging. However, as time goes, I realized that FCM notification sometimes stops working when the application runs on multiple threads. Read more

May 6, 2018

Running Desktop Applications on Containers

Docker is an important tool for running web applications in both production and development environments nowadays. Actually, it can also be used for running desktop applications. That means you can take advantage of Docker's mobility even on the desktop. However, there are some tricks to make that work well. In short, you have to enable applications inside containers to use some resources on the host machine. Using X11 via Unix Socket As you may know, X11 originally supports remote use and it can be accessed via TCP or Unix Domain sockets. Read more

© Hibariya 2020

Powered by Hugo & Kiss.