Gutenberg Blocks – Save a predefined text attribute?

I am trying to save an attribute for a custom Gutenberg block. Call it contenttype.

This attribute is already predefined – for instance, “discussion”

In my code, I figured this would be straightforward.

Here is my list of attributes:

    attributes: {

        selectedPost: {
            type: 'number',
            default: 0,
        contenttitle: {
            type: 'string',
            default: '',
        contenttype: {
            type: 'string',
            default: 'discussion',
        blockId: {
            type: 'string',
            default: '',

And here is where I set their values:

    onChangeSelectPost( value ) {
        // Find the post
        const post = this.state.posts.find( ( item ) => { return == parseInt( value ) } );
        // Set the state
        this.setState( { selectedPost: parseInt( value ), post } );
        // Set the attributes
        this.props.setAttributes( {
            selectedPost: parseInt( value ),
            contenttitle: post.title.rendered,
            contenttype: 'discussion',
            blockId: this.props.clientId,

All is working fine, except that this contenttype just isn’t showing up in the block’s attributes. What I see in the database is

<!-- wp:cgb/block-my-block {"selectedPost":1071,"contenttitle":"Some Title","blockId":"8654cc3c-5k6d-47f4-8e22-97a0c3554567"} /-->

Am I doing something obviously wrong here?


— Update:
This seems to shed light on the problem:

So now I have it working if I specify default so some arbitrary string, like “blah”. Oddly enough, it was not working when I had default:''. Here is how I know specify the default:

        contenttype: {
            type: 'string',
            default: 'discussion',

And with the setAttributes call unchanged, that is

        this.props.setAttributes( {
            selectedPost: parseInt( value ),
            contenttitle: post.title.rendered,
            contenttype: 'discussion',
            blockId: this.props.clientId,

all is working.

The 50×1 vector y.d and the 50×2 matrix X.d are pre-defined in R. Let β^=(β^0β^1) how to solve this in R: X.dTX.dβ^=X.dTy.d. Solve for β^

The 50×1 vector y.d and the 50×2 matrix X.d are pre-defined in R. Let β^=(β^0β^1)

we have the following system of linear equations: X.dTX.dβ^=X.dTy.d. Solve for β^.

I tried like : solve(t(X)%%t(d)%%X.d)%%t(X)%%t(d)%*%y.d

What is the code in R for this?

Document set template (DocSet with pre-defined folders)

I’m using document sets to store project for the team.
It has some meta data defined like start date, requester, owner and more stuff like that.
Now, within a document set, there should always be a couple of folders that are the same.
Think of folders like: Source files, For review, Final and Open project files.

Instead of having to create these folders by hand each time a new project (docset) is created, is there a way to “template” this so that a new docset has these folders by default?

game design – Slots – Reel with a predefined symbol positions or make each symbol change independently on the others

I’m making a slot machine game and I need some advice on how to implement the spinning reels or how it’s usually done. Right now, I’m thinking about two different approaches that would make sense – if you know any other way to implement this, please do share – and I don’t know which one is better or the more common (if either of those is even right).

Approach No.1 – Predefined Reels

In this approach, the symbols on the reels are predefined and fixed in place (akin to how it’s done on the old-school mechanical slots) and the reels rotate like this.

Approach No.1 Illustration

Approach No.2 – Random Symbols

Here all the symbols are randomly chosen on the go, just before the symbol appears in the view.

Approach No.2 Illustration

Which one of these approaches is the right way to go, if either. Are there any alternative solutions that are used normally?

How does BBEdit define “Predefined symbols” when syntax coloring?

The text editor BBEdit offers syntax coloring options for various categories of source code, including plain text, comments, strings, language keywords, etc. One of the categories is “Predefined symbols,” which is defined in the BBEdit documentation as

Predefined symbols are terms which are not language keywords, but which are predefined by a language’s reference implementation, or which are part of a language’s standard library/framework support, or which have other special meaning to developers writing code in that language.

When I edit Python files in BBEdit, I find which symbols get colored with this style to be unpredictable. For example, builtin constants NotImplemented or Ellipsis do not get colored as Predefined symbols, whereas words like index or count, which to my knowledge have no inherent special meaning in Python, do.

How is BBEdit deciding which symbols to highlight in this style? Is this viewable somewhere? Better yet, editable?

plugins – Can I share predefined fonts from theme_support with a gutenberg component?

I have a few fonts defined in my functions.php:

        add_theme_support('editor-font-sizes', array(
                'name' => esc_attr__('Small', 'moderna'),
                'size' => 13,
                'slug' => 'small'
                'name' => esc_attr__('Headline', 'moderna'),
                'size' => 40,
                'slug' => 'headline'

I want to use these defined fonts now in a FontSizePicker Component from Gutenberg. However I do not want to define these two times. Is there any way to get these fonts from php to the wordpress block?

    onChange={(newFontSize) => console.log(newFontSize)}

regex – Split a string by pre-defined terms which have no white spaces between them

Basically what I am trying to achieve is splitting a string that I get from AngleSharp, for example this one:

Single-playerMulti-playerCo-opFull Controller Support

As you can see there are no spaces between the different terms themselves so this is where my problem comes from. I tried using this:

b(Single-player|Multi-player|Cross-Platform Multiplayer|Full Controller Support|Online PvP|Partial Controller Support|Co-op)b

It works if there are spaces between the different terms but I don’t know how to do it when there are none. I hope this makes sense! Thank you!

script – How to automatically type pre-defined text with a simple command on IOS?

On IOS 14.4 or above, is there any way to automate the process of pasting pre-defined text into the currently focused textfield, (even a password textfield)?

In an ideal world, with the text cursor blinking, you could just say, “Hey Siri, type string_5” where string_5 has been predefined as your email address or password, for example… or maybe use some kind of keyboard plug-in.

But you can’t do that at the moment… or can you??

What I’ve tried so far:

  1. The “Paste It” keyboard app.

Result: Doesn’t work / app is seemingy broken. Even if it did work, for some asinine reason, it needs internet access and “the developer can see whatever you type.” No thanks.

  1. The Text Replacement feature of IOS, such that, for example, typing “ezpz” results in “” being entered.

Result: Works well, but this technique won’t work for password fields.

  1. The Shortcuts app.

Result: I cant figure out how to glue all the necessary peices together… or if it’s even possible. I have been able to create other simple shortcuts like sending pre-defined text messages.

  1. Just telling Siri, “type (the stuff I want to type)” or “paste (stuff).”

Result: Either doesn’t work or she thinks I want to send a text message. Siri doesn’t understand “type into the currently focused textfield.”

geometry – Tiling a circle with convex shapes of predefined location and size

I have been trying to prove Cauchy’s integral formula “my way” and it didn’t go well, but I found out another interesting geometry problem. If one could prove that my hypotheses are right, I would be able to finish my proof, which would be way more complicated than I initially thought.

The problem can be explained as maintaining a set of convex sets of euclidean plane that cover the given circle. Under “circle”, I assume a closed circle defined by its center $c$ and radius $r$, the set: $D(c,r)={xinmathbb{E}^2mid|x-c|leqslant r}$.

The problem:

Is there a positive real constant $K>1$ and a positive real constant $W>1$ such that for any given circle $B$ and any family of circles ${A_i=D(c_i,r_i)mid iin I}$ that cover the circle $B$: $bigcup{A_imid iin I}supseteq B$, there exists another family of sets ${P_jmid jin J}$ such that:

  1. For every $jin J$, the set $P_j$ is compact and convex,

  2. For every two different indices $j_1,j_2in J$ holds that $emptyset=text{int}P_{j_1}captext{int}P_{j_2}$,

  3. They are the exact cover of $B$: $bigcup{P_jmid jin J}=B$,

  4. For every $jin J$ there exists $iin I$ so that $c_iin P_jsubseteq D(c_i,Kcdot r_i)$,

  1. (this is an extra property) For every $jin J$, the maximal width $M$ and the minimal width $m$ of $P_j$ form a ratio smaller than $W$: $frac{M}{m}leqslant W$.

The fifth condition is additional. If you can prove the theorem for only first four conditions, it is still good. The width of a figure $F$ here represents the minimal width of a strip (the closure of space between two parallel lines) of fixed direction that can completely cover the figure $F$. The minimal width and the maximal width here are taken as extremes when the direction is the parameter.

unity – Free camera navigation and pre-defined locations

I’ve only ever seen this solved with the animation being controlled by a script – This can be done in the Update() method or via a tweening plugin like DoTween.

In the Update method you have a few options, including manual movement (manually manipulating transform.position‘s x, y and z parameters), using transform.position = Vector3.MoveTowards(transform.position, _movementTarget, MaxSpeed * Time.DeltaTime); and transform.position = Vector3.Lerp(_movementStart, _movementTarget, _animationState) where _animationState goes from 0 to 1 to indicate how far through the animation you are. The choice between MoveTowards and Lerp comes down to whether you care more to set the movement speed, or the time it’ll take to get to the target.

For rotation, you can also use Transform.LookAt(), Quaternion.Lerp() and Quaterion.LookRotation() however I tend to compute this manually to absolutely ensure the Z rotation is never changed.

In my solution I’ve gone with the Lerp approach for position, and am manually animating rotation by only lerping the y axis, you could also separately lerp the x rotation axis, that’d be fine, just make sure to never change the z axis.

Movement demonstrated in Unity

using UnityEngine;

namespace Assets
    public class MoveMe : MonoBehaviour
        private bool _isMoving = false;
        private Vector3 _movementStart;
        private Vector3 _movementTarget;
        private float _rotationStartEulerY;
        private float _rotationTargetEulerY;
        private const float AnimationSpeedFactor = 2f;
        private float _animationProgress = 0;

        private void Update()
            if (_isMoving)
                _animationProgress += Time.deltaTime * AnimationSpeedFactor; //Animation progress 0..1
                transform.position =
                    Vector3.Lerp(_movementStart, _movementTarget, _animationProgress); //Animate position
                var rot = transform.rotation.eulerAngles;
                transform.rotation = Quaternion.Euler(rot.x,
                    Mathf.Lerp(_rotationStartEulerY, _rotationTargetEulerY, _animationProgress),
                    rot.z); //Animate rotation
                if (_animationProgress >= 1)
                    _isMoving = false; //End animation, player free to move camera manually

            if (Input.GetKeyDown(KeyCode.A)) StartAnimationTowards(new Vector3(0, 1, -2.96f), -51.145f);
            if (Input.GetKeyDown(KeyCode.S)) StartAnimationTowards(new Vector3(-2.88f, 1, -3.52f), 39.054f);
            if (Input.GetKeyDown(KeyCode.D)) StartAnimationTowards(new Vector3(-8.97f, 3.97f, 3.2f), 103.39f);

        private void StartAnimationTowards(Vector3 position, float rotation)
            _isMoving = true;
            _movementStart = transform.position;
            _movementTarget = position;
            _rotationStartEulerY = ClampRotation(transform.rotation.eulerAngles.y);
            _rotationTargetEulerY = ClampRotation(rotation);
            _animationProgress = 0;

        private float ClampRotation(float rotation)
            //Ensures the returned value is between -180 .. 180. This ensures rotation doesn't animate the long way around the circle.
            rotation %= 360;
            return (rotation > 180)
                ? rotation - 360
                : rotation;