Skip to content

Instantly share code, notes, and snippets.

View stevekirkby's full-sized avatar

Steve Kirkby stevekirkby

  • Isle of Wight, UK
View GitHub Profile
@stevekirkby
stevekirkby / gist:bbbf1820da53be999bfb
Created November 30, 2015 07:44 — forked from keighl/gist:3289664
CABasicAnimation - tilt into background (a la National Geographic Park Guides)
- (void)dropItBack:(id)sender
{
// Position
CABasicAnimation *posAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
posAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(self.center.x, self.center.y - 50.f)];
// Opacity
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.toValue = [NSNumber numberWithFloat:0.5f];
@stevekirkby
stevekirkby / Asset.html
Created May 18, 2015 10:46
Wordpress custom queries example
function custom_query() {
// args
$args = array(
'numberposts' => -1,
'post_type' => 'artists',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'surname',
'value' => 'Blow',
@stevekirkby
stevekirkby / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@stevekirkby
stevekirkby / gist:7266e42145eba3076ed7
Last active August 29, 2015 14:09
Touch Icons and Favicons with Wordpress Template link
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices (57x57): -->
<link rel="apple-touch-icon-precomposed" href="<?php echo get_template_directory_uri(); ?>/library/images/favicons//icon-57.png">
<!-- For the iPad mini and the first- and second-generation iPad on iOS ≤ 6: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="<?php echo get_template_directory_uri(); ?>/library/images/favicons//icon-72.png">
<!-- For the iPad mini and the first- and second-generation iPad on iOS ≥ 7: -->
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="<?php echo get_template_directory_uri(); ?>/library/images/favicons//icon-76.png">
<!-- For iPhone with high-resolution Retina display running iOS ≤ 6: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="<?php echo get_template_directory_uri(); ?>/library/images/favicons//icon-114.png">
<!-- For iPhone with high-resolution Retina display running iOS ≥ 7: -->
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="<?php echo
<!-- For non-Retina iPhone, iPod Touch, and Android 2.1+ devices (57x57): -->
<link rel="apple-touch-icon-precomposed" href="icons/icon-57.png">
<!-- For the iPad mini and the first- and second-generation iPad on iOS ≤ 6: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="icons/icon-72.png">
<!-- For the iPad mini and the first- and second-generation iPad on iOS ≥ 7: -->
<link rel="apple-touch-icon-precomposed" sizes="76x76" href="icons/icon-76.png">
<!-- For iPhone with high-resolution Retina display running iOS ≤ 6: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="icons/icon-114.png">
<!-- For iPhone with high-resolution Retina display running iOS ≥ 7: -->
<link rel="apple-touch-icon-precomposed" sizes="120x120" href="icons/icon-120.png">
@stevekirkby
stevekirkby / index.html
Created July 21, 2013 15:13
Effect to expand offset lines with across screen as the user scrolls down the page
<!DOCTYPE html>
<html lang=en>
<head>
<title>Page Title</title>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js' type='text/javascript'></script>
<script src="javascript.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
@stevekirkby
stevekirkby / gist:5894674
Created June 30, 2013 10:36
PHP - Time since date
$start_date = new DateTime('2007-09-01 04:10:58');
$since_start = $start_date->diff(new DateTime('2012-09-11 10:25:00'));
echo $since_start->days.' days total<br>';
echo $since_start->y.' years<br>';
echo $since_start->m.' months<br>';
echo $since_start->d.' days<br>';
echo $since_start->h.' hours<br>';
echo $since_start->i.' minutes<br>';
echo $since_start->s.' seconds<br>';
@stevekirkby
stevekirkby / gist:5635183
Created May 23, 2013 10:32
Rotate a UIView around a fixed point. Note that setting the frame at init and then setting the anchor point will move the view. Init, then set the layer bound, position, anchor
CABasicAnimation *rotation;
rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotation.fromValue = [NSNumber numberWithFloat:0];
rotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
rotation.duration = 60.0f;
rotation.repeatCount = HUGE_VALF;
UIView *myview = [[UIView alloc] init];
[self.view addSubview:myview];
[myview setBackgroundColor:[UIColor orangeColor]];
@stevekirkby
stevekirkby / gist:5547043
Created May 9, 2013 11:55
Draggable UIView with bounce back to left and right limits. Uses animateWithDuration and log velocity to calculate return speed. An improvement would be to tweak the return speed to incorporate the distance from the return point
- (void)panLeftRight:(id)sender {
CGFloat autoLayoutConstant = _keyboardAuto.centerKeyboardConstraint.constant;
CGFloat panableKeyboardSize = [_keyboardAuto panableKeyBoardSize];
CGFloat frameWidth = _keyboardAuto.frame.size.width;
CGFloat lowerLimit = -panableKeyboardSize/2 + frameWidth/2;
CGFloat upperLimit = panableKeyboardSize/2 - frameWidth/2;
UIPanGestureRecognizer *pgr = (UIPanGestureRecognizer *)sender;
CGPoint translation = [pgr translationInView:pgr.view];
@stevekirkby
stevekirkby / gist:5433443
Created April 22, 2013 09:10
Animated UIView/UIButton appearance with growth past bounds and return to bounds. Note, there's no need for two sublayers here. Originally intended for UIView but works fine with UIButton as in code
- (void)showPopupButton {
// no need for two CALayers here. Originally intended for UIView but works fine with UIButton
UIButton *myButton = [[UIButton alloc] initWithFrame:CGRectMake(10, 10, CGRectGetMaxX(self.view.bounds)-20, 100)];
[myButton setBackgroundColor:[UIColor orangeColor]];
[myButton addTarget:self action:@selector(newButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[myButton.layer setCornerRadius:10.0];
[self.view addSubview:myButton];
CALayer *outerLayer = [CALayer layer];
CATextLayer *innerLayer = [CATextLayer layer];