Skip to content

Instantly share code, notes, and snippets.

View jouni-kantola's full-sized avatar
😘

Jouni Kantola jouni-kantola

😘
View GitHub Profile
@jouni-kantola
jouni-kantola / eleventy-external-links-transform.js
Last active February 19, 2023 13:56
Eleventy tranform for amending external links to include icon and screen reader message
define(function(require) {
'use strict';
(function(window, undefined) {
// Prepare our Variables
var history = window.history,
document = window.document,
$ = require('jquery');
@jouni-kantola
jouni-kantola / stub-properties-and-methods-sinon.js
Created February 2, 2014 02:02
Sinon.JS used to stub properties and methods in a sandbox. Methods and properties are restored after test(s) are run.
define(['can', 'localCache'], function(can, localCache) {
'use strict';
describe('storeLocal()', function() {
var sandbox;
beforeEach(function() {
// create sandbox environment for mocking about
sandbox = sinon.sandbox.create();
});
@jouni-kantola
jouni-kantola / test-max-cookie-value.js
Last active May 26, 2021 18:39
Test max cookie value
@jouni-kantola
jouni-kantola / reasons-for-webpack-chunk-hash-updates.md
Last active May 9, 2021 10:08
Reasons for webpack chunk hash updates

Reasons for hash change

First build, for reference

       0.14ff9d89ef59e0542b1d.dev.js    1.55 kB    0, 7  [emitted]
       1.bcca8d49c0f671a4afb6.dev.js  708 bytes    1, 7  [emitted]
       2.6617d1b992b44b0996dc.dev.js  708 bytes    2, 7  [emitted]
       3.c8edca9c31923a566f7f.dev.js  403 bytes    3, 7  [emitted]
       4.c67fbd67a62782c31d1c.dev.js  403 bytes    4, 7  [emitted]
  vendor.3c35d30d5995c0e6e1c1.dev.js     259 kB    5, 7  [emitted]  [big]  vendor
@jouni-kantola
jouni-kantola / .eleventy.js
Last active March 27, 2020 21:26
Inline styles from PostCSS with 11ty and Liquid
module.exports = eleventyConfig => {
/* ... */
eleventyConfig.addPairedShortcode("postcss", require("./shortcodes/postcss"));
/* ... */
}
@jouni-kantola
jouni-kantola / color-scheme.css
Created March 14, 2020 09:39
States (and cleaner code) with PostCSS custom selectors
@custom-selector :--dark-mode input#dark-mode:checked;
@custom-selector :--light-mode input#light-mode:checked;
$color-scheme-toggle-root: .color-scheme;
input[name="color-scheme"] {
display: none;
}
$color-scheme-toggle-root {
@jouni-kantola
jouni-kantola / dark-and-light-mode.html
Last active February 28, 2020 23:17
Dark & light mode switch (with preferred choice kept in localStorage)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
:root {
--light-color: #fafafa;
--dark-color: #222;
--background-color: var(--light-color);
@jouni-kantola
jouni-kantola / replay.sh
Last active February 5, 2020 21:22
Replay git commits
#!/bin/sh
# Remember current branch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
# Temp branch used for replaying history
TEMP_BRANCH=__tmp-replay-git-commits
# Checkout temp branch
git checkout -b $TEMP_BRANCH
@jouni-kantola
jouni-kantola / Program.cs
Last active November 10, 2019 17:03
Implicitly typed lambda expressions in C#
using System;
public class Program
{
static Func<TSource, TResult> CreateFunction<TSource, TResult>(Func<TSource, TResult> function)
{
return function;
}
public static void Main()