How to upload files to a web app using App Inventor

When you want to create an app that points to an existing website, a web app can be the right solution, and the App inventor tool made available by MIT makes the creation of this kind of app very easy.
However, the basic mechanism of the App Inventor web app allows only to read the content of the and not to upload or download files. To fix this situation, an extension called CustomWebView has been made available, which allows files to be downloaded and uploaded.

To download CustomWebViewer extension simply click the download button on the Github page. You will obtain back an *.aix file, that is the extension. To install it, simply click “Import extension” at the bottom of the left menu in App Inventor, like showed in image. This is the standard way to import almost all the extensions.

Then simply drag the installed extension in to the interactive screen of App Inventor, like you do with all other objects.

Components

In our main screen (named “Screen1“) we’ll have a Vertical Arrangment container, an Activity Starter and a Sound Recorder.

Blocks

Let’s look to the blocks now. We’ll grant read permissions to read files. Then we create a web app view using CustomWebView, and we put the web app in to a vertical container. We then set file access to true, and let the web app connect to the desired website.

In a second block we specify what to do when we click an upload button on our webapp. We call an activity , specify data type and start the activity.

In the third and last block we tell what to do when the activity is started: call a file upload a set the path of the file as a result. Doing that way we’ll be able to upload our files in to our web app.

Hotel in Italy charges 1€/night but in return guests will be broadcasted 24/7 on the web

Commonly the prices for a summer stay in the Riviera romagnola are medium-high. They range from 80-120 euros per night for a room in June, to 110-150 in July, and reach 180 euros in August. But things may soon change. The owner of a hotel in Rimini, the capital of the Riviera and the destination of hundreds of thousands of tourists from all over Italy and Europe in the summer season, has decided to make an amazing and extravagant marketing move: he will offer the guests of his hotel a stay in Rimini at the price of just 1 euro per night, but all the rooms will be equipped with cameras that will broadcast live on the web, on different platforms, all day 24 hours a day seven days a week.

Suites for just 1 euro per day, but …

“Three cameras will be placed in each of the three suites, plus others in the common areas: terraces with deck chairs and umbrellas, in the corridor where guests will have breakfast, in the whirlpool area, etc.” says Fabio Pegna, owner of the ‘Stupido Hotel’ in Miramare, specifying that only three of the suites will be booked at the sale price while the remaining eleven will remain bookable at full price.

An entrepreneur from southern Italy, Mr. Pegna opened the hotel in 2016 and quickly transformed it into a trendy hotel. However, with age restrictions: from 18 to 50. Even the name is extravagant in its own way: Stupido Hotel, which literally means “stupid hotel”, it is probably inspired by the popular song of the same name by the singer-songwriter Vasco Rossi.

A new kind of entertainment?

Mr. Pegna revealed that requests to participate at his ‘big brother‘ like initiative have already reached dozens: since he launched the offer on social networks he has been studded with phone calls from aspiring participants, including influencers: there is a male physiotherapist, a female doctor, a female masseuse, a very overweight boy and so on.
He was contacted from thirty people who have sent requests to participate so far.

It is actually a real reality show. Anyone can ask to partecipate and there will be a casting. “I would like a heterogeneous cast” says the owner, “for example a guest with his dog and one who can’t stand animals. To select the participants I will make surprise video calls, without warning, to see how they behave on camera”.

The live streaming will be on different platforms including 24/7 on Twitch, 12 hours a day on Youtube and two hours a day on Facebook. Viewing of the streaming will be limited to adults, and from what we learn, participants will only be allowed to go out for only a few hours a day. The live broadcasts will start from the reopening of the hotel for the summer season, on April 15, until the end of the season, on September 1.

Source of the news: Ansa

How to bulk publish or bulk delete pending posts in WordPress

Do you have many posts to edit on your WordPress website and you do not know how to do it? Actually, the WordPress editor doesn’t offer much in bulk editing: it only allows you to edit 10 posts at a time. Therefore, when there are a lot of pending posts to publish or delete this can be a problem. There is, anyway, a quick way to bulk edit posts.

Bulk edit from PhpMyAdmin

As you all know WordPress is a CMS that is installed on your server and which put the data in a database. Therefore you just have to go to the control panel (usually Cpanel) of your hosting provider and search PhpMyAdmin in the search bar (PhpMyAdmin is the app controlling databases of your sites, so we are going to bulk delete posts directly from there). So enter in PhpMyAdmin and search the database of your WordPress site (usually there is one database for each one of your WordPress websites). Once found the database containing your website posts you will find there are many tables in it. You should click in the one named “wp_posts” or “wpkn_posts”. In that table you will find the list of your wordpress posts and their current status, if published, pending or draft.

click to enlarge

So let’s do some edit. Click on the button SQL from the menu at the top of the page (see previous image to find it).

So once clicked, run this code in the white table:

UPDATE wpkn_posts (or wp_posts) SET post_status = ‘publish’ WHERE post_status = ‘pending’

in the case you want to bulk publish many posts.

When you want to bulk delete many posts run this other code:

DELETE FROM wpkn_posts (or wp_posts) WHERE post_status = ‘pending’  (or ‘publish’, or ‘draft’)

Calcolare la distanza euclidea tra due sequenze numeriche in php

In questo articolo calcoliamo la distanza euclidea di due serie numeriche molto semplici:

A (0,1,0)

B (0,5,10)

La distanza euclidea ci dice quanto le due serie sono simili tra di loro. Nel caso in cui il risultato è zero,le due serie sono uguali. Più la distanza euclidea è maggiore, più le due serie differiscono.

In php definiamo le serie come array:

$seqA=array(10,1,0);
$seqB=array(0,5,10);

Possiamo stampare uno qualsiasi dei valori degli array indicando il numero tra parentesi quadre accanto alla sequenza: Se per esempio vogliamo mostrare il primo valore della sequenza A, dobbiamo chiamare il valore 0 (cioè il primo valore) dell’array seqA.

echo $seqA[0] darà come risultato 10.

Ora stabiliamo delle coppie di array per ogni valore numerico (3) degli array di partenza:

$arraycoppia1= array($seqA[0],$seqB[0]);
$arraycoppia2= array($seqA[1],$seqB[1]);
$arraycoppia3= array($seqA[2],$seqB[2]);

Modifichiamo l’ordine dei valori degli array in base alla grandezza:

sort($arraycoppia1);
sort($arraycoppia2);
sort($arraycoppia3);

Ora calcoliamo le singoli distanze euclidee per ogni valore degli array coppia:

$de1=$arraycoppia1[1]-$arraycoppia1[0];
$de2=$arraycoppia2[1]-$arraycoppia2[0];
$de3=$arraycoppia3[1]-$arraycoppia3[0];

Per trovare la distanza euclidea tra i due array di partenza basta sommare le distanze euclidee singole:

$de= $de1+$de2+$de3;

Per trovare la distanza euclidea tra sequenze lunghe:

$seqA=array(0,1,0,5,4,…,n);
$seqB=array(0,5,10,4,5,..,n);

for($x = 0; $x <= 5; $x++) {

if(isset($de0)){

}else{ $de0 = 0;
}

$arraycoppia= array($seqA[$x],$seqB[$x]);
sort($arraycoppia);
$de= $arraycoppia[1]-$arraycoppia[0];
$de1=$de+$de0;
$de0=$de1;

}

echo $de1;