Skip to content

Instantly share code, notes, and snippets.

Reda Lemeden kaishin

Block or report user

Report or block kaishin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kaishin / NSColor+isLight.h
Last active Jan 19, 2020
Programmatically determine the perceived lightness of a color. More details on: + Online tool:
View NSColor+isLight.h
#import <Cocoa/Cocoa.h>
@interface NSColor (isLight)
- (BOOL)isLight;
View swiftui-headers.swift
SwiftUI Headers
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreText
import Darwin
View snapshot.swift
extension NSView {
var snapshot: NSImage {
guard let bitmapRep = bitmapImageRepForCachingDisplayInRect(bounds) else { return NSImage() }
bitmapRep.size = bounds.size
cacheDisplayInRect(bounds, toBitmapImageRep: bitmapRep)
let image = NSImage(size: bounds.size)
return image
kaishin / dataSize.m
Created Jun 1, 2014
Log NSData size in a human-readable format.
View dataSize.m
NSLog(@"%@",[NSByteCountFormatter stringFromByteCount:data.length countStyle:NSByteCountFormatterCountStyleFile]);
View ATS.plist
kaishin / UIColor+isLight.h
Last active Jun 16, 2016
Get whether a color is dark or light using either luminance or lightness.
View UIColor+isLight.h
#import <UIKit/UIKit.h>
@interface UIColor (isLight)
- (CGFloat)lightness;
- (CGFloat)perceivedLightness;
- (CGFloat)perceivedLightnessW3C;
- (BOOL)isLight;
- (BOOL)isPerceivedLightW3C;
- (BOOL)isPerceivedLight;
kaishin / threadCheck.m
Last active Dec 27, 2015
My concurrency homie. Sprinkle some of it inside and around your blocks and concurrency will never come back to haunt you again.
View threadCheck.m
NSLog([NSThread currentThread] == [NSThread mainThread] ? @"❇️ Main thread, it is." : @"♒️ Doesn't look like main thread around here...");
kaishin / gray-with-lightness.scss
Created Oct 24, 2013
Return a gray color with a level of lightness.
View gray-with-lightness.scss
@function gray-with-lightness($level: 0.5) {
@if $level > 1 {
$level: 1.0;
} @else if $level < 0 {
$level: 0.0;
@return lighten(#000, percentage($level));
kaishin / asset.m
Created Jul 1, 2013
Get statusBar window
View asset.m
UIWindow *statusBar = [[UIApplication sharedApplication] performSelector:@selector(statusBarWindow)];
View WKScriptMessage+LeakFix.m
#import <mach-o/dyld.h>
#import <objc/runtime.h>
#import <WebKit/WebKit.h>
@interface WKScriptMessage (WKScriptMessageLeakFix)
@implementation WKScriptMessage (WKScriptMessageLeakFix)
+ (void)load {
You can’t perform that action at this time.