Skip to content

Instantly share code, notes, and snippets.

View ds300's full-sized avatar
🏳️‍🌈

David Sheldrick ds300

🏳️‍🌈
View GitHub Profile
@ds300
ds300 / 18-07-2012
Created July 18, 2012 13:02
error report
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="0" time="1.319" errors="1" skipped="0" tests="8" name="uk.ac.susx.mlcl.byblo.commands.ExternalCountCommandTest">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries"/>
<property name="java.vm.version" value="20.8-b03-424"/>
<property name="awt.nativeDoubleBuffering" value="true"/>
<property name="gopherProxySet" value="false"/>
<property name="mrj.build" value="11M3720"/>
<property name="java.vm.vendor" value="Apple Inc."/>
@ds300
ds300 / gist:5758662
Last active December 18, 2015 08:59
JuggleGraph tips
# let's start with this:
siteswaplist = []
while len(siteswap) > 0:
if siteswap[0] == "a":
siteswaplist.append(10)
siteswap = siteswap[1:]
if siteswap[0] == "b":
siteswaplist.append(11)
siteswap = siteswap[1:]
@ds300
ds300 / gist:6763496
Created September 30, 2013 13:02
Illustration of AST Visitor pattern. (This is bad java, just to give you an idea of how things fit together)
public abstract class BaseAST {
public abstract void accept(Visitor v);
}
public abstract class Visitor {
public abstract void visitBinOpNode(Expression lhs,
Op op,
Expression rhs);
public abstract void visitIdentNode(String ident);
}
List(
Map(
"id" -> "d979c0f0c2f4b1ec310aff3ff48f75aa4e54c07752ae4fb76161739c6fd2980a2f0f7c469706aac421c449336f34147b8d72f89e2ecd6e7c6e286395a6548b7d",
"timestamp" -> "1462452325349",
"name" -> "Haim",
"country" -> "Curacao",
"amount" -> "4571.62"
),
Map(
"id" -> "857f1e5f2b8c0683aa450970dcf8c528e3fa87a9bf56e046b6b7ca5560ca0a76dd555b6666b88c35d908980218915e203882edc1fe79af6687d612357625e6e8",
@ds300
ds300 / index.js
Created July 25, 2016 13:11
requirebin sketch
// Welcome! require() some modules from npm (like you were using browserify)
// and then hit Run Code to run your code on the right side.
// Modules get downloaded from browserify-cdn and bundled in your browser.
var patch = require('snabbdom').init([
require('snabbdom/modules/props'),
]);
var h = require('snabbdom/h');
var elem = h('div', [
@ds300
ds300 / index.js
Created August 18, 2016 07:36
requirebin sketch
const d = require("derivable")
const name = d.atom("World"); // the name of the user
const countryCode = d.atom("en"); // for i18n
// static constants don't need to be wrapped
const greetings = {
en: "Hello",
de: "Hallo",
es: "Hola",
@ds300
ds300 / yarn-flat-auto.js
Created June 28, 2017 11:45
Automatically choose the latest versions of all packages when running yarn --flat
#!/usr/bin/env node
# run this before using: yarn add --dev node-pty semver
const os = require("os")
const pty = require("node-pty")
const semver = require("semver")
function semverComparator(a, b) {
if (semver.lt(a, b)) {
@ds300
ds300 / clean.sh
Last active May 12, 2019 09:29 — forked from zephraph/clean_node_modules.sh
Clean up node_modules
#!/bin/bash
DAYS_SINCE_LAST_CHANGE=14
TOTAL_BYTES_REMOVED=0
Mb=1000000
Kb=1000
node_modules=$(find . -name "node_modules" -type d -prune)
import React, { useContext, useEffect, useMemo, useState } from "react"
type ProviderComponent<T> = React.FC<{ initialValue: T }>
interface PrivateContextValue<T> {
useGlobalStateProxy(): T
}
class GlobalStateContext<T> {
constructor(private context: React.Context<PrivateContextValue<T>>, public Provider: ProviderComponent<T>) {}
}
/**
@ds300
ds300 / add-extensions.ts
Last active September 6, 2023 11:18
Add .js, .mjs, or .cjs file extensions to imports/exports in (transpiled) ESM files
import { existsSync, readFileSync, statSync, writeFileSync } from 'fs'
import glob from 'glob'
import path from 'path'
import { parse, print, visit } from 'recast'
const extensions = ['.js', '.mjs', '.cjs']
function resolveRelativePath(importingFile: string, relativePath: string) {
if (!relativePath.startsWith('.')) {
return relativePath
}