Skip to content

Instantly share code, notes, and snippets.

View chenshengzhi's full-sized avatar

Neil chenshengzhi

  • Xiamen, Fujian, China
View GitHub Profile
JunyuKuang / OverrideCatalystScaleFactor.swift
Last active September 26, 2023 05:17
Disable 77% scaling for Mac Catalyst apps. (Swift)
let overrideCatalystScaleFactor: Void = {
guard let sceneViewClass = NSClassFromString("UINSSceneView") as? NSObject.Type else {
if sceneViewClass.instancesRespond(to: NSSelectorFromString("scaleFactor")) {
// old
class: sceneViewClass,
originalSelector: NSSelectorFromString("scaleFactor"),
swizzledSelector: #selector(swizzle_scaleFactor)
magicdude4eva / zsh-syntax-highlighting paste performance improvement
Last active May 6, 2024 08:10
zsh-syntax-highlighting paste performance improvement
Add the following in .zshrc:
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl)
### Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
mikebuss / decode-json-swift.swift
Created January 25, 2019 21:46
Decode [Any] and [String: Any] Swift 4
// Adapted from:
// Original:
// Adds encoding:
// Adds fix for null inside arrays causing infinite loop:
struct JSONCodingKeys: CodingKey {
var stringValue: String
dannote / final-cut-pro-trial-reset.swift
Last active May 27, 2024 17:23
Final Cut Pro X trial reset
import Foundation
let path = URL(fileURLWithPath: NSString(string: "~/Library/Application Support/.ffuserdata").expandingTildeInPath)
let data = try! NSData(contentsOf: path) as Data
let dictionary = try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as! NSDictionary
let mutableDictionary = dictionary.mutableCopy() as! NSMutableDictionary
for (key, value) in mutableDictionary {
idleberg /
Last active February 20, 2024 09:37 — forked from vincentmac/
“Open in Sublime Text” in macOS context-menu

This list has been updated for Big Sur (and later). Since I don't use these versions, this guide might still need further improvements. For older macOS versions, please see this older revision.

Open in Sublime Text

  • Open Automator
  • Quick Action
  • Set “Service receives selected” to files or folders in any application
  • Add a Run Shell Script action
  • Set the script action to /Applications/Sublime\ -n "$@"
  • Set “Pass input” to as arguments
anonymous /
Created July 16, 2016 04:04
# Compile-Freetype-For-iOS
# Original Script
# Revised by: l'L'l
# New Features Include: auto download latest version, fixed toolchain locations, other various tweeks
# The MIT License (MIT)
# Copyright (c) 2016 l'L'l
paulirish / open-chrome-tabs-in-safari.scpt
Created April 4, 2016 00:24
open chrome tabs in safari
tell application "Google Chrome"
set tab_list to every tab in the front window
repeat with the_tab in tab_list
set the_url to the URL of the_tab
tell application "Safari" to open location the_url
end repeat
end tell
evantoli /
Last active May 20, 2024 08:42
Configure Git to use a proxy

Configure Git to use a proxy

In Brief

You may need to configure a proxy server if you're having trouble cloning or fetching from a remote repository or getting an error like unable to access '...' Couldn't resolve host '...'.

Consider something like:

Ashton-W / Breakpoints_v2.xcbkptlist
Last active January 25, 2023 09:28
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
type = "2"
version = "2.0">
<!-- All Exceptions -->
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for