Skip to content

Instantly share code, notes, and snippets.

View klaas's full-sized avatar
🤠
Howdy!

Klaas klaas

🤠
Howdy!
View GitHub Profile
@0xced
0xced / CopyLaunchedApplicationsInFrontToBackOrder.c
Created August 7, 2009 14:06
Get an array of running applications ordered by last use
#import <Carbon/Carbon.h>
#import <dlfcn.h>
/*
* Returns an array of CFDictionaryRef types, each of which contains information about one of the processes.
* The processes are ordered in front to back, i.e. in the same order they appear when typing command + tab, from left to right.
* See the ProcessInformationCopyDictionary function documentation for the keys used in the dictionaries.
* If something goes wrong, then this function returns NULL.
*/
CFArrayRef CopyLaunchedApplicationsInFrontToBackOrder(void)
@PaulSolt
PaulSolt / ImageHelper.h
Created December 13, 2010 15:54
A simple UIImage to RGBA8 conversion function
/*
* The MIT License
*
* Copyright (c) 2011 Paul Solt, PaulSolt@gmail.com
*
* https://github.com/PaulSolt/UIImage-Conversion/blob/master/MITLicense.txt
*
*/
#import <Foundation/Foundation.h>
@lukeredpath
lukeredpath / ExampleClass.m
Created June 30, 2011 22:18
Macro for creating your "shared instance" using GCD
@implementation MySharedThing
+ (id)sharedInstance
{
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{
return [[self alloc] init];
});
}
@end
@klaas
klaas / gist:3170952
Created July 24, 2012 16:14
Open a location in Little Locations and let it be displayed in the create tab
// Create location url object
NSURL *url = [NSURL URLWithString:@"littlelocations://create?lat=18.99&lon=72.95&name=Mumbai%20Inner%20Circus"];
// Test if Little Locations is installed
if([[UIApplication sharedApplication] canOpenURL:url] ) {
// Open Location in Little Locations
[[UIApplication sharedApplication] openURL:url];
@jder
jder / Downscaling ALAssets
Last active March 20, 2018 06:51
A method for downscaling ALAssets
// For details, see http://mindsea.com/2012/12/18/downscaling-huge-alassets-without-fear-of-sigkill
#import <AssetsLibrary/AssetsLibrary.h>
#import <ImageIO/ImageIO.h>
// Helper methods for thumbnailForAsset:maxPixelSize:
static size_t getAssetBytesCallback(void *info, void *buffer, off_t position, size_t count) {
ALAssetRepresentation *rep = (__bridge id)info;
NSError *error = nil;
@joshtwist
joshtwist / TodoService.m
Last active December 15, 2015 21:29
Simple sample of In-App purchase receipt verification and storage in Mobile Services DB
// this is from the client code - simply pass the transactionReceipt property of the SKPaymentTransaction
// as the receipt parameter to the method below. This will POST the data to the mobile service which will,
// in turn, invoke the insert function on the server shown in this gist
- (void)insertReceipt:(NSData *)receipt completion:(CompletionBlock)completion
{
NSString *string = [[NSString alloc] initWithData:receipt encoding:NSUTF8StringEncoding];
[self.receipts insert:@{ @"receipt" : string } completion:^(NSDictionary *item, NSError *error) {
completion();
}];
}
@ccstone
ccstone / BBEdit-TextWrangler_RegEx_Cheat_Sheet.txt
Last active May 10, 2024 15:41
BBEdit-TextWrangler Regular Expression Cheat-Sheet
————————————————————————————————————————————————————————————————————————————————————————————————————
BBEdit / BBEdit-Lite / TextWrangler Regular Expression Guide Modified: 2018/08/10 01:19
————————————————————————————————————————————————————————————————————————————————————————————————————
NOTES:
The PCRE engine (Perl Compatible Regular Expressions) is what BBEdit and TextWrangler use.
Items I'm unsure of are marked '# PCRE?'. The list while fairly comprehensive is not complete.
@vitorgalvao
vitorgalvao / Get Title and URL.applescript
Last active May 6, 2024 04:49
AppleScript and JavaScript for Automation to get frontmost tab’s url and title of various browsers.
-- AppleScript --
-- This example is meant as a simple starting point to show how to get the information in the simplest available way.
-- Keep in mind that when asking for a `return` after another, only the first one will be output.
-- This method is as good as its JXA counterpart.
-- Webkit variants include "Safari", "Webkit", "Orion".
-- Specific editions are valid, including "Safari Technology Preview".
-- "Safari" Example:
tell application "Safari" to return name of front document
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@eternalstorms
eternalstorms / Apple Evangelists.txt
Created June 12, 2013 09:07
Apple Evangelists (WWDC 2013)
UI- and App Frameworks Evangelist - Jake Behrens, behrens@apple.com, twitter: @Behrens
- What's new in Cocoa
- Accessibility in iOS
- Building User Interfaces for iOS 7
- Getting Started with UIKit Dynamics
- What's new in Cocoa Touch
- What's New With Multitasking
- Best Practices for Cocoa Animation
- Improving Power Efficiency with App Nap
- Introducing Text Kit