GooglePlay – ExpManager – Trick to transfer backup

Unfortunately the develore of this app ExpManager has quit to support it. I was in trouble when I wanted to tranfer my data to new my smartphone.

I found a trick.

I suppose you have the APP in both smartphones and want to transfer your data from the old to the new one.

On OLD smartphone:

1.1) In the menu choose Settings > Save/Restore
1.2) Press button SAVE to store backup
1.3) The file ExpManager.backup will be saved in this folder /storage/emulated/0/ExpManager/backup/ExpManager.backup
1.4) Using an APP to navigate your filesystem i.e. ES File Explorer, go to the folder where ExpManager saved your backup, select the file and send it with Bluetooth to the new smartphone.

On NEW Smartphone:

2.1) Save the file received from the old smartphone into folder /ExpManager/backup
2.2) In the menu choose Settings > Save/Restore
2.4) Press button RESTORE (Attention your actual data on the new smartphone will be erased)

I hope this can help you.

 

GooglePlay – ExpManager – Trucco per trasferire backup da un cellulare a un altro

Purtroppo lo sviluppatore ha smesso di supportarla poiché è passato su una nuova APP.
Di seguito mostro un trucco per passare i dati da un cellulare all’altro.

Ho trovato un modo per trasferire i DATI dal cellulare vecchio a quello nuovo.

Sul vecchio cellulare:
1.1) Da menu scegliere Impostazioni > Salva/Ripristina.
1.2) Premere il pulsante SALVARE per eseguire un Backup
1.2) Il file verrà salvato in /storage/emulated/0/ExpManager/backup/ExpManager.backup
1.3) Tramite ES File Explorer andare nella cartella dove si trova il file di Backup selezionarlo e inviarlo tramite Bluetooth al NUOVO cellulare

Sul nuovo cellulare:
2.1) Salvare il file trasferito dal vecchio cellulare nella cartella /ExpManager/backup
2.2) Da menu scegliere Impostazioni > Salva/Ripristina
2.3) Premere il pulsante RIPRISTINA (Attenzione questo cancellerà i dati già presenti nella APP,)

Posted in Uncategorized | Leave a comment

Symfony Doctrine Concurrency

I used Optimistic-Locking here you can find the documentation:

http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/transactions-and-concurrency.html

You can add in your entity the field version. Automatically doctrine will manage concurrency throwing an Exceprion.

use Doctrine\ORM\Mapping as ORM;

... 

 /**
 * @var int
 *
 * @ORM\Column(name="version", type="integer", nullable=true)
 * @ORM\Version
 */
 private $version;
Posted in Symfony | Tagged , , | Leave a comment

This is my solution to avoid constraint violation when you use Soft Delete

Here is an interesting article that explain how unique index are treated by DB
https://mariadb.com/kb/en/mariadb/getting-started-with-indexes/

The field deletedAt as Datetime with NULL value can’t be part of a unique index with NULL value, because you can have duplicate entries with NULL value.

To avoid this problem I added a field called deleted as integer with default value set as 0. When I remove with Soft Delete I set this value equal to the primary key.
So we can add deleted field partecipating in the unique index.

http://intelligentbee.com/blog/2015/01/09/symfony2-gedmo-softdeletable-doctrine-entities-with-unique-index-columns/

http://atlantic18.github.io/DoctrineExtensions/doc/softdeleteable.html

EXAMPLE

app/config/services.yml

services:
    ...
    app.soft_delete_listener:
        class: AppBundle\Events\SoftDeleteListener
        tags:
            - { name: doctrine.event_listener, event: preSoftDelete, priority: 10 }

 

AppBundle\Events\SoftDeleteListener.php

<?php
namespace AppBundle\Events;

use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
use Gedmo\Sortable\Sortable;

class SoftDeleteListener
{
    public function preSoftDelete(LifecycleEventArgs $event)
    {
        $entity = $event->getObject();
        if(method_exists($entity, "getId") && method_exists($entity, "setDeleted")
        {
            $deleted = $entity->getId();
            $entity->setDeleted($deleted);

            $om = $event->getObjectManager();
            $om->persist($entity);
            $om->flush();
        }
    }
}

AppBundle\Entity\User.php

<?php
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

use Gedmo\Mapping\Annotation as Gedmo; // gedmo annotations
use Doctrine\ORM\Mapping\UniqueConstraint;
use Doctrine\Common\Collections\ArrayCollection;

 
/**
 * User
 *
 * @ORM\Table(name="users", uniqueConstraints={@UniqueConstraint(name="item_unique", columns={"username", "deleted"})})
 * 
 * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
 * 
 */
class User
{
 /**
 * @var int
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
 private $id;

 /**
 * @var string
 *
 * @ORM\Column(name="username", type="string", length=25)
 */
 private $username;

 /**
 * @var \DateTime
 *
 * @ORM\Column(name="deleted_at", type="datetime", nullable=true)
 */
 private $deletedAt;

 /**
 * @var int 
 * 
 * @ORM\Column(name="deleted", type="integer", nullable=false, options={"default":0})
 */
 private $deleted = 0;


 /**
 * Get id
 *
 * @return int
 */
 public function getId()
 {
 return $this->id;
 }


 /**
 * Set username
 *
 * @param string $username
 *
 * @return User
 */
 public function setUsername($username)
 {
 $this->username = $username;

 return $this;
 }

 /**
 * Get username
 *
 * @return string
 */
 public function getUsername()
 {
 return $this->username;
 }

 
 /**
 * Set deletedAt
 *
 * @param \DateTime $deletedAt
 *
 * @return User
 */
 public function setDeletedAt($deletedAt)
 {
 $this->deletedAt = $deletedAt;

 return $this;
 }

 /**
 * Set deleted
 *
 * @param int $deleted
 *
 * @return User
 */
 public function setDeleted($deleted)
 {
 $this->deleted = $deleted;

 return $this;
 }
 
 /**
 * Get deletedAt
 *
 * @return \DateTime
 */
 public function getDeletedAt()
 {
 return $this->deletedAt;
 }

 /**
 * Get deleted
 *
 * @return int
 */
 public function getDeleted()
 {
 return $this->deleted;
 }
 
}
Posted on by gherardobertini | Leave a comment

SQL Access Equivalent MySQL Limit X, Y

In MySQL for paging a query we use

  • SELECT * FROM {table} LIMIT X, Y

In Access there is only

  • SELECT TOP Y * FROM {table}

to select first Y records of a query

We can use this trick:
First we have to know the num_rows of the query

  • NUM_ROWS => “SELECT COUNT(`{$primaryKey}`) FROM {$table} {$where}”

Then we can execute the query we want is equivalent to SELECT * FROM {table} LIMIT X, Y in MySQL

  • SELECT TOP Y * FROM (
    SELECT TOP (NUM_ROWS – X) * FROM {$table} {$where} {$order_inv}
    ) {$order}

Legend:
{$table} is the table name
{$where} is the where condition
{$order} is the order desired
{$order_inv} is the opposite order desired

Posted in Access, PHP, SQL | Tagged , , , , | Leave a comment

HTML JQuery – transform Inputbox into dropdown list (combobox)

Transform input textbox in combobox using JQuery and hide click out

Demo

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JQuery - Dropbox</title>
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.2.custom.min.js"></script>
<link rel="stylesheet" type="text/css" href="/css/ui-lightness/jquery-ui-1.8.2.custom.css"/>

<style type="text/css">
ul {
	margin: 0;
	padding: 0;
}
li {
	list-style: none;
}
#dropdown { position:absolute; width:200px; display:none; }
#dropdown li:hover { background:#ccc; cursor:pointer; }
#dropdown li {
    border: 1px solid #DEDEDE;
	
}
</style>
<script>

$(function() {
	$('#btn').click(function(e) {
		
		var pos = $('#txt').offset();
		pos.top += $('#txt').height();
	
		if($('#dropdown').is(':visible')) {
			   //str = 'visibile';
			   $('#dropdown')
			   	.removeClass('active')
				.fadeOut(100);
		} else {
			   //str = 'NOT visible';
			   $('#dropdown')
			     .addClass('active')
			   	.fadeIn(100);
		}
		
		e.stopPropagation();
		
		return false;
	});

	$('#dropdown li').click(function() {
		$('#txt').val($(this).text());
		$(this).parent().fadeOut(100);
	});

    $(document).click(function (e) {
        $('#dropdown').fadeOut(100);
    });
});
</script>    
</head>

<body>

<input type="text" id="txt" />
<button id="btn">Select </button>

<ul id="dropdown">
    <li>Value 1</li>
    <li>Value 2</li>
    <li>Value 3</li>
    <li>Value 4</li>
    <li>Value 5</li>
</ul>

</body>
</html>
Posted in JQuery | Tagged , , | Leave a comment