Skip to content

Instantly share code, notes, and snippets.

View sdboyer's full-sized avatar

sam boyer sdboyer

View GitHub Profile
@sdboyer
sdboyer / nested.txtar
Created August 25, 2021 10:13
cuetsy nested struct generator test
Verifies expected behavior with basic nested structs
-- cue --
package cuetsy
OneLevel: {
Foo: string
Bar: number
} @cuetsy(targetType="interface")
@sdboyer
sdboyer / dashboard.cue
Created August 18, 2021 21:05
Grafana dashboard schema with composed core plugin schemas, less optional fields
{
// Theme of dashboard.
style: *"light" | "dark"
// Whether a dashboard is editable or not.
editable: *true | bool
// 0 for no shared crosshair or tooltip (default).
// 1 for shared crosshair.
// 2 for shared crosshair AND shared tooltip.
graphTooltip: *0 | >=0 & <=2
// Version of the JSON schema, incremented each time a Grafana update brings
@sdboyer
sdboyer / uPlot.cue
Last active January 27, 2021 15:26
experimenting with CUEified ts decls
package uplot
// Note that we use the CUE #-prefixed "definitions" here, which means that CUE
// won't output that thing when doing its own eval/rendering. This may change,
// but for the moment we're assuming that typescript generation will not happen
// through any action taken by the `cue` binary, but rather by way of a custom
// program, where we can access the CUE structures directly.
//
// To that end, all that's really omitted here is "hints" to a theoretical
// typescript generator that tell it to treat the first group as enums, the

The primary purpose of a version selection algorithm is to create a transitively complete list of packages@versions (henceforth, atoms), such that a compiler or interpreter can take the list of atoms and produce working software.

Version selection algorithms aren't magic. They can only be as good as the information they operate on. And there's lots of different kinds of information we could feed in to such an algorithm.

Historically, the main focus has been on information that is more or less provided by humans - for example, negations/exclusions, like min or max version constraints. Relying on humans to make these statements has all the attendant problems of any system reliant on human input: that input is, at times, wrong both major directions:

  • False positives: Humans omit important information, wittingly or not. As a result, it is possible to select a non-working set of atoms.
  • False negatives: Humans include incorrect information, usually innocently. As a result, there are working sets of at
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
branch = "2.x"
digest = "1:ee2887fecb4d923fa90f8dd9cf33e876bf9260fed62f2ca5a5c3f41b4eb07683"
name = "github.com/Masterminds/semver"
packages = ["."]
pruneopts = "NUT"
revision = "24642bd0573145a5ee04f9be773641695289be46"
@sdboyer
sdboyer / mechanism.md
Last active July 27, 2018 01:38
incompats with shadows

Note: this is a WIP draft to outline the idea, not polished thoughts - will improve on it as i go

Let's start with a simplifying assumption: everything that's happening is API-level breakages in the v0 range, and that making the API signatures line up is sufficient to guarantee a truly compatible build. This is obviously not true, but it is useful because it means we can establish what ideal behavior looks like, and then seek to emulate it.

Say that we have some module at some version, A@v1.0.0, and another module it depends on, B@v0.1.0. We may reasonably expect that, in any future release, B may change its exported API in a way that is incompatible with the way that A@v1.0.0's consumption of it. This is most likely because Bjorn made a change that fell outside of G1P, but it also may be because A was consuming B in a way that cross-compatibility rules identify as being risky.

At the same time, we must also note that even if B does make a backwards-incompatible change, it does not necessar

@sdboyer
sdboyer / goslowtests.bash
Created October 30, 2017 01:57
Figure out which of your go (sub)tests are slow
# This will sort go test -v output in ascending order of time to complete the test
$ go test -v | sed -n 's#.*PASS: \([^ ]*\) (\([0-9]*\.[0-9]\{2\}\)s)#\2 \1#p' | sort -g
# Add this to e.g. ~/.bashrc, ~/.zshrc, then you can pipe to it: `go test -v | goslowtests`
function goslowtests {
sed -n 's#.*PASS: \([^ ]*\) (\([0-9]*\.[0-9]\{2\}\)s)#\2 \1#p' | sort -g
}
@sdboyer
sdboyer / output.txt
Last active September 19, 2017 01:42
[footmp] dep init -v 21:32:09
Getting direct dependencies...
Checked 1 directories for packages.
Found 1 direct dependencies.
Root project is "footmp"
1 transitively valid internal packages
2 external packages imported from 1 projects
(0) ✓ select (root)
(1) ? attempt github.com/openshift/origin with 2 pkgs; 93 versions to try
(1) try github.com/openshift/origin@20141003
"unify project on disjoint package imports + source switching": {
ds: []depspec{
dsp(mkDepspec("root 0.0.0", "b from baz 1.0.0"),
pkg("root", "a", "b"),
),
dsp(mkDepspec("a 1.0.0"),
pkg("a", "b/foo"),
),
dsp(mkDepspec("b 1.0.0"),
pkg("b"),
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/golang/dep/gps"
)