Skip to content

Instantly share code, notes, and snippets.

function getData(method, url) {
return new Promise(function(resolve, reject){
var xhr = new XMLHttpRequest();
xhr.open(method, url);
xhr.onload = function() {
if (this.status >= 200 && this.status < 300) {
resolve(xhr.response);
} else {
reject({
status: this.status;
# Jekyll Quick Reference (Cheat Sheet)
## Table of Contents
- [Jekyll Commands](#jekyll-commands)
- [Octopress Commands](#octopress-commands)
- [Folder Structure](#folder-structure)
- [Global Variables](#global-variables)
- [Site Variables](#site-variables)
- [Page Variable](#page-variables)
<img src="img-500.jpg" srcset="img-250.jpg 250w, img-500.jpg 500w, img-1000.jpg 1000w" sizes="(min-width: 700px) 700px, 100vw">
<!--
Great for responsive images; let the browser choose the best image to download __before__ it downloads it by giving it some hints on how big each image actually is AND what size it will be rendered in the final page. With this information the browser will load the smallest image it needs to fulfil the image size requirements.
In the above example, we provide the `src` attribute for old browsers that don't support `srcset` and then for those that do we give a choice of images and their actual widths (in pixels).
In the `sizes` attribute we tell the browser that all images will be rendered the full width of the viewport (100vw, the default) except when the viewport size is >= 700px in which case we're going to use CSS (somewhere) to limit the size of the image to 700px. Then the browser knows that it doesn't need to download, say, a 1000px-wide image on a 1200px wide screen (as
'
' Be careful, this will report false if you provide
' &view&anotherQS=something
' you have to include the = thus
' &view=&anotherQS=something
'
if(request.queryString("view").count > 0) then
' a queryString named view was provided
' even if it had no value &view=
else
//Ensure that older browsers <IE8 won't freak out when seeing a `console.log()` statement.
if(!window.console){window.console={log:function(){}};}
/*source: <http://alistapart.com/article/axiomatic-css-and-lobotomized-owls> */
* + * {
margin-top: 1.5em;
}
/* Or for book-like justified paragraphs… */
p {
text-align: justify;
}
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
@CarlRevell
CarlRevell / class_logger.asp
Last active November 4, 2022 07:56
Simple classic ASP log to file class.
<%
'// Usage:
'//
'// dim l : set l = new logger
'// l.log("Hello")("World")
'// l.includeTimetamp = false
'// l("Lorem ipsum")
'// l.setLogFile("c:\temp\log_2.log").log("This is a new log!")
'// set l = nothing
@CarlRevell
CarlRevell / basic-ratio-bookmarklet.js
Created December 30, 2013 16:29
Handy-dandy, simple ratio calculator bookmarklet.
javascript:var n = prompt("width?"); var d = prompt("height?"); gcd = function(a, b){if (b === 0) return a; return gcd(b, a % b);}; var div = gcd(+n, +d); alert(n/div + ":" + d/div);
@CarlRevell
CarlRevell / html5-boilerplate-rwd.html
Last active January 1, 2016 18:29
A very basic HTML 5 boilerplate I've used.
<!doctype html>
<html lang="en-gb">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Document</title>
<link href="/css/style.css" rel="stylesheet" type="text/css">
</head>
<body>