Skip to content

Instantly share code, notes, and snippets.

View leeprobert's full-sized avatar

Lee Probert leeprobert

View GitHub Profile
@leeprobert
leeprobert / StreetViewImageConversion
Created November 7, 2014 15:08
This bit of code will convert the StreetView getZoom() Number into the 'field of view' property you need for the StreetView Image API.
var zoom = panorama.getPov().zoom;
var fov = 180/Math.pow(2,zoom);
@leeprobert
leeprobert / CoolUnitySceneViewController
Created February 10, 2015 10:45
UnityAppController subclass
//
// CoolUnitySceneViewController.m
// Unity-iPhone
//
// Created by Frederik Jacques on 06/08/14.
//
//
#import "CoolUnitySceneViewController.h"
#import "GoodByeViewController.h"
@leeprobert
leeprobert / styles.css
Created July 21, 2015 12:28
Force webkit search input to look like a standard textfield
input[type="search"] { -webkit-appearance: textfield; }
@leeprobert
leeprobert / form_kit.html
Last active August 29, 2015 14:25
A bunch of things that are useful in a HTML5 form
<!-- Regular expression for UK postcodes -->
<label for=postcode>Postcode<span class="red">*</span></label>
<input name=postcode type=text aria-required required pattern="[0-9]{5}(\-[0-9]{4})?|[a-zA-Z]{1,2}\d{1,2}\s?\d[a-zA-Z]{1,2}" placeholder="A valid UK postcode" />
<!-- to test in the browser console use: -->
/^(:?[a-zA-Z]{1,2}\d{1,2}\s?\d[a-zA-Z]{1,2})$/.test("tn12 6an")
@leeprobert
leeprobert / NSTimer+Blocks.h
Created October 9, 2011 13:54
Category on NSTimer that adds Blocks support.
#import <Foundation/NSTimer.h>
@interface NSTimer (PSYBlockTimer)
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds repeats:(BOOL)repeats usingBlock:(void (^)(NSTimer *timer))fireBlock;
+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)seconds repeats:(BOOL)repeats usingBlock:(void (^)(NSTimer *timer))fireBlock;
@end
@leeprobert
leeprobert / getNewBitmap.as
Created December 6, 2011 10:03
fit a bitmap image to its container regardless of aspect ratio
protected function getNewBitmap(data:BitmapData):Bitmap
{
var horizontalRatio:Number = this.width / data.width;
var verticalRatio:Number = this.height / data.height;
var ratio:Number = Math.max(horizontalRatio,verticalRatio);
var matrix:Matrix = new Matrix();
matrix.scale(ratio,ratio);
@leeprobert
leeprobert / Main.as
Created February 12, 2012 06:31
Flash application class for loading Flex SWF files and calling methods off them
package {
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.SWFVersion;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
@leeprobert
leeprobert / flash-unicode-table.xml
Created February 21, 2012 18:01
Flash Unicode range mapping XML
<?xml version="1.0" encoding="iso-8859-1" ?>
<!--
This file provides a convenient mapping of the Flash MX 2004 UnicodeTable.xml character ranges
for use in Macromedia Flex's configuration file. You can copy ranges from this reference list and add
them to Flex's configuration file.
Developers embed fonts into applications as not every client has the same fonts installed. To reduce
the size of the application developers often include a subset of the characters available in a font -
this subset is known as a character range.
@leeprobert
leeprobert / CaptureViewController.m
Created February 24, 2012 23:04
Cocoa class for capturing the web cam and building an image up by rows of pixels
//
// CaptureViewController.m
// TimeSmear
//
// Created by Lee Probert on 23/02/2012.
// Copyright (c) 2012 LyraSpace Ltd. All rights reserved.
//
#import "CaptureViewController.h"
@leeprobert
leeprobert / GridConstraintBasicLayout
Created March 5, 2012 09:52
A layout class for automatically positioning and resizing child elements of a container to a grid.
package com.cc.eurostarlive.layouts
{
import mx.core.ILayoutElement;
import mx.core.IVisualElement;
import spark.layouts.supportClasses.LayoutBase;
public class GridConstraintBasicLayout extends LayoutBase
{
/*