Skip to content

Instantly share code, notes, and snippets.

View mirmostafa's full-sized avatar
🧗‍♂️
Coding is my lifestyle. But I live in Iran 😢

Mohammad Mirmostafa mirmostafa

🧗‍♂️
Coding is my lifestyle. But I live in Iran 😢
View GitHub Profile
@stephenhardy
stephenhardy / git-clearHistory
Created April 26, 2013 22:14
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin [email protected]:<YOUR ACCOUNT>/<YOUR REPOS>.git
@vkhorikov
vkhorikov / CustomerController.cs
Last active July 30, 2024 14:25
Handling failures and input errors in a functional way
[HttpPost]
public HttpResponseMessage CreateCustomer(string name, string billingInfo)
{
Result<BillingInfo> billingInfoResult = BillingInfo.Create(billingInfo);
Result<CustomerName> customerNameResult = CustomerName.Create(name);
return Result.Combine(billingInfoResult, customerNameResult)
.OnSuccess(() => _paymentGateway.ChargeCommission(billingInfoResult.Value))
.OnSuccess(() => new Customer(customerNameResult.Value))
.OnSuccess(
@DanielSWolf
DanielSWolf / Program.cs
Last active October 30, 2024 13:57
Console progress bar. Code is under the MIT License: http://opensource.org/licenses/MIT
using System;
using System.Threading;
static class Program {
static void Main() {
Console.Write("Performing some task... ");
using (var progress = new ProgressBar()) {
for (int i = 0; i <= 100; i++) {
progress.Report((double) i / 100);
@davidfowl
davidfowl / .NET6Migration.md
Last active December 2, 2024 11:08
.NET 6 ASP.NET Core Migration
@hamburger1984
hamburger1984 / MinimalAPIs.md
Created November 13, 2021 16:33 — forked from davidfowl/MinimalAPIs.md
Minimal APIs at a glance