Skip to content

Instantly share code, notes, and snippets.

View alirezanet's full-sized avatar
🏠
Working from home

AliReZa Sabouri alirezanet

🏠
Working from home
View GitHub Profile
@alirezanet
alirezanet / aws.ps1
Last active April 8, 2024 13:32
This PowerShell script automates the retrieval of AWS credentials via SSO login and saves them to the .aws/credentials file. Supports fetching credentials for all profiles, specific profiles, and listing available profiles.
param(
[string] $Session = "my-session",
[string] $Region = "eu-west-1",
[string] $Profile = "default",
[Parameter(Mandatory = $false, Position = 0)]
[string]$Mode = "help"
)
function Login {
@alirezanet
alirezanet / SortBenchmark.cs
Last active July 17, 2023 09:37
Sorting Algorithms example in C#
// BenchmarkDotNet=v0.13.2, OS=Windows 11 (10.0.22000.1098/21H2)
// 11th Gen Intel Core i5-11400F 2.60GHz, 1 CPU, 12 logical and 6 physical cores
// .NET SDK=6.0.402
// [Host] : .NET 6.0.10 (6.0.1022.47605), X64 RyuJIT AVX2
// DefaultJob : .NET 6.0.10 (6.0.1022.47605), X64 RyuJIT AVX2
//
//
// | Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
// |-------------- |-----------:|---------:|---------:|------:|--------:|-------:|----------:|------------:|
// | InsertionSort | 131.3 ns | 0.43 ns | 0.36 ns | 0.29 | 0.00 | - | - | 0.00 |
@ds1371dani
ds1371dani / gridify.ts
Last active September 21, 2022 03:14
Gridify query builder for typescript
import { GridifyConditionEnum, GridifyLogicalEnum, GridifyOrderEnum, FilterType, OperatorType, FiltersType } from "./types.ts";
function trimEnds(query: string): string {
let result = query;
// There should not be any starting or ending operator
if (result.startsWith(GridifyLogicalEnum.And)) result = result.slice(GridifyLogicalEnum.And.length);
if (result.startsWith(GridifyLogicalEnum.Or)) result = result.slice(GridifyLogicalEnum.Or.length);
if (result.endsWith(GridifyLogicalEnum.And)) result = result.slice(0, -GridifyLogicalEnum.And.length);
if (result.endsWith(GridifyLogicalEnum.Or)) result = result.slice(0, -GridifyLogicalEnum.Or.length);
return result;
@jonpulsifer
jonpulsifer / toggle-virtualization.bat
Last active June 17, 2024 17:30
Virtualization must be disabled to use CS:GO anti-cheat clients like FACEIT and ESEA, but I like to use WSL2 and Docker, and this script helps me do that
@echo off
echo Virtualization must be disabled to use anti-cheat clients like FACEIT and ESEA
echo.
net session >nul 2>&1
if %ERRORLEVEL% EQU 0 goto :chchchchoices
echo This script requires elevated privileges. Re-run as Administrator to continue
goto :exit
:chchchchoices
@alirezanet
alirezanet / Iran96-97.json
Last active March 17, 2024 14:41
List of provinces, states and cities of Iran with geographical coordinates (96-97 update)
[
{
"latitude": "34° 31' 24.924",
"longitude": "50° 0' 20.866",
"province": "مرکزی",
"state": "آشتیان",
"city": "آشتیان"
},
{
"latitude": "33° 40' 29.197",
@tomzorz
tomzorz / Enable_vt100_csharp.cs
Created April 12, 2017 19:26
Enable VT100 for the current console window from .NET Core
using System;
using System.Runtime.InteropServices;
namespace Vt100Test
{
public class Program
{
// ReSharper disable InconsistentNaming
@sloanlance
sloanlance / git-temporary-ignore.md
Last active March 2, 2024 01:32
git: A couple ways to temporarily ignore changed or new files without altering .gitignore.

There are times notifications aren't wanted about either a changed repo file or a new file that needs to be added to the repo. However, adding the name of the file to .gitignore might not be a good option, either. For example, locally-generated files that other users aren't likely to generate (e.g., files created by an editor) or files of experimental test code might not be appropriate to appear in a .gitignore file.

In those cases, use one of these solutions:

  1. If the file is a changed repo file

    Use the command:

    git update-index --assume-unchanged "$FILE"