Skip to content

Instantly share code, notes, and snippets.

View influxweb's full-sized avatar
Coffee Helps Me Focus...Coffee Helps Me Focus...Coffee Helps Me Focus...

Matt Zimmermann influxweb

Coffee Helps Me Focus...Coffee Helps Me Focus...Coffee Helps Me Focus...
View GitHub Profile
@influxweb
influxweb / dom-helper.js
Created March 29, 2017 20:08 — forked from SitePointEditors/dom-helper.js
Mini jQuery, sort of.
/**
* A collection of helper prototype for everyday DOM traversal, manipulation,
* and event binding. Sort of a minimalist jQuery, mainly for demonstration
* purposes. MIT @ m3g4p0p
*/
window.$ = (function (undefined) {
/**
* Duration constants
* @type {Object}
@influxweb
influxweb / how-to-force-a-file-download-in-the-browser.md
Created March 30, 2017 02:49 — forked from nepsilon/how-to-force-a-file-download-in-the-browser.md
How to force a file download in the browser? — First published in fullweb.io issue #92

How to force a file download in the browser?

The use case is simple, you have /reports/593874951.pdf on your web server and want to let your user download it — and if possible with a meaningful name.

In the past, you may tried using the Content-Disposition HTTP header to achieve this, but today, with Safari getting the support for the download attribute it’s going to simplify a lot of things.

Using the download attribute is simple as pie:

<a href="/reports/593874951.pdf" download="report.pdf">
 Download report
@influxweb
influxweb / how-to-disable-html-links-with-css.md
Created March 30, 2017 02:49 — forked from nepsilon/how-to-disable-html-links-with-css.md
How to disable HTML links with CSS? — First published in fullweb.io issue #92
@influxweb
influxweb / loadPageSection.js
Created April 7, 2017 23:59 — forked from lazamar/loadPageSection.js
Vanilla JS implementation of JQuery's .load
/**
* Loads an HTML document from a URL and retuns an element selected using
* the 'selector' parameter
* Example usage:
* loadPageSection('./myPage.html', '#container', (r, err) => console.log(r, err));
*
* @method loadPageSection
* @param {String} url
* @param {String} selector - A valid CSS selector
* @param {Function} callback - To be called with two parameters (response, error)
@influxweb
influxweb / loadScript.js
Last active April 19, 2017 18:19 — forked from jnrbsn/gist:4268258
Loads a JavaScript file asynchronously with a callback, like jQuery's `$.getScript()` except without jQuery.
function loadScript(url, callback) {
var head = document.getElementsByTagName('head')[0],
scriptCalled = document.createElement('script');
scriptCalled.async = true;
scriptCalled.src = url;
scriptCalled.onload = scriptCalled.onreadystatechange = function () {
if (!scriptCalled.readyState || /loaded|complete/.test(scriptCalled.readyState)) {
scriptCalled.onload = scriptCalled.onreadystatechange = null;
@influxweb
influxweb / tooltip.css
Created May 9, 2017 00:40 — forked from csasbach/tooltip.css
Create tooltips on mouseover or on click (for supporting touch interfaces).
abbr
{
border-bottom: 1px dotted #666;
cursor: help;
}
.tooltip
{
position:absolute;
background-color:#eeeefe;
@influxweb
influxweb / Dice.cs
Created May 9, 2017 00:41 — forked from csasbach/Dice.cs
This module exposes static methods for rolling dice.
/**
* Dice
*
* @author C. Scott Asbach
*
* This module exposes static methods for rolling dice.
*/
using System;
namespace Dice
@influxweb
influxweb / css-variables.js
Created August 8, 2017 21:39 — forked from wesbos/css-variables.js
Test for CSS Variables
function testCSSVariables() {
var color = 'rgb(255, 198, 0)';
var el = document.createElement('span');
el.style.setProperty('--color', color);
el.style.setProperty('background', 'var(--color)');
document.body.appendChild(el);
var styles = getComputedStyle(el);
var doesSupport = styles.backgroundColor === color;
@influxweb
influxweb / _grid.scss
Created August 15, 2019 21:36 — forked from aronhoyer/_grid.scss
SASS grid system with CSS grid
$screen-sizes: (
xxl: 1920px,
xl: 1440px,
l: 1360px,
ml: 1280px,
m: 768px,
s: 576px
);
$col-count: 24;
@influxweb
influxweb / swipe.js
Created November 20, 2019 21:20 — forked from chrishaensel/swipe.js
Simple swipe gesture recognizer in vanilla javascript
var swiper = {
touchStartX: 0,
touchEndX: 0,
minSwipePixels: 30,
detectionZone: undefined,
swiperCallback: function() {},
init: function (detectionZone, callback) {
swiper.swiperCallback = callback