Skip to content

Instantly share code, notes, and snippets.

View ironpython2001's full-sized avatar

Sunil P ironpython2001

  • OSI Digital
  • Hyderabad
View GitHub Profile
@ironpython2001
ironpython2001 / gist:fb15d377fef1adf88dac8988ba0ae64b
Last active May 18, 2023 08:45
git diff of a file in different branches
git diff two files in different branches
D:\pathofrepo>git diff origin/branch1 origin/branch2 -- pathtofile/filename.cs
if you want to ignore white spaces
git diff -b origin/branch1 origin/branch2 -- pathtofile/filename.cs
reference:
https://stackoverflow.com/questions/4350678/git-diff-w-ignore-whitespace-only-at-start-end-of-lines
@ironpython2001
ironpython2001 / gist:f27f3bcbfcbc404f76812e26c47506fa
Last active May 18, 2023 08:26
git what was changed in a branch
git whatchanged --name-only --pretty="" *.xaml *.cs
or
git whatchanged --oneline --name-only
https://stackoverflow.com/questions/25289469/how-to-find-list-of-unique-files-that-have-changed
https://stackoverflow.com/questions/10641361/get-all-files-that-have-been-modified-in-git-branch
find list of unique files that changed
@ironpython2001
ironpython2001 / gist:3aa6dcdbf27611a84925e1e4f93104b8
Created May 18, 2023 07:12
git show uncommitted changes in current branch
https://stackoverflow.com/questions/35978550/how-to-show-uncommitted-changes-in-git-and-some-git-diffs-in-detail
git diff
https://stackoverflow.com/questions/8554776/how-to-filter-git-diff-based-on-file-extensions
git diff -- '***.py'
@ironpython2001
ironpython2001 / gist:b727c57c30417a44ec3580851b492581
Created May 18, 2023 07:10
git change branch or checkout branch
git checkout <branch-name>
Refernce: https://stackoverflow.com/questions/1146973/how-do-i-revert-all-local-changes-in-git-managed-project-to-previous-state
#!/bin/sh
git reset --hard
git clean -f -d
git checkout HEAD
git rev-parse --abbrev-ref HEAD
or with Git 2.22 and above:
git branch --show-current
@ironpython2001
ironpython2001 / arraysplitwithrefelement.cs
Created May 6, 2022 10:47
Array Split with reference element in c#
//Desc: Array Split
//Say you have an array (or list) of arbitrary integers.
//The data structure must be reordered so that all values less than a
//special reference value are placed on the left. All values greater than
//or equal to the reference value are placed on the right.
//The ordering within the subranges is not relevant and may vary.
//Input Reference element Sample result
//[4, 7, 1, 20] 9 [1, 4, 7, 9, 20]
//[3, 5, 2] 7 [2, 3, 5, 7]
@ironpython2001
ironpython2001 / addonetoarrayasno.cs
Last active May 13, 2022 07:41
Add One to an Array as a Number in c#
//Add One to an Array as a Number
//Input Result
//[1, 3, 2, 4] [1, 3, 2, 5]
//[1, 4, 8, 9] [1, 4, 9, 0]
//[9, 9, 9, 9] [1, 0, 0, 0, 0]
var lst = new List<int> { 1, 4, 8, 9 };
var one = 1;
var revlst = lst.ToArray().Reverse().ToList();
@ironpython2001
ironpython2001 / palindromelists.cs
Created May 6, 2022 08:56
palindrome lists in c#
//Palindrome Lists
//Input Result
//[“One”, “Test”, “ – ”, “Test”, “One”] True
//[“Max”, “Mike”, “Mike”, “Max”] True
//[“Tim”, “Tom”, “Mike”, “Max”] False
//var lst = new List<string>() { "One", "Test", "–", "Test", "One" };
var lst = new List<string>() { "Max", "Mike", "Mike", "Max"};
var cnt = lst.Count()/2;
@ironpython2001
ironpython2001 / evenbeforeoddnos.cs
Created May 6, 2022 08:36
even before odd numbers in c#
//even before odd numbers
//Input Result
//[1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [2, 4, 6, 8, 10, 3, 7, 1, 9, 5]
//[2, 4, 6, 1, 8] [2, 4, 6, 8, 1]
//[2, 4, 6, 8, 1] [2, 4, 6, 8, 1]
var lst = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var lstEven = new List<int>();
var lstOdd = new List<int>();