Skip to content

Instantly share code, notes, and snippets.

View davidgilbertson's full-sized avatar

David Gilbertson davidgilbertson

  • Sydney, Australia
View GitHub Profile
function logColor(color, args) {
console.log(`%c ${args.join(' ')}`, `color: ${color}`);
}
const log = {
aliceblue: (...args) => { logColor('aliceblue', args)},
antiquewhite: (...args) => { logColor('antiquewhite', args)},
aqua: (...args) => { logColor('aqua', args)},
aquamarine: (...args) => { logColor('aquamarine', args)},
azure: (...args) => { logColor('azure', args)},
# MIT License
#
# Copyright (c) 2024 David Gilbertson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
/* Obsidian CSS reference: https://docs.obsidian.md/Reference/CSS+variables/Editor/Code */
body {
/* Code syntax highlighting */
--jetbrains-grey-code: #BCBEC4;
--code-normal: --jetbrains-grey-code;
--code-comment: #7A7E85;
--code-function: --jetbrains-grey-code;
--code-important: hotpink;
--code-keyword: #CF8E6D;
@davidgilbertson
davidgilbertson / http2.js
Last active October 9, 2023 06:09
HTTP2 server with compression and caching
const http2 = require('http2');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const brotli = require('brotli'); // npm package
const PORT = 3032;
const BROTLI_QUALITY = 11; // slow, but we're caching so who cares
const STATIC_DIRECTORY = path.resolve(__dirname, '../dist/');
const cache = {};
@davidgilbertson
davidgilbertson / Python-List.py.groovy
Last active August 23, 2023 20:37
Custom extractor for PyCharm - copy tables to a list of dicts
import static com.intellij.openapi.util.text.StringUtil.escapeStringCharacters as escapeStr
SEPARATOR = ", "
QUOTE = "\""
NEWLINE = System.getProperty("line.separator")
def record(columns, dataRow) {
OUT.append(" {").append(NEWLINE)
columns.eachWithIndex { column, idx ->
module.exports = {
entry: {
main: path.resolve(__dirname, 'src/index.js'),
ProductList: path.resolve(__dirname, 'src/ProductList/ProductList.js'),
ProductPage: path.resolve(__dirname, 'src/ProductPage/ProductPage.js'),
Icon: path.resolve(__dirname, 'src/Icon/Icon.js'),
},
output: {
path: path.resolve(__dirname, 'dist'),
Word Deconstruction
it's it ~is
years year ~s
going go ~ing
that's that ~is
i'm i ~am
things thing ~s
states state ~s
including include ~ing
called call ~ed
@mixin for-phone-only {
@media (max-width: 599px) { @content; }
}
@mixin for-tablet-portrait-up {
@media (min-width: 600px) { @content; }
}
@mixin for-tablet-landscape-up {
@media (min-width: 900px) { @content; }
}
@mixin for-desktop-up {
const path = require('path');
module.exports = {
entry: path.resolve(__dirname, 'src/index.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[contenthash].js',
},
optimization: {
splitChunks: {
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: path.resolve(__dirname, 'src/index.js'),
plugins: [
new webpack.HashedModuleIdsPlugin(), // so that file hashes don't change unexpectedly
],
output: {
path: path.resolve(__dirname, 'dist'),