Skip to content

Instantly share code, notes, and snippets.

Avatar

Cheah Chu Yeow chuyeow

View GitHub Profile
View com.example.KeyRemapping.plist
<!--
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">
@chuyeow
chuyeow / connect-to-vpn.scpt
Created May 27, 2020
Convenient way to connect to an IKEv2 VPN on macOS
View connect-to-vpn.scpt
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
View platform-admin.tmux.sh
#!/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'
View 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:

View import_zsh_history_to_fish.js
'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 / Fix Homebrew.md
Last active Aug 29, 2015
Homebrew on Mac OS X 10.10 Yosemite
View Fix Homebrew.md

Key things to note

  • The system ruby is now version 2.0 (was 1.8).
  • Homebrew has hardcoded paths to Ruby 1.8.

To fix:

  • sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/2.0 /System/Library/Frameworks/Ruby.framework/Versions/1.8
  • Download and install the 10.10 command line tools from https://developer.apple.com/downloads/index.action - look for "Command Line Tools (OS X 10.10) for Xcode"
@chuyeow
chuyeow / nginx.passenger.conf
Last active Dec 24, 2015
Nginx configs for Unicorn and Passenger Enterprise
View nginx.passenger.conf
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;
}
@chuyeow
chuyeow / unicorn
Created Sep 10, 2013
Unicorn init.d script
View unicorn
#! /bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO
@chuyeow
chuyeow / unicorn_logrotate.conf
Created Sep 10, 2013
Unicorn sample logrotate file
View unicorn_logrotate.conf
/var/railsapps/appname/shared/log/*.log {
daily
missingok
rotate 3
compress
dateext
delaycompress
lastaction
pid=/var/railsapps/appname/shared/pids/unicorn.pid