These work best with light (~#fff
) elements (eg a code snippet or ‘card’ component) on light backgrounds.
box-shadow: 0 1px 15px rgba(27, 31, 35, .15);
window.scrollTo({ | |
top: document.getElementById('foo').offsetTop, | |
left: 0, | |
behavior: 'smooth' | |
}); |
// Fetch JSON data | |
fetch('https://jsonplaceholder.typicode.com/todos/').then(response => { | |
// Success | |
if (response.ok) | |
return response.json(); // Returns to then() | |
// Error | |
return Promise.reject(response); |
document.addEventListener('click', function (e) { | |
for (let target = e.target; target && target != this; target = target.parentNode) { | |
if (target.matches('.foo')) { | |
// ⋯ | |
e.preventDefault(); | |
break; | |
} else if (target.matches('.bar')) { | |
// ⋯ | |
e.preventDefault(); | |
} |
function XHRRequest(url, type = 'text/plain') { | |
const request = new XMLHttpRequest(); | |
request.open('GET', `${url}?${new Date().getTime()}`, true); | |
request.setRequestHeader('Content-type', type); | |
request.onload = function () { | |
if (this.status >= 200 && this.status < 400) { // Success | |
console.log('Success', this.response); | |
} else |
#!/bin/sh | |
# we'll hide the work in a temporary directory | |
mkdir tmp_num | |
cp numbers.pdf tmp_num/. | |
cp newbook.pdf tmp_num/. | |
cd tmp_num/ | |
# burst newbook into its component pages and extract total pages | |
pdftk newbook.pdf burst output book_%04d.pdf |
These work best with light (~#fff
) elements (eg a code snippet or ‘card’ component) on light backgrounds.
box-shadow: 0 1px 15px rgba(27, 31, 35, .15);
# HTTPS redirect | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{HTTPS} off | |
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L] | |
</IfModule> | |
# END HTTPS | |
# Force non-www SSL | |
# https://simonecarletti.com/blog/2016/08/redirect-domain-http-https-www-apache/ |
/** | |
* @name MY_MODULE | |
* @author Jamie Smith | |
* @description Basic JavaScript module template with config and state objects, and private and public functions | |
*/ | |
const MY_MODULE = (function () { | |
"use strict"; |
/** | |
* Gets query string and returns as an object of key-value pairs | |
* @returns {Object or null} | |
*/ | |
function getQueryString() { | |
let q = document.location.href.split('?')[1]; | |
let o = {}; | |
if (q && q.length) { |