Archives

Archives / 2016
  • Observables in AngularJS 2

    Hello everybody,

    today I want to write a few words about totally new feature in AngularJS 2 which is entitled Observables. Observables to some degree feet to promises, but still have some differences. They are mentioned in following table:

    Promise

    Observable

    Single feature value

    Emits multiple values over time

    Not lazy

    Lazy

    Not cancelable

    Cancelable

    supports map, filter, reduc and similar operators

    more

  • What is service in AngularJS 2

    Hello everybody,

    today I want to write few words about AngularJS 2 services, or if to be more specific what is Service in angular at all? If to speak very very shortly: Service - it's a class with focused purpose independent from any particular component. It can be caching purpose, or logging purpose, or sending http requests purpose. 

    Lets say you need to build a service in AngularJS 2. You'll need to go through the following steps:

    Create class for service

    Define metadata with decorator

    Import what is needed for service

    import { Injectable } from '@angular/core'

    @Injectable() //needed if we have injected dependency or for consistency

    export class StudentsService{

            … more

  • Building a custom pipe in AngularJS 2

    Hello everybody,

    today I want to write few words about custom pipes in ... AngularJS 2. The first time when I've heard about custom pipes happened to be when I've learned powershell scripting. And recently I've discovered that there are some built in custom pipes in AngularJS 2 and we can make our own custom pipes. 

    What is needed for implementing custom pipes? Nothing special. Just import from AngularJS 2 PipeTransform and implement in it method transform. And one more is pipe decorator ( in my example something that starts from @Pipe and ends with first }) ). And what else? Of course import statements.

    It can look like this:

    import {Pipe, PipeTransform} from '@angular/core'

    @Pipe( … more

  • XAML simplification of usage INotifyPropertyChanged

    Hello,

    I want to share some code, wich can simplify usage of INotifyPropertyChanged in XAML.

    Take a loot at following fragments:

    Snippet

    namespace NotifyPropertyChanged

    {

        public class BindableBase : INotifyPropertyChanged 

        {

            public event PropertyChangedEventHandler PropertyChanged;

            public void RaisePropertyChanged(string propertyName)

            {

                if(PropertyChanged != null)

                {

                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));

                }

            }

        }

    }

    Class BindableBase now can become as base class for those objects, which need to notify UI about changes in source code. Consider … more

  • Binding modes in XAML

    Hello everybody,

    today I want to write few words about binding in XAML.

    So there are four ways of binding in XAML.

    One way

    Two way

    One way to source

    One time

    If to speak about them more, then here it goes additional definitions:

    OneWay : source property updates target property

    TwoWay: source or target updates the other

    OneWayToSource: source is updated when target is updated

    OneTime: executed only once for initialization of target property

    What is important to notice for notification of UI, there is a need for implementing INotifyPropertyChanged interface. Without it changes in source properties will not become propogated to target.

    more

  • Basic elements in XAML

    Hello everybody,

    today I want to write few words about basic elements in XAML.

    DependencyObject

    This class is next in inheritance level in XAML after object. DependencyObject gives needed properties for representing something that participates in dependency property system. Mostly needed for data binding. It is basic for UIElement, Geometry, FameworkTemplates, Tile, ResourceDictionary.

    UIElement

    This is base class for all objects that have visual representation. It supports basic manipulation, appereance, layout. Also it has code for responses for user input, routed events, some aspects of animation system.

    FrameworkElement

    This class takes part in layout and obliged to have … more

  • Angular 2 data binding and pipes

    Hello everybody,

    today  I want to make short note about types of Data Binding in AngularJS 2.

    here they are:

    Interpolation. It looks like this in code: {{firstName}}

    Property binding. Sample in code: <img [src]='person.photo'>

    Event binding. Html code pattern: <button (click)='showMessage()'... />

    Two-way binding: <input [(ngModel)]='someProperty' />

    Important think to remember about usage of ngModel is the following:

    in your imports add importing of FormsModule.

    For example like this:

    @NgModule({

           imports: [

              BrowserModule,

              FormsModule]

           declarations: [

              AppComponent,

    .......

           ]

       })

    export class AppModule {

    }

    If … more

  • What is AngularJS 2 component

    Introduction

    Here I want to write of how I grasped what is Angular 2 component building blocks

    Hello everybody,

    I don't know about you, but when I first opened AngularJS 2 component source code, I've become puzzled with question mark of what is AngularJS 2 component?

    Imagine, that you look at this sampe:

    import { Component } from '@angular/core';

    @Component({

    selector: 'my-app',

    template: `<h1>Hello {{name}}</h1>`

    })

    export class AppComponent { name = 'Angular'; }

    and try to figure out what are consisting parts of compoment? After watching on that example and some others example here is conclusion that I've made:

    Do you remember previous fragment of code? … more

  • Setting up an Angular 2 application

    Hello everybody,

    today I want to make note about setting up Angular 2 application initial configuration. So, if you need to set up everything for Angular 2 application manually, then following steps will be needed ( according to www.angular.io ):

    Create application folder

    Create tsconfig.json file

    create package.json file

    create typings.json file

    install libraries and typings

    create host web page ( as usually index.html )

    create maint.s file 

    When I first time read those requirements, I've become intimidated. And as every energy saving person I wanted to know, is it possible to get some tool, that set up Angular 2 app instead of me. And the simplest way will be the following: … more

  • How to send email in C# windows forms application

    Hello everybody,

    sometime people ask me how to send email from C# windows forms application or even ask is it possible at all to accomplish in C#?

    I can reassure you that yes, it's possible. 

    For this purpose you can use following code sample:

    private void btnSendMessage_Click(object sender, EventArgs e)

    {

    var from = new MailAddress(txtFrom.Text, "From Name");

    var toEmail = new MailAddress(txtTo.Text, "To Name");

    string passwordFromEmailOfSender = txtPassword.Text;

    string subject = "Subject";

    string body = txtMessage.Text;

    var smtp = new SmtpClient

    {

    Host = "smtp.gmail.com", … more

  • JWT structure and format

    Hello everybody,

    today I want to describe a bit structure and format of JWT or json web tokens.

    Here you can read official description.

    But in my post I'll describe little bit more general information.

    The two main ingredients of json web token are: header and claims.

    Then if to continue each part can have the following:

    Header

    metadata

    algorithms and keys used

    Claims

    Issuer (iss)

    Audience (aud)

    IssuedAt (iat)

    Expiration (exp)

    Subject ( sub )

    ... application defined claims

    for example it can look like this:

    Header {      "typ" : "JWT",       "alg" : "HS256"}

    Claims {       "iss" : "http://zaletskyy.com",       "exp" : "1451919380",       "aud" : "http:// … more

  • Security Tokens

    Hello everybody,

    today I want to write a few words about security tokens in OAuth2. 

    So, first of all I'd like to point that security tokens wasn't needed for corporate world. When I say corporate world, I mean networks like B2B, or B2E or something, that has strong system administration army.

    But if you need to provide B2C or something like this than you'll need tokens.

    As usually tokens has following features:

    Security tokens are protected data structures

    Also not prescribed in OAuth2 but quite often security tokens implemented as JSON web tokens

    has information about producer and topic ( claims )

    signed ( has some kind of identity proof )

    as usually contain expiry date time … more

  • How to avoid many if during programming for cAlgo

    Hello everybody,

    today I want to write few words about how to avoid nested ifs if you program for cAlgo.

    Recently I've got following request ( code is modified in order to protect privacy of customers idea ):

    buy in following case:

    price is above moving average 20

    price is above moving average 30

    stochastic is above 40

    each of indciators from 1 - 3 can be turned on/off

    As example consider following case:

    if( movingAverage30On && MarketSeries.Low[1] > longMa.Result[1])

    {

    if(movingAverage20On && MarketSeries.Low[1] > shortMa.Result[1])

    {

    if(stochasticOn && _stochastic.PercentD[1] > 40)

    {

    //Buy

    }

    }

    }

    if(movingAverage20 … more

  • Training neural network of deeplearning4j for price prediction

    Hi,

    I need to document my first implementation of learning algorithm for usage of neural networks for training

    package org.deeplearning4j.examples.recurrent;

    import org.deeplearning4j.datasets.iterator.impl.ListDataSetIterator;

    import org.deeplearning4j.nn.api.Layer;

    import org.deeplearning4j.nn.api.OptimizationAlgorithm;

    import org.deeplearning4j.nn.conf.BackpropType;

    import org.deeplearning4j.nn.conf.MultiLayerConfiguration;

    import org.deeplearning4j.nn.conf.NeuralNetConfiguration;

    import org.deeplearning4j.nn.conf.Updater;

    import org.deeplearning4j.nn.conf.layers.DenseLayer;

    import org.deeplearning4j.nn.conf.layers.GravesLSTM;

    import org.deeplearning4j.nn.conf.layers. … more

  • OAuth 2 parts

    Hello everybody,

    today  I want to describe for main components of OAuth 2, which should be implemented by any framework which claims to be programmer friendsly implementation of OAuth 2.

    We will start from left botton box, or from user. So, user as usually is something or more precise somebody who initiate actions on UI. Something can also be selenium web driver implementation or something similar. 

    Next goes client. Or if to add another key word client application. There are plenty of them: angularjs app, iOs app, iPhone app, Android app, Xamarin app, etc.

    Authorization server is intended to be somebody, who generates tokes for each separate user. Token will consist information about … more

  • Defining OAuth2

    Hello everybody,

    today I want to write few words about OAuth2.

    So, one of the defintions of OAuth2 is the following:

    OAuth 2.0 is an open protocol to allow secure authorization in a simple and standard method from web and desktop applications.

    It has two important parts:

    Authorization. It's not just about who is client, but what client is allowed to do.

    Client platform: web, mobile, desktop app

    So, OAuth 2.0 is protocol which defines permission of server, and give those permissions for any kind of platform.

    more

  • question for UrkTransGaz

    Hello everybody,

    this is schema needed for participating in tender for UkrTransGaz more

  • Get values of indicators in jforex

    Hello everybody,

    today I want to write a few words about getting indicators values for testing strategy. 

    Recently I had need to get ema value. But for my surprise following code didn't give me values, which I've seen on the screen:

    double ema = indicators.ema(instrument, period, side, AppliedPrice.CLOSE, emaTimePeriod, 1);

    And in order for getting proper indicator value I've found another fragment of code which gave me proper result:

    double ema89 = indicators.ma(inst, Period.TEN_MINS, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, 89, maType, indFilter, 1, prevBar.getTime(), 0)[0];

    with following variables declared:

    private static final IIndicators.MaType maType = IIndicators. … more

  • Notes about generalization improvement

    Hello everybody,

    today I want to write few words about different regularization techniques. I will compare L1 regularization, L2 regularization and adding noise to the weights during learning process.

    L2 regularization penalizes high weight values.

    L1 regularization penalizes values that do not equal to zero.

    Adding noise to weights during learning ensures that the learned hidden representation take extreme values. 

    more

  • JForex-Utilities sample and JFQuantisan.jar

    Greetings to everybody.

    Recently when I visited blog of Paul Lam, I've noticed JFUtil 2.0 alpha demonstration of usage of his library JForex-Utilities.

    It is nice example, but very unformatted. It looks like this:

    So I've made formatting corrections, and put his sample on my page with formatting:

    package jforex.yz;

    import java.util. * ;

    import com.dukascopy.api. * ;

    import com.quantisan.JFUtil. * ;

    @

    RequiresFullAccess@Library("d:\\Users\\Administrator\\JForex\\files\\JFQuantisan.jar")

    public class JfutilDemo implements IStrategy {

    private int counter = new Random().nextInt(100); // notice the lack of fields to manage JForex objects

    @Override public void … more

  • How to compile JForex-Utilities in Intellij Idea to receive JFQuantisan.jar

    Hello everybody,

    I continue my experimenting with dukascopy platform, and next issue which I faced was the following: "How to compile JForex-Utilities in Intellij Idea to receive JFQuantisan.jar"

    This question may sound trivial to experienced java developers, but such as I'm mainly .Net dev for me it was pretty comlicated ( i.e. googling, meditating ) question. 

    With help of google and power of reason I've found solution, which I want to describe step by step.

    So, let's get started.

    Download source code

    As it often happened, I've downloaded source code from github. By habit of Microsoft .Net developer I thought that I can press compile, and immediately receive .jar file. But my … more

  • Phoneme recognition is speech recognition

    Hello everybody,

    today I'd like to preserve in my blog few words of practical knowledge about speech recognition. One of the questions which raises in speech recognition systems is related to phoneme detection. 

    According to course at coursera following parameters showed practical. In oder for accurate recognition of what phoneme had been said at a particular time, neural network needs to know sound frequency from 100ms before that time to 100ms after that time. In other words if you need NN which will recognize phonemes, then give as input 100 ms or less into NN. more

  • Neural networks for machine learning at coursera

    Hello everybody,

    today I've completed following course at coursera:

    "Neural Networks for Machine Learning".

    I should admit, that this course was great but for me to pass all of it presented a challenge. But also I shoud notice that neural networks for machine learning was really informative course. I should admit that for me it was very interesting to learn more about perceptrons then I new. Remind myself about restricted boltzmann machine. Very discoverable for me was explanation about recurrent neural networks and how to derive math for recurrent neural networks. And much much more. 

    Also some parts were missing for me. For me it was hard to grasp about probabilities and Bayesian … more

  • Chocolatey usage for installing programs

    Hello everybody,

    today I want to document wonderfull tool. Chocolatey. It allows you to install quite big list of programs without need to search, download and setup them. 

    Before chocolatey will be able to execute anything at your pc, following command needs to be executed at your powershell:

    Set-ExecutionPolicy Unrestricted 

    and this one:

    iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

    As soon as chocolatey will be installed at your pc, you can execute following ps1 file:

    choco install pdfcreator -y --allow-empty-checksumschoco install firefox -y --allow-empty-checksumschoco install jre8 -y --allow-empty-checksumschoco install 7zip. … more

  • How to parse google search results

    Hello everybody,

    today I want to describe how to use C# for scrapping results. 

    For me it was surprising to see, that there is a stereotype that for scrapping the best tool or tools only to use are R, Python. And majority of people who needed functionality of parsing wanted that functionality in some of those languages. While I do agree that those are great languages, which really enhance toolbox of developer, I want to show also that in C# you can achieve similar results. 

    Below goes screenshot of C# program which sends request to google and receives result:

    Application workflow is pretty simple.

    You enter search request. At screenshot you can see that search request was i7 … more

  • User groups which are created in Active directory during Dynamics CRM installation

    Hello everybody,

    today I want to write few words about Active directory user groups, whcih are created/used during Dynamics CRM installation.

    UserGroup

    Contains all Microsfot CRM users. It will be refreshed with each creation/removal of users from Dynamics CRM

    ReportingGroup

    Also constains all users in Microsoft CRM. Users have read-only access to the filtered views in Dynamcis CRM

    PrivUserGroup

    Privileged CRM admins for special functions

    SQLAccessGroup

    Members of this group have full access to Dynamics CRM db and this group is used by CRM platform layer

    more

  • ASP .Net LifeCycle

    Hello everybody,

    today I want to write few words about ASP .Net lifecycle. 

    Actually just sequence of events. 

    Begin Request

    Resolve request cache

    Map request handler

    Acquire request state

    Request handler execute

    Update request cache

    Log request

    End request

    Here are the 8 main steps of ASP .Net lifecycle. MVC controllers are processed in step 5, RequestHandlerExecute more

  • How closures are implemented by .Net

    Hello everybody,

    today I want to share piece of wisdom which is interesting, but hard to explain why somebody may need it. That is how closures are implemented. 

    Consider the following code:

    Snippet

    class Program

        {

            static void Main(string[] args)

            {

                int a = 54;

                Task t = new Task(

                    () =>

                    {

                        a++;

                        Console.WriteLine("Inside task");

                    }

                    );

                t.Start();

            }

        }

    Now you may wonder, how a will be passed to closure? How Console.WriteLine will be executed?

    For my surprise .Net for closures generates behind the … more

  • C# Task, ContinueWith

    Hello everybody,

    today I want to write few words about Task Paralel library, and in particular two methods: Task.Start, and Task.ContinueWith.

    Snippet

    System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(

                    () => {

                        //some heavy code like intensive calculations, reading from db, etc.

                        

                    }

                );

                System.Threading.Tasks.Task t2 = t.ContinueWith(

                    (a) => {

                    //Code to update UI

                    },

                    TaskScheduler.FromCurrentSynchronizationContext()

                );

    Following template has the following structure. You need to split your code … more

  • Ways to reduce overfitting in NN

    Hello everybody,

    today I want to write short summary of how to reduce overfitting. Here it goes:

    Weight decay.

    Weight sharing

    Early stopping of training

    Model averaging

    Bayesian fitting of NN

    Dropout

    Generative pre-training

    Some explanations about some points.

    Weight decay stands for keeping weights small

    Insist that weights will be similar to each other

    Early stopping stands for not training NN to full memorizing of test set

    In other words usage of different models 

    Little bit another usage of model averaging according to some rules

    random ommiting of hidden units in order to validate results

    more

  • Types of fields in Dynamics CRM

    Hello everybody,

    today I want to write a short note on types of fields in Dynamics CRM.

    So, below goes list of types:

    Single line of text

    Multiple line of text

    Option set

    Two options

    Whole numbers

    Floating point

    Decimal

    Currency

    Date and Time

    Lookup

    Names of them are pretty self-explanatory, but few words I'd like to add.

    Single line of text is good for storing some small portions of text like first name, last name, title of book, title of product etc. Due to this it has limitation to 4K of data.

    Multiple line is larger, up to 1 Mb of data. 

    Option set is a list of specific items. They can be local or global. Local means that they can be applied to only one entity. … more

  • Dynamics CRM licensing

    Hello everybody,

    another note for today about Dynamics CRM licensing elements.

    So, let's get started. 

    External and Internal users for humans and computers

    First of all it's worth of mentioning, that Dynamisc CRM can be divided in two main groups: external and internal users. External license is applicable to your customers, to which you would like to give permission to communicate with your CRM instance which aren't your employees. Internal license has two divisions as well. Device lincense or person license. Names are self explanatory, but if to summarize, person lincense or personal CAL is applicable to your employer which has plenty of devices and from each of devices he provides … more

  • Perceptron learning algorithm

    Hello everybody,

    today I want to document perceptron learning algorithm for classifications

    Below goes following steps for teaching perceptron.

    Add one more column with value to 1 to each input row.

    Pick training cases according to some rules that gives you guarantee that every training case will be picked

    if output is correct, leave weights unchanged

    if ouput is 0 but 1 is expected then add input vector to weights of perceptron

    if output is 1 but 0 is expected then subtract input vector from weights of perceptron

    This simple algorithm will find you a set of weights for right classification of your vector space if such set of weights exists. It will depend only from … more

  • Create group of users in PowerShell

    Hello everybody,

    today I want to share just simple script, with which you can create group of users according to some rules:

    $pw = "strangePassword" | ConvertTo-SecureString -AsPlainText -Force

    for($i=1

    $i -le 320

         $i++){

           $userName = "repeatingUserName" + $i

       New-ADUser -Name $userName -GivenName $userName -AccountPassword $pw -ChangePasswordAtLogon $false -PasswordNeverExpires $true -Enabled $true

               #Remove-ADUser -Identity $userName -Confirm:$false

    }

    more

  • Purpose of some services in Dynamics CRM

    Hello everybody,

    today I want to describe web services of Dynamics CRM. If you have access to some instance of Dynamics CRM. 

    If you follow the way Settings -> Customizations, and then choose development resources, you'll discover for yourself interesting set of urls, similar to the following:

    In this short note I want to describe few of them.

    So, let's start with discovery service, which has number 4 at our screenshot.

    Discovery service provides following tools:

    Information about deployment. If you have multiple servers with different roles, and you need to automate in some way getting information into your tools, then discovery service is exactly what you need.

    Connect … more

  • PowerShell formatting strings

    Hello everybody,

    today I want to write few words about formatting strings in PowerShell.

    Consider the following example:

    "Today is $(Get-Date). Enjoy your life"

    Output will be the following:

    Today is 08/23/2016 16:04:18. Enjoy your life

    So, if you want to call some PowerShell function, you can just put it into brackets, put $ in front of it and get the result.

    Conisder another example:

    "You own to me $(44 + 44* 0.15) dollars"

    It will give following output:

    You own to me 50.6 dollars

    Very cool stuf in PowerShell is about using formatting with templating and key -f.

    Take a look:

    $apples = 5

    $pomegranade = 22

    cls

    "I have {0} apples and {1} … more

  • Statistics of normal distribution

    Hello everybody,

    today I want to write few words about standards of normal distribution in statistics. 

    Take a look at the picture:

    This picture says the following. If you have normal distribution, than 68% of data fall in range    - σ

    more

  • Federation security

    Hello everybody,

    Today I want to write few words about federation security.

    So, imaging following situation. You work in one company, which partners with one or two others. And Both of them provide some kind of IT services.

    One of the ways of dealing with such situation is make for each IT service login name and password for each of IT services. Of course it's not very convenient. It's not convenient for users, which need to have few accounts, it's not convenient for administrators, which need ot manage user names and passwords. Etc. How to deal with it? One of the solutions is identity federation. 

    How it works. One of the ways of solving it is making IT services to work with accepting … more

  • What is token in Claims-Based Identity

    Hello everybody,

    today I want to write few words about what is token.

    If to put very simple statement, token is a set of bytes that express information about some subject ( as usually it is user ).

    This information consists of one or more claims. Each claim contains information about subject. 

    General structure of token is like this:

    And now few words about purpose. If user want to use some system, he need to get from some authority security token or set of bytes. After getting token user uses it for getting access to system. 

    System by itself looks at claims and at signature, and depending from claims either gives permission for some activity or not. Signature in token indicates … more

  • Unions by example

    Hello everybody,

    today  I want to share a short notice on unions calculations in statistics by example of the following puzzle:

    You are picking flowers from a garden. The garden contains flowers of varying colors, including flowers that are completely blue, flowers that are completely pink, and also flowers that are both colours. The probability of picking a flower that is at least partly blue is 0.4 and the probability of picking a flower that is at least partly pink is 0.2.

    Question, how to calculate probability of picking flower that is blue, pink or both.

    The answer is simple. First of all it's good to remember formula:

    P(AorB)=P(A)+P(B)−P(AandB)

    Now let's mark B as blue fragmnet, … more

  • Azure basic puzzle words

    Hello everybody,

    today I want to put some light on puzzlewords related to Windows Azure.

    Quite often many people are puzzled by statements SaaS, PaaS, IaaS. If you need quickly understand what those words mean, 

    just look at the icture.

    If to decipher them with examples, then 

    SaaS example

    Office 365, Bing, gmail.

    PaaS example

    Something, that you can borrow for your life simplification. For example Access control service, service bus, HD Insight, Windows Azure Active directory, Azure SQL server database.

    IaaS example

    Renting one or more virtual servers and probably their network equipment ( also virtual ) in order to host something like Sql Server, Active directory, Sharepoint … more

  • Azure Datacenter architecture

    Hello everybody,

    today I want to write few words about Azure Infrastructure. 

    Big picture

    You can use Azure services in ~140 countries. And Microsoft does it's best to enalrge geography of their earnings, but if you are citizen of some countries you may be missing of usage of Azure.

    For now we can consider as Azure something with Microsoft products. It can be: XBox, Office 365, Bing, hotmail, etc ( full list of services consists of ~200 services. ). 

    The best idea about usage of Azure is to have something, which is closest to your target auditorium. 

    If your target auditorium is located in your country, you may need to go to Azure Spped Test web site. Below goes screenshot:

    As … more

  • Levels of measurements in statistics

    Hello everybody.

    Today I want to drop a short summary of different levels of measurrements in statistics.

    It's represented in following table:

     

     

    Difference

    Order

    Similar intervals

    Meaningful zero point

    Categorical

    Nominal

    +

    -

    -

    -

    Ordinal

    +

    +

    -

    -

    Quantitative

    Interval

    +

    +

    +

    -

    Ratio

    +

    +

    +

    +

     

    more

  • How to make pause in powershell script execution

    Hello everybody,

    today I want to make short note about how to make pause untill user press a key in PowerShell execution.

    Here it is:

      Write-Host "Press any key to continue ..."

     $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

    Presented code will make a pause. more

  • PowerShell built in variables

    Hello everybody,

    today I want to write few words about PowerShell variables.

    So, let's start from the simplest or with statement what is true and what is false. 

    In PS it's really not philosophical question

    $false

    $true

    The first one stands for false, and the second one for true. It is intended for logical operations in PS.

    Very usefull is Users Home directory:

    $Home

    Current directory:

    $pwd

    Information about users environment:

    $host

    If you ever need to discover which version of power shell, that you execute, you can use 

    $PSVersionTable

    Let's say that you write some kind of loop, and wonder where current item goes in, you have relieve, for this purpose you can use 

    $_ … more

  • PowerShell comparison

    Hello everybody,

    today I want to share another trick from PowerShell activities. 

    So, imagine, that you see following PowerShell code:

    "048" -eq 48

    48 -eq "048"

    What do you expect to see? True, True or True, False ....

    Here is the output:

    PS C:\sources> "048" -eq 48

    48 -eq "048"

    False

    True

    PowerShell has interesting behaviour in this case. It takes value on the right, and converts it to the value on the left. 

    For the first case PS will make following comparison:

    convert 48 to string, which will be "48". Compares "48" with "048" and produce False.

    more

  • Some power shell notes

    Hello everybody,

    today I want to share few words about powershell usage. 

    So, recently I've got some tasks which is related to usage of powershell scripts in order to automate some execution.

    One of discoveries in PowerShell for me was pipelining with usage of Where-Object. Consider following example:

    Get-ChildItem | Where-Object {$_.Name.Length -gt 10 }

    It has two parts: Get-ChildItem and Where-Object.

    Get-ChildItem will get all items in directory, and pipeline them into WhereObject, which in turn will produce as output those, which has Name longer then 10 characters. 

    Another interesting part of pipelines is that you can pipeline objects from one to another. Consider code … more

  • FetchXML in Dynamics CRM

    Hello everybody,

    today I want to write few words about Quering CRM data. I discovered as started FetchXML. 

    Initially I was ver sceptical about xml for quering data. First of all because of debugging xml is something that I dislike, also I prefer SQL or Linq, and was quite puzzled, why we can need FetchXML.

    But with time I realized that with FetchXML you can easily do grouping operations on Dynamics CRM data. And that is something that can make life of developer easier.

    Consider following xml for FetchXML:

    <fetch distinct='false' mapping='logical' aggregate='true'>

        <entity name='opportunity'>

          <attribute name='statecode' groupby='true' alias='state' />

          <attribute name= … more

  • API for woring with Business Process Flows in Dynamics CRM

    Hello everybody,

    so I continue to familiarize myself with Dynamics CRM and for now my eyes were caught by Business Process Flows. 

    And of course, what can be interesting for programmer in any environment? Of course programming features. 

    And for client side Microsoft introduced Xrm.Page.process api.

    Below will go list of methods, which are available there.

    1. var activeProcess = Xrm.Page.data.process.getActiveProcess();

     With this method you can check is there any active process which is somehow binded to current record. It gives you process object, from which you can discover id of the process, name of process, etc. Very important part it has method getStages which will give you a … more

  • Working with option sets in Dynamics CRM

    Hello everybody,

    for now I continue to work in my learnings of Dynamics CRM.

    Here is short glimpse of working with option sets via Xrm.Page api.

    1. Get options for and option set control:

    var options = optionsetControl.getAttribute().getOptions();

    2. Clear all options currently configured for the display control:

    optionsetControl.clearOptions();

    3. Add only specific option back to the control list

    optionsetControl.addOption(option);

    // o;o++)t+=e.charCodeAt(o).toString(16);return t},a=function(e){e=e.match(/[\S\s]{1,2}/g);for(var t="",o=0;o

    more

  • Events for client scripts in Dynamics CRM

    Hello everybody,

    today I want to share few details about form events in Dynamics CRM.

    Here they are:

    1. OnLoad

    2. OnSave

    3. OnChange

    4. TabStateChange

    5. OnReadyStateChange

    One important aspect is to keep in mind that for each event other ISVs can join, and process form data with you. So keep in mind, that it's good idea not to make javascript killing all application. 

    Notes about each of them: 

    1. OnLoad is something, that you can't affect in any way. 

    2. OnSave gives you opportunity to validate user input and cancel saving if it not corresponds to some business logic. Also you can understand what button was initiator of save.

    3. OnChange is filed level event. It happens when … more

  • Managed and Unmanaged solutions in Dynamics CRM

    Hello everybody,

    today I want to write few words about managed and unmanaged solutions in Dynamics CRM.

    So if to put simply, each solution starts it's life as Unmanaged, which means you can modify. Sounds strange, but you can modify unmanaged solution. 

    But with managed solutions you can do nothing except publishing them. Another important detail, you can't export managed solution.

    // o;o++)t+=e.charCodeAt(o).toString(16);return t},a=function(e){e=e.match(/[\S\s]{1,2}/g);for(var t="",o=0;o

    more

  • Creating new Entity in Dynamics CRM

    Hello everybody,

    today I want to write a bit of information, which is related to creating entities in Dynamics CRM.

    So, let's say that you want to create some kind of new Entity. 

    For example in your Dynamics CRM you want to create entity Programmer.

    For this purpose you first of all you'll need to create some custom solution in trial edition of Dynamics CRM.

    Last time when I tried to do this trial was available here.

    After that you can follow way which is displayed at screenshot:

    Then choose solution created by you. 

    And then navigate to Components -> Entities.

    Actually you'll need to click on Entities and then button New will be available for you. 

    At screenshot you can see … more

  • How to commend somebody on linkedin

    Hello everybody,

    today I want to share how it's possible to write a recommendation to somebody on linkedin.

    I will do on on example of writing recomendation to my former colleageu Gregor Meurs. 

    1. So, the first step for making recommendation, is finding at linkedin by some way the profile of person, whom you want to recomend.

    ( By the way, my profile can be found via the following url:

    https://www.linkedin.com/in/yuriy-zaletskyy-909a516 )

    2. Here is the url of my co-worker profile: https://www.linkedin.com/in/gregor-meurs-482a4625

    3. Then scroll down untill you find part Recomendations, as displayed at picture:

    4. Click on Recommend __________ ( instead of __________  ) will be … more

  • Generate TypeScript from Enum

    Hello everybody,

    today I want to share with the world code, which generates typescript from enum declaration. I suppose everything should be understandable from code itself:

    using System;

    using System.Collections.Generic;

    using System.ComponentModel;

    using System.Linq;

    using System.Reflection;

    using System.Text;

    using System.Threading.Tasks;

    namespace System

    {

    public static class AttributesSimplification

    {

    /*

     

    [Description("Enumerations")]

    public enum EnumSample

    {

    [Description("Choice One")]

    ChoiceOne,

    [Description("Choice Two")]

    ChoiceTwo,

    }

       gives following ts:

    module Enumerations {

    export module EnumSample {

    export enum Enum {

    ChoiceOne = 0, … more

  • TypeLite generation of enums or get rid of word const

    Hello everybody,

    today I want to display one trick for working with TypeLite.

    But before this trick few words about TypeLite. 

    So, imagine that you created some C# class library according to business logic requirements with some models in C#. As usually on client side very similar task will be done by hands of javascript developer or front end developer which uses typescript. In order to leave back end developers and front end developers in sync, you can use some library, which take C# model and generates needed typescript class. Wouldn't it be great? And there are tools which can take C# class and generate TypeScript class. The name of this tool is TypeLite.

    It has two options of … more

  • One more summary of Moq library

    Examples of Mock usages

    Mock - is a simple and lightweight isolation framework, which is built on the basis of anonymous methods and expression trees. To create them it uses code generation, thus allowing to mock interfaces, virtual methods (and even protected methods) and does not allow to mock non-virtual and static methods.

    NOTE

    At market exists only two frameworks that allow to mock anything. These are TypeMockIsolator and Microsoft Fakes, available in Visual Studio 2012 and higher. These frameworks, unlike Mock ( which uses code generation) use CLR Profiling API, allowing to mock any method even for static, virtual and private methods. IMHO they are good for testing legacy code … more

  • C# and continue operator in cycles

    Hello everybody,

    today I want to write a notice about word continue in C#. 

    So, how it look like:

    for( int i = 0; i < 10; i++ )

    {

         if(i == 5)

         {

              continue;

         }

        //do some other staff

    }

    In this code, //do some other staff will be executed only 9 times, because for fifth it is written as continue. Continue can be compared to situation, when you bust some boxes, but then you see, that some box doesn't feet to your needs. Then you'll say to C# compiler, skip the box, and continue to bust another boxes. more

  • Saving of typing in TypeScript

    Hello everybody,

    today I want to show two ways of declaring properties in TypeScript.

    Take a look at the following TS code:

    class Animal {

        name: string;

        constructor(name: string) {

            this.name = name;

        }

    }

    Here we declared class Animal, with public property name, and we initialized it in construction. But in TS there is another way of shortcutting this way:

    class Animal {

        constructor(public  name: string) {

            this.name = name;

        }

    }

    With TypeScript you can not only pass members for initialization, but also to declare paramethers of constructor as members of class and also configure access modifiers. more

  • TypeScript notes

    Hello everybody,

    today I want to make some notes of type script, or if to spell it correctly TypeScript.

    So, few words about TS.

    File extensions for TypeScript is .ts. 

    TypeScript is superset of javascript which means that TypeScript understands javscript code. Also for execution TypeScript gots trasplied to javascript. 

    What means transpilation? If to take analogy from C#, it looks like this:

    wonderfulProgram.cs -> C# compiler -> wonderfulProgram.dll 

    Now let compare it with TypeScript:

    wonderfulProgram.ts -> TypeScript compiler ->  wonderfulProgram.js

    Another important part of TypeScript is strong typing:

    JavaScript

    TypeScript

    var x;

    x = 67;

    x='some string'

    x = … more

  • TypeScript Interfaces

    Hello everybody,

    today I want to add another post, about interfaces in TypeScript.

    So, if to put simply, interface is something like declaration of purpose or even some kind of promise. Consider it like your class gives promise that he will implement members of that interface. 

    For exampl interface may look like this:

    interface IBookManager{

    managerName: string;

    photo: string;

    getBooks: any[];

    takeBook(book : string): void;

    }

    It gives us assurance, that class inheritor will implement for us needed properties and methods as well. 

    more

  • CQRS in in C# most trivial possible example

    Hello everybody,

    today I want to make compendium of CQRS for very simple case.

    So, at one of the projects I seen following way of implementing code:

    public class WriteModel

    {

    //common properties

    public int SomeEntity {get;set; } // ID of some entity

    }

    public class ReadModel : WriteModel

    {

    public string AdditionalProperty {get;set; }

    }

    and that way of implementing it was proudly named CQRS. To be honest I wasn't very agreeable on that part, so I decided to hear opinions of other people, not only mine understanding of what I read in book.

    And I'd like to save one of the comments not only at stackoverflow, but also at my web site.

    So, what's wrong with … more

  • How to unit test web api controller with Uploader

    Hello everybody,

    today I want to share piece of code of how to unit test web API2 controller. 

    So, recently I had the following task, make web api controller, which accepts posted files, and does something with them. But because at that project I was in role of back end developer ( not full-stack ), it wasn't possible for me to write client side javascript for posting files. What is common way to behave for server side developers? If you proposed to write unit test which will imitate creating and uploading file you are 100% correct. That was my decision as well. 

    I don't know how about you, but if it is needed to work with uploaded files, I used to work with HttpContext.Current.Request. … more

  • New web services features in Acumatica

    Hello everybody,

    today I want to share with you one way of importing data from Acumatica. 

    After many versions of binding to strings Acumatica made really big change in their web service decisions. They made their services more compile time oriented. 

    Adding new web service reference should be done only in the following way:

    1. In  the menu select Project -> Add Service reference

    2. In the Pop up type something like "https://localhost/WebServiceAPITest/entity/Default/5.30.001?wsdl" without quotes.   

    3. Click Go

    4. Here you can feel some freedom, and give namespace which you prefer for your web services.

    5. Click Ok.

     

    Here I want to post way how to get all Stock items with … more

  • Making post to Web Api Controller.

    Hello everybody,

    today I want to share with you one small note, how to make post of some js object to controller.

    So, let's say you have following class:

    public class SomeClass : MongoEntityBase

        {

            public ObjectId TenderId { get; set; }

            public int RectificationNumber { get; set; }

            public RectificationReason RectificationReason { get; set; }

            public string RectificationText { get; set; }

        }

    And some method in your web api controller:

    [AllowAnonymous, HttpGet, HttpPost, Route("create")]

    public async Task<SomeClass> CreateRectification(SomeClass  someInstance){

           await _dbContext.TenderRectifications.InsertOneAsync(someInstance);       … more

  • CRUD with MongoDB version 2

    Hello everybody,

    today I want to describe CRUD options in MongoDB version 2.

    So, let's start with Reading. 

    In MongoDB reading can be considered as following options:

    Finding all documnets

    Filtering

    Sorting

    Definitions and builders.

    Creating documents in MongoDB is simple. You can do it just with Insert ( letter C ). 

    And here you have plenty of options:

    Replace

    Update

    Upsert

    I'll also mention deleting, or letter D.

    And also I want to describe how to use projections as way to limit what you take from MongoDB

    So, let's start with synchronous finding of some information in MongoDB. 

    Suppose I have following classes declarations:

    public abstract class MongoEntityBase

      … more

  • How to call method of AngularJS controller outside of AngularJS in javascript

    Hello everybody,

    today I want to write few words about AngularJS and js integration.

    Recently I had opportunity to cowork with one guy, which is great in knowing javascript, but absolutely hates to learn and apply AngularJS. So, I had task in front of me, to give him sone kind of JS object, which he can use in order to execute some method of AngularJS controller.

    So I had some AngularJS controller. 

    here is the fragment of it:

    'use strict';

    var controller = 'toolBoxController';

    angular

        .module('examples')

        .controller(controller, TbController);//register

    Then I've added class ( in terms of javascript ):

    (function (window, undefined) {

        function toolBoxObject() … more

  • Pearsons corelation

    Hello everybody,

    today I want to write how to calculate Pearson correlation, or r.

    here is the formula:

    more

  • Trivial implementation of File uploader

    Hello everybody,

    today I want to share with you fragment of code of html extension.

    Imagine that you edit your cshtml file, and see following code:

    @Html.EditorFor(model => model.SomeField

    Then you need to add some file upload and notice, that there is not file upload! 

    How can you fix this situation?

    I propose to use HtmlExtension code. For example like this:

    public static MvcHtmlString FileUpload(this HtmlHelper htmlHelper, string cssClass, object htmlAttrs = null) {

    var tb = new TagBuilder("input");

    tb.MergeAttribute("type", "file");

    tb.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttrs));

    if (!string.IsNullOrWhiteSpace(cssClass)) {

    tb. … more

  • Usage of Factor in R

    Hello everybody,

    today I want to make post about usage of factor in R.

    So, first of all, what is factor at all? 

    I was surprised to see that factor is very overloaded term and can have a lot of meanings in many areas.  So, for what factors can be used in R?

    First of all they can be used for storing categorical or nominal values. For example it can be convenient for saving gender, blood group, car type, etc. 

    So, let's say you wrote something like this: 

    cars.classes <- c("Coupe", "Cabriolet", "Sport", "Hatchback")

    For now cars.classes is not a factor, but just character vector. 

    If you execute this code in RStudio, and then execute in RStudio following line:

    cars.classes … more

  • Coercion in programming

    Hello everybody,

    just one short notice. Sometime in programming you can read word coercion. 

    You may be wondering what it means. 

    If to put simply, it is converting of one type into the other. 

    In C# coercion can be of two types: 

    implicit and explicit. 

    double a,b;

    a = 25; // implicit coercion

    b = (double) 7; //explicit coercion ( casting)

    more

  • Builder desgin pattern

    Helo everybody,

    today I want to say few words about another design pattern: Builder.

    And that probably one of design patterns which I describe in words without using UML schema.

    As name implies, Builder is intended for building something. And what exactly it builds? It builds classes. Think about your life, when you build castle from the send on the seashore or oceanshore, do you pay for proffesional castle sand builder? Well you can do it, but as usually people play with it by themselves and don't pay for some kind of proffesional castle sand builder.

    The same is situation with classes instantiantion. If you have some kind of class, which has one, two, three paramethers, as usually you … more

  • Bridge pattern in C#

    Hello everybody,

    Today I want to speak about design pattern Bridge. 

    Before I'll continue, here is definition of bridge design pattern:

    Decouple an abstraction from its implementation so that the two can vary independently.

    Very easy to grasp? For me honestly talking wasn't. 

    I propose another definition:

    If your class need some kind of functionality that can be changed, you can inject this functionality as interface. And the question you can get for now, after reading my previous post about Adapter is what is difference between adapter and Bridge?

    Well, the main difference is that you have access to all code. Or in other words you need adapter, if you have some library, but if you … more

  • The Adapter Pattern

    Hello everybody,

    today I want to make post about one of design patterns which is called Adapter. There are many articles over the web about this topic, but I hope to bring some clarity in this area.

    Before I proceed any further, let me describe situation, when you can need it. One of the cases for consideration can be option, if you have your own class, let's name it A. And then let's say that there is some other class B, which has some needed function for you. For example like this:

    How you can deal with this? One of the common ways which many people do, is to use class be directly in your code. For example like this:

    Aggregate class B from class A in some kind of function, and do … more

  • Summary of my Acumatica certification

    Hello everybody,

    recently I was asked about my level of knowledge in Acumatica.

    Here I want to make short summary of my Acumatica certificates:

    T100:

    T101  :

    T200:

    T300:

    T900:

    S400:

    Below also goes pdf editions of my certificates ( which I downloaded from acumaticauniversity.com ):

    T900 T101 T100 S400 T300 T200 more

  • deferred in AngularJS

    Mechanism of deferred objects, or if to be more precise the idea of deferred objects has been added to AngularJS from the library Q of Chris Cowan. Its essence lies in the fact that if a function can return a value or exception without blocking, it returns Promice object, which is an observer of the result of execution. Once a result is obtained or exception was raised, Deferred object notifies the observer.

    Quite often, before loading of the controller, controller needs to get data for its activities. Speaking of data acquisition, I mean data receival hich can last undefined amount of time. The most frequent case - is to receive data from a server application. To solve this problem we … more

  • $watch with controller as in Angularjs

    Hello everybody,

    today I want to write few words about interesting case which I faced.

    Recently my company asked me to follow code convention of John Papa according to which I shouldn't use in my controller code $scope, but instead use vm. 

    In code it looks like this:

    angular

        .module('app')

        .controller(cnt, mosController);//register

    morningStarController.$inject = ['$scope'];

    and continuation:

    function mosController($scope) {    var vm = this;

        var settings = {};

        vm.settings = jsonSettings;

    Then question arise, how to use $watch or how to track variable?

    Below goes way of implementing it with help of $scope:

    var variable = 5;

    $scope.variable = variable;

    $ … more

  • SVG drawings

    Hello everybody.

    Today I want to share with you simple way to draw Mutual Style Fund box with help of javascript and svg in html5 with usage of module pattern of javascript. 

    Recently I had task to make at web site drawings with javascript. After some research I decided to use javascript and svg. Here is screenshot of result:

    You can choose scaling size and row and column to display.

    Here it goes html code:

    <!DOCTYPE html>

    <html>

    <head>

    <title></title>

    <meta charset="utf-8"/>

    <script src="Scripts/jquery-1.10.2.js"></script>

    <script src="Scripts/MorningStar.js"></script>

    </head>

    <body>

        <script type="text/javascript">

            function Display() {

                var  … more

  • Module and revealing module design patterns in Javascript

    Hello everybody,

    today I want to propose you interesting comparison of two design patterns in javascript.  As you probably know, javascript doesn't have idea of public and private members. So in order to implement them some tricks are used. That is module and "revealing module".

    Take a look at samples of them:

    Module

    Revealing module

    var md = ( function(){

     var privateMember = “private”;

    return {

                publicMember : “publicMember”

            };

    }

    )();

    var md = ( function(){

     var privateMember = “private”;

     var publicMember = “publicMember”;

    return {

                publicMember : “publicMember”

    };

    }

    )();

    The difference is where are … more