Skip to content

Instantly share code, notes, and snippets.

View tmdvs's full-sized avatar
:shipit:
making things and breaking things

Tim Davies tmdvs

:shipit:
making things and breaking things
View GitHub Profile
console.log($(this, 'input[name=basket_item\[product_id\]]').val());
PS1='\[\033[00;32m\]\u\[\033[01m\]@\[\033[00;36m\]\h\[\033[01m\]:\[\033[00;35m\]\w\[\033[00m\]\[\033[0;37m\](`git branch 2>/dev/null|tr -d \*\ `)\[\033[00m\]\$ '
@implementation UIApplication(Retina)
- (BOOL) deviceIsRetina
{
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] == YES && [[UIScreen mainScreen] scale] == 2.00) {
// RETINA DISPLAY
return YES;
}
else
{
@tmdvs
tmdvs / gist:869789
Created March 14, 2011 20:20
Using CALayers for dynamic shadows
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(30, 30, 260, 260)];
/* It's important to remember to pass CG structs like floats and CGColors */
[[myView layer] setShadowOffset:CGSizeMake(0, 1)];
[[myView layer] setShadowColor:[[UIColor darkGrayColor] CGColor]];
[[myView layer] setShadowRadius:3.0];
- (void) didRotate:(UIRotationGestureRecognizer *)sender
{
rotation = (rotation + [sender rotation]);
rotationTransform = CGAffineTransformMakeRotation(rotation);
[[self view] setTransform:rotationTransform];
}
- (void) didRotate:(UIRotationGestureRecognizer *)sender
{
CGAffineTransform original = [[self view] transform];
CGAffineTransform newTransform = CGAffineTransformMakeRotation([sender rotation]);
[[self view] setTransform:CGAffineTransformConcat(original, newTransform)];
[sender setRotation:0];
}
--
-- 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`
--
@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();
@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 / 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]