Skip to content

Instantly share code, notes, and snippets.

@rudyrichter
rudyrichter / CopyMACAddress.m
Last active August 27, 2020 16:08
In doing receipt validation for Mac App Store, there are certain rules that should be followed in getting the MAC address of the machine. This is what AppStore.app uses for its validation.
io_service_t io_service(const char *name, BOOL wantBuiltIn) {
io_iterator_t iterator = IO_OBJECT_NULL;
mach_port_t master_port = IO_OBJECT_NULL;
io_service_t service = IO_OBJECT_NULL;
if (KERN_SUCCESS != IOMasterPort(MACH_PORT_NULL, &master_port)) {
return IO_OBJECT_NULL;
}
CFMutableDictionaryRef matchingDict = IOBSDNameMatching(master_port, 0, name);
scutil
> n.add State:/Network/Interface
> n.watch
> notification callback (store address = 0x7feb1bc0ab80).
8:24:49.159 changedKey [0] = State:/Network/Interface
notification callback (store address = 0x7feb1bc0ab80).
8:25:03.313 (+14.153) changedKey [0] = State:/Network/Interface
@rudyrichter
rudyrichter / Growl.applescript
Created March 7, 2012 06:33 — forked from amccloud/Growl.applescript
Lion iChat Growl Notifications
using terms from application "iChat"
on message received message from theBuddy for textChat
set whoDidIt to full name of theBuddy
set buddyIcon to image of theBuddy
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
end tell
tell application frontApp
set window_name to name of front window
end tell
@rudyrichter
rudyrichter / Go home.applescript
Created March 5, 2012 23:35 — forked from nriley/Go home.applescript
Multiple disk unmounting script with Time Machine to disk image/iTunes support
property _timeMachineDiskName : "Backup of Babs"
property _diskNamesToTryToEject : {"MaryMedia", "MaryBackup+", "ShirleyClone", "ShirleyLion", "bzzt"}
property _growlApplication : "Go home"
property _growlNotification : "Status"
on _notify(_title, _description)
tell application id "com.Growl.GrowlHelperApp" to notify with name _growlNotification title _title description _description application name _growlApplication identifier _growlNotification
end _notify
sudo mkdir -p /Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app/Contents/MacOS
sudo touch /Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app/Contents/MacOS/GrowlHelperApp
- (void)scrollWheel:(NSEvent *)theEvent
{
if([theEvent modifierFlags] & NSShiftKeyMask)
[super scrollWheel:theEvent];
else
{
CGEventRef sourceEvent = [theEvent CGEvent];
CGEventRef cgEvent = CGEventCreateCopy(sourceEvent);
if(cgEvent)
{