Skip to content

Instantly share code, notes, and snippets.

View xhruso00's full-sized avatar

Marek Hrusovsky xhruso00

  • Bratislava, Slovakia
View GitHub Profile
@xhruso00
xhruso00 / gist:af12d0bd0785ed17a30101ee3c21e97d
Created February 14, 2024 09:40
ZIP compression for TIFF macOS Cocoa
NSTIFFCompression with zip has enum value 8
NSData *originalData = [NSData dataWithContentsOfURL:URL];
NSImage *image = [[NSImage alloc] initByReferencingURL:URL];
NSBitmapImageRep *imageRep = (NSBitmapImageRep *)[[image representations] firstObject];
NSLog(@"%@", [NSBitmapImageRep localizedNameForTIFFCompressionType:8]); //prints null
BOOL canBecompressed = [imageRep canBeCompressedUsing:8];
NSLog(@"%d", canBecompressed); //prints NO
@xhruso00
xhruso00 / README.md
Created June 13, 2022 02:49 — forked from IsaacXen/README.md
(Almost) Every WWDC videos download links for aria2c.
import Cocoa
class SomeView : NSView {
var trackingArea : NSTrackingArea?
override func draw(_ dirtyRect: NSRect) {
NSColor.red.setFill()
dirtyRect.fill()
}
@xhruso00
xhruso00 / CIFilter+CILineOverlay.h
Last active October 16, 2019 19:33
Magic behind CIFilter modernization (for swift) on macOS 10.15 uses class_addMethod
#import <Cocoa/Cocoa.h>
#import <CoreImage/CoreImage.h>
@protocol CILineOverlay <CIFilter>
@property (nonatomic, retain) CIImage *inputImage;
@property (nonatomic) float threshold;
@end
@interface CIFilter(CILineOverlay)
+ (CIFilter<CILineOverlay>*) lineOverlayFilter;
点我达iOS首页
iOS Block探究
2017/12/28
###
iOS Block探究
Block 结构体
对应的结构体定义如下:
#import <AVFoundation/AVFoundation.h>
@interface AVCaptureDevice(Additions)
+ (NSArray<AVCaptureDevice *>*)inputCameraDevices;
- (BOOL)isBuiltIn;
- (BOOL)hasVideoMedia;
- (BOOL)canOpenCamera;
@end
@xhruso00
xhruso00 / Mojave-dynamic-wallpaper-notes.md
Created June 14, 2018 02:29 — forked from ole/Mojave-dynamic-wallpaper-notes.md
Reverse-engineering the dynamic wallpaper file format in macOS Mojave.

The dynamic wallpaper in MacOS Mojave is a single 114 MB .heic file that seems to contain 16 embedded images.

It also contains the following binary plist data in its metadata under the key "Solar". It's an array of 16 items, each with four keys:

  • i (integer). This seems to be the image index.
  • o (integer). This is always 1 or 0. Stephen Radford thinks it indicates dark mode (0) vs. light mode (1).
  • a (decimal). I’m pretty sure this is the angle of the sun over the horizon. 0º = sunset/sunrise. 90º = sun directly overhead. Negative values = sun below horizon.
  • z (decimal). This seems to be the cardinal position of the sun relative to the camera. 0º = sun is directly in front of the camera. 90º = sun is directly to the right of the camera. 180º = sun is directly behind the camera.
1. Quit Photos app and run command "launchctl stop photolibraryd"
2. Use sqlite3 or some app to edit "database/photos.db" file; run SQL command UPDATE RKVersion SET createDate = imageDate WHERE imageDate >0
3. Run command "launchctl start photolibraryd"
@xhruso00
xhruso00 / gist:cf8243b552be4fb5372c857e602f6859
Created October 9, 2017 16:08 — forked from lukhnos/gist:2892699
Enumerate all available keyboard layouts on Mac OS X and write out their icons
// need to include <Carbon/Carbon.h> and link against Carbon.framework
// not every layout/input method has TIFF icon
CFArrayRef list = TISCreateInputSourceList(NULL, true);
for (int i = 0; i < CFArrayGetCount(list); i++) {
TISInputSourceRef source = (TISInputSourceRef)CFArrayGetValueAtIndex(list, i);
IconRef icon = TISGetInputSourceProperty(source, kTISPropertyIconRef);
CFStringRef sourceID = TISGetInputSourceProperty(source, kTISPropertyInputSourceID);
//
// main.m
// antidebugging
//
// Created by Vincent Tan on 7/8/15.
// Copyright (c) 2015 Vincent Tan. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"