Search Results

Search found 2 results on 1 pages for 'desigeek'.

Page 1/1 | 1 

  • How to Create Deterministic Guids

    - by desigeek
    In our application we are creating Xml files with an attribute that has a Guid value. This value needed to be consistent between file upgrades. So even if everything else in the file changes, the guid value for the attribute should remain the same. One obvious solution was to create a static dictionary with the filename and the Guids to be used for them. Then whenever we generate the file, we look up the dictionary for the filename and use the corresponding guid. But this is not feasible coz we might scale to 100's of files and didnt want to maintain big list of guids. So another approach was to make the Guid the same based on the path of the file. Since our file paths and application directory structure are unique, the Guid should be unique for that path. So each time we run an upgrade, the file gets the same guid based on its path. I found one cool way to generate such 'Deterministic Guids' (Thanks Elton Stoneman). It basically does this: private Guid GetDeterministicGuid(string input) { //use MD5 hash to get a 16-byte hash of the string: MD5CryptoServiceProvider provider = new MD5CryptoServiceProvider(); byte[] inputBytes = Encoding.Default.GetBytes(input); byte[] hashBytes = provider.ComputeHash(inputBytes); //generate a guid from the hash: Guid hashGuid = new Guid(hashBytes); return hashGuid; } So given a string, the Guid will always be the same. Are there any other approaches or recommended ways to doing this? What are the pros or cons of that method?

    Read the article

  • Preserve whitespace and formatting for text returned from $.get jquery call

    - by desigeek
    I have a jquery $.get() call in my app that requests an entire web page. In the callback function, I access a div in the returned page, get its data and show it on my page. The problem is that the text I get from the div does not preserve the source formatting. If the div in the requested page had say an ordered list, then when i get that text and display on my page, it shows up as a paragraph with items inline instead of being shown as a list. I do not know whether the problem is how $.get() is getting the data or in my displaying of the data. //get the page $.get($(this).attr('href'), function(data){ callbackFunc(data,myLink); }, "html"); function callbackFunc(responseText, customData){ //response has bg color of #DFDFDF var td = $("td[bgcolor='#DFDFDF']", responseText); //text to show is in div of that td var forumText = $('div', td).text(); //append new row with request data below the current row in my table var currentRow = $(customData).parent('td').parent('tr'); var toAppend = "<tr><td class='myTd' colspan='3'>" + forumText + "</td></tr>"; $(currentRow).after(toAppend); } The response data shows up like ABC in the new row I add to my div while the source page div had A B C I should add that this script is part of an extension for Google Chrome so that is my only browser that I have tested on

    Read the article

1