Skip to content

Instantly share code, notes, and snippets.

@yam-liu
yam-liu / git-multi-hook-template
Created December 23, 2020 16:58 — forked from damienrg/git-multi-hook-template
Script to allow multi hooks per hook type for git
#!/usr/bin/env bash
# Allow multiple hooks.
#
# To use it copy this script with executable permission in ".git/hooks/hook-name"
# where hook-name is the name of the hook (see man githooks to know available hooks).
# Then place your scripts with executable permission in ".git/hooks/hook-name.d/".
hook_type=${BASH_SOURCE##*/}
@yam-liu
yam-liu / WiFiChange.lua
Created September 11, 2020 16:51
WiFi Change Action
local prevSSID = 'NO_NET'
function ssidChangedCallback()
local ssid = hs.wifi.currentNetwork()
if ssid ~= nil then
print(prevSSID .. " -> " .. ssid)
if ssid ~= nil and ssid ~= prevSSID then
prevSSID = ssid
hs.notify.show('Wi-Fi changed to ' .. (ssid), '', '')

Disable Device Enrollment Program (DEP) notification on macOS Catalina.md

With full reinstall (recommended)

   a. Boot into recovery using command-R during reboot, wipe the harddrive using Disk Utility, and select reinstall macOS

   b. Initial installation will run for approximately 1 hour, and reboot once

   c. It will then show a remaining time of about 10-15 minutes

@yam-liu
yam-liu / karabiner_switch_input_source.json
Created May 24, 2019 06:50 — forked from gxfxyz/karabiner_switch_input_source.json
Karabiner-Elements config: switch input source | 输入法切换
{
"title": "Switch input source | 输入法切换",
"rules": [
{
"description": "Tap Command_L (⌘) → Switch input source to English | 短按左 Command (⌘) → 切换到英文输入法",
"manipulators": [
{
"conditions": [
{
"input_sources": [
@yam-liu
yam-liu / PSPDFGenerics.h
Created March 15, 2019 04:29 — forked from steipete/PSPDFGenerics.h
Override copy and mutableCopy on Objective-C collection classes to pass along both the collection type and the generic info. This is a header-only "library". MIT licensed. Craving for more? foreach: https://gist.github.com/steipete/7e3c69b985165dc23c5ec169b857ff42 even more: https://pspdfkit.com/blog/2016/swifty-objective-c/ - ships in https://p…
//
// PSPDFGenerics.h
// PSPDFFoundation
//
// PSPDFKit is the leading cross-platform solution for integrating PDFs into your apps: https://pspdfkit.com.
// Try it today using our free PDF Viewer app: https://pdfviewer.io/
//
// This file is MIT licensed.
/**
//
// Created on 2019/1/25.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface ThreadSafeMutableArray<ObjectType> : NSObject <NSFastEnumeration, NSCopying>
@yam-liu
yam-liu / PSPDFThreadSafeMutableDictionary.m
Created January 25, 2019 09:23 — forked from steipete/PSPDFThreadSafeMutableDictionary.m
Simple implementation of a thread safe mutable dictionary. In most cases, you want NSCache instead, but it can be useful in situations where you want to manually control what is evicted from the cache in low memory situations.**Warning:** I only use this for setting/getting keys. Enumeration is not thread safe here and will still throw exception…
//
// PSPDFThreadSafeMutableDictionary.m
//
// Copyright (c) 2013 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
extension Array {
func first() -> Element? {
if isEmpty {
return nil
}
return self[0]
}
func last() -> Element? {
@yam-liu
yam-liu / CCDeepCopy.h
Created December 8, 2014 10:55
Deep Copy Categories for NSArray & NSDictionary
//
// CCDeepCopy.h
//
// Created by ooops on 12/8/14.
// Copyright (c) 2014 http://ooopscc.com. All rights reserved.
//
#import <Foundation/Foundation.h>
#pragma mark - NSArray