{"id":17069001,"url":"https://github.com/kgn/kglib","last_synced_at":"2025-06-23T09:33:13.467Z","repository":{"id":138800932,"uuid":"1534222","full_name":"kgn/KGLib","owner":"kgn","description":"Cocoa library code","archived":false,"fork":false,"pushed_at":"2012-10-09T03:56:56.000Z","size":186,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T21:03:58.880Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kgn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-03-27T21:43:21.000Z","updated_at":"2023-12-25T22:34:41.000Z","dependencies_parsed_at":"2023-03-11T10:41:14.730Z","dependency_job_id":null,"html_url":"https://github.com/kgn/KGLib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kgn/KGLib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kgn%2FKGLib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kgn%2FKGLib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kgn%2FKGLib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kgn%2FKGLib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kgn","download_url":"https://codeload.github.com/kgn/KGLib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kgn%2FKGLib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261453025,"owners_count":23160438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T11:15:52.358Z","updated_at":"2025-06-23T09:33:08.457Z","avatar_url":"https://github.com/kgn.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"##OSX/KGAppExperation.h\n\n###@interface KGAppExperation : NSObject\n\nHere's an example of how to block and quit an application that has expired:\n\n``` obj-c\n- (void)applicationWillFinishLaunching:(NSNotification *)notification{\n    NSInteger daysLeft = [KGAppExperation daysLeftUntilExpiration:14 withCompileTimeZone:[NSTimeZone timeZoneWithName:@\"PST\"]];\n    NSLog(@\"days left: %lu\", daysLeft);\n\n    if(daysLeft == 0){\n        NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@\"CFBundleName\"];\n        NSString *appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@\"CFBundleVersion\"];\n\n        NSLog(@\"%@ %@ has expired\", appName, appVersion);\n        NSAlert *alert = [[NSAlert alloc] init];\n        [alert addButtonWithTitle:@\"OK\"];\n        [alert setMessageText:[NSString stringWithFormat:@\"%@ has expired\", appName]];\n        [alert setInformativeText:[NSString stringWithFormat:@\"The beta period for version %@ has expired.\", appVersion]];\n        [alert setAlertStyle:NSCriticalAlertStyle];\n        [alert runModal];\n\n        [NSApp terminate:self];\n    }\n}\n```\n\nDays left = compile day - current day \u003c= expiration\n\nThe time zone should be set to the time zone the code was compiled in\n\n```obj-c\n+ (NSUInteger)daysLeftUntilExpiration:(NSUInteger)days withCompileTimeZone:(NSTimeZone *)timeZone;\n```\n\n##OSX/KGDivider.h\n\n###@interface KGDivider : NSSplitView\n\n###@interface KGDividerDelegate : NSObject \u003cNSSplitViewDelegate\u003e\n\n##OSX/KGGrowl.h\n\n###@interface KGGrowl : NSObject \u003cGrowlApplicationBridgeDelegate\u003e\n\n```obj-c\n@property (strong, readonly) NSString *notification;\n```\n\n```obj-c\n- (id)initWithNotification:(NSString *)newNotification;\n```\n\n```obj-c\n- (void)displayMessage:(NSString *)message withTitle:(NSString *)title;\n```\n\n##OSX/KGLogin.h\n\n###@interface KGLogin : NSObject\n\n```obj-c\n+ (NSURL *)appURL;\n```\n\n```obj-c\n+ (BOOL)willStartAtLogin;\n```\n\n```obj-c\n+ (BOOL)willStartAtLogin:(NSURL *)itemURL;\n```\n\n```obj-c\n+ (void)setStartAtLogin:(BOOL)enabled;\n```\n\n```obj-c\n+ (void)setStartAtLogin:(NSURL *)itemURL enabled:(BOOL)enabled;\n```\n\n##OSX/KGMenuBarPopup.h\n\n###@interface KGMenuBarPopup : NSObject \u003cNSWindowDelegate\u003e\n\n```obj-c\n@property (nonatomic, strong) NSString *title;\n@property (nonatomic, strong) NSImage *image;\n@property (nonatomic, strong) NSImage *alternateImage;\n@property (nonatomic) CGFloat width;\n```\n\n```obj-c\n- (id)initWithWidth:(CGFloat)width view:(NSView *)view;\n```\n\n```obj-c\n- (id)initWithWidth:(CGFloat)width view:(NSView *)view offset:(CGFloat)offset;\n```\n\n```obj-c\n- (void)hideView;\n```\n\n```obj-c\n- (void)centerView;\n```\n\n##OSX/KGPasteboard.h\n\n###@interface KGPasteboard : NSObject\n\nThe general use pasteboard\n\n```obj-c\n+ (NSString *)generalPasteBoardString;\n```\n\nCopy a strig to the general pasteboard\n\n```obj-c\n+ (void)copyString:(NSString *)string;\n```\n\nCopy a string to the general pasteboard and html to the general html pasteboard\n\n```obj-c\n+ (void)copyString:(NSString *)string andHTML:(NSString *)html;\n```\n\n##OSX/KGPopUpButtonImageCell.h\n\n###@interface KGPopUpButtonImageCell : NSPopUpButtonCell\n\n##OSX/KGProcess.h\n\n###@interface KGProcess : NSObject\n\nTransform the process into a forground application\n\n```obj-c\n+ (void)transformToForegroundApplication;\n```\n\nSet the application as the front most one\n\n```obj-c\n+ (void)setApplicationFront;\n```\n\n##OSX/KGRatingView.h\n\n###@interface KGRatingView : NSView\n\n```obj-c\n@property (nonatomic, getter=isEnabled) BOOL enabled;\n@property (nonatomic) BOOL allowHalfRating;\n@property (nonatomic) NSUInteger rating;\n@property (nonatomic) NSTimeInterval hoverDelay;\n```\n\n```obj-c\n- (void)setRatingChangedCallback:(KGRatingViewCallback)block;\n```\n\n##OSX/KGURLHandler.h\n\n###@interface KGURLHandler : NSObject\n\n```obj-c\n+ (id)handlerWithScheme:(NSString *)scheme andIdentifier:(NSString *)identifier;\n```\n\n```obj-c\n- (id)initWithScheme:(NSString *)scheme andIdentifier:(NSString *)identifier;\n```\n\n```obj-c\n- (void)registerDefaultAction:(KGURLHandlerAction)action;\n```\n\n```obj-c\n- (void)registerCommandPath:(NSString *)path withAction:(KGURLHandlerAction)action;\n```\n\n##OSX/ScriptingBridge/KGFinder.h\n\n###@interface KGFinder : NSObject {}\n\n```obj-c\n+ (FinderApplication *)finder;\n```\n\n```obj-c\n+ (NSString *)activeFinderWindowURL;\n```\n\n```obj-c\n+ (NSArray *)selectedFinderURLs;\n```\n\n##OSX/ScriptingBridge/KGTerminal.h\n\n###@interface KGTerminal : NSObject\n\n```obj-c\n+ (NSString *)appId;\n```\n\n```obj-c\n+ (TerminalApplication *)terminal;\n```\n\n```obj-c\n+ (NSString *)escapePath:(NSString*)path;\n```\n\n```obj-c\n+ (void)shellTo:(NSString *)path;\n```\n\n```obj-c\n+ (void)shellTo:(NSString *)path clear:(BOOL)clear additionalCommand:(NSString *)additionalCommand;\n```\n\n```obj-c\n+ (void)runCommand:(NSString *)command;\n```\n\n##Shared/KGFoundation.h\n\n##Shared/KGImageCache.h\n\n###@interface KGImageCache : NSObject\n\n```obj-c\n- (id)initWithCapacity:(NSUInteger)capacity;\n```\n\n```obj-c\n- (void)retainKey:(id)key;\n```\n\n```obj-c\n- (BOOL)didLoad:(id)key;\n```\n\n```obj-c\n- (void)setDidLoad:(id)key;\n```\n\n```obj-c\n- (KGImageCacheImage *)imageForKey:(id)key;\n```\n\n```obj-c\n- (void)setImage:(KGImageCacheImage *)image forKey:(id)key;\n```\n\n```obj-c\n- (void)releaseKey:(id)key;\n```\n\n```obj-c\n- (void)removeKey:(id)key;\n```\n\n##Shared/KGKeychain.h\n\n###@interface KGKeychain : NSObject\n\n```obj-c\n+ (BOOL)passwordExistsForService:(NSString *)serviceName andAccount:(NSString *)accountName;\n```\n\n```obj-c\n+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName andAccount:(NSString *)accountName;\n```\n\n```obj-c\n+ (NSString *)passwordForService:(NSString *)serviceName andAccount:(NSString *)accountName;\n```\n\n```obj-c\n+ (BOOL)removeEntryForService:(NSString *)serviceName andAccount:(NSString *)accountName;\n```\n\n##Shared/KGXPath.h\n\n##Shared/NSArray+KG.h\n\n###@interface NSArray(KG)\n\nReturn the first object in the array\n\n```obj-c\n- (id)firstObject;\n```\n\nReturn the first `n` objects in the array\n\n```obj-c\n- (NSArray *)firstObjects:(NSUInteger)count;\n```\n\nReturn the last `n` objects in the array\n\n```obj-c\n- (NSArray *)lastObjects:(NSUInteger)count;\n```\n\n##Shared/NSDictionary+KGJSON.h\n\n###@interface NSDictionary(KGJSON)\n\n```obj-c\n- (NSUInteger)uintSafelyFromKey:(id)key;\n```\n\n```obj-c\n- (NSString *)stringSafelyFromKey:(id)key;\n```\n\n```obj-c\n- (NSURL *)URLSafelyFromKey:(id)key;\n```\n\n```obj-c\n- (id)objectSafelyFromKey:(id)key;\n```\n\n##Shared/NSMutableAttributedString+KG.h\n\n###@interface NSMutableAttributedString(KG)\n\n```obj-c\n- (NSRange)replaceString:(NSString *)src withString:(NSString *)dst;\n```\n\n```obj-c\n- (void)replaceString:(NSString *)src withString:(NSString *)dst andAttributes:(NSDictionary *)attributes;\n```\n\n```obj-c\n- (void)replaceString:(NSString *)src withString:(NSString *)dst andLink:(NSURL *)url withTooltip:(NSString *)tooltip;\n```\n\n```obj-c\n- (void)addTextShadow:(NSShadow *)shadow;\n```\n\n##Shared/NSString+KGFile.h\n\n###@interface NSString(KGFile)\n\nReturn a valid filename\n\n```obj-c\n- (NSString *)validFilename;\n```\n\nReturn a valid filename, if `allowHidden` is `YES` then periods will be allows as the first character\n\n```obj-c\n- (NSString *)validFilenameAllowHidden:(BOOL)allowHidden;\n```\n\nTransform a path into it's true mount path, or return nil\n\nExample: `/Volumes/slave1` -\u003e `afp://Slave%20One/slave1`\n\n```obj-c\n- (NSString *)volumeMountURLWithError:(NSError **)error;\n```\n\n##Shared/NSString+KGHTTP.h\n\n###@interface NSString(KGHTTP)\n\nEncode a dictionary into a url string.\n\nExample: `{name:'David Keegan', age:26}` -\u003e `name=David%20Keegan\u0026age=26`\n\n```obj-c\n+ (NSString *)urlEncodedStringForArgs:(NSDictionary *)args;\n```\n\nURL encode a string, this encodes more characters than `[NSString stringByAddingPercentEscapesUsingEncoding:]`\n\n```obj-c\n- (NSString *)stringWithURLEncoding;\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkgn%2Fkglib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkgn%2Fkglib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkgn%2Fkglib/lists"}