Skip to content

Instantly share code, notes, and snippets.

View zanglang's full-sized avatar

Jerry Chong zanglang

View GitHub Profile
@zanglang
zanglang / check_stuck_java.sh
Created July 30, 2018 09:15
Bash script to check for Java processes that have lived longer than their maximum expected run time
#/bin/sh
# number of ticks since boot
UPTIME=$(awk '{print $1}' /proc/uptime | xargs printf '%.0f')
WARNINGS=
FOUND=0
for pid in $(pgrep -f java)
do
# get elapsed jiffies in seconds for each java process
@zanglang
zanglang / migrate_fish_to_zsh.py
Created March 23, 2018 06:24
Migrate Fish Shell's history file to Zsh
#!/usr/bin/env python2
from __future__ import print_function
import re
CMD_RE = re.compile(r"^- cmd: (.*)")
WHEN = re.compile(r"^when: (\d+)")
with open("/home/zanglang/.local/share/fish/fish_history") as f:
cmd = when = None
for line in f:
@zanglang
zanglang / keybase.md
Created February 9, 2017 05:20
Initial commit

Keybase proof

I hereby claim:

  • I am zanglang on github.
  • I am zanglang (https://keybase.io/zanglang) on keybase.
  • I have a public key ASB_rAbWuHPhx76QcZPyb84pXxzmF30U7DIUJ3Z9s29c8Ao

To claim this, I am signing this object:

@zanglang
zanglang / read_properties.py
Created January 17, 2017 07:24
Ansible module that takes in a target Java .properties file, and reads it as an Ansible host fact.
#!/usr/bin/env python
"""
Ansible module that takes in a target Java .properties file, and reads it as
an Ansible host fact.
Example:
- read_properties: target=~/dists/cluster/test.properties
register: cluster_props
@author: Jerry Chong <jchong@netbase.com>
@zanglang
zanglang / properties.py
Created January 17, 2017 07:23
Ansible module that takes in a target Java .properties file, and patches in any arbitrary key-value properties specified in a JSON hash format
#!/usr/local/python/bin/python
"""
Ansible module that takes in a target Java .properties file, and patches in any
arbitrary key-value properties specified in a JSON hash format. This module is
expected to be used alongside the `properties` Ansible action module.
Examples:
- properties:
dest: ~/dists/cluster/ix/ZookeeperIndexMerger.properties
props:
@zanglang
zanglang / check-nfs-mounts.py
Last active December 2, 2019 00:10
Compares NFSv4 mounts defined in /etc/fstab and current mounts on the system
#!/usr/bin/env python
"""
Usage: check-nfs-mounts-v2.py
Compares NFSv4 mounts defined in /etc/fstab and current mounts on the system
"""
from __future__ import print_function
import re
try:
@zanglang
zanglang / gist:4958113
Created February 15, 2013 02:15
Tasker profile for Home Mode (Disable pattern locks, wifi sleep and mobile data)
<TaskerData sr="" dvi="1" tv="4.0b8m">
<Task sr="task14">
<cdate>1341662662718</cdate>
<edate>1360894297856</edate>
<id>14</id>
<nme>Home Mode</nme>
<pri>10</pri>
<Action sr="act0" ve="3">
<code>11820</code>
<Bundle sr="arg0">