Skip to content

Instantly share code, notes, and snippets.

View xdmorgan's full-sized avatar
Unverified

Dan Morgan xdmorgan

Unverified
View GitHub Profile
/**
* Hot BG
*/
background: #f06;
background: radial-gradient(0deg, #f06, yellow);
min-height:100%;
@xdmorgan
xdmorgan / class.js
Last active December 15, 2015 02:29
Ultra simple JavaScript class template (there's many ways to shoehorn OOP principles into JS but this is the way I like to do my classes, if you have a preferred method let me know). Follow the simple instructions at the top of the document to instantiate it and view the private/public variables/functions at work.
/* =========================================================
————————————— JS STYLE CLASS TEMPLATE —————————————
============================================================
Link to script in the <head> (or just before the </body>) of
your HTML document, then in the browser's console copy/paste
the following code to instantiate the class:
c = new Class();
@xdmorgan
xdmorgan / cacheguide.md
Created August 12, 2013 14:25
Introduction to the Cache Manifest. (WIP)

#HTML5 Cache Manifest

###Getting Started

Start by adding the cache attribute to your opening html tag <html cache="somefile.manifest">.

####Examples (Dev)

In this first example we're going to be using a dev version of the cache manifest where we will specify that nothing is cached. For examples of a production cache manifest see below.

@xdmorgan
xdmorgan / validate-email-function.js
Created February 5, 2014 17:57
regex, handles everything i've thrown at it (that was a legit email) including + signs
function validateEmail(email) {
var re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(email);
}
@xdmorgan
xdmorgan / lol.konami.js
Created May 30, 2014 20:53
Based on chris coyiers konami code, adds konami class to html to override styles and triggers jquery event "KONAMI_CODE" for js fun.
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(e) {
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ) {
$(document).unbind('keydown',arguments.callee);
@xdmorgan
xdmorgan / modulate.js
Last active August 29, 2015 14:26
Got a framer prototype with this handy function in it, tried writing my own, judging by my use-case it mimics Framer's modulate perfectly, however, I should to run it through some unit tests see if it always does. [feedback welcome]
// map a value from one range onto another, in this case scrolling
var st = _private.getScrollTop(),
m1 = _private.modulate( st, [0, 500], [0,1] ),
m2 = _private.modulate( st, [0, 400], [1,0] ),
m3 = _private.modulate( st, [0, 300], [0,3] );
_private.modulate = function(val, range1, range2){
var min1 = range1[0], max1 = range1[1],
min2 = range2[0], max2 = range2[1],
@xdmorgan
xdmorgan / _grid.scss
Last active August 29, 2015 14:27
A simple and flexible Sass grid.
$create-grid: true;
// Breakpoints
$break-mobile: 320px;
$break-mobile-max: 460px;
$break-tablet: 760px;
$break-tablet-max: 900px;
$break-desktop: 1104px;
$break-desktop-max: 1320px;
@xdmorgan
xdmorgan / random.string.js
Last active September 9, 2015 22:29
Generates a random string, in this case an ID.
/* Optional customization ==========================
generateID();
generateID({
base: 'video_',
length: 12,
charset: '1234asdf',
overkill: true
});
@xdmorgan
xdmorgan / NIBEXAMPLE.swift
Last active August 16, 2016 13:20
Swift 2 IBDesignable Nib Tutorial / Boilerplate
/*
Start by creating two files (replace NIBEXAMPLE with w/e you want but make sure the names match):
1, NIBEXAMPLE.xib
* File > New > File... > iOS > View
2, NIBEXAMPLE.swift
* File > New > File... > iOS > Cocoa Touch Class (Extends UIView)
After creating the two files above, replace the default contents of your .swift file
with the code below. Be sure to update `class NIBEXAMPLE` and `nibName = "NIBEXAMPLE"`
@xdmorgan
xdmorgan / raw.css
Created February 27, 2018 20:13
Testing styles over the internet, fam.
h1, .h1 {
color: royalblue;
}
a, a:link {
color: orangered;
}