This file contains 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
#!/usr/bin/env bash | |
# Lets you `cd 'iCloud Drive'` from your home directory, | |
# or `cd ~/iCloud\ Drive` from elsewhere. | |
ln -sv ~/Library/Mobile\ Documents/com~apple~CloudDocs/ ~/iCloud\ Drive | |
chflags -h hidden ~/iCloud\ Drive |
This file contains 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
#!/bin/bash | |
# | |
# (Above line comes out when placing in Xcode scheme) | |
# | |
# Inspired by original script by incanus: | |
# https://gist.github.com/1186990 | |
# | |
# Rewritten by martijnthe: | |
# https://gist.github.com/1379127 | |
# |
This file contains 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)drawGradientInContext:(CGContextRef)context withStartPosition:(CGPoint)startPosition endPosition:(CGPoint)endPosition startColor:(UIColor *)startColor endColor:(UIColor *)endColor | |
{ | |
CGFloat locations[2] = {0.0, 1.0}; | |
const CGFloat *startComponents = CGColorGetComponents(startColor.CGColor); | |
const CGFloat *endComponents = CGColorGetComponents(endColor.CGColor); | |
CGFloat components[8] = {startComponents[0], startComponents[1], startComponents[2], startComponents[3], endComponents[0], endComponents[1], endComponents[2], endComponents[3]}; | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); | |
CGGradientRef gradient = CGGradientCreateWithColorComponents(colorSpace, components, locations, 2); | |
CGContextDrawLinearGradient(context, gradient, startPosition, endPosition, 0); |
This file contains 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
int main (int argc, const char * argv[]) { | |
dispatch_queue_t waitingChairs = dispatch_queue_create("waitingChairs", 0); | |
dispatch_queue_t barber = dispatch_queue_create("barber", 0); | |
dispatch_semaphore_t semaphore = dispatch_semaphore_create(3); | |
NSInteger ident = 0; | |
while (++ident) { | |
if (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW) != 0) { | |
printf("Customer %d turned away\n", ident); | |
continue; | |
} |