Skip to content

Instantly share code, notes, and snippets.

@jatin-lab49
jatin-lab49 / shared-symlink.md
Created August 17, 2020 14:47
TIL-Lab49/Symlink errors in NodeJS projects on shared folders in Virtualbox
@jatin-lab49
jatin-lab49 / unzip-with-jar.md
Last active September 3, 2020 20:51
TIL-Lab49/Unzip jar file without unzip command inside a docker image

While triaging a running docker container, I was trying to check if a jar file had the correct properties file inside it.

I found the jar file and when I ran the handy unzip command, I got this error:

service@3f50ceae48d2:/tmp$ unzip micro-service.jar 
bash: unzip: command not found

Now, usually I would just go ahead and apt-get install unzip in a Ubuntu container like this. But I was not root, so ran into another issue:

@jatin-lab49
jatin-lab49 / quartz-one-job.md
Created November 24, 2020 19:27
TIL-Lab49/Ensuring only one Quartz scheduled job runs at one time

With the advances in Lambda and ECS task scheduling, I have not needed to use the trusty Quartz library for the past few years. I recently had to use it though in a project, and realized that the next job was starting when the current job was still running.

Thankfully with Spring, Quartz 2 makes this really easy. Just add the @DisallowConcurrentExecution to your job.

package com.lab49.example;

import org.quartz.DisallowConcurrentExecution;
import org.quartz.job;
@jatin-lab49
jatin-lab49 / apache-tika-basics.md
Created June 4, 2021 15:10
TIL-Lab49/Using Apache Tika for file type validation

We recently had a security team ask us to validate that the file being uploaded was indeed a plain text file. To do this, we decided to use Apache Tika.

The code itself is fairly straightforward:


import org.apache.tika.config.TikaConfig;
import org.apache.tika.exception.TikaException;
import org.apache.tika.io.TikaInputStream;
import org.apache.tika.mime.MediaType;
import org.apache.tika.metadata.MetaData;
@jatin-lab49
jatin-lab49 / image-base64.md
Created June 23, 2021 13:13
TIL-Lab49/Get a base64 version of image file locally

Maybe this is common knowledge. For most cases whenever I needed a base64 version of an image to use in a webpage, I used one of those online sites to get it.

Recently on a client project I wasn't sure if I wanted to upload their images on an unknown site. So I did a quick Google (fine, stackoverflow) and found that we can just run this on most Linux style systems.

cat image-file.jpg | base64

Also works on macOS and for other image types