Skip to content

Instantly share code, notes, and snippets.

@avarayr
avarayr / altermail.sh
Created January 30, 2022 08:08
Fix AltPlugin.mailbundle after MacOS updates
#!/bin/sh
# Check if running as root
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
token=`cat /System/Applications/Mail.app/Contents/Info.plist | grep -A1 "PluginCompatibilityUUID" | grep string | sed 's/<string>//' | sed 's/<\/string>//'`
path="/Library/Mail/Bundles/AltPlugin.mailbundle/Contents/Info.plist"
@lexrus
lexrus / delete_all_imessage_conversations.applescript
Last active January 26, 2024 16:12
Delete all iMessage conversations. Compatible with macOS Monterey. Please check Reduce motion before launch this apple script.
# System Preferences -> Accessibility -> Display -> Reduce motion
tell application "Messages" to activate
tell application "Messages"
set chatCount to (count of chats)
end tell
tell application "System Events"
tell process "Messages"
@tuxity
tuxity / navicat_premium_reset_trial.sh
Last active April 25, 2024 02:44
Reset Navicat Premium 15/16 remaining trial days
#!/bin/bash
set -e
file=$(defaults read /Applications/Navicat\ Premium.app/Contents/Info.plist)
regex="CFBundleShortVersionString = \"([^\.]+)"
[[ $file =~ $regex ]]
version=${BASH_REMATCH[1]}
{
const ratioConfig = (x, y) => ({
x,
y,
ratio: x / y
})
const commonRatio = [ratioConfig(1, 1), ratioConfig(4, 3), ratioConfig(16, 9), ratioConfig(16, 10)];
const getRatioConfig = (x, y) => {
@otakustay
otakustay / index.js
Created March 10, 2021 10:16
Compute aspect ratio
const isApproximateInteger = value => {
const min = Math.floor(value);
const max = Math.ceil(value);
return value - min <= 0.01 || max - value <= 0.01;
};
const MAX_TRY = 120;
const computeToRatio = (width, height) => {
@emptyfuel
emptyfuel / DiffableDataSource.swift
Last active October 10, 2022 07:05
Source code to use with Xcode playground related to the blog post on emptytheory.com at https://emptytheory.com/2021/01/11/using-ios-diffable-data-sources-with-different-object-types/
import UIKit
import PlaygroundSupport
/// Simple sample diffable table view to demonstrate using diffable data sources. Approximately 33% of the time, it should show "bad weather" UI instead of apples and oranges
final class DiffableTableViewController : UIViewController {
var tableView: UITableView!
enum Section: String, CaseIterable, Hashable {
case apples = "Apples"
@sarkrui
sarkrui / installScript_1016beta_aria2c.sh
Last active September 25, 2020 12:47
Script to Install macOS 1016
#!/bin/sh
printf '\033[8;60;172t'
clear
LocalScriptVer="v1.0.5"
RemoteScriptVer=""
RemoteScriptPath="https://raw.githubusercontent.com/crazybirdy/MBR-Manual-Method/master/Q6-DownloadFullApp"
LocateScriptPath="$HOME/Desktop/"
ScriptName="installScript_110fullapp"
@ravenxrz
ravenxrz / 彩云小译.js
Created August 1, 2020 07:22
彩云小译油猴脚本
// ==UserScript==
// @name 彩云小译
// @namespace https://github.com/yandd
// @version 1.1.0
// @icon https://www.caiyunapp.com/favicon.ico
// @description 彩云小译 提供中英对照翻译
// @author yandd <https://github.com/yandd>
// @supportURL https://github.com/yandd
// @match *://*/*
// @run-at document-end
@Kilo-Loco
Kilo-Loco / decode-dynamic-keys.swift
Last active February 16, 2023 14:15
Decoding nested objects with dynamic keys
import Foundation
// JSON response converted to Data
let response = """
{
"name": "Kilo Loco",
"pets": {
"0": {
"name": "Doggo"
},