Typed Arrays in GDScript
You can define an array of a strict type in Godot like this:
var names: Array[string] = ["Hash", "Rocket"]
# Or if you had a custom class:
var powerups: Array[Pickup] = []
You can define an array of a strict type in Godot like this:
var names: Array[string] = ["Hash", "Rocket"]
# Or if you had a custom class:
var powerups: Array[Pickup] = []
Today I discovered TOON (Token-Oriented Object Notation), a serialization format designed specifically for LLMs that achieves 30-60% token reduction compared to JSON.
Unlike JSON, TOON eliminates redundant syntax (braces, brackets, most quotes). Unlike CSV, it supports nested fields. It also provides better accuracy through explicit lengths and fields before hand, this seems to make LLM better to understand the data that's comming.
JSON:
{
"users": [
{ "id": 1, "name": "Alice", "role": "admin" },
{ "id": 2, "name": "Bob", "role": "user" }
]
}
TOON:
users[2]{id,name,role}:
1,Alice,admin
2,Bob,user
Keys are declared once, then data flows as comma-separated rows with YAML-style indentation for nesting.
Today I learned that ISO 8601 includes a spec for durations as well as dates and times.
Normally when I think of ISO 8601 I think of dates (2024-05-30) or times (2024-05-30T19:54:14Z).
But it also includes a spec for durations! Super convenient to have a standardized way to represent this, and rails and javascript libraries are able to parse it.
Some examples:
PT8H PT3H30M P2M1D P6Y5M4DT3H2M1S I was looking into OSX's quarantine mechanism, and learned how downloaded executables are prevented from running. OSX uses extended attributes to prevent these from running, aka quarantine.
For example, if you install chromedriver with homebrew, then try to open it, you'll see that all too familiar alert that "the developer cannot be verified". How does OSX know to do this? Well, when the file is downloaded, it writes an extended attribute (com.apple.quarantine) key-value to the file (see Gatekeeper). These extended attributes hold additional metadata about each file.
In the terminal, you can view these attributes on a file with the xattr command.
> xattr -l /usr/local/bin/chromedriver
com.apple.quarantine: xxxxxxxxxxxxxxxxxxxxxxxx
You can manually remove an attribute with this utility using the -d flag -
> xattr -d com.apple.quarantine
If you're like me, you may have thought that the word for ^ was spelled "carrot" because of its pointy shape.
Turns out, it is spelled "caret". This symbol was used as a mark in editing proofs, to show where something needs to be inserted. So, the name comes from the Latin verb "caret" which means "there is lacking".
Source: https://www.etymonline.com/word/caret
Csound operates uniquely. You can specify certain operations to happen at a certain rate based on the variable name.
kval random 0, 10
This line of code produces a random value between 0 and 10, 1000 times a second because it populates a k-rate (control rate) variable.
But what if I want to debug this? Or see in the console what values I'm producing? You can use the printks opcode.
kval random 0, 10
printks "kval: %f\n", 1, kval
Clearly, 1000 prints a second would eat up the console quickly. printks's second argument is how many seconds between prints. It's debouncing printing automatically.
It's output looks like this:
kval: 9.635761
kval: 6.579237
kval: 6.564805
kval: 7.650385
kval: 3.684652
kval: 2.481188
kval: 3.298008
kval: 5.385859
kval: 0.559652
kval: 5.215418
Read more about it here.
4 bits (or half a byte) is referred to as a "nibble".
On machines running OS X, there is an Apple icon in the upper left corner as part of the menu bar. Clicking on this icon reveals a number of options. The first reads About This Mac.
If you hold down the option key, however, that first option will instead
read System information...
Select that option to access the System Information panel which can tell you details about your hardware, software, and network.
h/t Dillon Hafer
If your Mac is behaving in an odd way, there may be an issue with some piece of the hardware -- such as the RAM.
You can perform a hardware check in order to chase down a diagnosis.
d key At this point, the machine should have booted into a special hardware check mode. Select your preferred language, the hardware check will be performed, and any issues will be reported.
h/t Dillon Hafer
Pure Data is graphical programming language
specialising in audio applications. It has an object called netreceive that
is a socket (either TCP or UDP) that accepts a connection and outputs messages
sent to it.
There are 2 gotcha's that I experienced in working with it.
The first. It requires a special protocol, called
FUDI. Each message must be terminated by
a semicolon ;. The message can contain any number of 'atoms' (strings)
separated by whitespace but the semicolon is essential.
The second. The documentation of pure data contains running examples, if you
open the documentation of netreceive before running the object in your patch,
you will get a bind: Address already in use (48) error. Close the
documentation and try again!
Graphql works with a type system. You ask for fruit and it returns fruit, but that fruit could be a pear or an orange.
(contrived example apologies)
interface Fruit {
seedless: Boolean
}
type Pear implements Fruit {
color: String
}
type Apple implements Fruit {
size: Int
}
So when you ask for fruit, and you want the size of the apple, you have to let graphql know that you want an Apple and are expecting an Apple and while I'm thinking about this as casting the graphql docs call it inline fragments.
query {
fruit {
seedless
... on Pear {
color
}
... on Apple {
size
}
}
}
The ... is a syntactic element not a writing convention.
RSA encryption (publickey/privatekey) is powerful encryption but its really only meant to encrypt small things like other encryption keys. The maximum size of the amount of data an rsa public key can encrypt is:
(key_size/8).floor - 11
So in the case of a key thats 1024 bits it can only encrypt data up to 117 bytes long. Not long enough for documents of any size or variable length.