Skip to content

Instantly share code, notes, and snippets.

<!--
Put this file in ~/Library/LaunchAgents/com.example.KeyRemapping.plist to
automatically remap your keys when macOS starts.
See https://developer.apple.com/library/archive/technotes/tn2450/_index.html for
the key "usage IDs". Take the usage ID and add 0x700000000 to it before putting it
into a source or destination (HIDKeyboardModifierMappingSrc and
HIDKeyboardModifierMappingDst respectively).
-->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
# Put this in nrpe.cfg on the remote host you're monitoring.
command[check_load]=/usr/local/nagios/libexec/check_load -w 5,4,3 -c 10,8,6
command[check_memory]=/usr/local/nagios/libexec/check_mem.pl -f -w 5 -c 2
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
$ ./hpricot_vs_nokogiri.rb
user system total real
hpricot:doc 0.230000 0.010000 0.240000 ( 0.265904)
nokogiri:doc 0.030000 0.010000 0.040000 ( 0.041641)
user system total real
hpricot:xpath 1.050000 0.020000 1.070000 ( 1.114454)
nokogiri:xpath 0.210000 0.010000 0.220000 ( 0.226418)
user system total real
hpricot:css 1.140000 0.030000 1.170000 ( 1.339635)
nokogiri:css 0.700000 0.010000 0.710000 ( 0.835559)
@chuyeow
chuyeow / connect-to-vpn.scpt
Created May 27, 2020 01:10
Convenient way to connect to an IKEv2 VPN on macOS
set vpnServiceName to "Your VPN name in Network Preferences"
tell application "System Events"
tell process "SystemUIServer"
set vpnMenu to (menu bar item 1 of menu bar 1 where description is "VPN")
tell vpnMenu to click
set connectionStatusItem to (menu item 1 of menu 1 of vpnMenu)
if title of connectionStatusItem is equal to ("Connect " & vpnServiceName) then
tell connectionStatusItem to click
@chuyeow
chuyeow / platform-admin.tmux.sh
Created April 6, 2020 03:17
Tmux script example
#!/bin/sh
set -e
cd $GOPATH/src/code.in.spdigital.sg/sp-digital/platform-admin-portal
attach() {
[ -n "${TMUX:-}" ] &&
tmux switch-client -t '=platform-admin' ||
tmux attach-session -t '=platform-admin'
@chuyeow
chuyeow / keybase.md
Created April 5, 2019 08:12
keybase.md

Keybase proof

I hereby claim:

  • I am chuyeow on github.
  • I am chuyeow (https://keybase.io/chuyeow) on keybase.
  • I have a public key whose fingerprint is A061 D72D 7975 59ED FE61 E065 A804 8F66 49AE 598E

To claim this, I am signing this object:

⊂(◉‿◉)つ
'use strict';
const fs = require('fs');
const expandHomeDir = require('expand-home-dir');
const zshHistoryRaw = fs.readFileSync(expandHomeDir('~/.zsh_history'), 'utf8');
const zshHistoryLines = zshHistoryRaw.split('\n');
const transformLine = line => {
try {
@chuyeow
chuyeow / Preferences.sublime-settings
Last active January 19, 2017 07:51
Sublime Text 3 preferences
{
"auto_complete_commit_on_tab": true,
"bold_folder_labels": true,
"caret_style": "solid",
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"create_window_at_startup": false,
"ensure_newline_at_eof_on_save": true,
"file_exclude_patterns":
[
".DS_Store"
@chuyeow
chuyeow / nginx.passenger.conf
Last active December 24, 2015 10:59
Nginx configs for Unicorn and Passenger Enterprise
user www-data www-data;
worker_processes 4; # Rule of thumb is 1 process per core.
error_log logs/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}