Tuesday, January 29, 2019

Check GDPR Compliancy in SQL Server with Dynamic Masking and Encryption

SELECT S.name AS schema_name,
       T.name AS table_name,
       C.name AS column_name,
       TY.name AS type_name,
       COALESCE(IT.value, N'') AS information_type,
       COALESCE(SL.value, N'') AS sensitivity_label,
          COALESCE(mc.is_masked, '0') as IsMasked,
          ISNULL(c.encryption_type, 0) as IsEncrypted
FROM sys.schemas AS S
    JOIN sys.tables AS T
        ON T.schema_id = S.schema_id
    JOIN sys.columns AS C
        ON C.object_id = T.object_id
    JOIN sys.types AS TY
        ON TY.user_type_id = C.user_type_id
    LEFT OUTER JOIN sys.extended_properties AS IT
        ON IT.major_id = C.object_id
           AND IT.minor_id = C.column_id
           AND IT.name = 'sys_information_type_name'
    LEFT OUTER JOIN sys.extended_properties AS SL
        ON SL.major_id = C.object_id
           AND SL.minor_id = C.column_id
           AND SL.name = 'sys_sensitivity_label_name'
       LEFT OUTER JOIN sys.masked_columns as mc
             ON mc.object_id = t.object_id
             AND mc.column_id = c.column_id
where it.value is not null
ORDER BY S.name,

Wednesday, May 10, 2017

Why using { } even for single line if else statemens in C#

If programmers at Apple had simply followed a couple of the rules in the Embedded C Coding Standard, they could have prevented the very serious `Gotofail` SSL bug from entering the iOS and OS X operating systems. Here’s a look at the programming mistakes involved and the easy-to-follow coding standard rules that could have easily prevent the bug.
Source: http://embeddedgurus.com/barr-code/2014/03/apples-gotofail-ssl-security-bug-was-easily-preventable/

Wednesday, June 01, 2016

Converting unix epoch to datetime in streaming analytics

sample input:
        "Key": "Dryer_Sensor",
        "State": "0.8",
        "Timestamp": "1464782405968",
        "Site": "Bir57",
        "EventProcessedUtcTime": "2016-06-01T13:24:49.4517020Z",
        "PartitionId": 0,
        "EventEnqueuedUtcTime": "2016-06-01T12:00:06.4520000Z",
        "IoTHub": {
            "MessageId": "7e6d0379d85046f295c0cdaeaabe25d8",
            "CorrelationId": null,
            "ConnectionDeviceId": "openhab",
            "ConnectionDeviceGenerationId": "635957210185596241",
            "EnqueuedTime": "0001-01-01T00:00:00.0000000",
            "StreamId": null

 query: DATEADD(millisecond, CAST([Timestamp] as bigint), '1970-01-01T00:00:00Z') as timeFromString

this will result in  '1970-01-03T07:09:18.032Z' which is wrong!

you can correct this by modifying the input so its strips the quotes from the epoch

        "Key": "Dryer_Sensor",
        "State": "0.8",
        "Timestamp": "1464782405968",
        "epochtime": 1464782405968,
        "Site": "Bir57",
        "EventProcessedUtcTime": "2016-06-01T13:24:49.4517020Z",
        "PartitionId": 0,
        "EventEnqueuedUtcTime": "2016-06-01T12:00:06.4520000Z",
        "IoTHub": {
            "MessageId": "7e6d0379d85046f295c0cdaeaabe25d8",
            "CorrelationId": null,
            "ConnectionDeviceId": "openhab",
            "ConnectionDeviceGenerationId": "635957210185596241",
            "EnqueuedTime": "0001-01-01T00:00:00.0000000",
            "StreamId": null

and modifying the query so it omits the cast (where the bug resides):  DATEADD(millisecond, epochtime, '1970-01-01T00:00:00Z') as time

this will result in the expected result: 2016-06-01T12:00:05.968Z

Friday, April 08, 2016

Registering a device in Azure IoT Hub

Using Node.js

npm install -g iothub-explorer@latest
iothub-explorer <connection string> create MyDevice


Using Device Explorer

See: azure iot sdk on github

Friday, February 26, 2016

Installing Z-Wave Stick Gen 5 on Windows IoT Core

I am currently fiddling around with Windows 10 IoT Core on a raspberry Pi. I wanted to use Z-Wave to be able to control a Fibaro Wall Plug (http://www.fibaro.com/uk/the-fibaro-system/wall-plug)

But I could not find the Z-Stick that was on the supported hardware list of windows iot core

so I bought a Z-Wave Aeon Labs Z-Stick USB Controller - Gen5.

the following steps will explain how to get it working for windows iot core

Step 1
Download the drivers here: http://aeotec.com/z-wave-usb-stick/1358-z-wave-drivers.html

step 2
Connect to tou you raspberry e.g. \\freyr\c$\Data\Users\Administrator\Documents
and unzip and copy the drivers

step 3
connect using powershell

[freyr]: PS C:\Data\Users\Administrator\Documents>

freyr]: PS C:\Data\Users\Administrator\Documents> dir

    Directory: C:\Data\Users\Administrator\Documents

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        8/24/2015   8:34 PM           8424 uzb.cat
-a----        8/24/2015   8:34 PM            710 uzb.inf

[freyr]: PS C:\Data\Users\Administrator\Documents> devcon dp_add .\uzb.inf


Driver package 'oem0.inf' added.
[freyr]: PS C:\Data\Users\Administrator\Documents>

[freyr]: PS C:\Data\Users\Administrator\Documents> devcon status usb*


    Name: USB Serial Device
    Driver is running.


Thursday, March 05, 2015

About CQS, CQRS and Event Sourcing

Seems to be a lot of confusion going on about these terms. The below extract form Greg Young explains it all:
Many people have been getting confused over what CQRS is. They look at CQRS as being an architecture; it is not. CQRS is a very simple pattern that enables many opportunities for architecture that may otherwise not exist. CQRS is not eventual consistency, it is not eventing, it is not messaging, it is not having separated models for reading and writing, nor is it using event sourcing. I want to take a few paragraphs to describe first exactly what CQRS is and then how it relates to other patterns.

Reference: http://codebetter.com/gregyoung/2010/02/16/cqrs-task-based-uis-event-sourcing-agh/

Thursday, May 15, 2014

What is the difference between IaaS, Paas and SaaS?

Software as a Service (SaaS)

This has been around as long as the internet exists. These are pieces of software that you can subscribe to, like for instance Gmail, outlook.com, office 365 but as well as Adobe's creative cloud for instance. The main characteristics of this model is that you always are up to date with the latest version. If you take the example of outlook.com (Hotmail), Microsoft will not ask you to update it, you cannot rollback to a previous version. This off course will require from the provider that they always have to ensure continuity of their service. Since I as a customer would not appreciate it that I would not be able to read the emails in my inbox I received or sent 5 years ago.

Platform as a Service (PaaS)

In Microsoft azure these are all the features Microsoft makes available to you the only thing you need to worry about is get your code on there and Microsoft will keep all these features up to date to the latest versions. You have little or no Control over the Operation System or the underlying Infrastructure. In return off course you get certain things in return. For instance in Azure Websites You can have zero downtime scaling, high availability, and failover. Cloud Services provide you with more control in configuring the underlying infrastructure but that's it, you cannot install additional components on these features like a SQL server, you get an OS, an IIS and that's it, there is however some control in the version of the underlying OS and network (expose additional endpoints, deploy on a virtual network, etc). 

Infrastructure as a Service (IaaS)

These are basically virtual machine, the customer is responsible to monitor and maintain the OS and install and maintain the necessary features on these Virtual Machines like e.g. IIS, MSMQ, …
It's all matter of what you want to do yourself, are willing to do yourself

Scott Hanselman provides a very good analogy with regards to this: http://www.hanselman.com/blog/IntroducingWindowsAzureWebJobs.aspx

Tuesday, April 29, 2014

Microsoft Azure VPN: Error 0x8007274c whilst trying to connect

When trying to connect you are getting the below error message:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
 (Error 0x8007274c)

try to upload the root certificate again.