Skip to content

Instantly share code, notes, and snippets.

View andreasvirkus's full-sized avatar
🙊
made you look

andreas andreasvirkus

🙊
made you look
View GitHub Profile
@andreasvirkus
andreasvirkus / build.js
Created June 8, 2017 14:40
Simple Metalsmith robots.txt plugin
import metalsmith from 'metalsmith';
import markdown from 'metalsmith-markdown';
import robots from './metalsmith-robots.js';
metalsmith(__dirname)
.use(markdown())
.use(robots({
source: 'sample-robots.txt'
})
.destination('./build');
function getContent(selector) {
var html = document.querySelector(selector).innerHTML;
return html.replace(/<[^>]*>/g, "");
}
// In-place merge b to a
let a = ['foo', 'bar'],
b = ['baz', 'foobar', 'foobaz'];
a.push(...b);
console.log('a with ES6 sexiness', a);
// or the old way
[].push.apply(a, b);
console.log('a with apply', a)
module.exports = function() {
let now = new Date().getTime();
let loadTime = now - performance.timing.navigationStart;
console.log("User-perceived page loading time: " + loadTime);
return loadTime;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
const nodeList = document.getElementsByTag('a')
// Nothing else to it!
[].forEach.call(nodeList, e => {
e.addEventListener('click', controller)
})
// or
for (const el of document.querySelectorAll('.tippy-popper')) {
el.addEventListener('click', slickAsF)
/**
* Highlight navigation by subheading and update navbar/page url with section hash
*
* NOTE: Taken raw from Docker docs.
* TODO: Refactor to vanilla JS and ES6
*/
function highlightRightNav(heading) {
if (document.location.pathname.indexOf("/glossary/")<0){
console.log("highlightRightNav called on",document.location.pathname)
if (heading == "title")
@andreasvirkus
andreasvirkus / outlineStyles.html
Created August 7, 2017 11:01
The proper way to get rid of outline styles _aesthetically_, whilst keeping them for accessibility purposes!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<style id="_outline-styles">
/* Outline styles will be injected here */
</style>
</head>
import './carousel.scss';
var _forEach = require('lodash').forEach;
import {lory} from 'lory.js'; // get lory
export class Carousel {
constructor(settings = {}) {
var timer = this._timer = 0;
var paused = this._paused = false;
var speed = this._speed = 5000;
# Just so I'd remember how to add files that you forgot to a local commit
# Maybe one day I'll learn... x_x
# edited file-that-i-remember.txt
git add file-that-i-remember.txt
git commit
# realize you forgot a file
git add file-that-i-forgot.txt
git commit --amend --no-edit