Skip to content

Instantly share code, notes, and snippets.

View CMessinides's full-sized avatar

Cameron Messinides CMessinides

View GitHub Profile
@CMessinides
CMessinides / utopia-type-table.js
Created October 24, 2023 04:05
Parse the type table on https://utopia.fyi into a JS object
function parseTable() {
let rows = $$('.font-table tbody tr')
let step = row => row.querySelector('td:nth-of-type(1) strong')
let min = row => row.querySelector('td:nth-of-type(2)')
let max = row => row.querySelector('td:nth-of-type(3)')
let textContent = cell => cell.textContent
let toFloat = text => parseFloat(text, 10)
let round = number => Math.round(number)
@CMessinides
CMessinides / contrast.js
Last active July 9, 2023 16:26
Color Contrast Checker
/**
* ============================================================================
* Constants for later reference
* ============================================================================
*/
const WCAG_MINIMUM_RATIOS = [
['AA Large', 3],
['AA', 4.5],
['AAA', 7],
@CMessinides
CMessinides / contrast.js
Created February 20, 2020 14:36
A simple color contrast checker
/**
* ============================================================================
* Constants for later reference
* ============================================================================
*/
const WCAG_MINIMUM_RATIOS = [
['AA Large', 3],
['AA', 4.5],
['AAA', 7],
- site_title = site_info && site_info['site_info.site_title'] && site_info['site_info.site_title'].as_text || 'The Collegian Magazine'
- articles.sort_by! do |doc|
- [ (doc['article.date'] && doc['article.date'].value || doc.first_published_date),
- (doc['article.weight'] && doc['article.weight'].value || 10),
- (doc['article.title'] && doc['article.title'].as_text || doc.uid) ]
- articles.reverse!
- feat_article = articles.find { |article| !!article['article.featured_image'] }
- if feat_article
- content_for :meta_image do
- feat_article['article.featured_image'].views['small'].url
@CMessinides
CMessinides / loadable.js
Last active July 18, 2019 23:10
This code loads and displays articles in an infinite feed. An example of JavaScript written for kenyoncollegian.com.
Loadable.prototype.load = function(url, onload, onerror) {
const _this = this;
asyncLoadPage(url).then( function(nextPage) {
let newList = nextPage.querySelector('[data-channel="' + _this.channel + '"]');
let dest = newList.querySelector('a, button, [tabindex]');
let newLoader = nextPage.querySelector('[data-target="' + _this.el.id + '"]');
let newNext = newLoader && newLoader.getAttribute('data-next');
var count = 0;
_this.el.classList.add('is-locked');
@CMessinides
CMessinides / loadable.js
Last active July 18, 2019 23:10
This code loads and displays articles in an infinite feed. An example of JavaScript written for kenyoncollegian.com.
Loadable.prototype.load = function(url, onload, onerror) {
const _this = this;
asyncLoadPage(url).then( function(nextPage) {
let newList = nextPage.querySelector('[data-channel="' + _this.channel + '"]');
let dest = newList.querySelector('a, button, [tabindex]');
let newLoader = nextPage.querySelector('[data-target="' + _this.el.id + '"]');
let newNext = newLoader && newLoader.getAttribute('data-next');
var count = 0;
_this.el.classList.add('is-locked');
@CMessinides
CMessinides / comment-forms.js
Created July 3, 2019 15:04
Kenyon Collegian Website Examples
const ToggleFactory = (el) => ({
notify (state) {
if (state === 'closed') {
el.classList.remove('is-open');
el.classList.add('is-closed');
} else {
el.classList.remove('is-closed');
el.classList.add('is-open');
}
}
@CMessinides
CMessinides / five-colleges-of-ohio.json
Last active February 16, 2019 00:30
48 Contiguous U.S. States TopoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.