26 November 2017

Example on how to use C++ regex_token_iterator

 #pragma once   
 #pragma warning(disable:4996)   
 #define _SCL_SECURE_NO_WARNINGS   
 #include "stdafx.h"  
 #include <fstream>  
 #include <iostream>  
 #include <regex>  
 #include <iterator>  
 #include <algorithm>  
 using namespace std;  
 int main() {  
      string seq("tatagcagtcccgctgtgtgtacgacactggcaacatgaggtctttgctaatcttggtagctttg");  
      regex e("(tata)([gatc]*)(tag)");  
      int submatches[] = { 1, 2, 3 };  
      sregex_token_iterator rend;  
      sregex_token_iterator a(seq.begin(), seq.end(), e, submatches);  
      while (a != rend) std::cout << " [" << *a++ << "]";  
      getchar();  
      return 0;  
 }  

22 November 2017

Are you being tracked by Facebook?

One way to find out whether the websites you are visiting has facebook tracker is to install Facebook pixel extension on your Google Chrome browser

https://chrome.google.com/webstore/detail/facebook-pixel-helper/fdgfkebogiimcoedlicjlajpkdmockpc?hl=en

You can also see it by examining your network traffic using the developer tool on your browser


02 November 2017

String.Compare is a better method to compare strings than String.Equal


String.Compare is a better method to compare strings than String.Equal

Below example illustrates how String.Compare handles nulls better than String.Equal


    class Program
    {
        static void Main(string[] args)
        {
            string A = "Hello World";
            string B = "Hello World";
            string C = null;

            if (String.Compare(B, A) == 0) { Console.WriteLine("A equals B"); }
            if (String.Compare(C, A) == 0) { Console.WriteLine("A equals C"); }
            if (B.Equals(A)) { Console.WriteLine("A equals B"); }
            try
            {
                if (C.Equals(A)) { Console.WriteLine("A equals C"); }
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }

            Console.ReadKey();
        }
    }