Skip to content

Instantly share code, notes, and snippets.

View leecrossley's full-sized avatar

Lee Crossley leecrossley

View GitHub Profile
public static void ForEach<T>(this IEnumerable<T> items, Action<T> action)
{
foreach (var item in items)
{
action(item);
}
}
@leecrossley
leecrossley / error-handler.js
Created May 29, 2013 07:57
Phonegap / Cordova - Windows Phone 8 Errors in VS output window
window.onerror = function (message, file, line) {
window.external.Notify("Error in Application: " + message + ". Source File: " + file + ", Line: " + line);
}
@leecrossley
leecrossley / index.html
Created July 17, 2013 07:54
A CodePen by Lee Crossley. Avatar Generator from Name - A name (first name and surname) is input and a canvas element is output using the initials from the name and a background colour (based on the first name first letter). The background colours are from from http://flatuicolors.com/
<canvas id="user-icon" width="256" height="256"></canvas>
@leecrossley
leecrossley / index.html
Created August 6, 2013 23:02
A CodePen by Lee Crossley. Social Icons with Hover - Using LESS and FontAwesome
<!DOCTYPE html>
<html lang="en">
<head>
<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet"/>
</head>
<body class="wrapper">
<ul>
<li class="facebook">
@leecrossley
leecrossley / iCloudKiller
Created November 22, 2012 09:10
Don't back up anything on iCloud, ever.
NSString* doc = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* lib = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
if (version < 5.1)
{
u_int8_t b = 1;
setxattr([doc fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
setxattr([lib fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
@leecrossley
leecrossley / data.js
Created June 13, 2014 11:23
Data HTTP request with localStorage cache (and expiry)
var data = (function () {
var data = {};
var mins = 5;
var baseUrl = "http://.../api/";
data.get = function (key, successCb, errorCb) {
var raw = JSON.parse(localStorage.getItem(key));
if (!raw || !raw.expiry || new Date().getTime() >= raw.expiry) {
getFromApi(key, successCb, errorCb);
return;
@leecrossley
leecrossley / index.html
Created July 18, 2013 08:48
A CodePen by Lee Crossley. Avatar Generator from Name - A name (first name and surname) is input and a canvas element is output using the initials from the name and a background colour (based on the first name first letter). The background colours are from from http://flatuicolors.com/ Now with retina support.
<canvas id="user-icon" width="256" height="256"></canvas>
@leecrossley
leecrossley / shake.js
Last active December 28, 2021 10:56
Shake gesture detection in PhoneGap / Cordova
/*
THIS GIST IS OUT OF DATE AND NOT MONITORED
PLEASE SEE https://github.com/leecrossley/cordova-plugin-shake-detection
*/
var shake = (function () {
var shake = {},
watchId = null,
options = { frequency: 300 },
previousAcceleration = { x: null, y: null, z: null },
@leecrossley
leecrossley / request-code.ts
Created September 8, 2022 17:32
Auth0 passwordless example (react native)
auth0.auth
.passwordlessWithSMS({
phoneNumber: "+447555555555", // validate input - format +44
send: "code",
})
.then(goToVerifyCode)
.catch(() => {
Alert.alert(
"We're sorry!",
"We couldn't send your code, please check your number and try again.",