Skip to content

Instantly share code, notes, and snippets.

@xarbit
xarbit / chbrt.m
Created Jul 4, 2021 — forked from waydabber/chbrt.m
This should change the brightness level of a single external display connected to an M1 MBP or MBA relative to the current setting using DDC/CI. Reportedly does not work on M1 Mini.
View chbrt.m
@import Darwin;
@import Foundation;
@import IOKit;
/*******
This should change the brightness level of a single external display connected to an M1 MBP or MBA relative to the current setting using DDC/CI. Reportedly does not work on M1 Mini.
Credits to @tao-j and @alin23
Compile:
View i2cwrite.m
@import Darwin;
@import Foundation;
@import IOKit;
// clang -fmodules -o i2cwrite i2cwrite.m && ./i2cwrite
typedef CFTypeRef IOAVServiceRef;
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator);
extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2);
// outputBufferSize must be less than (1 << 12) (4096 bytes)
@xarbit
xarbit / brt.m
Created Jul 4, 2021 — forked from tao-j/brt.m
M1 External Monitor Brightness Control over DDC
View brt.m
@import Darwin;
@import Foundation;
@import IOKit;
// clang -fmodules -o brt brt.m && ./brt
// credit to @zhuowei for discovering the following APIs
typedef CFTypeRef IOAVServiceRef;
extern IOAVServiceRef IOAVServiceCreate(CFAllocatorRef allocator);
extern IOReturn IOAVServiceCopyEDID(IOAVServiceRef service, CFDataRef* x2);
@xarbit
xarbit / m3u.swift
Created Mar 30, 2019 — forked from Cosmo/m3u.swift
Swift M3U Parser
View m3u.swift
struct MediaItem {
var duration: Int?
var title: String?
var urlString: String?
static func parseM3U(contentsOfFile: String) -> [MediaItem]? {
var mediaItems = [MediaItem]()
contentsOfFile.enumerateLines({ line, stop in
if line.hasPrefix("#EXTINF:") {
let infoLine = line.stringByReplacingOccurrencesOfString("#EXTINF:", withString: "")
@xarbit
xarbit / fritz_tv.m3u
Created Mar 29, 2019
fritzbox dvbc to ip
View fritz_tv.m3u
#EXTM3U
#EXTINF:-1 tvg-name="Das Erste HD" tvg-id="ARD.de" group-title="FritzTV" tvg-logo="http://tv.avm.de/tvapp/logos/daserstehd.png",Das Erste HD
rtsp://192.168.10.1:554/?avm=1&freq=330&bw=8&msys=dvbc&mtype=256qam&sr=6900&specinv=1&pids=0,16,17,18,20,5100,5101,1170,1176,2171,2172,5102,5103,5104,5105
#EXTINF:-1 tvg-name="ZDF HD" tvg-id="ZDF.de" group-title="FritzTV" tvg-logo="http://tv.avm.de/tvapp/logos/zdfhd.png",ZDF HD
rtsp://192.168.10.1:554/?avm=1&freq=450&bw=8&msys=dvbc&mtype=256qam&sr=6900&specinv=1&pids=0,16,17,18,20,6100,6110,6120,6121,6123,6130,6131,6170
#EXTINF:-1 tvg-name="RTL" tvg-id="RTL.de" group-title="FritzTV" tvg-logo="http://tv.avm.de/tvapp/logos/rtl.png",RTL
rtsp://192.168.10.1:554/?avm=1&freq=122&bw=8&msys=dvbc&mtype=64qam&sr=6900&specinv=1&pids=0,16,17,18,20,101,1401,1400,1402,1403,1404,1406,1407,1408
#EXTINF:-1 tvg-name="SAT.1" tvg-id="Sat1.de" group-title="FritzTV" tvg-logo="http://tv.avm.de/tvapp/logos/sat1.png",SAT.1
rtsp://192.168.10.1:554/?avm=1&freq=122&bw=8&msys=dvbc&mtype=64qa
@xarbit
xarbit / etc.fstab
Created Feb 3, 2019 — forked from vadviktor/etc.fstab
Ubuntu guest VMware shared folders using open-vm-tools package and vmhgfs-fuse
View etc.fstab
.host:/vmshared /mnt/vmshared fuse.vmhgfs-fuse allow_other,uid=1000,gid=1000,auto_unmount,defaults 0 0
@xarbit
xarbit / recovery.sh
Created Jan 13, 2019 — forked from jonathantneal/recovery.sh
Create or update macOS Mojave Recovery Partition Without Reinstalling
View recovery.sh
#!/bin/sh
# Set the macOS installer path as a variable
MACOS_INSTALLER="/Applications/$(ls /Applications | grep "Install macOS")"
MOUNT_POINT="$MACOS_INSTALLER/Contents/SharedSupport"
echo "macOS installer is \"$MACOS_INSTALLER\""
# Set the target disk as a variable
TARGET=$(diskutil info "$(bless --info --getBoot)" | awk -F':' '/Volume Name/ { print $2 }' | sed -e 's/^[[:space:]]*//')
echo "Target disk is \"$TARGET\""