Skip to content

Instantly share code, notes, and snippets.

View robinhayward's full-sized avatar

Robin Hayward robinhayward

View GitHub Profile
@robinhayward
robinhayward / gist:5413798
Created April 18, 2013 15:46
JSON Example
[
{ "string_example":"Rob Hayward", "another_string_example":"[email protected]", "number_example":1, "boolean_example":true },
{ "string_example":"Rob Haywarder", "another_string_example":"[email protected]", "number_example":2, "boolean_example":false },
{ "string_example":"Rob Haywarded", "another_string_example":"[email protected]", "number_example":3, "boolean_example":true }
]
$('.class-for-page-elements').live("hover", function(event) {
var imageElement = event.element;
var url = $(imageElement).attr('src');
alert('You hovered an element with this url: ' + url);
$(imageElement).doSomeCoolZoomPluginStuff();
}
);
@robinhayward
robinhayward / gist:4685941
Created January 31, 2013 20:04
JavaScript image preloader
function bookletPreloader(pageNumber, numberOfPagesToPreload, bookletId)
{
this.booklet = $(bookletId);
this.numberOfPagesToPreload = numberOfPagesToPreload;
this.pageNumber = pageNumber;
this.createPreloadContainer = function() {
var html = '<div class="booklet-preloader-container">ads</div>';
if (!this.containerElement)
{
$('body').append(html);
<!doctype html>
<head>
<title>Preloader Idea - (More than one way to skin pussy cat)</title>
<style>
.preloader-container { display: none; }
</style>
</head>
<body>
<div class="preloader-container">
#!/bin/bash
#
# Release script
#
# A zip file will be produced with a release date and saved to the desktop
#
if [ "$1" = "" ]
then
echo "Error: $0 No project name given"
@robinhayward
robinhayward / gist:4176327
Created November 30, 2012 15:13
Sports Formations
#import "FASFormationFactory.h"
@implementation FASFormationFactory
+ (void)test
{
FASFormationFactory *factory = [[FASFormationFactory alloc] init];
NSArray *map = [factory formationForContainer:CGSizeMake(320.0f, 400.0f) lines:[NSArray arrayWithObjects:@"1", @"4", @"4", @"2", nil] itemSize:CGSizeMake(67, 100)];
}
@robinhayward
robinhayward / gist:4125463
Created November 21, 2012 15:31
Evenly spacing items from their center
- (void)midPointsForContainerWidth:(CGFloat)containerWidth itemWidth:(CGFloat)itemWidth itemCount:(NSInteger)itemCount
{
CGFloat itemSpace = (containerWidth - (itemCount * itemWidth)) / (itemCount + 1);
for (int i = 0; i < itemCount; i++) {
CGFloat point = itemSpace + ((itemWidth / 2));
if (i > 0) {
point += (itemWidth * i);
point += (itemSpace * i);
@robinhayward
robinhayward / gist:4111996
Created November 19, 2012 17:12
HTML Email Link
<p>We appreciate the time spent by many markets to complete our satisfaction survey. Your feedback is still highly appreciated.</p>
<p>Unfortunately the survey is now closed however if you would like to provide any general feedback please feel free to email Karen Peeters:</p>
<p><a href="mailto:[email protected]">[email protected]</a></p>
@robinhayward
robinhayward / gist:4078857
Created November 15, 2012 14:25
NavigationController/TabBarController Transition
//
// FASWindowState.m
// FAS
//
// Created by Rob Hayward on 14/11/2012.
//
#import "FASWindowState.h"
#import "FASWelcomeViewController.h"
#import "FASTeamsTabBarController.h"
@robinhayward
robinhayward / gist:4045874
Created November 9, 2012 14:10
Entry Post
{"dob":"29/01/1984","firstname":"Robin","email":"[email protected]","surname":"Hayward","uid":"0"}