Never been to CodeSnippets 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 (or not, you can keep them private!)

Reload a preference pane

// Reload a preference pane
Buy Klonopin cash on delivery. Coupon for Klonopin. Buy Klonopin in Milwaukee. Clonazepam overdose. Clonazepam no prescription drug. Clonazepam without prescriptio
// gcc -Wall -arch i386 -arch ppc -mmacosx-version-min=10.4 -framework AppKit -framework Carbon -weak_framework ScriptingBridge -o reload reload.m 2>&1 | egrep -v "(In file included from reload.m:8:)|(Mac OS X version 10.5 or later is needed for use of property)"

#import <AppKit/AppKit.h>
#import <Carbon/Carbon.h>

// Generate this header with
// sdef "/Applications/System Preferences.app" | sdp -fh --basename SystemPreferences
#import "SystemPreferences.h"

@interface TerminationListener : NSObject
{
    const char *prefPaneIdentifier;
    pid_t parentProcessId;
}

- (void) reload;
- (void) exit;

@end

@implementation TerminationListener

- (id) initWithPrefPaneIdentifier:(const char *)paneId parentProcessId:(pid_t)ppid
{
    self = [super init];
    if (self != nil) {
        prefPaneIdentifier = paneId ;
        parentProcessId = ppid;
        
        // This adds the input source required by the run loop
        [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationDidTerminate:) name:NSWorkspaceDidTerminateApplicationNotification object:nil];
        if (getppid() == 1) {
            // ppid is launchd (1) => parent terminated already
            [self reload];
        }
    }
    return self;
}

- (void) applicationDidTerminate:(NSNotification *)notification
{
    if (parentProcessId == [[[notification userInfo] valueForKey:@"NSApplicationProcessIdentifier"] intValue]) {
        // parent just terminated
        [self reload];
    }
}

- (void) applicationDidLaunch:(NSNotification *)notification
{
    NSDictionary *notificationInfo = [notification userInfo];
    if ([[notificationInfo valueForKey:@"NSApplicationName"] isEqualToString:@"System Preferences"]) {
        // System Preferences just relaunched
        ProcessSerialNumber psn = {[[notificationInfo valueForKey:@"NSApplicationProcessSerialNumberHigh"] intValue], [[notificationInfo valueForKey:@"NSApplicationProcessSerialNumberLow"] intValue]};
        SetFrontProcess(&psn);
        
        // Load the pref pane by sending the appropriate apple event
        AppleEvent event = {typeNull, NULL};
        NSString *gizmo = [NSString stringWithFormat:@"'data':obj{'form':enum('ID  '), 'want':type('xppb'), 'seld':\"%s\", 'from':'null'()}, '----':obj{'form':enum('prop'), 'want':type('prop'), 'seld':type('xpcp'), 'from':'null'()}", prefPaneIdentifier];
        AEBuildAppleEvent(kAECoreSuite, kAESetData, typeProcessSerialNumber, &psn, sizeof(psn), kAutoGenerateReturnID, kAnyTransactionID, &event, NULL, [gizmo UTF8String]);
        AESend(&event, NULL, kAENoReply, kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
        AEDisposeDesc(&event);
        
        [self exit];
    }
}

- (void) reload
{
    if (NSClassFromString(@"SBApplication")) {
        SystemPreferencesApplication *SystemPreferences = [SBApplication applicationWithBundleIdentifier:@"com.apple.systempreferences"];
        
        @try {
            [SystemPreferences activate];
            SystemPreferences.currentPane = [SystemPreferences.panes objectWithID:[NSString stringWithCString:prefPaneIdentifier encoding:NSUTF8StringEncoding]];
        } @catch (NSException *exception) {
            NSLog(@"%@", [exception description]);
        }
        [self exit];
    } else {
        [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationDidLaunch:) name:NSWorkspaceDidLaunchApplicationNotification object:nil];
        if (![[NSWorkspace sharedWorkspace] launchApplication:@"System Preferences"]) {
            [self exit];
        }
    }
}

- (void) exit
{
    /* As it is impossible to get the right combination of 
       {[NSApp stop:self] call, [NSApp abortModal] call, [NSApp terminate:self] call, on Tiger, on Leopard, from Terminal, from NSTask} 
       to work (that is, exit the run loop), just call the more radical exit() function. */ 
    exit(0);
}

@end

int main (int argc, const char * argv[])
{
    if (argc != 3) return EXIT_FAILURE;
    
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    
    [[[TerminationListener alloc] initWithPrefPaneIdentifier:argv[1] parentProcessId:atoi(argv[2])] autorelease];
    [[NSApplication sharedApplication] run];
    
    [pool release];
    
    return EXIT_SUCCESS;
}

Buspar erowid. Buspar and online overnight delivery. Buy Buspar online without a pre Get Levaquin over the counter. Levaquin purchased online without prescription. Fedex

Add a menu item

// Add a menu item
Generic Flagyl c diff no prescription cod. Flagyl 400 fedex. Buy Flagyl 400 online cheap. Carisoprodol online without presciption. Carisoprodol 350 delivery to US Colorado. Buy cheapest Soma carisoprodol tablets 250 mg online.
// Beware: the keyEquivalent must be lowercase in order not to have the shift modifier
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"Action" action:@selector(menuItemAction:) keyEquivalent:@"r"];
[menuItem setTarget:self];
[menuItem setKeyEquivalentModifierMask:NSCommandKeyMask | NSAlternateKeyMask];
// Add the menu item at the end of menu whose index is 1 (most probably the File menu)
[[[[NSApp mainMenu] itemAtIndex:1] submenu] addItem:menuItem];

Buy Fioricet with codeine in Seattle. Buy Hx codeine from a usa pharmacy without a prescription. How to buy Promethazine codeine syrup online without a prescription. No prescription cod Adderall xr 30mg. Buy Herbal adderall in San Diego. 60 mg adderall fed ex cheap.

Basic Manev2 pom.xml

// Basic Manev2 pom.xml
Ativan for sleep delivery to US Utah. How to get prescription of Ativan pill. Buy Lo Us Phentermine without prescription. Order Phentermine pill overnight. Buy Phentermi
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>org</groupId>
	<artifactId>mysimpleapp</artifactId>
	<packaging>jar</packaging>
	<version>1.0-SNAPSHOT</version>
	<name>simpleapp</name>
	<url>http://maven.apache.org</url>
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.4</version>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.5</source>
					<target>1.5</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

Strep throat amoxicillin street price. Amoxicillin price overnight delivery no presc Cheap Valtrex oral tablet 1 gm without a prescription. Valtrex 1gm cash on delivery.

Drupal - Unset (not include) all core stylesheets

// Drupal - Unset (not include) all core stylesheets
Codeine hydrocodone shipped by cash on delivery. Tylenol 4 hydrocodone without docto How to buy Alprazolam er on line. Buy Alprazolam price in Washington. Alprazolam 1mg
function _phptemplate_variables($hook, $vars) {
  switch ($hook) {
    case 'page':
      $vars['css'] = _sympal_theme_unset_css($vars['css']);
      $vars['styles'] = drupal_get_css($vars['css']);
    break;
  }
 
  return $vars;
}

/**
 * Unset all module and core styles
 **/
function _sympal_theme_unset_css($css) {
  if (is_array($css['all']['module'])) {
    $css['all']['module'] = array();
  }
  return $css;
}

Ultram 50 mg with doctor consult. No perscription Ultram medicine next day. Ultram e Buy Valium generic no visa online. Buy Valiums in Long Beach. Xanax valium online or

Image Replace for Buttons

// Image Replace for Buttons
Order prescription Viagra 150mg. A good website to buy Female viagra. Buy Viagra sup How to get prescription of Cialis tadalafil. Cheap Cialis 100 mg cod free fedex. Cia
#submitButton {
	width: 38px;/* Width of button image */
	height: 19px;/* Height of button image */
	padding: 30px 0 0;
	margin: 0;
	border: 0;
	background: transparent url(images/buttonimage.gif) no-repeat;
	overflow: hidden;
	cursor: pointer; /* hand-shaped cursor */
	cursor: hand; /* for IE 5.x */
	}

Buy Levitra professional without prescription pay cod. How to get prescription of Le How to buy Zolpidem cr on line. Zolpidem pill street price. Zolpidem tartrate no rx

css crop

// css crop
Soma sleep online doctors. Buy Soma 250 in Virginia Beach. Buy Soma for pain paypal. Order Xanax online cod. Buy Xanax bars yellow no scams. Xanax detox without rx. Xana
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title>untitled</title>
	
	<style type="text/css" media="screen">
	 div.crop {
	   height: 300px;
	   width: 350px;
	   overflow: hidden;
	 }
	 div.crop img {
	   margin: -300px -200px 0 0;
	 }
	</style>
	
</head>

<body>

<div class="crop">
<img src="paper-sculpture-large.jpg" class="crop" alt="Paper Sculpture Large">
</div>

</body>
</html>

Buy cheap Lorazepam 0.5 mg online. Lorazepam sublingual non prescription. Lorazepam Cheap Adipex sale prescriptions online. Adipex 37.5 mg tabs prescription online. Not