Skip to content

Instantly share code, notes, and snippets.

Avatar

Reda Lemeden kaishin

View GitHub Profile
@kaishin
kaishin / asset.m
Created Jul 1, 2013
Get statusBar window
View asset.m
UIWindow *statusBar = [[UIApplication sharedApplication] performSelector:@selector(statusBarWindow)];
@kaishin
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
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
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
kaishin / NSColor+isLight.h
Last active Jan 19, 2020
Programmatically determine the perceived lightness of a color. More details on: http://robots.thoughtbot.com/closer-look-color-lightness + Online tool: http://thoughtbot.github.io/color-lightness-test/
View NSColor+isLight.h
#import <Cocoa/Cocoa.h>
@interface NSColor (isLight)
- (BOOL)isLight;
@end
@kaishin
kaishin / tabs.coffee
Last active Aug 29, 2015
Accordion Tabs
View tabs.coffee
ACTIVE_CLASS = 'js-is-active'
$tabs = $("[data-role='tab']")
$toggles = $tabs.find("[data-role='link']")
$toggles.on 'click', (event) ->
event.preventDefault()
$toggle = $(@)
$tab = $toggle.closest($tabs)
unless $tab.hasClass(ACTIVE_CLASS)
$tabs.removeClass(ACTIVE_CLASS)
@kaishin
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]);
@kaishin
kaishin / SassMeister-input-HTML.html
Created Jun 2, 2014
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<div class="container">
<section>Section 1</section>
<section>Section 2</section>
</div>
View selector-helpers.scss
@function attr-ends-with-string($attr, $string) {
@return "[#{$attr}$=#{$string}]";
}
@kaishin
kaishin / SassMeister-input.scss
Last active Aug 29, 2015
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// Sass (v3.4.6)
// Compass (v1.0.1)
// Bourbon (v4.0.2)
// Neat (v1.6.0)
// ----
@import "bourbon/bourbon";
$grid-columns: 6;
@import "neat/neat";
You can’t perform that action at this time.