Skip to content

Instantly share code, notes, and snippets.

View thuandt's full-sized avatar
💀
This.isDevOps(powah_code=36)

Thuan Duong thuandt

💀
This.isDevOps(powah_code=36)
View GitHub Profile
@thuandt
thuandt / no_accent_vietnamese.py
Created August 22, 2012 03:07
Chuyển đổi từ Tiếng Việt có dấu sang Tiếng Việt không dấu
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Chương trình chuyển đổi từ Tiếng Việt có dấu sang Tiếng Việt không dấu
Chỉnh sửa từ mã nguồn của anh NamNT
http://www.vithon.org/2009/06/14/x%E1%BB%AD-ly-ti%E1%BA%BFng-vi%E1%BB%87t-trong-python
"""
import re
INTAB = "ạảãàáâậầấẩẫăắằặẳẵóòọõỏôộổỗồốơờớợởỡéèẻẹẽêếềệểễúùụủũưựữửừứíìịỉĩýỳỷỵỹđẠẢÃÀÁÂẬẦẤẨẪĂẮẰẶẲẴÓÒỌÕỎÔỘỔỖỒỐƠỜỚỢỞỠÉÈẺẸẼÊẾỀỆỂỄÚÙỤỦŨƯỰỮỬỪỨÍÌỊỈĨÝỲỶỴỸĐ"
@thuandt
thuandt / install_xenserver_usb.md
Created October 30, 2013 15:56
Create XenServer USB Install

Installing XenServer 6.2.0 from a USB Stick

  • Download the XenServer 6.2.0 ISO image

  • Format a USB stick using FAT32.

  • Use unetbootin to install the ISO to the USB stick. Use the “DiskImage” option instead of the “Distribution” one, and point it right to the ISO file.

  • Now we need to fix up some boot stuff (All paths are relative to the root of the USB drive)

{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"enable": true,
@thuandt
thuandt / grafana-redis-exporter-dashboard-by-pod.json
Last active July 6, 2022 13:19 — forked from polefishu/grafana-redis-exporter-dashboard-by-pod.json
Redis Exporter 1.x Dashboard for Grafana (breakdown by pod instead of an IP)
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"enable": true,
@thuandt
thuandt / openwrt-setup.sh
Created April 24, 2020 08:44
OpenWRT setup
#!/bin/sh
# Setup OpenWRT router
set -e
if [ -f /etc/upgraded ]; then
echo "router has been configured properly!"
else
if ping -q -c 1 -W 1 8.8.8.8 >/dev/null; then
echo "start reconfigure router"
@thuandt
thuandt / st_icon_512.png
Last active April 1, 2020 23:52
Replace Sublime Text Icon in Ubuntu
st_icon_512.png

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

@thuandt
thuandt / deployment-tool-ansible-puppet-chef-salt.md
Created June 8, 2018 01:06 — forked from jaceklaskowski/deployment-tool-ansible-puppet-chef-salt.md
Choosing a deployment tool - ansible vs puppet vs chef vs salt

Requirements

  • no upfront installation/agents on remote/slave machines - ssh should be enough
  • application components should use third-party software, e.g. HDFS, Spark's cluster, deployed separately
  • configuration templating
  • environment requires/asserts, i.e. we need a JVM in a given version before doing deployment
  • deployment process run from Jenkins

Solution

# List unique values in a DataFrame column
# h/t @makmanalp for the updated syntax!
df['Column Name'].unique()
# Convert Series datatype to numeric (will error if column has non-numeric values)
# h/t @makmanalp
pd.to_numeric(df['Column Name'])
# Convert Series datatype to numeric, changing non-numeric values to NaN
# h/t @makmanalp for the updated syntax!
@thuandt
thuandt / random-crontab.md
Created January 9, 2017 04:19
Random delay for cron.daily, cron.weekly, cron.monthly

Random delay for cron.daily, cron.weekly, cron.monthly

Source

Wouldn’t it be nice if cron’s daily, weekly and monthly jobs could be run with a slight offset? At least that’s what I thought when 20+ servers were hitting my backup infrastructure at once. The scripts in /etc/cron.daily, /etc/cron.weekly and /etc/cron.monthly are triggered directly from crontab at fixed times. Here’s what /etc/crontab looks like in Ubuntu Server 16.04: