Skip to content

Instantly share code, notes, and snippets.

Avatar

Lee Crossley leecrossley

View GitHub Profile
@leecrossley
leecrossley / Happy Panda.
Created Mar 28, 2012
Panda: without context splurge, callbacks or base library.
View Happy Panda.
var panda = (function () {
var panda = {}, bambooLevel = 0, isAsleep = false;
function wakeUp() {
isAsleep = false;
}
panda.eatBamboo = function () {
bambooLevel = bambooLevel + 1;
};
View gist:2251165
<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 / FuzzBuzz with CSS
Created May 7, 2012
There's no JavaScript or markup content :)
View FuzzBuzz with CSS
<!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 / cookieLaw.js
Created Jul 18, 2012
NICE Cookie Usage - shows a banner at the top of the page (once) if based in the EU.
View cookieLaw.js
(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 / shake.js
Last active Feb 8, 2021
Shake gesture detection in PhoneGap / Cordova
View shake.js
/*
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 / iCloudKiller
Created Nov 22, 2012
Don't back up anything on iCloud, ever.
View iCloudKiller
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);
View RDF Graph Writing
var turtleWriter = new CompressingTurtleWriter
{
HighSpeedModePermitted = true,
CompressionLevel = WriterCompressionLevel.None,
PrettyPrintMode = false
};
View ForEach Extension
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
Phonegap / Cordova - Windows Phone 8 Errors in VS output window
View error-handler.js
window.onerror = function (message, file, line) {
window.external.Notify("Error in Application: " + message + ". Source File: " + file + ", Line: " + line);
}
@leecrossley
leecrossley / index.html
Created Jul 17, 2013
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/
View index.html
<canvas id="user-icon" width="256" height="256"></canvas>