Sunday, January 29, 2017

GIT - Commands Reminder

  • git --version
  • git -status
  • git add *file*  - adds files to the repository so that Git knows to track their changes.
  • git commit -m "message"  - commits all added files to the repository as a change. With the -a flag, commits all changes to all tracked files. With the -m flag, allows you to specify a commit message directly on the command line instead of in your default editor.
  • git config - allows you to make configuration changes to Git. With the --global flag, makes these changes available across your entire system.
  • git config --global user.name "Steven"
  • git config --global user.email some@sss.com
  • git log - Show us a chronological log of all of our commits to the current repository.
  • git checkout - "check out" a different version of the code from the one you're currently looking at.
  • git diff - create a "diff" view to demonstrate what has changed between two different versions of your repository.
  • git log --all --decorate --oneline --graph - Decorated commit list.
Commiting

  • git add - adds files to the repository so that Git knows to track their changes.
  • git commit - commits all added files to the repository as a change. With the -a flag, commits all changes to all tracked files. With the -m flag, allows you to specify a commit message directly on the command line instead of in your default editor.
Branching

  • git branch branchname - create a new branch named branchname.
  • git checkout branchname - switch to the branch named branchname.
  • git checkout -b branchname - create a new branch named branchname and switch to that branch.
Cherry-pick

Cherry picking is the act of picking a commit from a branch and applying it to another.

  • git cherrypick ff9a9ab2

Git remove last commit:
git reset --hard Point to next last guid.



Monday, January 23, 2017

Episerver - Autoremap Dynamic Data store


Fix for problems with dynamic datastore tables not being able to remap because of changes in the table.
Add the following attribute:

[EPiServerDataStore(AutomaticallyRemapStore = true)]

Wednesday, January 18, 2017

C# - Parse Query Parameter to Name Value Collection


  var query = HttpUtility.ParseQueryString(httpContext.Request.Url.Query);  

/// <summary>
        /// Get URL With QueryString Dynamically
        /// </summary>
        /// <param name="url">URI With/Without QueryString</param>
        /// <param name="newQueryStringArr">New QueryString To Append</param>
        /// <returns>Return Url + Existing QueryString + New/Modified QueryString</returns>
        public string BuildQueryStringUrl(string url, string[] newQueryStringArr)
        {
            string plainUrl;
            var queryString = string.Empty;

            var newQueryString = string.Join("&", newQueryStringArr);

            if (url.Contains("?"))
            {
                var index = url.IndexOf('?');
                plainUrl = url.Substring(0, index); //URL With No QueryString
                queryString = url.Substring(index + 1);
            }
            else
            {
                plainUrl = url;
            }

            var nvc = HttpUtility.ParseQueryString(queryString);
            var qscoll = HttpUtility.ParseQueryString(newQueryString);

            var queryData = string.Join("&",
                nvc.AllKeys.Where(key => !qscoll.AllKeys.Any(newKey => newKey.Contains(key))).
                    Select(key => string.Format("{0}={1}",
                        HttpUtility.UrlEncode(key), HttpUtility.UrlEncode(nvc[key]))).ToArray());
            //Fetch Existing QueryString Except New QueryString

            var delimiter = nvc.HasKeys() && !string.IsNullOrEmpty(queryData) ? "&" : string.Empty;
            var queryStringToAppend = "?" + newQueryString + delimiter + queryData;

            return plainUrl + queryStringToAppend;
        }

Javascipt - Cut Html Text with nice ending.


The item.Teaser = "Something and then something. or somewhat like";
Will be cut to down with a ... ending.

Javascript
  let teaser = item.Teaser.substring(0,35);  
    let teasercut = teaser.substr(0, Math.min(teaser.length, teaser.lastIndexOf(" "))) + '...';  

C#
string shortDescription = DescriptionString.Substring(0, 255);
   var shortDescriptionfixed = shortDescription?.Substring(0, Math.Min(shortDescription.Length, shortDescription.LastIndexOf(" ", StringComparison.Ordinal)));
   shortDescriptionfixed +="...";