Skip to content

Instantly share code, notes, and snippets.

@craigmdennis
craigmdennis / horizontal.masonry.js
Created July 5, 2011 10:48
Simple Horizontal Masonry
/**
* Builds a horizontal masonry in whats possbily (i haven't researched
* the techniques) a crude manner.
* Fits elements into columns if there is room and sets the width of
* the container element to contain all the columns.
*
* Known Issues:
* - Does not do anything clever for elements where height exceeds
* window height (probably just gets chopped off if overflow: hidden)
* - All elements are expected to be the column width
@craigmdennis
craigmdennis / update.sh
Created September 26, 2023 20:06
Update Cloudflare Access Group IP address based on current public IP address from the requestor
ACCOUNT_ID="YOUR_ACCOUNT_ID"
GROUP_ID="YOUR_ACCESS_GROUP_ID"
GROUP_NAME="YOUR_ACCESS_GROUP_NAME"
API_TOKEN="YOUR_CLOUDFLARE_API_KEY"
IP_ADDRESS=$(curl -s https://api.ipify.org)
curl --request PUT \
--url https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/access/groups/$GROUP_ID \
--header 'Content-Type: application/json' \
@craigmdennis
craigmdennis / svgo.json
Last active May 16, 2023 16:46
SVGo Sketch Plugin Configuration
{
"comment": "This is the settings file for the SVGO Compressor Plugin. For more info, please check <https://github.com/BohemianCoding/svgo-compressor>",
"pretty": true,
"indent": 2,
"floatPrecision": 3,
"plugins": [
{
"name": "removeDoctype",
"enabled": true
},
@craigmdennis
craigmdennis / _debug.scss
Last active March 21, 2023 02:31
Sass mixins for vertical rhythm and scoped typography with pixel fallback for IE.
$debug-rhythm: false;
@craigmdennis
craigmdennis / index.html
Last active February 1, 2022 03:08
When not including Modernizr, use this to remove the no-js class from the html.From: http://www.paulirish.com/2009/avoiding-the-fouc-v3/
<html class="no-js">
<head>
<script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
</head>
<body>
</body>
</html>
@craigmdennis
craigmdennis / stickToTop.js
Created March 8, 2012 18:02
A simple sticky header jQuery plugin
(function($){
$.fn.stickToTop = function (offset) {
// Return this to maintain chainability
return this.each(function () {
// Set some variables
var $this = $(this),
elemTop = $this.offset().top,
@craigmdennis
craigmdennis / markup.html
Created November 30, 2011 15:22
Show password text with checkbox toggle
<form action="">
<fieldset class="error">
<div class="form-row">
<span class="error-hook">
Please enter a valid email address
</span>
<div class="input-hook">
<label for="email-address" class="placeholder">
Email address
</label>
@craigmdennis
craigmdennis / spinSubmit.js
Created December 7, 2011 16:02
Add a loading animation to a submit <button> or <a> before submitting a form
/**
Requires:
Spin.js (http://fgnass.github.com/spin.js/)
Spin.js jQuery plugin (https://gist.github.com/1290439)
Usage: $(#your-id).spinSubmit();
For best results, change the 'small' to - small:{lines:12,length:3,width:2,radius:4} in the jQuery plugin
@craigmdennis
craigmdennis / clearsans.scss
Created May 22, 2014 01:52
The correct @font-face setup for Clear Sans
// ===================================================
// Font Face Rules
// ===================================================
@font-face {
font-family: 'Clear Sans';
font-style: normal;
font-weight: 100;
src: local('ClearSans-Thin'), local('Clear Sans Thin'),
url('../fonts/clearsans/ClearSans-Thin.eot'),
@craigmdennis
craigmdennis / devtools.js
Last active May 7, 2020 11:59
Create a comma separated string of the text from a series of nodes using devtools
let comma = ''; for (const cf of document.querySelectorAll('.class a')) { comma += `${cf.innerHTML},` }; console.log(comma);