Skip to content

Instantly share code, notes, and snippets.

💀
This.isDevOps(powah_code=36)

Thuan Duong thuandt

💀
This.isDevOps(powah_code=36)
Block or report user

Report or block thuandt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@thuandt
thuandt / router-reboot
Created Aug 28, 2019
Reboot TP-Link router via telnet using expect
View router-reboot
#!/usr/bin/expect -f
# Usage: router-reboot 192.168.0.1 admin admin
# If it all goes pear shaped the script will timeout after 10 seconds.
set timeout 10
set server [lindex $argv 0]
if {$server eq ""} {set server "$env(ROUTER_ADDR)"}
set username [lindex $argv 1]
View quick-tips-optimizing-jvm.md

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 Choosing a deployment tool - ansible vs puppet vs chef vs salt
View deployment-tool-ansible-puppet-chef-salt.md

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

View useful_pandas_snippets.py
# 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 / readme.md
Created Jan 2, 2018 — forked from olvesh/readme.md
Kubernetes and Kops migrate from public to private topology
View readme.md

From public to private topology

Run kops get cluster -o yaml --full > cluster-full.yaml for reference and backup

Bastion and weave networking

kops edit cluster:

  • change networking to
    spec: 
      networking:
        weave: 
@thuandt
thuandt / random-crontab.md
Created Jan 9, 2017
Random delay for cron.daily, cron.weekly, cron.monthly
View random-crontab.md

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:

@thuandt
thuandt / gke.md
Created Nov 20, 2016
Working with GKE cluster using Google Cloud SDK
View gke.md

GCP & GKE setup

$ gcloud auth application-default login
$ gcloud config set core/project ${GCP_PROJECT}
$ gcloud config set core/account ${SERVICE_ACCOUNT}
$ gcloud config set compute/region ${REGION}
$ gcloud config set compute/zone ${ZONE}
$ gcloud config set container/cluster ${CLUSTER_NAME}
# gcloud config set container/use_client_certificate True
View types.markdown

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

@thuandt
thuandt / st_icon_512.png
Last active Sep 3, 2016
Replace Sublime Text Icon in Ubuntu
@thuandt
thuandt / static_dynamic_linked_binaries.md
Created Apr 1, 2016
What are some of the advantages and some of the disadvantages of static binaries against dynamically linked binaries?
View static_dynamic_linked_binaries.md

What are some of the advantages and some of the disadvantages of static binaries against dynamically linked binaries?

You can’t perform that action at this time.