Skip to content

Instantly share code, notes, and snippets.

@misterbailey
misterbailey / wedge.svg
Created June 24, 2016 13:31
The Students at UWE - Red Polygon SVG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@misterbailey
misterbailey / UWE Email Validation
Created September 12, 2016 10:31
Used for forms on the Student Ideas submission form
$( document ).ready(function() {
// Delcare Vars
var email = $('input#email');
var emailWrap = $('.email-wrap');
var emailWrapperAlert = email.parent('.input-wrap > div.alert');
var alertBox = true;
var emailVal = $('input#email').val()
$('#ideas-submit-button').click(function(event){
// Stop the button default
@misterbailey
misterbailey / HighlightCurrentNav.js
Last active September 15, 2016 14:19
A simple jQuery function to add a class of 'active' to the current navigation. Great for all those one-pagers out there
// Highlight Current Nav
$(document).ready(function() {
// Declare vars
var sections = $('section')
var nav = $('nav')
// When the window scrolls get the position
$(window).on('scroll', function() {
var curPos = $(this).scrollTop();
// An offset value based on window height
@misterbailey
misterbailey / jQueryShyHeader.css
Last active October 13, 2016 22:35
jQuery to show/hide header in a fashion similar to medium.com
.shy-header {
position: fixed;
top: 0;
width: 100%;
left: 0;
height: 91px;
z-index:9999;
}
@misterbailey
misterbailey / v-align.css
Last active November 16, 2016 13:40
Vertical align class I use often
.v-align-wrapper {
position: absolute;
left: 0;
bottom: 0;
top: 0;
width: 100%;
height: 100%;
display: table;
margin: 0 auto;
@misterbailey
misterbailey / shadows.css
Created November 16, 2016 13:41
Material Design shadows
// Shadows
.shadow-1 {
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
}
.shadow-2 {
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
transition: all 0.3s cubic-bezier(.25,.8,.25,1);
@misterbailey
misterbailey / date_regex.php
Last active January 5, 2017 11:55
Regex: retrieve date from string
$regex = '/(?<date_format_1>(?<day>(?i)\b\s*[0-9]+(?:st|nd|rd|th|)?)
(?<month>(?i)(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sept(?:ember?)|Oct(?:ober)?|Nov(?:ember?)|Dec(?:ember)?))
(?<year>\b\s*20[0-9]{2}))|
(?<date_format_2>(?P>month)(?P>day)(?!\s+-)(?:\s&amp;\s(?P>day))?) |
(?<range_type_1>(?P>month)(?P>day)\s+-\s+(?P>day))
/x';
document.observe("dom:loaded", function() {
console.log('DOM loaded');
// $$('td').invoke('observe', 'click', setColor);
});
var smile = {
0:[0,0,0,0,0,0,0,0,0,0,0,0,0], // Dont use this row
1:[0,0,0,1,1,1,1,1,0,0,0,0,0],
2:[0,0,1,0,0,0,0,0,1,0,0,0,0],
@misterbailey
misterbailey / 0_reuse_code.js
Created September 20, 2017 09:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console