hofstadter-io / cuetorials.com Goto Github PK
View Code? Open in Web Editor NEWLearn you some CUE for a great good!
Home Page: https://cuetorials.com
License: BSD 3-Clause "New" or "Revised" License
Learn you some CUE for a great good!
Home Page: https://cuetorials.com
License: BSD 3-Clause "New" or "Revised" License
Following the Convert JSON Schema with the current compose schema (as of this commit), cue import
raises the following error:
% cue import -f -p compose -l '#ComposeSpec:' compose-spec.json
constraint not allowed because type object is excluded:
./compose-spec.json:471:11
The offending JSON Schema section is below, specifically the "patternProperties": {"^x-": {}}
.
"development": {
"id": "#/definitions/development",
"type": ["object", "null"],
"properties": {
"watch": {
"type": "array",
"items": {
"type": "object",
"required": ["path", "action"],
"properties": {
"ignore": {"type": "array", "items": {"type": "string"}},
"path": {"type": "string"},
"action": {"type": "string", "enum": ["rebuild", "sync", "sync+restart"]},
"target": {"type": "string"}
}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
}
}
Removing that line (and the comma on the line above) worked around the issue. I'm not sure what a more correct fix would be.
Hello, it seems https://cuetorials.com/ is no longer reachable, apparently for a few days already, anyone looking at it or any communication about it already?
Who's using CUE ?
Dagger
Repository: https://github.com/dagger/dagger
website: https://dagger.io
Documentation: https://docs.dagger.io
Hugo has some helpers to combine, minify, and create files named with their hashes. This should help with loading, both size and caching issues on updates.
Hi ๐
Thanks very much for this tutorial repo. Really useful for implementing cue's features, with Go.
I have a (probably) basic question. I have been able to load and evaluate a cue value. How do I encode it to JSON? I am unable to find specific references to this in cue's source as well. I am sure I am missing something.
Any help would be highly appreciated. Thank you :)
import "list"
#test: this={
a?: [...string]
b?: string
c?: string
#AnyOfABC: true & list.MinItems([ for label, val in this if list.Contains(["a", "b", "c"], label) {label}], 1)
}
{
"a": ["bar"],
"b": "foo"
}
cue eval -c ./test.cue ./testany.json -d "#test"
#test.#AnyOfABC: conflicting values false and true:
./test.cue:7:13
./test.cue:7:20
changing from array a to string works or changing the array field from optional to default works as well. This is slightly outside of the content of the page, bug a simple derivative.
In the example here:
https://cuetorials.com/go-api/loading/#loading-and-printing-cue-code
it says:
// to cause a load error, remove the '&'
// to cause a build error, change '#A' to '#B'
// to cause a validation error, change foo to '1'
However, the third case actually produces a build error. I'm not sure it's possible to reach this line
fmt.Println("Error during validation:", err)
Am I missing something?
For some time now my browsers started to reject loading the truetype font embedded on the site.
On Chrome I get this error in the console:
Refused to load the font 'data:font/truetype;charset=utf-8;base64,d09GRgABAAAAAL...' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.
I don't get any similar logs on Firefox, but the site looks the same there too.
Shouldn't the ParsePath
on this line be looking for the value "hello" instead of "foo"?
cuetorials.com/code/go-api/flow/custom.go
Line 100 in 1b90070
We should have a page on the website to thank all those who have contributed, if they wish to have their name listed.
Let's make it the last menu item.
The bounded recursion function works for cue 0.5, but breaks on cue 0.6. To reproduce.
To reproduce the issue, take the following cue code (copied from the website, presented here as one block for easy of reproducibility):
package r
import "list"
#RecurseN: {
// this is the bound on our recursion
#maxiter: uint | *4
// This is the function list element
// we generate this to simulate recursion
#funcFactory: {
#next: _
#func: _
}
// this is our "recursion unrolling"
for k, v in list.Range(0, #maxiter, 1) {
// this is where we build up our indexed functions and the references between them
#funcs: "\(k)": (#funcFactory & {#next: #funcs["\(k+1)"]}).#func
}
// our final value needs to be null
#funcs: "\(#maxiter)": null
// we embed the head of the list so that the values
// we write this into can be used like other CUE "functions"
#funcs["0"]
}
#DepthF: {
#next: _
#func: {
#in: _
#basic: int | number | string | bytes | null
out: {
// if we have a basic type, we are at a leaf, depth is 1
if (#in & #basic) != _|_ {1}
// if we are not a basic type, then we are 1 + the max of children
if (#in & #basic) == _|_ {
// this is our "recursion" for each child
let depths = [ for k, v in #in {(#next & {#in: v}).out}]
list.Max(depths) + 1
}
}
}
}
#Depth: #RecurseN & {#maxiter: 11, #funcFactory: #DepthF}
tree: {
a: {
foo: "bar"
a: b: c: "d"
}
cow: "moo"
}
d: #Depth & {#in: tree}
and run (with recur.cue
containing the above):
$ cue export --out json recur.cue
with cue 0.5, the result will be:
{
"tree": {
"a": {
"foo": "bar",
"a": {
"b": {
"c": "d"
}
}
},
"cow": "moo"
},
"d": {
"out": 5
}
}
with cue 0.6 (or 0.7.1), the result errors:
d: cannot add field #maxiter: was already used:
./recur.cue:49:22
if I remove the #maxiter
field, I get a result, but out
is now missing:
{
"tree": {
"a": {
"foo": "bar",
"a": {
"b": {
"c": "d"
}
}
},
"cow": "moo"
},
"d": {}
}
Not sure why any of this happens to be honest, haven't been able to find this issue or a lead anywhere.
Goal: make it easy for translators to see which files are new or have changed since and need updating / translating.
It should be easy to write a script which uses git to determine which content/*.md files are older than their english counterpart.
Rainbond
Repository: https://github.com/goodrain/rainbond.git
website: https://www.rainbond.com/
Documentation: https://www.rainbond.com/docs/quick-start/get-start/
Was the pattern meant to look like this? It seems to be missing #Thing
for either thing1
or thing2
#First: {
foo: string
}
#Other: {
msg: string
}
#Either: #First | #Other
#Thing: {
name: string
#Either
}
thing1: #Thing & {
name: "thing1"
foo: "bar"
}
thing2: #Thing & {
name: "thing2"
msg: "hello"
}
Hi,
The Building Up Values example on https://cuetorials.com/overview/foundations/ doesn't work:
โฏ cat building-up.cue
#Base: {
name: string
kind: string
... // so it can be extended
}
#Meta: {
// string and a semver regex
version: string & =~"^v[0-9]+\\.[0-9]+\\.[0-9]+$"
// list of strings
labels: [...string]
}
#Permissions: {
role: string
public: bool | *false
}
// Building up a schema using a conjunction and embedding
#Schema: #Base & {
// "embed" meta and permissions
#Meta
#Permissions
// with no '...' this is final
}
value: #Schema & {
name: "app"
kind: "deploy"
version: "v1.0.42"
labels: ["server", "prod"]
role: "backend"
// public: false (by default)
}
โฏ cue export building-up.cue
#Schema: field not allowed: kind:
./building-up.cue:3:2
./building-up.cue:6:8
./building-up.cue:13:15
./building-up.cue:19:10
./building-up.cue:19:18
./building-up.cue:21:2
./building-up.cue:22:2
#Schema: field not allowed: name:
./building-up.cue:2:2
./building-up.cue:6:8
./building-up.cue:13:15
./building-up.cue:19:10
./building-up.cue:19:18
./building-up.cue:21:2
./building-up.cue:22:2
value: field not allowed: kind:
./building-up.cue:3:2
./building-up.cue:6:8
./building-up.cue:13:15
./building-up.cue:19:10
./building-up.cue:19:18
./building-up.cue:21:2
./building-up.cue:22:2
./building-up.cue:26:8
./building-up.cue:28:2
value: field not allowed: name:
./building-up.cue:2:2
./building-up.cue:6:8
./building-up.cue:13:15
./building-up.cue:19:10
./building-up.cue:19:18
./building-up.cue:21:2
./building-up.cue:22:2
./building-up.cue:26:8
./building-up.cue:27:2
โฏ cue version
cue version 0.4.0 linux/amd64
I could get it to work by moving #Base inside of the definition, but that's doing something different.
Hello ๐ , thanks for cuetorials.com, for several topics I find it better/simpler than the original Cue docs ๐
In the walkthrough section I came across this empty page:
It's https://cuetorials.com/walkthroughs/kubernetes/helm/, i.e. https://github.com/hofstadter-io/cuetorials.com/blob/055f33e6d9fc99401009d9995b3a1c5b40a324e1/content/walkthroughs/kubernetes/helm.md, which appears empty.
But the others also don't seem to be correct, for example I was expecting a walkthrough on https://cuetorials.com/walkthroughs/building-a-cue-powered-tool/self-driving-desktop/, but there's no walkthrough.
https://caniuse.com/?search=importmap
https://github.com/hofstadter-io/cuetorials.com/blob/main/layouts/partials/scripts.html#L27
We should be using a proper JS toolchain for Vue
Something like this should work: https://medium.com/gumgum-tech/faster-development-experience-with-vite-hugo-and-preact-c08cbcfce5fb
Hello
I'm trying to gently modify the basic cue example, but often get the below .
The command I'm running is cue cmd -t "name=bob" gen-todos
gen.templates.contents: invalid string: invalid string: invalid whitespace:
./first.cue:27:14
This error comes up when modifying what should be considered plain text, within """
.
For example:
contents: """
{{ range $T := .I -}}
model {{ $T.name }} {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
published Boolean @default(true)
}
{{ end }}
"""
Oddly, the following code does NOT error:
contents: """
{{ range $T := .I -}}
model {{ $T.name }} {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
}
{{ end }}
"""
These are all the path of the site.
If you want to contribute in Chinese translation work, please claim one of them and pull request all the pages under the one.
Any plan to translation? I'd like to contribute
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.