Skip to content

Instantly share code, notes, and snippets.

View jasonclark's full-sized avatar

Jason A. Clark jasonclark

View GitHub Profile
<?php
//get and set url protocol
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
//set and sanitize global variables for URL construction
$server = isset($_SERVER['SERVER_NAME']) ? htmlentities(strip_tags($_SERVER['SERVER_NAME'])) : null;
$path = isset($_SERVER['PHP_SELF']) ? htmlentities(strip_tags(dirname($_SERVER['PHP_SELF']))) : null;
$fileName = isset($_SERVER['SCRIPT_NAME']) ? htmlentities(strip_tags(basename($_SERVER['SCRIPT_NAME']))) : null;
$fileNameURI = isset($_SERVER['REQUEST_URI']) ? htmlentities(strip_tags($_SERVER['REQUEST_URI'])) : null;
$fileExtension = isset($_SERVER['PATH_INFO']) ? pathinfo($fileName, PATHINFO_EXTENSION) : null;
@jasonclark
jasonclark / The `app` object (with scrolltop improvement for long views).markdown
Created December 23, 2015 04:31
The `app` object (with scrolltop improvement for long views)

The app object (with scrolltop improvement for long views)

The simple app object defining routes and "life cycle" like functions.

A Pen by Heydon on CodePen.

License.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Speech API demo</title>
<link rel="stylesheet" href="css/style.css">
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
@jasonclark
jasonclark / social-media-share-markup
Last active January 27, 2017 15:43
Minimum viable social metadata markup - opengraph and twitter; Based on: https://dev.twitter.com/cards/getting-started#opengraph
<meta property="og:title" content="EmbedThis (Oembed)"/>
<meta property="og:description" content="Utility app that checks for an Oembed endpoint & returns HTML embed code."/>
<meta property="og:image" content="http://www.lib.montana.edu/~jason/files/oembed-this/meta/img/share-code-small.png"/>
<meta property="og:url" content="http://www.lib.montana.edu/~jason/files/oembed-this/index.php"/>
<meta property="og:type" content="website"/>
<meta name="twitter:creator" property="og:site_name" content="@jaclark"/>
<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:site" content="http://www.jasonclark.info"/>
@jasonclark
jasonclark / gist:6d6613358f43653fec89
Created January 26, 2015 02:20
JSON-LD for Web page with additional types using schema.org
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "WebPage",
"name": "Title of web page",
"description": "Description of web page",
"additionalType": [
{
"@id": "http://dbpedia.org/page/Navajo"
},
@jasonclark
jasonclark / booklist-lhuede.html
Created November 19, 2012 22:00
Book Review List using Google Spreasheet API and jQuery
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Reading List</title>
<style type="text/css">
.items {display:table;list-style:none;margin:0;padding:0;border-spacing:5px;}
.items li {display:table-row;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;border:1px solid #ccc;padding:5px;margin:0 0 10px 0;}
.items li img {display:table-cell;vertical-align:top;height:100px;width:100px;}
.items li span.meta {display:table-cell;vertical-align:top;margin:0;padding:0 0 0 5px;}
@jasonclark
jasonclark / cite-this-uncompressed.js
Created October 4, 2012 14:02
CiteThis Bookmarklet (Javascript unencoded and uncompressed)
javascript: (function () {
var h = document.createElement('div');
var t = document.getElementsByTagName('title')[0];
var info = '<p><strong>Title(' + t.innerHTML.length + '):</strong> ' + t.innerHTML + '</p>';
var m = document.getElementsByTagName('meta');
for (var i = 0; i < m.length; i++) {
if (null !== m[i].getAttribute('name')) {
var c = m[i].getAttribute('content');
info += '<p><strong>' + m[i].getAttribute('name') + '(' + c.length + '):</strong> ' + c + '</p>';
}
@jasonclark
jasonclark / jquery-google-analytics-example
Created September 14, 2012 02:36
How to add Google Analytics to jQuery Mobile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Mobile @ Your Library</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<link rel="stylesheet" href="./meta/styles/m.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
@jasonclark
jasonclark / booklist HTML CSS and Javascript (complete file)
Last active May 8, 2019 16:26
booklist HTML CSS and Javascript (complete file) - Using the Google Spreadsheets Data API to build a Recommended Reading List
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Reading List</title>
<style type="text/css">
.items {display:table;list-style:none;margin:0;padding:0;border-spacing:5px;}
.items li {display:table-row;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;border:1px solid #ccc;padding:5px;margin:0 0 10px 0;}
.items li img {display:table-cell;vertical-align:top;}
.items li span.meta {display:table-cell;vertical-align:top;margin:0;padding:0 0 0 5px;}
@jasonclark
jasonclark / booklist.html
Last active December 28, 2023 16:27
booklist HTML - page structure and markup
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Reading List</title>
<!-- Insert booklist.css here (https://gist.github.com/2585089) -->
<!-- Insert booklist.js here (https://gist.github.com/2585071) -->