Skip to content

Instantly share code, notes, and snippets.

View michaelschofield's full-sized avatar

Michael Schofield michaelschofield

View GitHub Profile

The Sherman Library took the unique opportunity to build a public library website where there wasn’t one before. A fresh start, no baggage, with plenty of time to talk, plan, design, develop, make mistakes, get delayed, and user-test. This is the narrative of the entire process – the whole shebang: answering why the design committee opted to build a mobile-first, responsive, and flat website, the data they used to convince stakeholders to ditch the carousel, the techniques and pains behind development, content strategy, and seeing the website launch. Attendees have a unique look into the workflow of another library, the user-experience research and best practices that drove our decision-making. In short: we made the font huge, stopped supporting old Internet Explorers, took all the tabs off the search box, and embraced the white space. This is why.

@michaelschofield
michaelschofield / getQueryParameters.js
Created February 21, 2014 21:25
Returns the address bar query string as a key/value object.
/*
* jquery.getQueryParameters.js
* Copyright (c) 2014 Nicholas Ortenzio
* The MIT License (MIT)
*
*/
jQuery.extend({
getQueryParameters : function(str) {
@michaelschofield
michaelschofield / ordinals.js
Created February 21, 2014 21:29
Simple one-liner to painlessly return ordinals.
function nth(o){return o+([‘st’,’nd’,’rd’][(o+’’).match(/1?\d\b/)-1]||’th’)}
@michaelschofield
michaelschofield / semantic-directory.html
Last active August 29, 2015 13:57
Trying to markup the most semantic directory ever. Inspired by cool semantic things being done by Jason Clark and Scott Young.
# Have to get creative with Schema though. I'm actively finagling. DTs cannot contain any block level elements, but DDs can.
<dl vocab="http://schema.org/" typeof="Person">
<dt property="name">Sandra Fiegi</dt>
<dd>
<img property="image" src="example.jpg" alt="A photo of Sandra Fiegi">
</dd>
@michaelschofield
michaelschofield / parallel.js
Created May 2, 2014 13:24
Multiple AJAX and JSON Requests, One Callback
// From David Waslh: http://davidwalsh.name/jquery-ajax-callback
$.when(
$.getScript('/media/js/wiki-min.js?build=21eb633'),
$.getJSON('https://developer.mozilla.org/en-US/demos/feeds/json/featured/')
).then(function(a, b) { // or ".done"
// Yay, stuff loaded and now we can do something!
});
// There are probably more legit ways of doing this,
// but for my sparse use I sometimes use this.
// IE8 ployfill for GetComputed Style (for Responsive Script below)
if (!window.getComputedStyle) {
window.getComputedStyle = function(el, pseudo) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop == 'float') prop = 'styleFloat';
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@michaelschofield
michaelschofield / micromanage-assets.php
Created July 17, 2014 21:39
A little WordPress function for micromanaging what, where, and when scripts and styles load.
// Deregister all the things
add_action( 'wp_print_scripts', 'libux_deregister_scripts', 100 );
function libux_deregister_scripts() {
// Ditch jQuery - except on one page that requires it,
// but load that with a CDN.
wp_deregister_script( 'jquery' );
if ( is_page( 'something' ) ) {
add_filter('ef_user_following_posts_query_args','any_posts_ef_user_following_posts_query_args',10,1);
function any_posts_ef_user_following_posts_query_args( $post_args ){
$post_args['post_type'] = 'any';
return $post_args;
}
@michaelschofield
michaelschofield / loop_all_in_cat.php
Last active August 29, 2015 14:05
Loop any Post-Type in Specific Category
<?php
// Fetch all posts, regardless of post-type, in "my_category".
$args = array(
'post_type' => 'any',
'category_name' => 'my_category'
);
// Call the $args ^ in a new WP_Query().
$the_query = new WP_Query( $args );