Skip to content

Instantly share code, notes, and snippets.

View willbamford's full-sized avatar

Will Bamford willbamford

  • Twinkl
  • Chester
  • 01:49 (UTC)
View GitHub Profile
@willbamford
willbamford / parse-nextjs-build-output.mjs
Last active January 28, 2025 16:15
Parse Next.js Build Output
// Note:
// This was generated by ChatGPT o1 using Next.js v15.1.3 output
// No guarantee it'll work for your builds
// and likely to break when Next.js is updated
import fs from "node:fs";
function extractBuildData(filePath) {
try {
const output = fs.readFileSync(filePath, "utf8");
@willbamford
willbamford / edge-bucket.js
Last active November 9, 2023 16:42
edge-bucket.js
const crypto = require("crypto");
// https://github.com/davidbau/seedrandom
const seedrandom = require("seedrandom");
const data = {
"027d7344-5dba-4613-8272-68c32d91a12c": {
name: "exp-a",
type: "experiment",
variants: {
@willbamford
willbamford / gist:37f0a0ff29352d0cf04900ad25a956e5
Created September 29, 2020 17:59
Linnworks templatem macro to extract Amazon customisations from OptionNotes (Additional Info)
EVAL{BEGIN}
TEXT_PROP:="s1a1_text";
TEXT_PROP_WITH_DELIM:="s1a1_text : ";
NEXT_PROP:=", s1a1_";
HAS_TEXT:=iif[contains[-1, SearchString[[{OptionNotes}], 0, TEXT_PROP]], False, True];
TEXT_VALUE_INDEX:=iif[
HAS_TEXT,
SearchString[[{OptionNotes}], 0, TEXT_PROP] + len[TEXT_PROP_WITH_DELIM],
-1
];
@willbamford
willbamford / TextInputHookExample.jsx
Created November 6, 2018 19:53
Controlled + Uncontrolled React Components using useState Hook
import React, { useState } from "react";
const ControlledTextInput = props => (
<div>
<input type="text" value={props.value} onChange={props.onChange} />
<div>Count {props.value.length}</div>
</div>
);
const TextInput = props => {
<Grid.Wrapper element="ul" equalHeight matrix gutterSize="sm">
<Grid.Item element="li" size={{ def: "1/2", xs: "1/2", sm: "1/5" }}>
<PrimaryButton fullWidth containerElement={<a href="#typography" />}>
Typography
</PrimaryButton>
</Grid.Item>
{ /* and so it continues... */ }
</Grid.Wrapper>
<ul class="ln-o-grid
ln-o-grid--equal-height
ln-o-grid--matrix
ln-o-grid--gutter-sm"
>
<li class="ln-o-grid__item
ln-u-1/2
ln-u-1/3@xs
ln-u-1/5@sm"
>
{
"data": {
"type": "me",
"id": 50,
"attributes": {
"email": "First.Last@sainsburys.co.uk"
},
"relationships": {
"role": {
"links": {
@willbamford
willbamford / _at-min.scss
Last active July 29, 2016 12:57
Responsive fonts in Sass
@mixin at-min($breakpoint) {
@if map-has-key($breakpoints, $breakpoint) {
@media (min-width: map-get($breakpoints, $breakpoint)) {
@content;
}
}
@else {
@warn "Breakpoint key '#{$breakpoint}' does not exist.";
@willbamford
willbamford / Dockerfile
Last active July 8, 2016 10:03 — forked from yefim/Dockerrun.aws.json
Build a Docker image, push it to AWS EC2 Container Registry, then deploy it to AWS Elastic Beanstalk
# Example Dockerfile
FROM hello-world
@willbamford
willbamford / README.md
Created December 23, 2015 14:37 — forked from bsergean/README.md
Anti-aliasing (FXAA) with headless-gl and three.js

Aliased

Anti-aliased

Getting the code