This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <utility> | |
#include <tuple> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
typedef tuple<string, float> DistributedFloatMatrixElement; | |
struct DistributedFloatMatrixFile { |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db // database interface generated by extracting database schema into typescript | |
.users.as('u') | |
.innerJoin.users.as('u2') | |
.onCol.u.name.trim | |
.equals.u2.name.trim | |
// shorthand support for exact matches, in clauses | |
.whereColumnsOf.u2({ | |
id: [1, 2] | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// inferred shape is { x: { name: string; }; y: { name: string; } }[] | |
const results = await builder | |
.stack('test') | |
.addFirewall('edge-firewall', firewallBuilder => firewallBuilder.allowInbound('80', ['::'])) | |
.addNode('gateway', // typechecked, no duplicates allowed | |
nodeBuilder => nodeBuilder | |
.size.v1cpu2gb() | |
.withDynamicVolume('edge-statics', {// typechecked, no duplicates allowed | |
target: '/mnt/edge-statics', | |
sizeGb: 20 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RootBuilder< | |
FirewallNames extends string = never, | |
NodeNames extends string = never, | |
NodesVolumes extends string = never, | |
DockerServiceNames extends string = never | |
> {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type AddFirewall<Builder, FirewallName extends string> = | |
Builder extends RootBuilder<infer FirewallNames, infer NodeNames, infer NodesVolumes, infer DockerServiceNames> | |
? RootBuilder<FirewallNames | FirewallName, NodeNames, NodesVolumes, DockerServiceNames> | |
: never |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addFirewall< | |
FirewallName extends string, | |
ReturnType extends AddFirewall<this, FirewallName> | |
>(firewallName: Exclude<FirewallName, FirewallNames>): ReturnType { | |
// … do whatever logic needs to be done | |
return this as RootBuilder as ReturnType | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new RootBuilder().addFirewall('x').addFirewall('y'); // all good | |
new RootBuilder().addFirewall('x').addFirewall('x'); // no good |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type InferFirewallNames<Builder> = | |
Builder extends RootBuilder<infer FirewallNames, infer NodeNames, infer NodesVolumes, infer DockerServiceNames> | |
? FirewallNames | |
: never |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NodeBuilder< | |
Builder | |
> { } |