Skip to content

Instantly share code, notes, and snippets.

@terryyounghk
terryyounghk / README.md
Created March 7, 2024 05:29
Chrome Extension Vimium-C Settings

Chrome Extension Vimium-C Settings

These are my exported Vimium-C settings, to be shared between personal and work machines.

@terryyounghk
terryyounghk / README.md
Created March 7, 2024 05:15
VsCode User Keyboard Shortcuts

Custom Keybindings for VsCode

These are keybindings for VsCode tailor-made to work with the combo-mods defined in https://github.com/terryyounghk/zmk-config

The VsCode built-in sync features is not necessarily work-environment friendly in my case: personal accounts are restricted in work machines, and work accounts are restricted in personal machines.

This file is to be used to manually import/export the shortcut settings instead.

Some shortcuts require certain VsCode Extensions to work.

@terryyounghk
terryyounghk / README.md
Last active March 7, 2024 05:09
Swish Preferences

Working with plist files - Swish

I use Swish by HighlyOpinionated for Window Management on MacOS.

My copy of Swish is licensed via SetApp, hence the plist file name is co.highlyopinionated.swish-setapp.plist.

This is my preference plist file for Swish, exported in XML format, configured to use vim-like hjkl hotkeys as arrow keys. ​ The plist file of Swish is binary.

@terryyounghk
terryyounghk / view-commit
Created February 11, 2019 10:28
Atlassian SourceTree Custom Action: "View Commit In Browser"
#!/bin/sh
# -----------------------------------------------------------------------------------------------
#
# This script is to be used by SourceTree > Action > Custom Action
#
# (See https://confluence.atlassian.com/sourcetreekb/using-git-in-custom-actions-785323500.html)
#
# Copy this file into your 'bin' directory, (e.g. ~/.dotfiles/bin/view-commit)
#
# In Terminal, go to your 'bin' directory and run 'chmod +x view-commit'
@terryyounghk
terryyounghk / account_controller.rb
Created October 3, 2018 04:41
params vs. params.permit
class AccountController < ApplicationController
# Just to disable the CSRF protection for specific controller for quick testing
# @see https://stackoverflow.com/a/34252150/277666
skip_before_action :verify_authenticity_token
def test
# 'params' is NOT recommended to be used directly
@terryyounghk
terryyounghk / hell.js
Last active July 31, 2018 08:39
js hell
// ---------------------------------------------------------------
// Callback Hell
moveTo(50, 50, function () {
moveTo(20, 100, function () {
moveTo(100, 200, function () {
// done
});
});
});
@terryyounghk
terryyounghk / momentjs-extensions.js
Last active December 31, 2015 15:29
Extensions for momentjs This is a small extension to moment.js, and adds the ability to add/subtract number of business days, snap to nearest business day, and calculate difference in terms of business days. Note that this simply excludes Sundays and Saturdays.
/* jshint laxbreak: true */
/**
* moment.js plugin: additional methods
* businessDiff (mStartDate)
* businessAdd (numberOfDays)
* businessSubtract (numberOfDays)
* business ([false])
*/
(function () {
var moment;
@terryyounghk
terryyounghk / jquery-text-selection.js
Last active December 31, 2015 15:09
This gist contains four small jQuery plugins, namely .selectText(), $.deselectText(), .disableSelection() and .enableSelection(). .disableSelection() and .enableSelection() has been deprecated since jQuery UI 1.9 - this gist brings back those two functionalities, without the jQuery UI dependency. .selectText() and $.deselectText() is not a new c…
/*jshint multistr: true */
(function ($) {
/**
* Selects text within the DOM element
*/
$.fn.selectText = function() {
var doc = document,
element = this[0],
range,
selection;