Skip to content

Instantly share code, notes, and snippets.

View peterjwest's full-sized avatar

Peter West peterjwest

  • Oxford, UK
View GitHub Profile
@peterjwest
peterjwest / expandBem.ts
Created January 31, 2025 13:13
BEM classes example
import reactBem from 'react-bem';
class Component() {
const name = 'Anna', age = 42;
return reactBem(<section className="User:& &-active">
<ul className="&_details">
<li className="&_name">
Name: <span className="&_name &-highlight">{name}</span>
</li>
<li className="&_age italic">Age: {age}</li>
@peterjwest
peterjwest / search.py
Last active January 3, 2025 19:10
UUID search
import random
random.seed(42)
UUID_ENTROPY = 122
UUID_COUNT = 1 << UUID_ENTROPY
BIT_MASK_FULL = UUID_COUNT - 1
INDEX_OFFSET = 0
INDEX_OFFSET = random.randrange(UUID_COUNT)
@peterjwest
peterjwest / wishlist.md
Last active January 7, 2025 11:08
Wishlist
@peterjwest
peterjwest / ducky7
Last active July 8, 2023 10:47
Artic phone
AQAAAAMAAAAAAAAAAgACAAMAogCbAJMAAwCiAJsAkwABAAUAAQAFAAAAWQAAAIJu1XMCAIJu1XMCAIJuGnQCAKhuXnQCAM5u53QCABtvtHUCAI5vxnYCAE1wYHgCADNxP3oCAItyMH0CAFZ07oACACJ2rIQCAIZ4e4kCAN55bIwCADd7044CAGl8spACACh9xJECAMF91pICADR+o5MCAIF+cJQCAPR++ZQCAEB/gpUCAGZ/xpUCAI1/T5YCALN/T5YCANl/lJYCAP9/2JYCACaAHJcCAEyAHJcCAHKAHJcCAJmAYZcCAL+AYZcCAOWApZcCAAuB6pcCADKBc5gCAFiBQJkCAH6ByZkCAMuBDZoCAPGBlpoCAD6C2poCAGSCH5sCAIqCH5sCANeCH5sCAP2CH5sCAEmDH5sCALyDH5sCAAmE2poCAHyElpoCAMiEUZoCADuFDZoCAK6FyZkCAEeGhJkCALqGhJkCAFOHQJkCABKI+5gCAF+I+5gCAKuIt5gCANGIt5gCANGIc5gCANGILpgCAKuILpgCAIWILpgCADiI6pcCAOyH6pcCAMaH6pcCAHmHpZcCAFOHpZcCAAaHYZcCAOCGYZcCALqGYZcCAJOGHJcCAG2GHJcCACGGHJcCANSF2JYCAGGF2JYCABWF2JYCAKKE2JYCAFWElJYCAAmElJYCAOODlJYCAOOD2JYCAOODHJcCAAmEHJcCAAmEYZcCAAmEpZcCAAmE6pcCAAmELpgCAOODLpgBAOODLpgEAAMAsACEAEAAAwCwAIQAQAAAADQAAADBYH9yAgDBYH9yAgDnYH9yAgANYX9yAgANYTtyAgA0YTtyAgBaYfZxAgCAYfZxAgDNYbJxAgDzYW1xAgBAYilxAgBmYilxAgCMYuVwAgCyYuVwAgD/YqBwAgAlY1xwAgBLYxdwAgCYYxdwAgC+Y9NvAgDlY49vAgALZEpvAgAxZEpvAgBXZAZvAgB+ZMFuAgDKZH1uAgDwZDhuAgAXZThuAgA9ZfRt
@peterjwest
peterjwest / example1.md
Last active June 17, 2020 13:09
Functional function examples

The goal in this example is to count the number of books each author has written, from a list of book objects.

Example input:

const books = [
    { author: "Jane", name: "Foo: a bar" },
    { author: "John", name: "Tale of Zim" },
    { author: "Jan", name: "Legend of Gir"  },
    { author: "Jane", name: "Zig 2: the sequel" },
@peterjwest
peterjwest / large-dataset.json
Last active October 3, 2017 10:29
Assignment dataset
{
"/slf4j-logkit/org/slf4j/implStaticLoggerBinder.java": {
"coveredLines": 7,
"totalLines": 78
},
"/slf4j-logkit/org/apache/jmeter/loggingLogkitLoggerAdapter.java": {
"coveredLines": 137,
"totalLines": 327
},
"/slf4j-logkit/org/apache/jmeter/loggingLogkitLoggerFactory.java": {
@peterjwest
peterjwest / test.js
Created April 21, 2017 17:07
Mocha timeouts
var assert = require('assert');
describe('Synchronous timeout', () => {
beforeEach(() => {
var x = Date.now();
while (Date.now() < x + 2100) {}
});
it('Tests nothing', () => assert.equal(1, 1));
});
@peterjwest
peterjwest / README.md
Last active August 29, 2015 14:23
Prototype template

Prototype for a Perch-inspired CMS template.

  • Tags based on handlebars, using JS syntax for arguments
  • Four tags:
    • block - defines a named section in the CMS
    • repeat - allows items to repeated; can set min, max or exact number of repetitions
    • content - defines a piece of content, same kind of configuration as Perch, sensible defaults based on where the tag is used (i.e. text in a <p>, URL in a href, text in an alt),
    • template - loads another file as a template, templates can contain any of the four tags

Thinking about something like: {{ template('shared/content', {shared: true}) }} to allow templates to be shared across different pages.

@peterjwest
peterjwest / git-cleanup.sh
Last active July 7, 2023 15:42
Git aliases
#!/usr/bin/env bash
set -euo pipefail
for BRANCH in $(git branch | grep -E -v "^(\* | (develop|master|main)$)"); do
if [[ -z $(git --no-pager log develop..$BRANCH --author=$(git config user.email)) ]]; then
git branch -D $BRANCH
fi
done
@peterjwest
peterjwest / purge.sh
Created February 3, 2015 10:25
Delete .DS_Store files
sudo find / -name ".DS_Store" -depth -exec rm {} \;