Skip to content

Instantly share code, notes, and snippets.

Hi ;)

Tuan Anh Tran tuananh

Hi ;)
View GitHub Profile
tuananh /
Created Mar 29, 2021
Enable cgroup v2 on Manjaro/Arch
sudo nano /etc/default/grub
# add systemd.unified_cgroup_hierarchy=1 to the key GRUB_CMDLINE_LINUX_DEFAULT (space separated list)
sudo grub-mkconfig -o /boot/grub/grub.cfg
# reboot
tuananh / archive.html
Created Nov 12, 2013
Group posts by month in Jekyll archive page
View archive.html
layout: default
title: Archive
<div class="post">
{% for post in site.posts %}
{% unless %}
tuananh / check-mime-type-from-base64-string-node.js
Created Apr 7, 2018
Check mime type from base64 string in Node.js
View check-mime-type-from-base64-string-node.js
const fileType = require('file-type')
const base64String = 'iVBORw0KGgoAAAANSUhEUgAAAC0AAAAtCAYAAAA6GuKaAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAhOAAAITgBRZYxYAAAABxpRE9UAAAAAgAAAAAAAAAXAAAAKAAAABcAAAAWAAABW85tpoQAAAEnSURBVGgF7JbLDYMwDIYZoSN0pI7QUdikI+QESAXJozACR6SCRO2IHIBgnIRHKhUpQsSO/fFjnCRJwDWAun3exbOvsldX5oBjYAaQH/nTuoC0fkv7Kn8gnGIAOXhjUxTHj8BhFSXBUQfCGmh9p3iHwLdFcUdQ2BPWEgsoj4OG665Ug5igsSSZKLaTvaF86zQCS1dm6U4wji+YpQK8pcvYERyTsd3DKRblX1IxM9cpPH9poeJjDTupcmQJbdb42CXO+umkwjRsV0HF4EjVAmKDtZqpwQcElarm7WfdgGhnihy6nqgdu8pGzInaOBl6+PH+7AZIeFdabTomChecBcbm0cfa2PryloC6b1+9XW9Bzu16e8dJmBsif4YkckBrff+hz/pqP6n0FwAA//85LScuAAAA+0lEQVTV1u0NgyAQBuAboSN0pI7QUdykI/ALSaoJozgCP5tUE8tL0FiQSNNWORM/IEQfLucB9U09cjuJGxhetmjNLNqahlbeOKHhpeddXTmh4aVRixMnNLyEw6IFE7hwYFyGtr5wQMM5oz28Kxluwd0b2KOLjnYU5WkGNtKl1mw9GaP7Q6mzhZvC0sTAFWGXHaXVbVeXl8DUc9/IqoxoyyplXO0/enl3y/WqbKPzuIh/GOFwHj7H9/o5TXYOh9Cw7avKv8uh3qwSISynjQKPlemXPynel1w4clC5Y/ARC/92kyV2wYaTwjYROegrzVb6aIzD+Hl7Gb4ws/0Cqd8IYgt7isgAAAAASUVORK5CYII='
const mimeInfo = fileType(Buffer.from(ba
tuananh /
Created May 10, 2018 — forked from marnovo/
Enable AptX and AAC codecs on macOS
# (c) 2018 Marcelo Novaes
# License - MIT
# Enable AptX and AAC codecs on bluetooth connections on macOS
sudo defaults write bluetoothaudiod "Enable AptX codec" -bool true
sudo defaults write bluetoothaudiod "Enable AAC code" -bool true
# Reads set values, should return something like:
# {
tuananh /
Last active Dec 20, 2020
microk8s on Raspberry Pi 4
tuananh / configmap.yaml
Last active Dec 13, 2020
Pi-hole on Kubernetes
View configmap.yaml
apiVersion: v1
kind: ConfigMap
name: pihole-config
TZ: 'Asia/Ho_Chi_Minh'
tuananh /
Created Apr 27, 2016
How to convert a .pfx SSL certificate to .crt/key (pem) formats


openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]

What this command does is extract the private key from the .pfx file. Once entered you need to type in the importpassword of the .pfx file. This is the password that you used to protect your keypair when you created your .pfx file. If you cannot remember it anymore you can just throw your .pfx file away, cause you won’t be able to import it again, anywhere!. Once you entered the import password OpenSSL requests you to type in another password, twice!. This new password will protect your .key file.

Now let’s extract the certificate:

openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]

View gist:8f9bfd3719d8e6b45fd11625b3756454
const data = [
roomId: 1,
rateId: 2,
name: 'room 1'
roomId: 1,

Git cheat list

  • all commits that your branch have that are not yet in master

    git log master..<HERE_COMES_YOUR_BRANCH_NAME>
  • setting up a character used for comments

    git config core.commentchar <HERE_COMES_YOUR_COMMENT_CHAR>
tuananh /
Created Jun 9, 2018 — forked from josiahcarlson/
A method to get sql-like multiple-column order by in Redis
Copyright 2013 Josiah Carlson
Released into the public domain.
Let's imagine that there are 3 restaurants with price, score, distance info