Skip to content

Instantly share code, notes, and snippets.

View tmdvs's full-sized avatar
🔆
making cool stuff with cool people

Tim Davies tmdvs

🔆
making cool stuff with cool people
View GitHub Profile
#pragma mark -
#pragma mark Core Data stack
/**
Returns the managed object context for the application.
If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
*/
- (NSManagedObjectContext *) managedObjectContext {
if (managedObjectContext != nil) {
NSArray *myMainThreadShit = nil;
dispatch_async( dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
// do massive intensive shit
NSArray *myShit = [MyModel getMyShit];
dispatch_async( dispatch_get_main_queue(), ^{
// this is on main thread
myMainThreadShit = [myShit copy];
typedef enum {
SyncManagerStatusOK,
SyncManagerStatusFailed,
SyncManagerStatusPending,
SyncManagerStatusDownloading,
SyncManagerStatusWriting,
SyncManagerStatusDownloadingTemplates,
SyncManagerStatusWritingTemplates,
SyncManagerStatusDownloadingDocuments,
SyncManagerStatusWritingDocuments,
typedef enum {
SyncManagerStatusOK,
SyncManagerStatusFailed,
SyncManagerStatusPending,
SyncManagerStatusDownloading,
SyncManagerStatusWriting,
SyncManagerStatusDownloadingTemplates,
SyncManagerStatusWritingTemplates,
SyncManagerStatusDownloadingDocuments,
SyncManagerStatusWritingDocuments,
nav#socialicons img { margin-right: 16px; opacity: 0.35; -webkit-transition-duration: 0.5s;}
nav#socialicons span { display: block; padding: 0px 10px; position: absolute; top: -28px; opacity: 0; border-radius: 50px; background: #222; -webkit-transition-duration: 0.5s;}
nav#socialicons a:hover img { opacity: 1; -webkit-transform: rotateY(360deg); -webkit-transition-timing-function: ease-out; }
nav#socialicons a:hover img + span { opacity: 1;}
@tmdvs
tmdvs / gist:1501956
Created December 20, 2011 15:32
For your Prefix.pch
#define UILoremIpsum [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"filltext" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil]
@tmdvs
tmdvs / gist:1433922
Created December 5, 2011 15:16
Subtracting a string from inside a CALayer. Like an cut out mask in Photoshop.
CALayer *myLayer = [CALayer layer];
[myLayer setFrame:rect];
[myLayer setBackgroundColor:[myColour CGColor]];
[myLayer setCornerRadius:radius];
UIGraphicsBeginImageContext([myLayer frame].size);
CGContextRef context = UIGraphicsGetCurrentContext();
@tmdvs
tmdvs / example.m
Created December 5, 2011 15:14
Subtracting a string from inside a CALayer. Like an cut out mask in Photoshop.
CALayer *myLayer = [CALayer layer];
[myLayer setFrame:rect];
[myLayer setBackgroundColor:[myColour CGColor]];
[myLayer setCornerRadius:radius];
UIGraphicsBeginImageContext([myLayer frame].size);
CGContextRef context = UIGraphicsGetCurrentContext();
--
-- Constraints for table `roles_users`
--
ALTER TABLE `roles_users`
ADD CONSTRAINT `roles_users_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE,
ADD CONSTRAINT `roles_users_ibfk_2` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;
--
-- Constraints for table `user_tokens`
--
- (void) didRotate:(UIRotationGestureRecognizer *)sender
{
CGAffineTransform original = [[self view] transform];
CGAffineTransform newTransform = CGAffineTransformMakeRotation([sender rotation]);
[[self view] setTransform:CGAffineTransformConcat(original, newTransform)];
[sender setRotation:0];
}