Skip to content

Instantly share code, notes, and snippets.

// swiftc -o /tmp/InternetReachable ~/Temp/InternetReachable.swift && /tmp/InternetReachable
import AppKit
import Cocoa
import Foundation
import Network
private var window: NSWindow = {
let w = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: NSScreen.main!.frame.width, height: 20),
import Cocoa
import Foundation
func restart() {
// Check if the app was started fresh or if was restarted with arg `restarts=timestamp:timestamp:...`
// If the app was restarted more than 3 times in 10 seconds, exit with status 1
guard CommandLine.arguments.count == 1 || (
CommandLine.arguments.count == 2 && CommandLine.arguments[1].starts(with: "restarts=")
) else {
#!/usr/bin/env fish
# Needs rg: `brew install ripgrep`
set -xg visitedLibs
function libdeps -a bin depth -d "Finds all dylibs that a binary depends on recursively and prints them on separate lines, sorted alphabetically"
if test -z "$depth"
set depth 0
end
aacsportmuntenia.ro
adventstore.ro
aeroventic.ro
albertshop.ro
aliatokazii.ro
amanetlizeanu.ro
anton-schaaf.de
anunturi-apibio.ro
artuniversum.ro
audicanalplustour.es
@alin23
alin23 / .ublacklist
Last active September 29, 2022 12:29
*://*.amuddycup.com/*
*://*.athabasca-foto.com/*
*://*.cfadnc.org/*
*://*.codefaq.info/*
*://*.codeflow.site/*
*://*.coredump.biz/*
*://*.culinarydegree.info/*
*://*.developreference.com/*
*://*.domainelespailles.net/*
*://*.ec-europe.org/*
@alin23
alin23 / runbg.swift
Last active April 25, 2023 13:16
Run processes on the "Icestorm" efficiency cores of the M1 Mac chip
#!/usr/bin/env swift
// Inspired by: https://eclecticlight.co/2021/09/14/how-to-run-commands-and-scripts-on-efficiency-cores/
// Run directly:
// chmod +x runbg.swift
// ./runbg.swift
//
// Compile to static binary:
// swiftc runbg.swift -o runbg
@alin23
alin23 / ioreg.swift
Created September 9, 2021 06:30
AppleCLCD2 HDMI ioreg output
| | {
| | "QoSDebug" = 1
| | "ean-mode-caching" = 0
| | "CFBundleIdentifierKernel" = "com.apple.driver.AppleMobileDispH13G-DCP"
| | "IOMFBTemperatureCompensationEnable" = No
| | "PixelClock" = 533333328
| | "maxAverageBpp" = 0
| | "IOMFBBICSType" = 0
| | "enableDither" = Yes
| | "BacklightMatching" = {"IOPropertyMatch"={"backlight-control"=Yes}}
@import Darwin;
@import Foundation;
@import IOKit;
// clang -fmodules -o i2cwrite-scan i2cwrite-scan.m && ./i2cwrite-scan
typedef CFTypeRef IOAVServiceRef;
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator);
extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service);
import Cocoa
import Foundation
enum OSDImage: Int64 {
case brightness = 1
case contrast = 11
case volume = 3
case muted = 4
}
@import Darwin;
@import Foundation;
@import IOKit;
// clang -fmodules -o i2cwrite i2cwrite.m && ./i2cwrite
typedef CFTypeRef IOAVServiceRef;
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator);
extern IOAVServiceRef IOAVServiceCreateWithService(CFAllocatorRef allocator, io_service_t service);