Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS 

How to make the system notify you of audio cd insertion

// Uses the DiskArbitration framework to notify ya of when new audio cds are inserted

NSDictionary *match = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"IOCDMedia", [NSNumber numberWithBool:YES], nil] forKeys:[NSArray arrayWithObjects:(NSString *)kDADiskDescriptionMediaKindKey, kDADiskDescriptionMediaWholeKey, nil]];
		
_session = DASessionCreate(kCFAllocatorDefault);
DASessionScheduleWithRunLoop(_session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
DARegisterDiskAppearedCallback(_session, (CFDictionaryRef)match, diskAppearedCallback, NULL);
DARegisterDiskDisappearedCallback(_session, (CFDictionaryRef)match, diskDisappearedCallback, NULL);

common command line equivalent in python

>>> import os

>>> os.getcwd() # get current working directory
'C:\\lang\\python23'

>>> os.chdir('C:/') # change directory
>>> os.chdir('lang') # again

>>> os.listdir('.') # list
['dotnet', 'try', 'editplus', 'python23', 'leo', 'mingw', 'perl', 'gtk', 'ironpy', 'java142']
>>>
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS