Skip to content

Instantly share code, notes, and snippets.

View smic's full-sized avatar

Stephan Michels smic

View GitHub Profile
@0xced
0xced / CLAlert.h
Last active January 17, 2021 13:26
CLAlert
/*
* CLAlert is a drop-in replacement for NSAlert
*
* A CLAlert is exactly the same as a NSAlert, except for the alert style behavior
*
* - An alert with the informational style (NSInformationalAlertStyle) will always display a "Note icon" (kAlertNoteIcon)
* - An alert with the warning style (NSWarningAlertStyle) will always display a "Caution icon" (kAlertCautionIcon)
* - An alert with the critical style (NSCriticalAlertStyle) will always display a "Stop icon" (kAlertStopIcon)
*
* Tested on Mac OS X 10.5.8, 10.6.1 and 10.11.5
#!/bin/sh
~/Applications/UniversalIndentGUI/indenters/uncrustify -l OC -q -c ~/Applications/UniversalIndentGUI/config/uncrustify_obj_c.cfg
@paulirish
paulirish / rAF.js
Last active July 19, 2024 19:50
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@mikeabdullah
mikeabdullah / gist:2836559
Created May 30, 2012 14:08
Etched appearance labels
[[textField cell] setBackgroundStyle:NSBackgroundStyleRaised];
@mikeabdullah
mikeabdullah / gist:3553124
Created August 31, 2012 14:07
Carefully suggesting a previous location to a save panel
NSSavePanel *savePanel = [NSSavePanel savePanel];
NSURL *url = [self mostRecentlySavedToURL];
NSURL *parentDirectory = [url URLByDeletingLastPathComponent];
NSNumber *isDirectory;
if ([parentDirectory getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:NULL] &&
[isDirectory boolValue])
{
[savePanel setDirectoryURL:parentDirectory];
@adib
adib / BSManagedDocument.h
Created September 11, 2012 06:07
An NSDocument subclass that supports asynchronous Core Data operations
//
// BSManagedDocument.h
//
// Created by Sasmito Adibowo on 29-08-12.
// Copyright (c) 2012 Basil Salad Software. All rights reserved.
// http://basilsalad.com
//
// Licensed under the BSD License <http://www.opensource.org/licenses/bsd-license>
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@mikeabdullah
mikeabdullah / gist:3706001
Created September 12, 2012 11:15
Pre-flight saving a Core Data binary store
NSNumber *writable;
if ([storeURL getResourceValue:&writable forKey:NSURLIsWritableKey error:outError])
{
if ([writable boolValue])
{
return [context save:outError];
}
else if (outError)
{
// Generic error. NSError takes care of supplying a nice generic message to go with it
@odrobnik
odrobnik / gist:3811844
Created October 1, 2012 13:37
Modally presenting a sheet/panel the UIKit style
//
// NSWindow+DTViewControllerPresenting.m
// DTFoundation
//
// Created by Oliver Drobnik on 10/1/12.
// Copyright (c) 2012 Cocoanetics. All rights reserved.
//
#import "objc/runtime.h"
@mikeabdullah
mikeabdullah / BSManagedDocument.h
Created November 2, 2012 12:04 — forked from adib/BSManagedDocument.h
An NSDocument subclass that supports asynchronous Core Data operations
//
// BSManagedDocument.h
//
// Created by Sasmito Adibowo on 29-08-12.
// Copyright (c) 2012 Basil Salad Software. All rights reserved.
// http://basilsalad.com
//
// Licensed under the BSD License <http://www.opensource.org/licenses/bsd-license>
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ryanmaxwell
ryanmaxwell / ryan-objc.cfg
Last active June 26, 2019 16:41
Objective-C Uncrustify Config
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.2 (140)
#
# Alignment
# ---------
## Alignment