This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Built using gen AI | |
# https://x.com/i/grok/share/ECyhfrv2uFRV39tDT9izzKnop | |
DRY_RUN=false | |
TARGET_DIR="" | |
while [[ $# -gt 0 ]]; do | |
case $1 in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script installs or updates Zsh on Windows using Git Bash. | |
# It requires elevated privileges and the following commands: | |
# - git | |
# If Git is not installed, the script will stop. | |
# The script will: | |
# 1. Check if it is running with elevated privileges on Windows and stop if it is not. | |
# 2. Check if Git is installed and stop if it is not. | |
# 3. Automatically determine the latest version of zstd, download, and install it if it is not available and Zsh needs to be installed or updated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IEnumerable<IList<Type>> GetPermutations(IList<Type> arraySource, int takeArrayLength) | |
{ | |
// Short circuit process if take array length is 0 | |
if (takeArrayLength == 0) | |
{ | |
yield return Array.Empty<Type>(); | |
yield break; | |
} | |
var uniqueValues = new List<string>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2022 Nordin Rahman | |
# [@nordinrahman](https://twitter.com/nordinrahman) | |
# [@nordinrahman](https://www.facebook.com/nordinrahman) | |
# [@nordinrahman](https://www.linkedin.com/in/nordinrahman)) | |
# find files with pattern "*.cs" on current directory and sub directories recursively, then emit relative path to each found file, one file per line | |
# Use `find` command | |
# `.` refers to current directory | |
# `-name` is options flag to denote file name pattern | |
# `"*.cs"` wild card patterns to match files we are looking for |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git - list local branches except current branch and main/develop | |
# First, make sure we are on main/develop branch first | |
# This is to get all local branches excep current branch and main/develop without indentation | |
git br | grep -E "^ " | grep -Ev "^\\*" | sed s/^\ \ //g | grep -Ev "^(main|develop)$" | |
# delete all local branches as originally listed above | |
for BRANCH_NAME in $(git br | grep -E "^ " | grep -Ev "^\\*" | sed s/^\ \ //g | grep -Ev "^(main|develop)$") | |
do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
email = [email protected] | |
name = YOURNAME | |
[core] | |
autocrlf = true | |
editor = \"C:/Program Files/Notepad2/Notepad2.exe\" | |
pager = diff-so-fancy | less --tabs=4 -RFX | |
[diff] | |
algorithm = histogram | |
[i18n] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class MongoClientExtensions | |
{ | |
/// <summary> | |
/// Evaluates the specified javascript within a MongoDb database | |
/// </summary> | |
/// <param name="database">MongoDb Database to execute the javascript</param> | |
/// <param name="javascript">Javascript to execute</param> | |
/// <returns>A BsonValue result</returns> | |
public static async Task<BsonValue> EvalAsync(this IMongoDatabase database, string javascript) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rs.slaveOk(); | |
db.getCollectionNames().forEach(function(coll) { | |
db[coll].getIndexes().forEach(function(index) { | |
if ("_id_" !== index.name) { | |
print("db." + coll + ".createIndex(" + tojson(index.key) + ")"); | |
} | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New-Item c:/temp/msi -ItemType Directory | |
Invoke-WebRequest 'http://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi' -OutFile c:/temp/msi/WebPlatformInstaller_amd64_en-US.msi | |
Start-Process 'c:/temp/msi/WebPlatformInstaller_amd64_en-US.msi' '/qn' -PassThru | Wait-Process | |
cd 'C:/Program Files/Microsoft/Web Platform Installer'; .\WebpiCmd.exe /Install /Products:'UrlRewrite2,ARRv3_0' /AcceptEULA /Log:c:/temp/msi/WebpiCmd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GetUniqueId() | |
{ | |
return Convert.ToBase64String(Guid.NewGuid().ToByteArray()) | |
.Replace('+', '-') | |
.Replace('/', '_') | |
.TrimEnd('='); | |
} |
NewerOlder