This file contains hidden or 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
//install this nuget: https://www.nuget.org/packages/RulesEngine | |
using RulesEngine.Extensions; | |
using RulesEngine.Models; | |
var rules = new List<Rule>(); | |
rules.Add(new Rule() | |
{ | |
RuleName = "Weekend Rule", | |
SuccessEvent = "Weekend Schedule", |
This file contains hidden or 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
function levenshteinDistance(arr1, arr2) { | |
const m = arr1.length; | |
const n = arr2.length; | |
const maxLength = Math.max(m, n); | |
// Create a matrix to store the distances | |
const dp = new Array(m + 1).fill(null).map(() => new Array(n + 1).fill(0)); | |
// Initialize the matrix | |
for (let i = 0; i <= m; i++) { |
This file contains hidden or 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
using Microsoft.IdentityModel.Tokens; | |
using System.IdentityModel.Tokens.Jwt; | |
using System.Security.Cryptography; | |
using System.Security.Cryptography.X509Certificates; | |
/* | |
Use the following command to generate a proper self signed certificate | |
openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -sha256 -days 365 -nodes | |
-nodes removes the password requirement |
This file contains hidden or 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
require 'openssl' | |
def generate_hmac_sha256(secret_key, payload) | |
OpenSSL::HMAC.hexdigest('SHA256', secret_key, payload) | |
end | |
# Example usage | |
secret_key = 'your-secret-key' | |
payload = 'your-payload' | |
digest = generate_hmac_sha256(secret_key, payload) |
This file contains hidden or 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
using Microsoft.AspNetCore.Authentication.JwtBearer; | |
using Microsoft.AspNetCore.Authorization; | |
using Microsoft.IdentityModel.Tokens; | |
using System.IdentityModel.Tokens.Jwt; | |
using System.Security.Claims; | |
using System.Text; | |
var builder = WebApplication.CreateBuilder(args); | |
// Add services to the container. |
This file contains hidden or 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
//first version | |
using System.Runtime.InteropServices; | |
[DllImport("user32.dll", SetLastError = true)] | |
static extern IntPtr OpenDesktop(string lpszDesktop, uint dwFlags, bool fInherit, uint dwDesiredAccess); | |
[DllImport("user32.dll", SetLastError = true)] | |
static extern bool CloseDesktop(IntPtr hDesktop); | |
[DllImport("user32.dll", SetLastError = true)] |