Skip to content

Instantly share code, notes, and snippets.

View parsalotfy's full-sized avatar
🙂

Parsa parsalotfy

🙂
View GitHub Profile
@teleginski
teleginski / ExpressionBuilder.cs
Last active June 5, 2024 16:11
C# .NET - Expression Builder - Dynamic Filter - Dynamic Where
public static class ExpressionBuilder
{
private static readonly MethodInfo containsMethod = typeof(string).GetMethod("Contains");
private static readonly MethodInfo toLowerMethod = typeof(string).GetMethod("ToLower", new Type[0] { });
public static Func<T, bool> GetExpression<T>(IList<Filter> filters)
{
ParameterExpression parameter = Expression.Parameter(typeof(T), "t");
Expression expression = null;
@gunjanpatel
gunjanpatel / revert-a-commit.md
Last active June 11, 2024 19:48
Git HowTo: revert a commit already pushed to a remote repository

Revert the full commit

Sometimes you may want to undo a whole commit with all changes. Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. Just like above, the bad commit remains there, but it no longer affects the the current master and any future commits on top of it.

git revert {commit_id}

About History Rewriting

Delete the last commit

Deleting the last commit is the easiest case. Let's say we have a remote origin with branch master that currently points to commit dd61ab32. We want to remove the top commit. Translated to git terminology, we want to force the master branch of the origin remote repository to the parent of dd61ab32:

@kmorcinek
kmorcinek / .gitignore
Last active June 13, 2024 22:44
.gitignore for C# projects
# The following command works for downloading when using Git for Windows:
# curl -LOf http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
#
# Download this file using PowerShell v3 under Windows with the following comand:
# Invoke-WebRequest https://gist.githubusercontent.com/kmorcinek/2710267/raw/ -OutFile .gitignore
#
# or wget:
# wget --no-check-certificate http://gist.githubusercontent.com/kmorcinek/2710267/raw/.gitignore
# User-specific files