English (UK)

Javascript is the language of the moment. An interesting new project is born every week.

But, what is WebAssenbly? From the official website we read:

WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable target for compilation of high-level languages like C/C++/Rust, enabling deployment on the web for client and server applications.

WebAssembly is a technology that creates a virtual machine in the browser where it is possible to execute code not designed for the web
Even more interesting for .NET programmers, the Mono Project has developed a virtual machine in WebAssembly for the Mono runtime, with which it's possible to run C# programs natively by the browser.
There is another technology that allows you to run C# code in the browser. It's Blazor and belongs to Microsoft.
Blazor is a frontend framework and allows you to develop a full C# application that runs natively by the browser.
Mono-WASM allows you to create even a single piece of the application and to request it from Javascript code.

Let's try using Mono-WASM
In this basic tutorial we create a simple C# library and run it in the browser, making it interact with the HTML page using Javascript. Let's get the necessary tools first.

Download and install Mono SDK.

Get the latest build of Mono-WASM from this site

Download sdks/wasm/mono-wasm-###########.zip and extract it, for example in C:\mono-wasm

After installation, add a path to the bin directory of mono (C:\Program Files\Mono\bin) and Mono-WASM (C:\mono-wasm) directory in environment paths variable.
Make sure you can access mono and Mono-WASM directly from your terminal.

Now create a folder to use for the project, for example


Create a Sample.cs file with a simple C# class that includes a static method

using System;

public class Sample
public static string Hello(string Name)
return "Hello " + Name;

We also create an index.html file

<!doctype html>
<html lang="en">

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Hello WASM</title>

<textarea id="output" rows="10"></textarea>
<button type="button" id="button" onclick="App.onClick">Run WASM</button>

<script type='text/javascript'>
let that = this;
var App = {
onClick: function () {
that.output.value = "Please wait";
that.output.value = that.execute("Noos");

init: function () {
that.execute = Module.mono_bind_static_method("[Sample] Sample:Hello");
that.output = document.getElementById("output");
that.button = document.getElementById("button");
that.button.disabled = false;

document.body.addEventListener("load", App.init);
<script type="text/javascript" src="/mono-config.js"></script>
<script type="text/javascript" src="/runtime.js"></script>
<script async type="text/javascript" src="/dotnet.js"></script>


Bound a static method of .NET to a JS variable:

var execute = Module.mono_bind_static_method("[Sample] Sample:Hello");

Module is an object that is injected by mono.js files into the page. This object has many methods but one of the most useful ones is the mono_bind_static_method. With this method, you can bind any static methods from .NET to the JS world and execute it like a simple JS function.

Using command prompt, compile the code in NET assemblies with Mono

mcs /target:library -out:Sample.dll /noconfig /nostdlib 
/r:C:\mono-wasm\framework\WebAssembly.Net.Http.dll Sample.cs

As you can see with -out we defined the output name of our assembly. At the end of the command, you should add the CSharp files you want to compile. Other assemblies are inside the Mono-WASM directory that is referenced for compilation.
If you compiled the code successfully, Sample.dll assembly should be created.

So we can publish the library for web assembly using Mono-WASM

mono C:\mono-wasm\packager.exe --copy=always --out=.\publish --asset=.\index.html Sample.dll

This command run packager.exe which is a tool from Mono that publishes your assembly with all of the requirements. The packager will create a folder called publish, and it will copy things in it.

mono.js, mono-config.js, and runtime.js are mono bindings for JavaScript.
mono.wasm is the Mono .NET runtime for web assembly.
In managed folder you will see lots of DLL assembly files including your Sample.dll.
You can copy content of publish folder on your static web server
Run it and navigate to the URL.

This post is made to teach you how to create and set up a simple fully functional Telegram bot written in pure PHP.
There are many good ready to use SDKs written in PHP.
This is only a simple tutorial that explains how to interact with the Telegram APIs without use of any SDK.

Bots are third-party applications that run inside Telegram. Users can interact with bots by sending them messages, commands and inline requests.
At the core, Telegram Bots are special accounts that do not require an additional phone number to set up.
Messages, commands and requests sent by users are passed to the software running on your servers.
Telegram intermediary server handles all encryption and communication with the Telegram API for you.
You communicate with this server via a simple HTTPS-interface that offers a simplified version of the Telegram API.
Telegram Bot API is an HTTP-based interface created for developers keen on building bots for Telegram.

How do I create a bot? There's a... bot for that.
BotFather is the one bot to rule them all. It will help you create new bots and change settings for existing ones.
Message @BotFather with the /newbot command to create a new bot. The BotFather will ask you for a name and username, then generate an authorization token for your new bot.
If you don't know how to message by username, click the search field on your Telegram app and type @BotFather, where you should be able to initiate a conversation. Be careful not to send it to the wrong contact, because some users have similar usernames to BotFather.

The name of your bot is displayed in contact details and elsewhere.

The Username is a short name, to be used in mentions and telegram.me links. Usernames are 5-32 characters long and are case insensitive, but may only include Latin characters, numbers, and underscores. Your bot's username must end in ‘bot’, e.g. ‘tetris_bot’ or ‘TetrisBot’.

The token is a string along the lines of 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw that is required to authorize the bot and send requests to the Bot API. Keep your token secure and store it safely, it can be used by anyone to control your bot.
If your existing token is compromised or you lost it for some reason, use the /token command to generate a new one.

In order to make your Bot answering to requests from your Telegram users you can register a WebHook to automatically being called once updates are available.
The quickest and easiest way to set a WebHook for your Bot is to issue a GET request to the Bot API.
All you have to do is to call the setWebHook method in the Bot API via the following url write in your browser


my_bot_token is the token you got from BotFather when you created your Bot
url_to_send_updates_to is the url of the piece of code you wrote to implement your Bot behavior (in order to set a Webhook you need a server with HTTPS)
For instance


And you’ve got it.
Now if you go to the following url (you have to replace {my_bot_token} with your Bot Token)


you should see something like this


Now let's explain how to develop the bot PHP file.
In your favorite editor, create a my-telegram-bot.php file with the following content.

$botToken = "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11";
$botAPI = "https://api.telegram.org/bot" . $botToken;
$update = file_get_contents('php://input');
$update = json_decode($update, TRUE);
if (!$update) {
$message = isset($update['message']) ? $update['message'] : "";

$botToken is the bot token, generated by BotFather for your bot and used to register the bot on the Webhook service
$botAPI is the URL used to send commands to the Telegram API
file_get_contents('php://input') handle the call incoming from Telegram server
json_decode($update, TRUE) decode communication message in a JSON structure
if (!$update) { exit; } if it's not a valid JSON command, it exits the script
$message if it's a valid command, it extracts the sent message

The script can already be published; it still does nothing but works already.
Now let's add some lines to extract useful data from the message incoming

$messageId = isset($message['message_id']) ? $message['message_id'] : "";

$messageText = isset($message['text']) ? $message['text'] : "";
$messageText = trim($messageText);
$messageText = strtolower($messageText);
$date = isset($message['date']) ? $message['date'] : "";
$chatId = isset($message['chat']['id']) ? $message['chat']['id'] : "";
$username = isset($message['chat']['username']) ? $message['chat']['username'] : "";
$firstname = isset($message['chat']['first_name']) ? $message['chat']['first_name'] : "";
$lastname = isset($message['chat']['last_name']) ? $message['chat']['last_name'] : "";

$messageId is the unique identification number of the chat message
$messageText if it is a text message, the text contained in the message sent
$date is the date the message was sent
$chatId is the unique id of the user who sent the message
$username is the username of the user who sent the message
$firstname is the firs tname of the user who sent the message
$lastname is the last name of the user who sent the message

Message is not necessarily a text, it is possible to managed the type of incoming message with the following lines

if (isset($message['text'])) {
    $response = "Received a text message: " . $message['text'];
} elseif (isset($message['audio'])) {
    $response = "Received an audio message";
} elseif (isset($message['document'])) {
    $response = "Received a document message";
} elseif (isset($message['photo'])) {
    $response = "Received a photo message";
} elseif (isset($message['sticker'])) {
    $response = "Received a sticker message";
} elseif (isset($message['video'])) {
    $response = "Received a video message";
} elseif (isset($message['voice'])) {
    $response = "Received a voice message";
} elseif (isset($message['contact'])) {
    $response = "Received a contact message";
} elseif (isset($message['location'])) {
    $response = "Received a location message";
} elseif (isset($message['venue'])) {
    $response = "Received a venue message";
} else {
    $response = "I received a message?";

When a photo is sent to the bot, you can retrieve the file and its info from Telegram API.

if (isset($message['photo'])) {
    $fileAPI = "https://api.telegram.org/file/bot" . $botToken;
    $url = $GLOBALS[botAPI] . '/getFile?file_id=' . $message['photo'][0]['file_id'];
    $fileinfo = file_get_contents($url);
    $fileinfo = json_decode($fileinfo, TRUE);                          
    $filePath = $fileinfo['result']['file_path'];
    $url = $GLOBALS[fileAPI] . '/' . $filePath;
    $imgData = "File size: " . $message['photo'][0]['file_size'] . "byte" . chr(10)
        . "Width: " . $message['photo'][0]['width'] . "px" . chr(10)
        . "Height: " . $message['photo'][0]['height'] . "px" . chr(10)
        . "URL: " . $url);

$fileAPI is the URL used to retrieve file info from Telegram API
$fileinfo the script performs an HTTP GET call to get file info in JSON format
$filePath the script get the URL path of file
$message['photo'][0]['file_size'] is the size of the first file in byte
$message['photo'][0]['width'] and $message['photo'][0]['height'] are the dimension of the first file in pixels

Bot can send several type of message to the chat

Text messages

$url = $GLOBALS[botAPI] . '/sendMessage?chat_id=' . $chatId . '&text=' . urlencode($message);

Photo messages

$url = $GLOBALS[botAPI] . '/sendPhoto?chat_id=' . $chatId . '&photo=' . urlencode("https://webnoos.altervista.org/noos.jpeg");

Location messages

$url = $GLOBALS[botAPI] . '/sendLocation?chat_id=' . $chatId . '&latitude=' . urlencode("45.1") . '&longitude=' . urlencode("11.3");

Telegram also features the ability to display keyboards in chat like this

header("Content-Type: application/json");
$parameters = array('chat_id' => $chatId, "text" => $messageText);
$parameters["method"] = "sendMessage";
$parameters["reply_markup"] = '{ "keyboard": [["uno", "due"], ["tre"], ["quattro", "5", "6"]], "one_time_keyboard": false}';
echo json_encode($parameters);

The current keyboard can be removed from the chat in this way

header("Content-Type: application/json");
$parameters = array('chat_id' => $chatId, "text" => $messageText);
$parameters["method"] = "sendMessage";
$parameters["reply_markup"] = '{ "remove_keyboard" : true}';
echo json_encode($parameters);

You can also display an inline keyboard

header("Content-Type: application/json");
$parameters = array('chat_id' => $chatId, "text" => $messageText);
$parameters["method"] = "sendMessage";
$keyboard = ['inline_keyboard' => [[
    ['text' =>  'Vai su Google', 'url' => 'https://www.google.com'],
    ['text' => 'Vai su Microsoft', 'url' => 'https://www.microsoft.com']
$parameters["reply_markup"] = json_encode($keyboard, true);
echo json_encode($parameters);

Finally, you have the ability to manage messages sent to the bot as a series of commands, to do different things, as in this example

switch ($messageText) {
    case "/hi":
        // TODO
        // TODO

This little starting tutorial ends here.

This is a short step-by-step tutorial to distribute a .NET Core application in a docker image.
I’ll cover how you can use Docker to run your application in an isolated, minimal environment with fewer moving parts.

To build and distribute a .NET Core application in Docker, first we need an application to Dockerize and some prerequisites.

In this tutorial, we'll perform the steps from a Terminal, like Windows command prompt.

First, create a working folder for our exercise

mkdir NetCoreDocker

Check .NET Core version installed on your computer

dotnet --info

Check Docker version installed on your computer

docker version

Place a file named global.json in exercise directory with the following content

    "sdk": { 
        "version": "3.0.100" 

This will force the compiler to use 3.0 version of the SDK

Then create .NET Core console application

dotnet new console -o app -n myapp

The folder structure will be similar to the following example

│   global.json 
    │   myapp.csproj 
    │   Program.cs 

.NET Core creates a console application that is executed, then terminated.
We modify the application that runs continuously instead.

Modify Program.cs as below

using System; 
namespace myapp 
    class Program 
        static void Main(string[] args) 
            var counter = 0; 
            var max = args.Length != 0 ? Convert.ToInt32(args[0]) : -1; 
            while(max == -1 || counter < max) 
                Console.WriteLine($"Counter: {counter}"); 

Move in app sub-folder and test application

dotnet run

Finally, publish the application

dotnet publish -c Release

Application will be published in this folder


Place a file named Dockerfile in the working folder with the following content

FROM mcr.microsoft.com/dotnet/core/runtime:3.0
COPY app\bin\Release\netcoreapp3.0\publish app/ 
ENTRYPOINT ["dotnet", "app/myapp.dll"]

Now we can build Docker image of our application

docker build -t myimage -f Dockerfile .

Finally, verify the right build of the image

docker images

Final notice

If you want to try starting from the source code of your application (contained in the /src folder, not in the /app folder like now) and compile directly on a Docker image, change the Dockerfile contents with this multistage builds

FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
COPY ["myapp.csproj", "./"]
RUN dotnet restore "./myapp.csproj"
COPY . .
RUN dotnet build "myapp.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "myapp.csproj" -c Release -o /app
FROM mcr.microsoft.com/dotnet/core/runtime:3.0 AS base
FROM base AS final
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "myapp.dll"]

Taken from: http://enyojs.com

Enyo 2 has its roots in the framework developed to power the applications on HP’s TouchPad, an innovative device powered by webOS that embraced the web stack as its primary application environment. Over a thousand apps, including the stock applications that shipped with the TouchPad, were built using Enyo 1. Although Enyo was conceived from the start as platform-independent framework, Enyo 1 out of necessity targeted webOS and the TouchPad specifically.

The basics Create an empty gadget.xml file with Notepad and save it. In the Encoding drop-down, select UTF-8. Create an empty MyGadget.html file with Notepad and save it. In the Encoding drop-down, select UTF-8.

Create the manifest gadget.xml file and save it to folder.

<?xml version="1.0" encoding="utf-8" ?>
 <host name="sidebar">
 <base type="HTML" apiVersion="1.0.0" src="/MyGadget.html" />
 <platform minPlatformVersion="1.0" />

From: www.tutorialsforopenoffice.org

A Macro is a sequence of keystrokes that are recorded (saved) and given a name. When the Macro is run (selected) by a few keystrokes, the recorded keystrokes are “automatically” performed.

Tratto da: openoffice.org

Supponete di dover inserire ripetutamente sempre le stesse informazioni. Sebbene sia possibile memorizzare le informazioni negli appunti, se questi nel frattempo vengono utilizzati, il loro contenuto cambia. Una semplice soluzione consiste nel memorizzare i dati in una macro (in alcuni semplici casi, come l'esempio utilizzato in questa sede, una soluzione migliore consiste nell'utilizzo del completamento automatico).