reference request – Were algebraic theories and abstract clones defined independently?

Algebraic theories (by which I mean the formalism based on bijective-on-objects functors) and abstract clones both capture universal algebraic structure, and are well-known to be equivalent. Algebraic theories were introduced in the Lawvere’s 1963 thesis Functorial Semantics of Algebraic Theories; while abstract clones were seemingly first defined in Cohn’s 1965 Universal algebra and attributed to Hall. The two therefore appeared in the literature at similar times. Though Cohn mentions that Hall lectured on universal algebra between 1947 – 1951, he does not mention whether abstract clones were defined there. In neither source does Lawvere or Cohn mention the other’s work, though it is observed at least as early as Linton’s 1966 Some aspects of equational categories that the two are closely related.

Is there any evidence to suggest either definition was inspired by the other, or that these were invented entirely independently?

PHP function that clones HTML form structure to MySQL database structure

I built a function that should greatly simplify working with long HTML forms, that save data to MySQL using PHP.

My forms usually have several hundred input elements that are added / altered / removed frequently from the form.

Goal of this function is to only write frontend HTML form markup, MySQL structure gets updated automatically once form is submitted. If new form is not yet being stored into a table, table is automatically created.

<?php
$mysqli = mysqli_connect('127.0.0.1', 'root', '', 'test');
$mysqli->set_charset('utf8');

function SubmitForm($mysqli, $table) {
    if(isset($_POST('submit'))) {
        // unset redundant $_POST fields
        unset($_POST('submit'));

        // create table if not exists
        $mysqli->query('create table if not exists `'.$table.'` (`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, `status` INT(11) NOT NULL DEFAULT "1", `date_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `code` VARCHAR(100) NOT NULL, UNIQUE KEY `code_unique` (code)) ENGINE=MyISAM DEFAULT CHARSET=utf8') or die($mysqli->error);

        // prepare data
        $next_after = null; // used to add columns in order of $_POST fields
        $columns = $placeholders = $types = $values = $duplicates = array();
        foreach ($_POST as $key => $value) {
            // add column if not exists
            $column_query = $mysqli->query('show columns from `' . $table . '` like "'.$key.'"') or die($mysqli->error);
            if ($column_query->num_rows === 0) {
                $mysqli->query('alter table `' . $table . '` add `' . $key . '` text NOT NULL ' . $next_after) or die ($mysqli->error);
            }

            // set AFTER for next column check query
            $next_after = 'after `' . $key . '`';

            // implode arrays that are passed from select(multiple='multiple')
            $value = is_array($value) ? implode(',', $value) : $value;

            // prepare data for query
            $columns() = $key;
            $placeholders() = '?';
            $types() = 's';
            $values() = $value;
            $duplicates() = $key . ' = values(' . $key . ')';
        }

        // insert / update data
        $stmt = $mysqli->prepare('insert into '.$table.' ('.implode(',', $columns).') values('.implode(',', $placeholders).') on duplicate key update '.implode(',', $duplicates)) or die($mysqli->error);
        $stmt->bind_param(implode('', $types), ...$values);
        $stmt->execute();

        // return success
        return 'form saved';
    }
    return null;
}
echo SubmitForm($mysqli, 'table_name');
?>
<form method="post">
    <input type="text" name="code" value="<?php echo time(); ?>" />
    <input type="text" name="apples" />
    <input type="text" name="bananas" />
    <input type="text" name="grapes" />
    <input type="submit" name="submit" />
</form>

hard drive – Clonezilla looping through multiple clones

As I attempt to clone a disk to another disk Clonezilla goes through it once, then twice, then three times. It performs the exact same action over and over. Eventually, it finishes but this is not expected behavior. This is a recently updated version of Clonezilla and the previous did not take multiple hours like this does.

Thanks in advance.

Rust blog backend in Rocket and Diesel, lots of clones

I have a small blog backend in Rust with Rocket and Diesel on Postgres. It reads and writes to and from the database fine, but to get to where it is I used a lot of clone() calls on strings. I feel like it could be written more efficiently with lifetimes, but my grasp of lifetimes in Rust is quite tenuous and I get a lot of compiler complaints.

The blog is divided into collections called ‘atlases’ with sub pages in each atlas. Each page has properties including ancestors, content blocks, and user IDs and roles. Each request comes with a cookie containing a session ID. To get a page the program receives a POST request to an endpoint containing an atlas ID and a page ID. It uses the cookie to authenticate the request, then queries the database through a Diesel schema to get the content blocks, ancestors, and other bits and bobs belonging to the page, and returns them as JSON data.

The main.rs file is generally standard Rocket boilerplate. The relevant bits for the POST handler to get a page from an atlas:

mod atlas;
#(macro_use)
extern crate rocket;
#(macro_use)
extern crate rocket_contrib;
#(macro_use)
extern crate diesel;

use response::{ResponseJson, ResponsePublicMedia, ResponseStaticFile, STATIC_FILES};
use rocket::http::CookieJar;
use rocket::Data;

pub mod schema;

#(database("postgres_conn"))
pub struct Db(diesel::PgConnection);

... // various endpoints and handlers

#(post("/endpoint/atlas.page.get/<atlas_id>/<page_id>"))
async fn tel_atlas_page_get(
    conn: Db,
    cookies: &CookieJar<'_>,
    atlas_id: String,
    page_id: String,
) -> ResponseJson {
    atlas::page_get(conn, cookies, atlas_id, page_id).await
}

...

#(launch)
fn rocket() -> rocket::Rocket {
    rocket::ignite()
        .mount(
            "/",
            routes!(
                ...
                tel_atlas_page_get,
                ...
            ),
        )
        .attach(Db::fairing())
}

The handler internals file:

use crate::atlas;
use crate::response::ResponseJson;
use crate::users::auth;
use crate::utilities::ERR;
use crate::Db;

use rocket::http::CookieJar;
use rocket_contrib::databases::diesel::prelude::*;

pub async fn page_get(
    conn: Db,
    cookies: &CookieJar<'_>,
    atlas_id: String,
    page_id: String,
) -> ResponseJson {
    // Page data
    let a_clone_page = atlas_id.clone();
    let p_clone_page = page_id.clone();
    let page = match conn.run(|c| get_page(c, a_clone_page, p_clone_page)).await {
        Some(p) => p,
        None => return ResponseJson::message("page.404", ""),
    };

    // User ID
    let user_id = match cookies.get("token") {
        Some(cookie) => match auth::check(cookie).await {
            Some((_email, user_id, _name, _token)) => Some(user_id),
            None => None,
        },
        None => None,
    };

    // Atlas role
    let a_clone_role = atlas_id.clone();
    let role = match user_id.clone() {
        Some(u) => conn.run(|c| get_atlas_role(c, u, a_clone_role)).await,
        None => "none".to_owned(),
    };

    // Page users
    let a_clone_users = atlas_id.clone();
    let p_clone_users = page_id.clone();
    let users = match user_id.clone() {
        Some(u) => {
            conn.run(|c| get_users(c, u, a_clone_users, p_clone_users))
                .await
        }
        None => Vec::new(),
    };

    if page.public || role != "none" || (user_id.is_some() && !users.is_empty()) {
        // Page ancestors
        let a_clone_ancestors = atlas_id.clone();
        let p_clone_ancestors = page_id.clone();
        let ancestors = conn
            .run(|c| get_ancestors(c, a_clone_ancestors, p_clone_ancestors))
            .await;

        // Page children
        let a_clone_children = atlas_id.clone();
        let p_clone_children = page_id.clone();
        let children = conn
            .run(|c| get_children(c, a_clone_children, p_clone_children))
            .await;

        // Page blocks
        let timestamp_clone = page.timestamp.clone();
        let blocks = conn
            .run(|c| get_blocks(c, atlas_id, page_id, timestamp_clone))
            .await;

        // JSON encode
        let page_encoded = match serde_json::to_string(&page) {
            Ok(e) => e,
            Err(_) => return ResponseJson::error(ERR.generic),
        };
        let users_encoded = match serde_json::to_string(&users) {
            Ok(e) => e,
            Err(_) => return ResponseJson::error(ERR.generic),
        };
        let ancestors_encoded = match serde_json::to_string(&ancestors) {
            Ok(e) => e,
            Err(_) => return ResponseJson::error(ERR.generic),
        };
        let children_encoded = match serde_json::to_string(&children) {
            Ok(e) => e,
            Err(_) => return ResponseJson::error(ERR.generic),
        };
        let blocks_encoded = match serde_json::to_string(&blocks) {
            Ok(e) => e,
            Err(_) => return ResponseJson::error(ERR.generic),
        };
        ResponseJson::message(
            "atlas.page",
            &format!(
                "{{"page":{},"atlas_role":"{}","users":{},"ancestors":{},"blocks":{},"children":{}}}",
                page_encoded, role, users_encoded, ancestors_encoded, blocks_encoded, children_encoded
            ),
        )
    } else {
        ResponseJson::message("auth.forbidden", "")
    }
}

fn get_page(
    conn: &mut diesel::PgConnection,
    atlas_id: String,
    page_id: String,
) -> Option<atlas::Page> {
    use crate::schema::atlas_pages;

    if &page_id == "maps" || &page_id == "locations" {
        match atlas_pages::table
            .select((
                atlas_pages::page_id,
                atlas_pages::atlas_id,
                atlas_pages::title,
                atlas_pages::image,
                atlas_pages::public,
                atlas_pages::parent,
                atlas_pages::timestamp,
            ))
            .filter(atlas_pages::atlas_id.eq(&atlas_id))
            .filter(atlas_pages::page_id.eq("index"))
            .first::<atlas::Page>(conn)
        {
            Ok(a) => Some(atlas::Page {
                page_id,
                atlas_id,
                title: a.title,
                image: a.image,
                public: a.public,
                parent: "index".to_owned(),
                timestamp: a.timestamp,
            }),
            Err(_) => None,
        }
    } else {
        match atlas_pages::table
            .select((
                atlas_pages::page_id,
                atlas_pages::atlas_id,
                atlas_pages::title,
                atlas_pages::image,
                atlas_pages::public,
                atlas_pages::parent,
                atlas_pages::timestamp,
            ))
            .filter(atlas_pages::atlas_id.eq(&atlas_id))
            .filter(atlas_pages::page_id.eq(&page_id))
            .first::<atlas::Page>(conn)
        {
            Ok(a) => Some(a),
            Err(_) => None,
        }
    }
}

fn get_users(
    conn: &mut diesel::PgConnection,
    user_id: String,
    atlas_id: String,
    page_id: String,
) -> Vec<atlas::AtlasUser> {
    use crate::schema::page_users;

    let user = match page_users::table
        .select((page_users::user_id, page_users::user_type))
        .filter(page_users::user_id.eq(&user_id))
        .filter(page_users::atlas_id.eq(&atlas_id))
        .filter(page_users::page_id.eq(&page_id))
        .first::<atlas::AtlasUser>(conn)
    {
        Ok(a) => a,
        Err(_) => return Vec::new(),
    };

    if user.user_type == "owner" {
        match page_users::table
            .select((page_users::user_id, page_users::user_type))
            .filter(page_users::atlas_id.eq(&atlas_id))
            .filter(page_users::page_id.eq(&page_id))
            .load::<atlas::AtlasUser>(conn)
        {
            Ok(a) => a,
            Err(_) => Vec::new(),
        }
    } else {
        vec!(user)
    }
}

fn get_atlas_role(conn: &mut diesel::PgConnection, user_id: String, atlas_id: String) -> String {
    use crate::schema::page_users;

    match page_users::table
        .select((page_users::user_id, page_users::user_type))
        .filter(page_users::user_id.eq(&user_id))
        .filter(page_users::atlas_id.eq(&atlas_id))
        .filter(page_users::page_id.eq("index"))
        .first::<atlas::AtlasUser>(conn)
    {
        Ok(a) => a.user_type,
        Err(_) => "none".to_owned(),
    }
}

fn get_ancestors(
    conn: &mut diesel::PgConnection,
    atlas_id: String,
    page_id: String,
) -> Vec<atlas::Ancestors> {
    use crate::schema::page_ancestors;

    match page_ancestors::table
        .select((
            page_ancestors::page_id,
            page_ancestors::atlas_id,
            page_ancestors::title,
            page_ancestors::index,
            page_ancestors::ancestor,
        ))
        .filter(page_ancestors::atlas_id.eq(&atlas_id))
        .filter(page_ancestors::page_id.eq(&page_id))
        .order(page_ancestors::index.asc())
        .load::<atlas::Ancestors>(conn)
    {
        Ok(a) => a,
        Err(_) => Vec::new(),
    }
}

fn get_children(
    conn: &mut diesel::PgConnection,
    atlas_id: String,
    page_id: String,
) -> Vec<atlas::Page> {
    use crate::schema::atlas_pages;

    match atlas_pages::table
        .select((
            atlas_pages::page_id,
            atlas_pages::atlas_id,
            atlas_pages::title,
            atlas_pages::image,
            atlas_pages::public,
            atlas_pages::parent,
            atlas_pages::timestamp,
        ))
        .filter(atlas_pages::atlas_id.eq(&atlas_id))
        .filter(atlas_pages::parent.eq(&page_id))
        .order(atlas_pages::title.desc())
        .load::<atlas::Page>(conn)
    {
        Ok(a) => a,
        Err(_) => Vec::new(),
    }
}

fn get_blocks(
    conn: &mut diesel::PgConnection,
    atlas_id: String,
    page_id: String,
    timestamp: String,
) -> Vec<atlas::Block> {
    use crate::schema::page_blocks;

    match page_blocks::table
        .select((
            page_blocks::page_id,
            page_blocks::atlas_id,
            page_blocks::index,
            page_blocks::label,
            page_blocks::block,
            page_blocks::text,
            page_blocks::data,
            page_blocks::timestamp,
        ))
        .filter(page_blocks::atlas_id.eq(atlas_id))
        .filter(page_blocks::page_id.eq(page_id))
        .filter(page_blocks::timestamp.eq(timestamp))
        .order(page_blocks::index.asc())
        .load::<atlas::Block>(conn)
    {
        Ok(a) => a,
        Err(_) => Vec::new(),
    }
}

unity – Clones size is bigger than the original?

I’m trying to clone items inside array. But the clones i’m getting is bigger than the original one!! Also, after couple of second the script is missing/removing some clones !!

Update 1:
I’m working on puzzle game such as “Candy Crush”. Now I have my items to fill inside sorts”dots”. What script should do, Clone my items and insert them on sort place. What happen is I get the size bigger than the original one. and after seconds script is missing/removing some clones from “Clone_Ghost” !!

public GameObject() Items; // 4 elements
public GameObject() dots; // where to place my clones
public GameObject ClonePlace; // hold inside canvas
public GameObject() Clone_Ghost; //


void Start()
{
    
    Clone_Ghost = new GameObject(dots.Length);

    for (int i = 0; i < dots.Length; i++)
    {           
        Clone_Ghost(i) = Instantiate(Items(Random.Range(0,3)), dots(i).transform.position, dots(i).transform.rotation);
        Clone_Ghost(i).transform.parent = ClonePlace.transform;
    }
    
}

dnd 5e – What happens to clones of a deepspawn created if/when the deepspawn dies?

The spawn appear to survive.

The D&D 3.5 adventure module Expedition to Undermountain, p.107, describes the result of slaying a deepspawn:

If the PCs kill or drive away the deepspawn, they each gain a story award of 250 XP, in addition to the combat XP. They have eliminated a creature that could repopulate this section of Undermountain with dangerous creatures. If they do not defeat it but negotiate for safe passage through its territory, give each PC a 100 XP story award.

Note the lack of any special rule for what happens to the deepspawn’s offspring. They don’t die or explode or anything; killing the deepspawn just prevents it from producing more.

The AD&D 2e Elminster’s Ecologies, p. 30-31, The Thunder Peaks and he Storm Horns, suggests that the allegiance of the offspring is due to some psychic control or influence, at least partly. Defeating one might impede the cohesion of a group of the offspring, and they would no longer have a leader, though there are no game rule mechanics that specifically cover this. However, they are self-willed, sentient beings, not puppets of the deepspawn, and can continue to fight and live normally without their creator.

Past rules for the deepspawn, particularly 3e’s Monsters of Faerûn and 2e’s Monstrous Compendium, also fail to mention any special rule for what happens to the offspring when the deepspawn dies. They merely no longer have a leader.

dnd 5e – What happens to clones a deepspawn created if/when the deepspawn dies? (D&D mechanics and/or lore)

The spawn appear to survive.

The D&D 3.5 adventure module Expedition to Undermountain, p.107, describes the result of slaying a deepspawn:

If the PCs kill or drive away the deepspawn, they each gain a story award of 250 XP, in addition to the combat XP. They have eliminated a creature that could repopulate this section of Undermountain with dangerous creatures. If they do not defeat it but negotiate for safe passage through its territory, give each PC a 100 XP story award.

Note the lack of any special rule for what happens to the deepspawn’s offspring. They don’t die or explode or anything; killing the deepspawn just prevents it from producing more.

The AD&D 2e Elminster’s Ecologies, p. 30-31, The Thunder Peaks and he Storm Horns, suggests that the allegiance of the offspring is due to some psychic control or influence, at least partly. Defeating one might impede the cohesion of a group of the offspring, and they would no longer have a leader, though there are no game rule mechanics that specifically cover this. However, they are self-willed, sentient beings, not puppets of the deepspawn, and can continue to fight and live normally without their creator.

Past rules for the deepspawn, particularly 3e’s Monsters of Faerûn and 2e’s Monstrous Compendium, also fail to mention any special rule for what happens to the offspring when the deepspawn dies. They merely no longer have a leader.

dnd 5e – How can a character make clones of themselves without magic? Is it possible?

I am making a character and I want him to be able to create clones that are not as strong as he is, but use some of his skills and can be useful in reconnaissance and combat.

My character is a level 4 barbarian, whom I would like to make meliodas-like out of the seven deadly sins. Magical items that cast clone spells would be fine, and I'm looking for a way to make clones a mixture of flesh and blood and illusion. I was hoping that they could fight with my skills and have hit points so that they could disappear when they died.

I thought the clones could have some of my hit points depending on how many, like half of my hit points for one clone, a quarter for two clones, etc.

They can either last until they die or until I release them.

But I'm open to ideas!

Curveball clones WP site to new URL

I scratched my head and wondered what I was missing here. I have done this type of cloning many times and have never had a problem. I am a Linux system administrator by profession with considerable experience with WordPress, but not a WordPress expert.

I tried to clone a particular WordPress site (I tried more than once in case I made stupid mistakes) but I can't get it to work. I have

  1. Dumped DB from old site.
  2. Copied files from the old to the new site and updated file permissions.
  3. When replacing the database for the relevant domain name, a global URL search was carried out.
  4. Perform a global search and replace all files for the domain name in question
  5. The file wp-config.php has been changed accordingly for the new database and loaded into.
  6. Checked, double checked, triple checked. Is also checked for path problems. Can't find anything.
  7. Disabled all of the caching I could find, including searching for caching files and plugins. Including on the server and locally.
  8. Checks if the server I am visiting and cloning is correct.

The site in question uses Beaver Builder. An interesting data point is that the menu does not work in the new version of the site – it shows "SELECT MENU". When I am logged in and click on the "Select menu" icon, I go to the main menu there.

I have no problem logging into the backend and can see all the data that should be there.

If I clone the topic to another server and keep the domain name the same (and use a hosts file), does everything seem to work? The problem seems to be related to the changed URL.

I tried to disable all plugins (but rename the plugins folder). Didn't make a difference.

Has anyone seen this before? What did i miss?

dnd 5e – Can incubating clones develop?

The situation is as follows:

Faced with a war that exposes his cowardice, a nobleman goes to the necromancer’s laboratory, where he uses the wizard to protect him from failure. The noble who feels generous also pays for a clone to be made for his whole family, including his four-year-old daughter, and goes to war.

Years later, the child, who is now a rebellious woman, is impregnated with a sword that costs her life. She remembers her father's gift and lets herself die so that her soul can willingly enter the clone.

As written in the clone magic:

This spell creates an inert duplicate of a living medium creature as
Protection from death. This clone forms in a closed container and
grows to full size and ripeness after 120 days; You can also choose
The clone is said to be a younger version of the same creature. Remains
inert and indefinitely as long as its vessel remains
undisturbed.

Anytime after the clone matures when the original creature dies,
his soul passes to the clone, provided the soul is free and
ready to return. The clone is physically identical to the original
and has the same personality, memories and skills, but none of those
Original equipment. The physical condition of the original creature is preserved if
They still exist, become sluggish, and cannot be restored afterwards
Life since the soul of the being is somewhere else.

On the surface, RAW, it sounds simple enough. As long as the glass is still intact and ready, it should be able to return, but there are two options that seem like a gamble for this situation:

  1. The requirement for this spell is a diamond and a cubic inch of flesh from the creature, but it is not stated "unchanged". That said, as I understand it, the necromancer couldn't stand the nobles, he could summon a werewolf who would nibble the meat cubes before incubating them. Of course, hypothetically.

  2. There is a certain line in the rules that says "You can also choose to make the clone a younger version of the same creature."Although the necromancer could return to the noble this way, I take a closer look at what this means for the child …


When you put everything together, it seems like hiring a necromancer to clone you. This poses a high risk. Yes, they may be benevolent, but they could also mess with your clone or see what would happen if the whole family went in the same container.

Even if everything goes according to plan, the woman had a clone made at the age of 4, so the question remains whether the clone would age with her or whether she would be an adult woman in a 4-year-old body (that would be fun but does bring also complications).

Together sum up:

  1. Do clones age with the original body? or do they stay at the age at which they were cloned forever?
  2. Can the clone be altered in any way before it comes to life? To be cursed with lycanthrope or a transformed spell?

  3. (Bonus) What would happen if someone ordered 3 clones and put the 3 meat cubes in the same pot just to win 2000 gp of diamonds?