Skip to content

Instantly share code, notes, and snippets.

@huynhbaoan
huynhbaoan / disable-ipv6.sh
Created February 13, 2019 03:07 — forked from kwilczynski/disable-ipv6.sh
Amazon Linux OS tweaks
#!/bin/bash
set -u
set -e
set -o pipefail
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
cat <<'EOF' > /etc/modprobe.d/blacklist-ipv6.conf
@huynhbaoan
huynhbaoan / Python notes
Last active January 5, 2024 07:47
Python notes
### Handling error example
import sys
import traceback
try:
f = open('myfile.txt')
s = f.readline()
i = int(s.strip())
except OSError as err:
@huynhbaoan
huynhbaoan / list.txt
Created October 25, 2018 07:40 — forked from shortjared/list.txt
List of AWS Service Principals
acm.amazonaws.com
apigateway.amazonaws.com
athena.amazonaws.com
autoscaling.amazonaws.com
clouddirectory.amazonaws.com
cloudformation.amazonaws.com
cloudfront.amazonaws.com
cloudsearch.amazonaws.com
cloudtrail.amazonaws.com
codecommit.amazonaws.com
@huynhbaoan
huynhbaoan / cors.nginxconf
Created August 9, 2018 10:06 — forked from pauloricardomg/cors.nginxconf
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {
Recently, I use JMXterm to collect info about Java JVM via JMX and MBeans. Here is a short note.
- Download JMXterm
https://sourceforge.net/projects/cyclops-group/files/jmxterm/1.0.0/jmxterm-1.0.0-uber.jar/download
- Run JMXterm
java -jar jmxterm-1.0.0-uber.jar --url localhost:<jmx listen port>
- All MBeans from java.lang
$>domain java.lang
@huynhbaoan
huynhbaoan / collectd.conf
Created August 2, 2018 04:10 — forked from ajayverghese/collectd.conf
Sample collectd configuration to fetch jetty and jvm metrics for monitoring (and send to graphite)
#
# Config file for collectd(1).
# Please read collectd.conf(5) for a list of options.
# http://collectd.org/
#
##################
# Global settings
##################
@huynhbaoan
huynhbaoan / MongoDB slowlog.md
Created July 9, 2018 07:20 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...