Friday

c# binary deserialize unable to find assembly version=1.0.0.0, culture=neutral, publickeytoken=null

Got error with binary deserialisation : unable to find assembly xxx version=1.0.0.0, culture=neutral, publickeytoken=null 
It requires to have additional SerializationBinder class .
Here is whole workable storage class:

using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System;
using System.Runtime.Serialization;
using System.Reflection;

public static  class Storage {

    public const string ConfigurationName = "dev.settings";
    public static string SettingFileName
    {
        get
        {
            return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ConfigurationName);
        }
    }

    public static  void Save(cProfile gh)
    {
        FileStream writeStream = new FileStream(SettingFileName, FileMode.Create);
        BinaryFormatter formatter = new BinaryFormatter();
        formatter.Serialize(writeStream, gh);
        writeStream.Close();
    }


    public static cProfile  Load() {
        cProfile ret= new cProfile();

        Manager.getInstance().RunSafe (delegate()
        {
            if (File.Exists(SettingFileName))
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Binder = new PreMergeToMergedDeserializationBinder();

                FileStream readStream = new FileStream(SettingFileName, FileMode.Open);
                ret = (cProfile)formatter.Deserialize(readStream);
                readStream.Close();
            }
        });
        return ret;


    }


    sealed class PreMergeToMergedDeserializationBinder : SerializationBinder
    {
        public override Type BindToType(string assemblyName, string typeName)
        {
            Type typeToDeserialize = null;

            // For each assemblyName/typeName that you want to deserialize to
            // a different type, set typeToDeserialize to the desired type.
            String exeAssembly = Assembly.GetExecutingAssembly().FullName;


            // The following line of code returns the type.
            typeToDeserialize = Type.GetType(String.Format("{0}, {1}",
                typeName, exeAssembly));

            return typeToDeserialize;
        }
    }
}





Thursday

"app_name" is not translated in "af" (Afrikaans), "am" (Amharic), "ar" (Arabic), "az" (Azerbaijani), "be" (Belarusian), "bg" (Bulgarian), "bn" (Bengali), "bs" (Bosnian), "ca" (Catalan), "cs" (Czech), "da" (Danish), "de" (German), "el" (Greek), "es" (Spanish), "es-US" (Spanish: United States), "et" (Estonian), "eu" (Basque), "fa" (Persian), "fi" (Finnish), "fr" (French), "fr-CA" (French: Canada), "gl" (Galician), "gu" (Gujarati), "hi" (Hindi), "hr" (Croatian), "hu" (Hungarian), "hy" (Armenian), "in" (Indonesian), "is" (Icelandic), "it" (Italian), "iw" (Hebrew), "ja" (Japanese), "ka" (Georgian), "kk" (Kazakh), "km" (Khmer), "kn" (Kannada), "ko" (Korean), "ky" (Kyrgyz), "lo" (Lao), "lt" (Lithuanian), "lv" (Latvian), "mk" (Macedonian), "ml" (Malayalam), "mn" (Mongolian), "mr" (Marathi), "ms" (Malay), "my" (Burmese), "nb" (Norwegian Bokm?l), "ne" (Nepali), "nl" (Dutch), "pa" (Punjabi), "pl" (Polish), "pt-BR" (Portuguese: Brazil), "pt-PT" (Portuguese: Portugal), "ro" (Romanian), "ru" (Russian), "si" (Sinhala), "sk" (Slovak), "sl" (Slovenian), "sq" (Albanian), "sr" (Serbian), "sv" (Swedish), "sw" (Swahili), "ta" (Tamil), "te" (Telugu), "th" (Thai), "tl" (Tagalog), "tr" (Turkish), "uk" (Ukrainian), "ur" (Urdu), "uz" (Uzbek), "vi" (Vietnamese), "zh-CN" (Chinese: China), "zh-HK" (Chinese: Hong Kong SAR China), "zh-TW" (Chinese: Taiwan), "zu" (Zulu)

I was gettign this error after running build with apache cordova for visual studio : Severity Code
Severity Code Description Project File Line Suppression State
Error C:\Cordova\SpaceRiddle\SpaceRiddle\platforms\android\res\values\strings.xml:3: Error: "app_name" is not translated in "af" (Afrikaans), "am" (Amharic), "ar" (Arabic), "az" (Azerbaijani), "be" (Belarusian), "bg" (Bulgarian), "bn" (Bengali), "bs" (Bosnian), "ca" (Catalan), "cs" (Czech), "da" (Danish), "de" (German), "el" (Greek), "es" (Spanish), "es-US" (Spanish: United States), "et" (Estonian), "eu" (Basque), "fa" (Persian), "fi" (Finnish), "fr" (French), "fr-CA" (French: Canada), "gl" (Galician), "gu" (Gujarati), "hi" (Hindi), "hr" (Croatian), "hu" (Hungarian), "hy" (Armenian), "in" (Indonesian), "is" (Icelandic), "it" (Italian), "iw" (Hebrew), "ja" (Japanese), "ka" (Georgian), "kk" (Kazakh), "km" (Khmer), "kn" (Kannada), "ko" (Korean), "ky" (Kyrgyz), "lo" (Lao), "lt" (Lithuanian), "lv" (Latvian), "mk" (Macedonian), "ml" (Malayalam), "mn" (Mongolian), "mr" (Marathi), "ms" (Malay), "my" (Burmese), "nb" (Norwegian Bokm?l), "ne" (Nepali), "nl" (Dutch), "pa" (Punjabi), "pl" (Polish), "pt-BR" (Portuguese: Brazil), "pt-PT" (Portuguese: Portugal), "ro" (Romanian), "ru" (Russian), "si" (Sinhala), "sk" (Slovak), "sl" (Slovenian), "sq" (Albanian), "sr" (Serbian), "sv" (Swedish), "sw" (Swahili), "ta" (Tamil), "te" (Telugu), "th" (Thai), "tl" (Tagalog), "tr" (Turkish), "uk" (Ukrainian), "ur" (Urdu), "uz" (Uzbek), "vi" (Vietnamese), "zh-CN" (Chinese: China), "zh-HK" (Chinese: Hong Kong SAR China), "zh-TW" (Chinese: Taiwan), "zu" (Zulu) [MissingTranslation] SpaceRiddle 1



In order to resolve this error I had to update problem file : C:\Cordova\SpaceRiddle\SpaceRiddle\platforms\android\res\values\strings.xml 
with adding translatable="false" so final file looks like :

<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="app_name" translatable="false">SpaceRiddle</string>
    <string name="launcher_name" translatable="false">@string/app_name</string>
    <string name="activity_name" translatable="false">@string/launcher_name</string>
</resources>

Monday

Configuring Web for ASP.NET 4.5 failed .

To resolve error:
Configuring Web for ASP.NET 4.5 failed. You must manually configure this site for ASP.NET 4.5 in order for the site to run correctly. ASP.NET 4.0 has not been registered on the Web server. You need to manually configure your Web server for ASP.NET 4.0 in order for your site to run correctly.”

I manually created pool for with 4.5, in order to create it I had to do following:
Because there is no v4.5 shown in the gui, and typically you don't need to manually specify v4.5 since it's an in-place update. However, you can set it explicitly with appcmd like this:
appcmd set apppool /apppool.name: [App Pool Name] /managedRuntimeVersion:v4.5
Appcmd is located in %windir%\System32\inetsrv. 
This helped me to fix an issue with Web Deploy, where it was throwing an ERROR_APPPOOL_VERSION_MISMATCH error after upgrading from v4.0 to v4.5



Sunday

Requested registry access is not allowed Error in webservice or website.



To fix  Requested registry access is not allowed error in webservice or website you need to know name of the event log and here is how to grant access:

Grant permission to create a custom event log
  1. Log on to the computer as an administrator.
  2. Click Start, click Run, type regedit in the Open box, and then click OK. The Registry Editor window appears.
  3. Locate the following registry subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
  1. Right-click Eventlog, and then click Permissions. The Permissions for Eventlog dialog box appears.
  2. Click Advanced. The Advanced Security Settings for Eventlog dialog box appears.
  3. In the Name column, double-click the Users group. The Permission Entry for Eventlog dialog box appears.
  4. Select the Set Value check box, select the Create Subkey check box, and then click OK.
  5. Quit Registry Editor, and then log off from the administrator account.

rainmeter blinking text

Here is instruction how to make blinking text in rainmeter:
1.right click and select  "Edit skin"
2.add following code to template:


[Fade]
Measure=Calc
Formula=Counter% 2 = 1 ? 255 : 0


[MeterSeconds]
Meter=STRING
X=100
Y=50
W=1500
SolidColor=0,0,0,1
StringStyle=Normal
StringAlign=Center
FontColor=255,255,255,[Fade]
FontSize=20
FontFace=#FontName#
AntiAlias=1
Text=CTID
DynamicVariables=1

3.Save tempalate into notepad.
4.Right click and select  "Refresh skin"

Now you have blinking  CTID letters.

Tuesday

Game based on pomodoro technique

Game based on pomodoro technique 
pomodoro technique game

removing E-02 from Excel numbers

this problem can be resolved once per column :
1.highlight the column
2.from ribbon select Data -> Text to Columns -> Fixed length -> Don't create any break lines. Clear any that show up -> Select column data format text -> Finish.
3.Done!

Visual Studio 2015 cordova taco Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space

This was resolved by creating system variable in :
Windows button-> search for "system variables"
Open Environment Variables window
click New... name: _JAVA_OPTIONS, value:  -Xmx1G -Xms1G
this should help

Sunday

Meditation Software

Computer Meditation Software

Many software applications have been created in order to help to achieve meditation technique mastery and become guru in Zen,mindfulness,transcendental meditations. Or for using it in yoga practice.There are following main characteristic these applications can be classified:

  • Learning - Guides and software helping people establish technique.
  • Timers - software for measuring time
  • Soundscape -software for creating sounds
  • Biofeedback Software - software and hardware capable for reading human body characteristics


Name Platform Link Description
Calm Android/IOS https://www.calm.com/ Soundscape app
Insight Timer Android/IOS https://insighttimer.com/ guided meditations, music tracks, talks
Learning Meditation Game Android/PC http://www.whiterocksoftware.com/2015/02/learning-meditation-game.html Learning Meditation game,timer, guide.
Omvana Android/IOS http://www.omvana.com/ guided meditations, inspirational speeches, binaural tracks

Wednesday

split large xml file in c#

      
using Microsoft.XLANGs.BaseTypes;
using MyWebComponents;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;

[Serializable]
public class MasterProductSplitter
{
    public MasterProductSplitter()
    {
    }

    List<string> ops = new List<string>();

    const string schema = "http://schemas.datacontract.org/2004/07/MyWebACPRecords";
    const string RecordTag = "b:getACPMasterRecords_Result";

    public void Dispose()
    {
        Thread.Sleep(5000);//let's wait until all files closes.
        foreach (var s in ops)
        {
            try
            {
                File.Delete(s);
            }
            catch (Exception ex)
            {
                LogError("Error deleting file :", ex);
            }

        }

    }

    public void InitialiseMsg(XLANGMessage message, DateTime RequestTime)
    {
        Initialise((Stream)message[0].RetrieveAs(typeof(Stream)), RequestTime);
    }

    public int Length { get { return ops.Count; } }
    public int Current;

    public const int MaxCount = 1000;

    public void Initialise(Stream ins, DateTime RequestTime)
    {
        Debug.Write("MasterProductSplitter v1.1 started.");
        ins.Seek(0, SeekOrigin.Begin);
        ops = new List<string>();
        Current = 0;

        XmlTextReader doc = new XmlTextReader(ins);
        int count = MaxCount;//getting 1K records 
        XmlDocument outdoc = new XmlDocument();
        var r = outdoc.CreateElement("e");

        while (!doc.EOF)
        {

            if (doc.Name == RecordTag)
            {
                //wrap Records into <l> tag in case we would need to transfer more infor within a Record.
                XmlElement rootNode = outdoc.CreateElement("l");
                rootNode.InnerXml = doc.ReadOuterXml();
                r.AppendChild(rootNode);

                count -= 1;
                if (count < 0)
                {
                    outdoc.AppendChild(r);
                    count = MaxCount;
                    ops.Add(CreateGlobalProductMsg(outdoc, RequestTime));
                    outdoc = new XmlDocument();
                    r = outdoc.CreateElement("e");
                }
            } else {
                doc.Read();
            }
        }

        if (count != MaxCount)
        {
            outdoc.AppendChild(r);
            ops.Add(CreateGlobalProductMsg(outdoc, RequestTime));
        }

        Debug.Write("MasterProductSplitter:parts created:" + this.Length);
        ins.Seek(0, SeekOrigin.End);
    }


    public bool hasData()
    {
        return Current < Length;
    }


    public void LogError(string message, Exception e)
    {
        LogError(message + "" + e.ToString());
    }
    public void LogError(string err)
    {
        Debug.Write("MasterProductSplitter:Error:" + err);
        EventLog.WriteEntry("Biztalk Server", "MasterProductSplitter:Error:" + err, System.Diagnostics.EventLogEntryType.Error, 1);
    }

    public XmlDocument GetPart()
    {
        XmlDocument xmldoc = new XmlDocument();
        try
        {
            StreamReader sr = new StreamReader(ops[Current]);
            xmldoc.Load(sr);
            Current += 1;
        }
        catch (Exception ex)
        {
            Current += 1;//this part is broken , moving to the next part
            LogError("MasterProductSplitter:Error reading part:", ex);
        }

        return xmldoc;
    }

    public static string CreateGlobalProductMsg(XmlDocument globalProductsMessage, DateTime RequestTime)
    {
        string ret = Path.GetTempFileName();
        using (FileStream res = new FileStream(ret, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite, 4096))
        {
            StreamWriter sb = new StreamWriter(res);
            sb.Write("<ns0:MasterProductSync xmlns:ns0=\"http://tempuri.org/\"><ns0:masterProducts><![CDATA[<r RequestTime=\"");
            sb.Write(RequestTime.ToString("s"));
            sb.Write("\">");
            sb.Write(globalProductsMessage.InnerXml);
            sb.Write("</r>]]></ns0:masterProducts></ns0:MasterProductSync>");
            res.Flush();
            sb.Flush();
            sb.Close();
            res.Close();
            Debug.Write("Create file:" + ret);
        }
        return ret;
    }



    /// <summary>
    ///  Copy data from one stream into anoter
    /// </summary>
    /// <param name="input"></param>
    /// <param name="output"></param>
    public void CopyStream(Stream input, Stream output)
    {
        byte[] buffer = new byte[8 * 1024];
        int len;
        while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
        {
            output.Write(buffer, 0, len);
        }
    }



    /// <summary>
    /// Saving Stream Into File
    /// </summary>
    /// <param name="stm"></param>
    /// <param name="filename"></param>
    public static void SaveStreamIntoFile(Stream stm, string filename)
    {
        stm.Seek(0, SeekOrigin.Begin);
        FileStream fileStream = File.Create(filename, (int)stm.Length);
        byte[] bytesInStream = new byte[stm.Length];
        stm.Read(bytesInStream, 0, bytesInStream.Length);
        // Use write method to write to the file specified above
        fileStream.Write(bytesInStream, 0, bytesInStream.Length);
        fileStream.Close();
    }

}
   

delete all duplicates in TSQL but one

     

WITH a as
(
SELECT PeriodId
,StationId
,WeekDay
,WeekCycle
,ProductId
,AssignedDate
,MenuId
,ROW_NUMBER() OVER(PARTITION by PeriodId
                        ,StationId
                        ,WeekDay
                        ,WeekCycle
                        ,ProductId
                        ,AssignedDate
                        ,MenuId ORDER BY PrimawebMenuId desc ) AS duplicateRecCount
FROM MenuProducts
)
--Deleting Duplicate Records
DELETE FROM a
WHERE duplicateRecCount > 1
    

assertive programming.assertion class

Below is assertion class.And here is programming example
 


using System;
using System.Runtime.Serialization;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;


 /// <summary>
 ///  Asserion block
 /// </summary>
 [Serializable]
 public class AssertionException : ApplicationException {
 public AssertionException(SerializationInfo info, StreamingContext context) : base(info, context) {}
 public AssertionException() : base() { }

 public AssertionException(string msg) : base(string.Format(msg)) { }




    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="msg"></param>
    /// <param name="obj"></param>
public AssertionException(string msg, params object[] obj) :base(string.Format(msg, obj)) {}
}

    public class Assertions {


        public   void Throw(string message,params string[] objs ){
            Throw(String.Format(message, objs));
        }

        public  void Throw(Exception exception)
        {
            throw exception;
        }

        public  void Throw(string message)
        {
            var x = new AssertionException(message);
            throw (x);
        }


        public  void IsInt(string num, string Message, out int result) {
            if (!int.TryParse(num,out result)) {
                Throw(Message);
            }
        }

        public  void IsTrue(bool evaluation, string format, params string[] objects){
            if (!evaluation){
                Throw(format,objects );
            }
        }

        public  void IsFalse(bool evaluation, string format, params string[] objects){
            if (evaluation) Throw(format, objects);
        }

        public  void IsTrue(bool evaluation,string message){
           if (!evaluation) Throw(message);

        }

        public  void IsTrue(bool evaluation, Exception exception)
        {
            if (!evaluation) Throw(exception);
        }

        public  void NotDBNull(Object evaluation, string message){
            if (evaluation == DBNull.Value){
                Throw(message);
            }
        }

        public  void AllNotDBNull(string message,params object[] evaluation )
        {
            foreach (object o in evaluation) {
                NotDBNull(o,message);
            }
        }

        public  void AllNotDBNullOREmptyString(string message, params object[] evaluation)
        {
            foreach (object o in evaluation)
            {
                NotDBNull(o, message);
                NonEmptyString(o.ToString(), message);
            }
        }

        public  void IsNotNull(Object  evaluation,string message) {
           if (evaluation ==null) {
               Throw(message);
           }
        }


        public  void AllNotNull( string message,params object[] evaluation)
        {
            foreach (object o in evaluation) { IsNotNull(o, message); }
        }


        public  void AllNonEmptyString(string message, params object[] evaluation)
        {
            foreach (object o in evaluation) {
                IsNotNull(o,message);
                NonEmptyString(o.ToString(), message);
            }
        }

        public  void NonEmptyString (string str,string message) {
            if  (!(str!=null && str.Trim().Length >0)) {
                Throw(message);
            }
        }

        public  void RegexMatch(string s, string reg,string message ) {
            Regex rg = new Regex(reg);
            IsTrue(rg.IsMatch(s), message);
        }

        public  void RegexMatchAtLeastWithOne(string s, string[] reg, string message)
        {
            bool matched = false;
            foreach (string rega in reg) {
                Regex rg = new Regex(rega);
                if (rg.IsMatch(s)) {
                    matched = true;
                    break;
                }
            }

            IsTrue(matched, message);

        }



    }

tsql select from xml with xmlns

tsql select from xml with xmlns here is how to do that :
       
declare @document xml ='<TypedPollingResultSet0 xmlns="http://schemas.microsoft.com/Sql/2008/05/TypedPolling/ModifiedProductsGet"><TypedPollingResultSet0><id>2</id><ProductID>M10570</ProductID><OriginalCatalog> Master Recipes HE</OriginalCatalog><Status>0</Status><DateTimeCreated>2014-10-20T11:48:10.373Z</DateTimeCreated></TypedPollingResultSet0><TypedPollingResultSet0><id>1</id><ProductID>M9519</ProductID><OriginalCatalog> Master Recipes HE</OriginalCatalog><Status>0</Status><DateTimeCreated>2014-10-20T11:48:10.373Z</DateTimeCreated></TypedPollingResultSet0></TypedPollingResultSet0>'
;WITH XMLNAMESPACES(DEFAULT 'http://schemas.microsoft.com/Sql/2008/05/TypedPolling/ModifiedProductsGet')
Select T.N.value('id[1]', 'int') as id
from @document.nodes('/TypedPollingResultSet0/TypedPollingResultSet0') as T(N)

mplayer play random file into folder

to shuffle and play random audio files in folder , create following .bat file:

cd C:\Audio\mix\
c:\tools\mplayer\mplayer -quiet -shuffle *


Monday

BizTalk Archive not available or not configured. Timeout error

Here are steps how to resolve BizTalk timeout issue and see tracked messages:

1.purge all tracking data
USE [BizTalkDTADb]
GO
DECLARE              @return_value int
EXEC      @return_value = [dbo].[dtasp_PurgeAllCompletedTrackingData]
SELECT  'Return Value' = @return_value
GO

2.submit  messages to BizTalk

3.After messages are placed run this job on BizTalk server in order to see messages bodies:
TrackedMessages_Copy_BizTalkMsgBoxDb


imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...