This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SQLite3 | |
import Foundation | |
func main(dbPath: String) { | |
// Pointer for database connection | |
var db: OpaquePointer? | |
// Open database | |
guard sqlite3_open(dbPath, &db) == SQLITE_OK else { | |
print("Error opening database: \(String(cString: sqlite3_errmsg(db)))") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// main.m | |
// TheCaseOfTheMissingPixel | |
// | |
// Created by August Mueller on 3/13/24. | |
// | |
#import <AppKit/AppKit.h> | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Before running this, setup a python venv for everything: | |
# python3 -m venv coremltools-venv | |
# source coremltools-venv/bin/activate | |
# pip install -U coremltools | |
import coremltools as ct | |
from coremltools.models.neural_network import quantization_utils | |
# load full precision model | |
model_fp32 = ct.models.MLModel('Beby-GANx4.mlmodel') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 | |
*/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
NewerOlder