Skip to content

Instantly share code, notes, and snippets.

View leecrossley's full-sized avatar

Lee Crossley leecrossley

View GitHub Profile
@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);
}
public static void ForEach<T>(this IEnumerable<T> items, Action<T> action)
{
foreach (var item in items)
{
action(item);
}
}
var turtleWriter = new CompressingTurtleWriter
{
HighSpeedModePermitted = true,
CompressionLevel = WriterCompressionLevel.None,
PrettyPrintMode = false
};
@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 / 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 / cookieLaw.js
Created July 18, 2012 14:03
NICE Cookie Usage - shows a banner at the top of the page (once) if based in the EU.
(function ($) {
function setCookie(a, b, c) {
var d = new Date();
d.setDate(d.getDate() + c);
var e = escape(b) + ((c == null) ? "" : "; expires=" + d.toUTCString());
document.cookie = a + "=" + e;
}
function getCookie(a) {
var i, x, y, cookieArray = document.cookie.split(";");
@leecrossley
leecrossley / FuzzBuzz with CSS
Created May 7, 2012 17:40
There's no JavaScript or markup content :)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>FuzzBuzz with CSS</title>
<style type="text/css">
body{counter-reset:fuzzbuzz;font-family:arial;font-size:18px;}
div{padding:10px;margin:10px;width:80px;float:left;height:30px;color:#999;text-align:center;}
div:after{content:counter(fuzzbuzz);counter-increment:fuzzbuzz;}
div:nth-child(3n):not(:nth-child(5n)):after{content:"fuzz";color:red;font-weight:bold;}
@leecrossley
leecrossley / gist:2251165
Created March 30, 2012 12:29
Style this.
<h1>CSS Basic Elements</h1>
<p>The purpose of this HTML is to help determine what default settings are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.</p>
<hr />
<h1 id="headings">Headings</h1>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
@leecrossley
leecrossley / Happy Panda.
Created March 28, 2012 12:36
Panda: without context splurge, callbacks or base library.
var panda = (function () {
var panda = {}, bambooLevel = 0, isAsleep = false;
function wakeUp() {
isAsleep = false;
}
panda.eatBamboo = function () {
bambooLevel = bambooLevel + 1;
};