Monday, August 28, 2017

How to quickly add a twitter follow button in the blog?

I setup my twitter account, then i want to add it to my blog.

here is quick way that i used to add a twitter follow button.


first open this link in the web browser https://publish.twitter.com

second select a handle lik @TwitterDev



 

alternatively you can also pick Twitter Button from the Browse your option below




third select Follow Button from the Modal




now you can copy the generated code or do additional work by click on the customization link




here is the generated code from my twitter account




<a href="https://twitter.com/Danhdeng" class="twitter-follow-button" data-show-count="false">Follow @Danhdeng</a><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>







How to add Open Folder in Visual Studio Code?

It is quite convenient to have a Open Folder in Visual Studio Code in the Popup Context Menu
































we can simply right click the selected folder and click on it, then the visual studio code will be launch and project will be loade.

here is the link to show you how to do so

I copied the code from the below link in case the author remove the this blog content
(you will have to create a reg file and save it, then click on the reg file, it will automatically install and update)

Windows Registry Editor Version 5.00
; Open files
 [HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
    @="Edit with VS Code"
    "Icon"="C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe,0"
    [HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
    ; This will make it appear when you right click ON a folder
    ; The "Icon" line can be removed if you don't want the icon to appear
    [HKEY_CLASSES_ROOT\Directory\shell\vscode]
    @="Open Folder as VS Code Project"
    "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0"
    [HKEY_CLASSES_ROOT\Directory\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%1\""
    ; This will make it appear when you right click INSIDE a folder
    ; The "Icon" line can be removed if you don't want the icon to appear
    [HKEY_CLASSES_ROOT\Directory\Background\shell\vscode]
    @="Open Folder as VS Code Project"
    "Icon"="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\",0"
    [HKEY_CLASSES_ROOT\Directory\Background\shell\vscode\command]
    @="\"C:\\Program Files (x86)\\Microsoft VS Code\\Code.exe\" \"%V\""



http://thisdavej.com/right-click-on-windows-folder-and-open-with-visual-studio-code/


Monday, August 21, 2017

My office 365 Site is finally up and run

I had registered my office site for a while, since i was too busy with work project.

Today i finally configure and make my office 365 site up and run, there are so many features.
 I will spend time to play this new toy and sharepoint page framework which will be development model for Office 365


Thursday, August 17, 2017

How to solve KnockOut JS observable object not update with Canada Post autocomplete

when i integrate the Canada Post Autocomplete with an KnockOut JS web application, it looks very smooth, all the street related fields had been populated on autocomplete selection.

however, the observable object that binding to the control did not update automatically.


From Canada Post web site, I found this sample code for my own customization on auto populate event

  1. <script type="text/javascript">
  2.  
  3. addressComplete.listen('load', function(control) {
  4. control.listen("populate", function (address) {
  5. document.getElementById("line1").value = address.Line1;
  6. });
  7. });
  8.  
  9. </script>

I try use this in my javascript, but it never work out. actually we only need to setup the controller listen event.

  var fields = [
             {
                 element: customerType + "street-address", field: "Line1"
             },
             {
                 element: "street-address2", field: "Line2", mode: pca.fieldMode.POPULATE
             },
             {
                 element: "city", field: "City", mode: pca.fieldMode.POPULATE
             },
             {
                 element: "province", field: "ProvinceCode", mode: pca.fieldMode.POPULATE
             },
             {
                 element: "postalCode", field: "PostalCode"
             },
             { element: "country", field: "CountryIso3", mode: pca.fieldMode.COUNTRY }
        ],

 options = {
               key: window.MyOwn.canadaPostKey
           },
          control = new pca.Address(fields, options);
        control.listen('populate', function (address) {
            customer.streetAddress(address.Line1);
            customer.city(address.City);
            customer.province(address.ProvinceCode);
            customer.postalCode(address.PostalCode);
            customer.country(address.CountryIso3);
        });






Monday, June 12, 2017

How to quickly fixed Skype for business conversition did not save to Conversation History Folder in OutLook 2013?

it is quick frustrate when i discovered that my conversation with my teammates did not save in the conversation history. as a result, i can't search the conversation history to find some previous information for reference.

the fix is quite simple and fast.

step 1. shut down Skype for business and outlook 2013.

step 2. go to this folder C:\Users\{Your User ID}\AppData\Local\Microsoft\Office\15.0\Lync

step 3. delete all the files inside the above folder.

step 4. relaunch the Skype for Business, you will find the conversation saved back to the Conversation history.

Monday, May 29, 2017

How to save your day with simple Hello World SharePoint Page Framework Add-In depolyment in Sharepoint Online?

it is quite annoying when i try to deployed my app to SharePoint online or SharePoint 365.

since i always keep gotting the following errors.

Something went wrong

If the problem persists, contact the site administrator and give them the information in Technical Details.

How to Invoke the Azure api from Server Side with C#?

it is quick easy to call Web Api from client side with Ajax or XMLHttpRequest.

but it is also not so hard to implement a server side execution.

we can either use HttpWebReqeust or HttpClient to call Web Api

if you use api to load data, HttpWebRequest Method should be GET.  you can skip
the GetRequestStream part.

if your action send data to server,  HttpWebRequest Method should be POST.
 

the following sample will demonstrate a call to Web API that hosted in Azure.


   public static async Task<APIResult> InvokeAzureAPICall(string url, string inputData)
        {
            try
            {
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                  req.Headers.Add("SubscriptionKey", "KEYFromAzure");

                var cert = new X509Certificate2(File.ReadAllBytes("C:\\Certs\\myCertificate.pfx"), "MYPassword");
                req.ClientCertificates.Add(cert);
   
                // from this line below only required for Post data to server
                //if passing in object are in json format.
                req.ContentType = "application/json";
                req.Method = "POST";
                Encoding encoding = new UTF8Encoding();

                byte[] dataBytes = encoding.GetBytes(inputData);
                req.ContentLength = dataBytes .Length;

                Stream stream = req.GetRequestStream();
                stream.Write(data, 0, dataBytes.Length);
                stream.Close();
              
                //ending here the above is code is required only for Post Method in the web api call. 


                WebResponse resp = await req.GetResponseAsync();

                string response = "";
                using (var readStream = new StreamReader(resp.GetResponseStream()))
                {
                    response = readStream.ReadToEnd();
                }
                return new APIResult
                {
                    apiResponse = response,
                    apiStatusCode = HttpStatusCode.OK
                };
            }
            catch (Exception ex)
            {
                string response = "";
                using (var rdstream = new StreamReader(((System.Net.WebException)ex).Response.GetResponseStream()))
                {
                    response = rdstream.ReadToEnd();
                    return new APIResult
                    {
                        apiResponse = response,
                        apiStatusCode = ((System.Net.HttpWebResponse)((System.Net.WebException)ex).Response).StatusCode
                    };
                }

            }
        }