Skip to content

Instantly share code, notes, and snippets.

View matherton's full-sized avatar

Mark Atherton matherton

View GitHub Profile
@matherton
matherton / calendar.php
Created November 15, 2011 17:57
This form generates a calendar and poulates it with event data from my localhost MySQL DB
<?php
/* Database connection to test database */
$connection = mysql_connect('localhost','wp_user','wp_password');
if (!$connection)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("wordpres",$connection);
?>
<html>
@matherton
matherton / index.html
Last active November 26, 2019 12:09
es6 Higher Order Functions & Arrays example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- The page title that is displayed in the top of the browser -->
<title></title>
<!-- Meta content describes your page and is indexed by search engines such as Google -->
<meta name="description" content="JS High Order function">
<meta name="author" content="Mark Atherton">
@matherton
matherton / Update Eventbrite form
Created September 23, 2011 10:20
Simple Eventbrite create venue and event form
<html>
<head>
<title>Event creation form</title>
</head>
<!-- All strings - These are mandatory fields title, start_date, end_date, timezone. The description is optional but guess we would require -->
<body>
<!-- A form to create an event and passes it's variables to event_creator.php -->
<form method="post" action="event_creator.php">
<fieldset>
@matherton
matherton / .jsx
Created August 30, 2018 11:31
ES6 function for un-selectable radio buttons
radioChecked = () => {
var allRadios = document.querySelectorAll('input[type="radio"]');
allRadios.forEach(r => {
r.addEventListener('mouseup', function(e) {
if (r.checked) {
setTimeout(() => {
r.checked = false;
}, 0);
}
});
$(window).resize(function() {
var captions = $('.module-main-links .caption'),
height = 0;
captions.each(function() {
var captionHeight = $(this).outerHeight();
if (captionHeight > height) {
height = captionHeight;
}
});
@matherton
matherton / ajaxloaderdemo.html
Last active January 4, 2016 17:19
AJAX demo that loads a PHP script once the request has completed. I use MAMP but any server running APACHE and PHP would be fine.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="custom-booking-search.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$(document).ajaxStart(function(){
$("#plane-border").css("display","block");
@matherton
matherton / HTML5template
Last active January 4, 2016 02:39
Basic HTML5 page template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<!-- The page title that is displayed in the top of the browser -->
<title>The HTML5 Herald</title>
<!-- Meta content describes your page and is indexed by search engines such as Google -->
<meta name="description" content="The HTML5 BASE template">
@matherton
matherton / unlinked-search
Last active January 4, 2016 02:39
Bash script to find unlinked files in a directory
@matherton
matherton / test-jquery.html
Created January 22, 2014 10:25
Example of how to do a simple AJAX injection of a datepicker field on an onClick event. NOTE requires to be run on a server (I use Apache) and the file being injected is stored in a test folder.
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="../css/ui.css">
</head>
<body>
<div id="tempload"></div>
<button id="btntest" name="btntest">test</button>
@matherton
matherton / showHide.js
Last active December 29, 2015 00:28
Show and hide JS with no jQuery
function toggle(id) {
var element = document.getElementById(id);
if(element.style.display == "block")
hide(id);
else
show(id);
}