Skip to content

Instantly share code, notes, and snippets.

hoangtranwork /
Last active Mar 7, 2021
problem with installing python on macOS 2021-03-07 (asdf)
# this helps:
AR=/usr/bin/ar asdf install python 3.9.2
View batch rename
# install rename tool
brew install rename
# add -n to dry-run
rename --camelcase -s '2001-01-0' '' -S '-' '' -s 'Eng.' '000.' -s '.Midi' '.mid' MIDI/*
rename --camelcase -s '2001-01-0' '' -S '-' '' -s 'Eng.' '000.' -s '.Pdf' '.pdf' PDF/*
rename --camelcase -s '2001-01-0' '' -S '-' '' -s 'Eng.' '000.' -s '.Mxl' '.mxl' MXL/*
View gist:312343192af1eb4db928142dee9c8f1a
Verifying my Blockstack ID is secured with the address 1Kzj9aLDdXm4LaK8Ttpv6PJDDALLZ7t1D8
View centos_logrotate
sudo bash -c "cat <<EOT > /etc/logrotate.d/api
/opt/app/*.log {
size 10k
hoangtranwork / DateUtil.kt
Last active Oct 12, 2018
Java/Kotlin DateTimeFormatter to parse Apple version of RFC3339 date returned by Apple API (Itune receipt)
View DateUtil.kt
val appleRfc3339DateFormatter: DateTimeFormatter =
.appendValue(YEAR, 4).appendLiteral('-').appendValue(MONTH_OF_YEAR, 2).appendLiteral('-').appendValue(DAY_OF_MONTH, 2)
.appendLiteral(' ')
.appendValue(HOUR_OF_DAY, 2).appendLiteral(':').appendValue(MINUTE_OF_HOUR, 2).appendLiteral(':').appendValue(SECOND_OF_MINUTE, 2)
.appendLiteral(' ')
val aRfc3339DateString = "2016-03-17 03:24:38 Etc/GMT"
hoangtranwork /
Last active Oct 10, 2018
Steps to make Firefox open maximized on macOS
  1. Get the profile folder location in about:support page

  2. Edit the file xulstore.json found in the above folder. It's a json file and we need only to edit the key main-window to something like this:



  • Step 2 should be done when Firefox is not open, as it seems that the file get updated when Firefox closes.
  • Sometimes you need to put negative value to screenX if the windows is still shifted abit from the screen edge.
hoangtranwork /
Created Oct 3, 2018
s3 bucket filtering in different ways
fn process(buckets: Vec<Bucket>) {
buckets.iter().filter(|b| == Some(EXACT_NAME.to_string())).for_each(|b| println!("{:#?}", b));
.filter(|b| {
let matched =; && matched
.for_each(|b| println!("{:#?}", b));
View ConsoleStringTable.kt
class ConsoleStringTable {
private data class Index(val row: Int, val column: Int)
private val contents = mutableMapOf<Index, String>()
private val columnSizes = mutableMapOf<Int, Int>()
private var rowCount = 0
private var columnCount = 0
hoangtranwork / xxf.zsh-theme
Last active Dec 19, 2018 — forked from xfanwu/xxf.zsh-theme
Yet another theme for oh-my-zsh
View xxf.zsh-theme
# Copy and self modified from ys.zsh-theme, the one of default themes in master repository
# Clean, simple, compatible and meaningful.
# Tested on Linux, Unix and Windows under ANSI colors.
# It is recommended to use with a dark background and the font Inconsolata.
# Colors: black, red, green, yellow, *blue, magenta, cyan, and white.
# 2 Jul 2015 - Xiaofan
# Machine name.
function box_name {
hoangtranwork /
Last active Nov 28, 2017
Without restart. Retain across ssh sessions (pernament). This also help avoiding `sudo: unable to resolve host` warning


  1. edit /etc/hostname: only 1 line with the new-hostname
  1. edit /etc/hosts: 2 lines localhost new-hostname new-hostname