automata – DFA to accept a String containing even number of both A and B, but rejects empty String

I’m going to assume that your DFA has 4 states with the start state also being the singular accepting state.

Add a new (non-accepting) state where the outgoing transitions are a copy from your existing accepting start state. Make that new state the start state.

If my assumption about your existing DFA is correct then this way you should not be able to get into an accepting state with the empty string.

virtualbox – Local folder mounted as empty on Ubuntu with docker-machine

It appeared that docker-machine mounted my local /home to /hosthome by default.

Also using -v or --volume option for docker run has a difference to --mount option: local folder is automatically created if it doesn’t exist.

That’s why when calling docker run -v /home/a/b/c:/xxx, an empty folder was created at path /home/a/b/c inside virtual machine first, and then mounted to container at path /xxx.

First takeaway was to stop using -v option and start using --mount instead: docker run --mount type=bind,source=/home/a/b/c,target=/xxx. In this case the command will fail fast with error as the source path doesn’t exist in virtual machine.

Second step was to remove default shared folder from the virtual machine (my driver was virtualbox) and replace it with proper one with matching path. Performing these operations on stopped vm:

docker-machine stop
vboxmanage sharedfolder remove default --name hosthome
vboxmanage sharedfolder add default --name $HOME --hostpath $HOME --automount
docker-machine start

innodb – Cannot drop empty database in mariadb

I am having trouble dropping a database on my server
innodb-file-per-table is set to true

We previously had a huge table (1TB) which we used a drop table command. This result i believe was successfully completed but left a file called #sql-ib116.ibd in the directory.

We have completely cleared out the db, but when i issue a drop database dbname, it seems to be stuck in the “closing tables” phase

I then tried to create a frm equivalent and drop the table using this guide to no avail
https://mariadb.com/resources/blog/get-rid-of-orphaned-innodb-temporary-tables-the-right-way/

Im running out of server space and would ideally like manually remove the idb file
If i delete the file from the datadir, will this cause issues? im not worried about the data in this idb file. I also many other databases in this mariadb instance, will deleting affect the remaining?

Any ideas would be fantastic!
Thanks

complex analysis – Continuous function on compact Hausdorff space with empty interior is analytic

Thanks for contributing an answer to Mathematics Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

I need to make a shell script that displays config files without the commented and empty lines

This is my code:

#!/bin/bash
echo "Type in your file"
read file
sed -r -e 's/(^(^#)*$) ; s/(^(^;)*$) ; s/(^(^$)*$) ; s/(^(^/)*$) ; s/(^(^ )*$)' $file

This is the output when I give it a file:

sed: -e expression #1, char 31: unknown option to `s’

Why am I getting this error? Would you suggest another way to do it?
Thanks in advance

php – No encuentro solucion. “Creating default object from empty value” Laravel 6

me encuentro trabajando en un proyecto para la gestion de una biblioteca popular y me encuentro con este mensaje de error al querer ingresar libros de mis proveedores y de esta manera aumentar mi stock individual de cada libro.

Vista

<div class="card card-primary card-outline">
    <div class="card-header">
        <div class="row">
            <div class="col-4">
                <div class="form-group ">
                    <label for="libros" class="">Libro</label>
                    <label for="libros">
                        <a role="button" type="button" href="{{route('libros.create')}}" title="Nuevo libro"><i
                                class="fas fa-plus-circle fa-md"></i></a>
                    </label>

                    <select class="form-control" name="libros_select_id" id="libros_select_id" required>
                        <option value="" disabled selected>--Seleccione un libro por favor--</option>
                        @foreach($libros as $libro)
                        <option value="{{$libro->id}}" @if(old('libro_id')==$libro->id) selected
                            @endif>{{$libro->nombre}} - {{$libro->editoriales->nombre_editorial}}</option> 
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="col-4">
                <div class="form-group ">
                    <label for="cantidad">Cantidad que ingresa</label>
                    <input type="number" class="form-control  @error('cantidad') is-invalid @enderror" id="cantidad"
                        name="cantidad_libros" value="{{ old('cantidad') }}" placeholder="Especifique la cantidad de ingreso" >
                    @error('cantidad')
                    <span class="invalid-feedback" role="alert">
                        <strong>{{ $message }}</strong>
                    </span>
                    @enderror
                </div>
            </div>
            <div class="col-4">
                <a href="#" id="addRow" class="btn btn btn-primary"><i class="fa fa-plus"></i> Agregar</a>
            </div>
        </div>

Script

<script>
$('#addRow').on('click',function(){
    addRow();
});

function addRow(){
    //Obtener los valores de los inputs
    libro_select_id = $('#libros_select_id').val() ;
    libro = $("#libros_select_id option:selected").text();
    cantidad = $("#cantidad").val();

    if(libro_select_id != null ){
        if(cantidad > 0){
                var fila = '<tr> <td><input type="hidden" name="libros_select_id()" value="'+libro_select_id+'">'+libro+'</td>'+
                            '<td style="text-align:right;"><input type="hidden" name="cantidad()" value="'+cantidad+'">'+cantidad+' </td>'+
                            '<td style="text-align:center;"><a href="#" class="btn btn-danger btn-xs remove"><i class="fas fa-minus"></i></a></td>' +
                            '</tr>' ;

                $('tbody').append(fila) ;
                limpiar();
        }else{
            swal({
                    title: "Error",
                    text: "Ingrese una cantidad valida y mayor a 0",
                    icon: "error",
                });
        }
    }else{
        swal({
                    title: "Error",
                    text: "Seleccione un producto",
                    icon: "error",
                });
    }

}

function limpiar(){
    $("#cantidad").val("");
    $("#libro_select_id").val(null).trigger("change");

}

$('body').on('click', '.remove',function(){
    // var last=$('tbody tr').length;
    // if(last==1){
    //     alert("No es posible eliminar la ultima fila");
    // }
    // else{
        $(this).parent().parent().remove();
    //}

});

Controlador

public function store(Request $request)
{
    
    $data = request()->validate((
        'tipo_ingresos_id'=> 'required',
        'libros_select_id.*'=> 'required',
        'proveedor_id'=> 'required',
        'cantidad.*' => 'required',
        'fecha_ingreso' => 'required|date',
        //'fecha_perdida' => 'required|date',
    )) ;
      
    for ($i = 0; $i < sizeof($request->cantidad); $i++){
        $ingreso_libro = new IngresoLibro();
        $ingreso_libro->tipo_ingresos_id = $request->tipo_ingresos_id;  
        $ingreso_libro->libro_id = $request->libros_select_id($i);
        $ingreso_libro->proveedor_id = $request->proveedor_id;
        $ingreso_libro->cantidad = $request->cantidad($i);
        $ingreso_libro->fecha_ingreso = $request->fecha_ingreso;
        //$ingreso_libro->fecha_perdida = $request->fecha_perdida;
        $ingreso_libro->save();
        
        //Update realizado en la tabla libros (se sumaron la cantidad que ingreso de este libro)
        
         $libro = Libro::find($request->libro_id);
         $cant = $request->cantidad($i);
         $libro->stock_libro += $cant;
         $libro->update();
    }
    
    
    return redirect(route('ingreso_libros.index'))->with('success','Ingreso nuevo guardado con exito!'); 
}

Estoy consciente que el problema se encuentra en el update de libro que se encuentra dentro del bucle for.

Este código guarda en la base de datos cada uno de los ingresos que cargo y los puedo mostrar en mi datatable en mi vista index, pero algo guardar me salta este error y no me actualiza el stock de cada libro que ingreso.

Si podrían comentar algo estaría muy agradecido. Saludos.

java – Why is my second print statement returning empty []

Why is my second print statement returning empty ()

public class Listcheck {

public static void main(String() args) {
    // TODO Auto-generated method stub
        List<String> list = Arrays.asList("clean up","clean more","more cleaning","take rest");
        List<String> list1 = new ArrayList<>();
        System.out.println(list);
        for(String s:list) {
        if(list.contains("clean")) {
            list1.add(s);
        }
        }
        System.out.println(list1);
}

}

unity – Why the saveObjects List is empty when calling the Load method?

SaveLoad script :

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;

public class SaveLoad : MonoBehaviour
{
    public List<Transform> objectsToSave = new List<Transform>();
    public Button saveButton;

    private void Awake()
    {
        SaveSystem.Init();
    }

    public void Save()
    {
        SaveGame saveGame = new SaveGame();
        saveGame.saveObjects = new List<SaveObject>();
        SaveObject saveObject = new SaveObject();
        for (int i = 0; i < objectsToSave.Count; i++)
        {
            saveObject.gameObjectInstanceID = objectsToSave(i).gameObject.GetInstanceID();
            var x = objectsToSave(i).GetComponents<Component>();
            var stateQueryComponent = x.Where(component => component is IStateQuery).ToList();
            List<KeyToValue> componentsState = new List<KeyToValue>();
            foreach (var z in stateQueryComponent)
            {
                var w = z as IStateQuery;
                componentsState.Add(new KeyToValue(w.UniqueId.ToString(), w.GetState()));
            }

            saveObject.position = objectsToSave(i).position;
            saveObject.rotation = objectsToSave(i).rotation;
            saveObject.scaling = objectsToSave(i).localScale;

            saveObject.componentsState = componentsState;
            saveGame.saveObjects.Add(saveObject);

            string json = JsonUtility.ToJson(saveObject);

            SaveSystem.Save(json);
        }
    }

    public void Load()
    {
        Dictionary<int, Transform> instanceIdToObject = objectsToSave
            .ToDictionary(o => o.GetInstanceID(), o => o);
        var saveString = SaveSystem.Load();
        if (saveString != null)
        {
            SaveGame saveGame = JsonUtility.FromJson<SaveGame>(saveString);
            foreach (var saveObject in saveGame.saveObjects)
            {
                List<KeyToValue> loadedComponents = saveObject.componentsState;
                var objectToSetState = instanceIdToObject(saveObject.gameObjectInstanceID);

                objectToSetState.position = saveObject.position;
                objectToSetState.rotation = saveObject.rotation;
                objectToSetState.localScale = saveObject.scaling;

                var y = objectToSetState.GetComponents<Component>();
                var z = y.Where(component => component is IStateQuery).ToList();
                Dictionary<string, IStateQuery> zz = z.ToDictionary(sq => (sq as IStateQuery).UniqueId.ToString(), sq => sq as IStateQuery);

                foreach (KeyToValue keyvalue in loadedComponents)
                {
                    zz(keyvalue.Key).SetState(keyvalue.Value);
                }
            }
        }
    }
}

In the Save method I’m doing on line 41 :

saveGame.saveObjects.Add(saveObject);

Using a break point I see that the List saveObjects contains one item.

Then in the Load method I’m doing :

SaveGame saveGame = JsonUtility.FromJson<SaveGame>(saveString);
            foreach (var saveObject in saveGame.saveObjects)

Now the List saveObjects in the foreach loop is empty.

This is the class SaveGame :

using System;
using System.Collections.Generic;


(Serializable)
public class SaveGame
{
    public List<SaveObject> saveObjects;
}

This is the script for saving to the file :

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

public static class SaveSystem
{
    private static readonly string SAVE_FOLDER = Application.dataPath + "/save_";
    public static void Init()
    {
        if (!Directory.Exists(SAVE_FOLDER))
        {
            Directory.CreateDirectory(SAVE_FOLDER);
        }
    }

    public static void Save(string saveString)
    {
        string fileName = Path.Combine(SAVE_FOLDER, "savegame.txt");
        File.WriteAllText(fileName, saveString);

    }

    public static string Load()
    {
        string fileName = Path.Combine(SAVE_FOLDER, "savegame.txt");
        string content = File.ReadAllText(fileName);

        return content;
    }
}

And this is a screenshot of the saved file content on the hard disk :

File content