Microsoft is bringing the Bash shell to Windows 10

BashComingInWindows

Here is an announcement from Microsoft Build you probably didn’t see coming: Microsoft today announced that it is bringing the GNU project’s Bash shell to Windows. Bash (Bourne Again SHell) has long been a standard on OS X and many Linux distribution systems, while the default terminal for developers on Windows is Microsoft’s own PowerShell.

More importantly than bringing the shell over to Windows, developers will now be able to write their .sh Bash scripts on Windows, as well (or use Emacs to edit their code). Microsoft noted that this will work through a new Linux subsystem in Windows 10 that Microsoft worked on with Canonical.

“The native availability of a full Ubuntu environment on Windows, without virtualization or emulation, is a milestone that defies convention and a gateway to fascinatingly unfamiliar territory,” Canonical founder Mark Shuttleworth said in a statement today. “In our journey to bring free software to the widest possible audience, this is not a moment we could have predicted. Nevertheless we are delighted to stand behind Ubuntu for Windows, committed to addressing the needs of Windows developers exploring Linux in this amazing new way, and excited at the possibilities heralded by this unexpected turn of events.”

BashScreenshot

The idea here is clearly to position Windows as a better operating system for developers who want to target other platforms besides Microsoft’s own. Under its new CEO Satya Nadella, the company has quickly embraced the idea that it wants to target all developers and platforms — not just its own. While seeing Microsoft doing anything even remotely associated with a rival operating system like Linux was unthinkable only a few years ago, the company now offers support for Linux on Azure, has open sourced numerous of its technologies and even plans to bring its flagship database product SQL Server to Linux in the near future.

Bash will arrive as part of the Windows 10 Anniversary Update this summer, but it’ll be available to Windows Insiders before that. And looking ahead, Microsoft says it may bring other shells to Windows over time, too.

BashScreenshot2

C# and HTML5: drag and Drop elements

HTML5 API includes Drag and Drop (DnD) native functionality.

The event listener methods for all the drag and drop events accept Event object which has a readonly attribute called dataTransfer. The event.dataTransfer returns DataTransfer object associated with the event

This is the list of events fired during the different stages:

Event Description
dragstart Fires when the user starts dragging of the object.
dragenter Fired when the mouse is first moved over the target element while a drag is occuring. A listener for this event should indicate whether a drop is allowed over this location. If there are no listeners, or the listeners perform no operations, then a drop is not allowed by default.
dragover This event is fired as the mouse is moved over an element when a drag is occuring. Much of the time, the operation that occurs during a listener will be the same as the dragenter event.
dragleave This event is fired when the mouse leaves an element while a drag is occuring. Listeners should remove any highlighting or insertion markers used for drop feedback.
drag Fires every time the mouse is moved while the object is being dragged.
drop The drop event is fired on the element where the drop was occured at the end of the drag operation. A listener would be responsible for retrieving the data being dragged and inserting it at the drop location.
dragend Fires when the user releases the mouse button while dragging an object.

 

In this post we develop an application to handle the drag and drop events between two elements, and launch a HttpPost method in the server which will ends inserting the dragged value in database.

First of all we create an MVC project in C#. Under Controller folder in the HomeController we add this code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HTML5DragAndDrop.Controllers {
   public class HomeController : Controller {
      ITestDatabase _testDatabase = new TestDatabase();

      public ActionResult Index() {
         return View();
      }

      public ActionResult About() {
         ViewBag.Message = "Your application description page.";

         return View();
      }

      public ActionResult Contact() {
         ViewBag.Message = "Your contact page.";

         return View();
      }

      [HttpPost]
      public JsonResult InsertTestElements(string testElement) {
         int? insertResult = null;

         if (!string.IsNullOrEmpty(testElement)) {
            string[] elementData = testElement.Split(':');

            string symbol = elementData[0].Trim();
            string name = elementData[1].Trim();

            insertResult = _testDatabase.InsertElement(symbol, name);
         }

         return Json(insertResult);
      }
   }
}

Now we create a folder in the root of the project called Code. Under this folder we create two new files:

ITestDatabase.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

public interface ITestDatabase {
   int InsertElement(string symbol, string name);
}   
 

TestDatabase.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

public class TestDatabase : ITestDatabase {
   /// <summary>
   /// Save an element in the database and return the new ID
   /// </summary>
   /// <param name="symbol"></param>
   /// <param name="name"></param>
   /// <returns></returns>
   public int InsertElement(string symbol, string name) {
      // save the element in database
      // now it returns just a number: it will be the Id of the record
      return 1;
   }
}

The first step is the definition of the UXinterface, in sequence the display is this

DragAndDrop_App

We are adding h5utils.js file, with an implementation of AddEvent function to simplify our code:

h5utils.js

var AddEvent = (function () {
   if (document.addEventListener) {
      return function (el, type, fn) {
         if (el && el.nodeName || el === window) {
            el.addEventListener(type, fn, false);
         } else if (el && el.length) {
            for (var i = 0; i < el.length; i++) {
               AddEvent(el[i], type, fn);
            }
         }
      };
   } else {
      return function (el, type, fn) {
         if (el && el.nodeName || el === window) {
            el.attachEvent('on' + type, function () 
                  { 
                    return fn.call(el, window.event); 
                  });
         } else if (el && el.length) {
            for (var i = 0; i < el.length; i++) {
               AddEvent(el[i], type, fn);
            }
         }
      };
   }
})();

var pDragElement = document.createElement('p');
var chemicalElements = document.querySelectorAll('div > p'), el = null;
for (var i = 0; i < chemicalElements.length; i++) {
   el = chemicalElements[i];
   el.setAttribute('draggable', 'true');
   AddEvent(el, 'dragstart', dragStartElement);
   AddEvent(el, 'dragend', dragEndElement);
}

function dragStartElement(e) {
   e.dataTransfer.effectAllowed = 'copy';
   e.dataTransfer.setData('Text', this.id);
   e.dataTransfer.setData('Type', this.innerHTML);

   this.style.backgroundColor = "#ffa31a";
}

function dragEndElement(e) {
   this.style.backgroundColor = "#fff9f0";
}

var divBoxElements = document.querySelector('#divBoxElements');

AddEvent(divBoxElements, 'dragover', function (e) {
   if (e.preventDefault) e.preventDefault();
   e.dataTransfer.dropEffect = 'copy';
   return false;
});

AddEvent(divBoxElements, 'drop', function (e) {
   if (e.stopPropagation) e.stopPropagation();

   var element = e.dataTransfer.getData('Type');
   pDragElement.innerHTML = "Adding " + element + " element";

   var pClone = pDragElement.cloneNode(true);
   var newDiv = document.createElement("div");
   newDiv.appendChild(pClone);
   divBoxElements.appendChild(newDiv);
   InsertTestElement(element);

   return false;
});

In the Index.cshtml we change as following code:

Index.cshtml

@{
   ViewBag.Title = "Home Page";
}

<div class="jumbotron">
    <h1>Drag and drop example</h1>
    <p class="lead">HTML5 API includes Drag and Drop (DnD) 
    native functionality. The event listener methods for all the drag and 
    drop events accept Event object which has a readonly attribute called 
    dataTransfer. The event.dataTransfer returns DataTransfer object 
    associated with the event.</p>
    <p><a href="http://puresourcecode.com" 
    class="btn btn-primary btn-lg">Learn more »</a></p>
</div>

<div class="row">
    <p id="1A">1: A</p>
    <p id="2B">2: B</p>
    <p id="3C">3: C</p>
    <p id="4D">4: D</p>
    <p id="5E">5: E</p>
    <div id="divBoxElements 
       style="border: 1px solid #dcdcdc; width: 300px; height: 300px;"
    ></div>
</div>

@section scripts {
    <script src="~/Scripts/html5utils.js"></script>
    <script>
        <!--
        function InsertTestElement(element) {
            var url = '@Url.Action("InsertTestElements", "Home")';

            $.post(url, { testElement: element }, function (data) {
                switch (data) {
                    case 1:
                        divBoxElements.innerHTML = 
                             element + " inserted OK";
                        setTimeout(function () { 
                             divBoxElements.innerHTML = ""; }, 2000);
                        break;

                    default:
                        alert("Error inserting the element");
                }
            });
        }
        //-->
    </script>
}

Download or fork tthis code on Github.

Happy coding!

Microsoft's multipronged strategy for bringing speech to IoT devices

speechiot1

speechiot2

Microsoft has been stepping up its game around connecting its Azure cloud services to Internet of Things (IoT) devices. But few may realize the company also is simultaneously working to bring its various speech capabilities to IoT devices, too.

Microsoft provides IoT developers with various tools for integrating speech with their devices. There are built-in Windows 10 speech application programming interfaces (APIs) for tasks like dictating a simple message and Web search. There are natural-language services -- known as Language Understanding Intelligent Service (LUIS) -- that are part of Microsoft Research's Oxford API set, and are available for non-Windows platforms, too. There's Bing Translate. And there's Cortana, Microsoft's personal digital assistant.

Figuring out which of these tools is best for which kinds of tasks seemingly can be a bit tricky. Company officials provided a framework for guidance during WinHEC, listing some potential scenarios, like controlling a sous-vide machine by voice (using a combination of LUIS with Windows 10 or Oxford Speech APIs), and controlling a robot using voice (using Windows 10 local speech APIs).

In the home automation/device control example, Microsoft showed how a user could check whether her/his garage door is closed with voice queries without having to use a phone or tablet.

Insert spaces between words on a camel-cased token

Here's an extension method that I have used extensively for this kind of thing

public static string SplitCamelCase( this string str )
{
    return Regex.Replace( 
        Regex.Replace( 
            str, 
            @"(\P{Ll})(\P{Ll}\p{Ll})", 
            "$1 $2" 
        ), 
        @"(\p{Ll})(\P{Ll})", 
        "$1 $2" 
    );
}

It also handles strings like "FistName", converting it to "First Name".

Happy coding!

World's First Autonomous Drone, The DJI Phantom 4, Revealed

Recently, the Irish Internet of Things chip maker Movidius, has won a multi-million dollar deal with Google, and it has been revealed as the brain behind the breakthrough autonomous drone, the DJI Phantom 4.

This autonomous drone, which went on sale in Apple Stores across the US last week, features a new visual guidance facet, which sticks to and follows a subject, and can stay in a fixed position without the need of a GPS signal.

Described as the first in the industry, the addition of Movidius chips technology and algorithms allows spatial computing and 3D depth sensing.

This gives the DJI Phantom 4 drone the capability to sense and avoid obstacles in real time, which means that it has more autonomous flight functions – along with improved awareness of flight space in air. Additional intelligence features include improved vision based on tracking modes and advanced mapping capabilities.

The Phantom 4 drone is understood to be the only visually intelligent drone available in the market which has the ability to see the world through six different sensors, and it can also sense obstacles.

This comes with included features such as Tap Fly -- which would enable pilots to tap a spot on their display, which causes the drone to fly to that particular spot on its own. Active Track is also present, which would allow the pilot to track objects by using advanced image recognition algorithms.

In recent weeks, it materialized that Movidius’s internet of things chips will be the intelligence within an extremely powerful new VR headset which is being created by Google, and it will not need to be tethered to a PCs or the smartphone.

WebRole and WorkerRole Templates in VS 2015

Download the Azure SDK for Visual Studio 2015 from here: https://azure.microsoft.com/en-us/downloads/

It should force you to close Visual Studio, but if it doesn't, do so anyways. Once it's installed, you can reboot it.

When you go to add a new project, you can look under Cloud and then choose Azure Cloud Service.

Visual-Studio-2015-New-Project-Azure-Cloud-Service

This will give you the same old familiar screen, where you can choose a Web Role or Worker Role:

Visual-Studio-2015-New-Project-Azure-Cloud-Service

Microsoft Azure Storage Explorer for OS X, Linux, and Windows (and it's free)

microsoft-azure-storage-explorer-screenshot

Microsoft Azure Storage Explorer (Preview) is a standalone app from Microsoft that allows you to easily work with Azure Storage data. The Preview release currently supports Azure Blobs only. Tables, queues, and files are coming soon.

Features

  • Mac OS X, Linux, and Windows versions
  • Sign in to view your Storage Accounts – use your Org Account, Microsoft Account, 2FA, etc
  • Add Storage Accounts by account name and key, as well as custom endpoints
  • Add Storage Accounts for Azure China
  • Add blob containers with Shared Access Signatures (SAS) key
  • Local development storage (use storage emulator, Windows-only)
  • ARM and Classic resource support
  • Create and delete blobs, queues, or tables
  • Search for specific blobs, queues, or tables
  • Explore the contents of blob containers
  • View and navigate through directories
  • Upload, download, and delete blobs and folders
  • Open and view the contents text and picture blobs
  • View and edit blob properties and metadata
  • Generate SAS keys
  • Manage and create Stored Access Policies (SAP)
  • Search for blobs by prefix
  • Drag ‘n drop files to upload or download

Known Issues

  • Cannot view/take actions on Queues or Tables (coming soon!)
  • Linux install needs gcc version updated or upgraded – steps to upgrade are below:
    • sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    • sudo apt-get update
    • sudo apt-get upgrade
    • sudo apt-get dist-upgrade
  • After reentering credentials, you may need to manually refresh Storage Explorer to show your Storage Accounts

Project Deco

Looking for the old open-source version? It's still available on GitHub!

Microsoft, others join forces to work on encrypted email protocols

cortana-email-lead-780x445

In the world of the Internet, technology is constantly changing. The SMTP technology behind email, however, has not changed much since it was first released a very long time ago. Despite the invention of SMTP SMARTTM to solve this problem, most emails are still unencrypted, and thus open to a man in the middle hack. Luckily though, a team of engineers from Microsoft, Google, Yahoo, Comcast, and other leading companies have been working on a proposal which would cut out the middle man hacker

The proposal which has been submitted to the Internet Engineering Task Force attempts to protect against hackers who want to intercept or modify emails. Under the proposal, when sending emails to a domain that supports SMTP STS,  a technology will automatically check if the email’s destination supports encryption and if the email’s certificate is valid. Essentially, this will ensure that your email is talking to the right server. In the event that anything is seen as invalid, the email should fail to deliver and then tell the user why.

275 million Android phones imperiled by new code-execution exploit

metaphor-expoit-demo-640x360

Almost 300 million phones running Google's Android operating system are vulnerable to a newly developed drive-by attack that can install malware and take control of key operations, a security firm has warned.

A proof-of-concept exploit dubbed Metaphor works against Android versions 2.2 through 4.0 and 5.0 and 5.1, which together are estimated to run 275 million phones, researchers from Israeli security firm NorthBit said. It attacks the same Stagefright media library that made an estimated 950 million Android phones susceptible to similar code-execution attacks last year. The following video demonstrates how a malicious attacker might use a Metaphor-style attack to take control of a phone after luring an unsuspecting end user to a booby-trapped website.

The NorthBit-developed attack exploits a Stagefright vulnerability discovered and disclosed last year by Zimperium, the security firm that first demonstrated the severe weaknesses in the code library. For reasons that aren't yet clear, Google didn't fix the vulnerability in some versions, even though the company eventually issued a patch for a different bug that had made the Zimperium exploits possible. While the newer attack is in many ways a rehash of the Zimperium work, it's able to exploit an information leak vulnerability in a novel way that makes code execution much more reliable in newer Android releases. Starting with version 4.1, Android was fortified with an anti-exploitation defense known as address space layout randomization, which loads downloaded code into unpredictable memory regions to make it harder for attackers to execute malicious payloads. The breakthrough of Metaphor is its improved ability to bypass it.

"They've proven that it's possible to use an information leak to bypass ASLR," Joshua Drake, Zimperium's vice president for platform research and exploitation, told Ars. "Whereas all my exploits were exploiting it with a brute force, theirs isn't making a blind guess. Theirs actually leaks address info from the media server that will allow them to craft an exploit for whoever is using the device."

The other big advance offered by Metaphor is that it works on a wider base of phones. Previous patches published by Google make anyone with version 5.1 or higher immune, and in some cases those may also protect users of 4.4 or higher, Drake said. Metaphor, by contrast, exposes users of 5.1, which is estimated to run on 19 percent of Android phones. Currently, Metaphor works best on Nexus 5 models with a stock ROM, but it also works on the HTC One, LG G3, and Samsung S5, the company said. Depending on the vendor, a drive-by attack requires anywhere from 20 seconds to two minutes to work.

Microsoft Edge finally supports Extensions, available to Insiders now

Microsoft-Edge-chrome-extensions

Last night, Microsoft introduced Extensions support for Edge in Windows 10 Build 14291. The company released three official Extensions for Microsoft Edge yesterday, and more are expected to come later this year. Now, Microsoft’s Jacob Rossi today announced on Twitter that the company will be releasing a porting tool which will allow developers to port their Chrome extensions to Microsoft Edge. The company is apparently working on it now, and it isn’t finished as not all the APIs are supported just yet.

Microsoft-Edge-Screenshot-26-1

It is worth noting that porting Chrome extensions to Microsoft Edge is actually quite easy. If you are a developer, you will be able to port your Chrome extension to Edge pretty easily after changing several lines of code. Nonetheless, this upcoming tool should make porting Chrome extensions to Edge even easier, and we hope to hear more about it from Microsoft at Build 2016 later this month.

Advertsing

125X125_06

Planet Xamarin

Planet Xamarin

Calendar

<<  September 2017  >>
MonTueWedThuFriSatSun
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

View posts in large calendar

Month List