View main.m
#import <Foundation/Foundation.h> | |
#import <dlfcn.h> | |
// clang main.m -framework Foundation | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
dlopen("/System/Library/Frameworks/CoreGraphics.framework/Resources/BridgeSupport/CoreGraphics.dylib", RTLD_LAZY); | |
View 10.15.4 initWithHTML: attributed string change
from AppKit import * | |
from Foundation import * | |
html = NSString.stringWithString_("<b style='font-size: 20px; font-family: HelveticaNeue'>Hi</b>") | |
d = html.dataUsingEncoding_(NSUTF8StringEncoding); | |
ats = NSAttributedString.alloc().initWithHTML_options_documentAttributes_(d, None, None)[0]; | |
ps = ats.attribute_atIndex_effectiveRange_(NSParagraphStyleAttributeName, 0, None)[0] | |
print(ps.minimumLineHeight()) | |
print(ps.maximumLineHeight()) |
View Leaky16BPCTiff.m
/* | |
This sample shows how CGImageSourceCreateThumbnailAtIndex leaks something akin | |
to the memory behind a CGImageRef when asked to create a thumbnail for a 16bpc | |
TIFF image if one isn't present. | |
Full sample project here: | |
http://shapeof.com/archives/2019/media/SixteenBitPerComponentThumbnailLeak.zip | |
*/ | |
View nodestyle.m
- (FJSValue*)evaluateModuleAtURL:(NSURL*)scriptURL { | |
if (scriptURL) { | |
NSError *error; | |
NSString *script = [NSString stringWithContentsOfURL:scriptURL encoding:NSUTF8StringEncoding error:&error]; | |
if (script) { | |
#define NODE_STYLE_WRAPPER 1 | |
#ifdef NODE_STYLE_WRAPPER |
View AddCursor.jstalk
/* | |
How to install this plugin: | |
1) Choose Acorn's Help ▸ Open Acorn's App Support Folder menu item. | |
2) Place this script in the Plug-Ins folder (and make sure it ends with .jstalk) | |
3) Restart Acorn. The plugin will now show up in the Filter menu. | |
*/ | |
function main(image, doc, layer) { | |
View gist:a475e2916f1e860b3b7dd2143862d5a5
var url = NSURL.fileURLWithPath_('/Library/Desktop Pictures/Yosemite.jpg'); | |
var img = CIImage.imageWithContentsOfURL_(url) | |
var f = CIFilter.filterWithName_('CIColorInvert'); | |
f.setValue_forKey_(img, kCIInputImageKey); | |
var r = f.outputImage(); | |
var tiff = r.TIFFRepresentation(); | |
tiff.writeToFile_atomically_('/tmp/foo.tiff', true); | |
NSWorkspace.sharedWorkspace().openFile_('/tmp/foo.tif'); |
View gist:6324222
[db makeFunctionNamed:@"UTTypeConformsTo" maximumArguments:2 withBlock:^(sqlite3_context *context, int argc, sqlite3_value **argv) { | |
if (sqlite3_value_type(argv[0]) == SQLITE_TEXT) { | |
const unsigned char *a = sqlite3_value_text(argv[0]); | |
const unsigned char *b = sqlite3_value_text(argv[1]); | |
CFStringRef as = CFStringCreateWithCString(nil, (const char*)a, kCFStringEncodingUTF8); | |
CFStringRef bs = CFStringCreateWithCString(nil, (const char*)b, kCFStringEncodingUTF8); | |
sqlite3_result_int(context, UTTypeConformsTo(as, bs)); |
View TSCreateImageFromIOSurface
void TSCreateImageFromIOSurfaceReleaseCallback(void * __nullable info, const void *data, size_t size); | |
void TSCreateImageFromIOSurfaceReleaseCallback(void * __nullable info, const void *data, size_t size) { | |
CFRelease(info); | |
} | |
CGImageRef TSCreateImageFromIOSurface(IOSurfaceRef surface, CGColorSpaceRef cs) { | |
View bring to front
NSWorkspace *workspace = [NSWorkspace sharedWorkspace]; | |
NSDictionary *activeAppDict = [workspace activeApplication]; | |
ProcessSerialNumber psn; | |
psn.highLongOfPSN = [[activeAppDict objectForKey:@"NSApplicationProcessSerialNumberHigh"] intValue]; | |
psn.lowLongOfPSN = [[activeAppDict objectForKey:@"NSApplicationProcessSerialNumberLow"] intValue]; | |
SetFrontProcess( &psn ); |
View gist:de321e5a00894f8f7df57b78d7468ba8
NSImageRep *originalCursorRep = [originalCursorImage bestRepresentationForRect:NSMakeRect(0, 0, [originalCursorImage size].width * retinaScale, [originalCursorImage size].height * retinaScale) context:nil hints:[NSDictionary dictionaryWithObject:[NSAffineTransform transform] forKey:NSImageHintCTM]]; |
NewerOlder