Skip to content

Instantly share code, notes, and snippets.

View endymion1818's full-sized avatar
🦈
47

Ben Read endymion1818

🦈
47
View GitHub Profile
@lukasholzer
lukasholzer / index.mjs
Created May 31, 2023 08:06
Netlify affected builds plugin for Nx
// file located under: plugins/affected-build/index.mjs
/** @type {import('@netlify/build').OnPreBuild} */
export const onPreBuild = async ({ utils }) => {
const prevCommitRef = process.env.CACHED_COMMIT_REF;
const currentCommitRef = process.env.COMMIT_REF;
const isInitialBuild = currentCommitRef === prevCommitRef; // check if it's the initial build
const projectName = process.env.PROJECT_NAME; // can be set through an env variable in the `netlify.toml` or UI.
@Potherca
Potherca / compile-lynx-wasm.sh
Last active April 13, 2024 16:05
Steps to compile the Lynx web browser to Web Assembly
# Sources used in figuring this out:
#
# - https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm
# - https://emscripten.org/docs/compiling/Building-Projects.html#building-projects
# Set up Emscripten SDK
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk/
./emsdk install latest
./emsdk activate latest
@5t3ph
5t3ph / element-classes-and-ids-vanilla.css
Last active January 25, 2022 04:06
Tag HTML elements with their class names and IDs to visualize page structure
*[class],
*[id] {
position: relative;
outline: 2px dashed red;
}
*[class]::before, *[class]::after,
*[id]::before,
*[id]::after {
position: absolute;
@rstacruz
rstacruz / README.md
Last active April 23, 2024 00:19
Setting up Jest with ESM

Setting up Jest with ESM

Here are some different ways on how to set up Jest to support ESM. This applies for Jest v25, Node v13, and Babel v7.

Method A: Native Node.js support

Node v14 and Jest v26 support ESM natively with the --experimental-vm-modules flag.

Install cross-env:

@ecwyne
ecwyne / CampFireHousing.ts
Last active July 23, 2019 08:05
Serverless CampFireHousing
import fetch from 'node-fetch';
import Twitter from 'twit';
import { parse, format } from 'fecha';
import { take } from 'ramda';
const URL = 'GOOGLE_SHEETS_URL';
const T = new Twitter({
consumer_key: 'consumer_key',
consumer_secret: 'consumer_secret',
exports.onCreateNode = ({ node, actions, createNodeId, createContentDigest }) => {
const { createNode, createNodeField } = actions
if (node.internal.type === `NodeTypeWithMarkdownField`) {
const newNode = createNode({
id: createNodeId(`${node.id} markdown field`),
children: [],
parent: node.id,
internal: {
content: node.markdownField,
mediaType: `text/markdown`,
@bradtraversy
bradtraversy / docker-help.md
Last active May 4, 2024 14:32
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

'use strict';
const pointsToFile = uri => /\/[^/]+\.[^/]+$/.test(uri);
exports.handler = (event, context, callback) => {
// Extract the request from the CloudFront event that is sent to Lambda@Edge
var request = event.Records[0].cf.request;
// Extract the URI from the request
@nabilfreeman
nabilfreeman / lambda-redirect-to-trailing-slash.js
Last active March 7, 2023 20:31
Redirect to trailing slashes on CloudFront with AWS Lambda. (all this because S3 uses 302 redirects instead of 301)
'use strict';
const path = require('path')
const redirect = new_url => {
return {
status: '301',
statusDescription: 'Moved Permanently',
headers: {
location: [{

The problem with SASS mixins*

  1. mixins with SASS can balloon your css files quickly.
  2. mixins stop it being clear where stuff came from (can't search for class names for instance).

WARNING: The below is pseudo-code as I'm too lazy to double-check the APIs, output etc:

@mixin flexThing {
  color: red;