Skip to content

Instantly share code, notes, and snippets.

View Xor-el's full-sized avatar
🏠
Working from home

Ugochukwu Mmaduekwe Xor-el

🏠
Working from home
View GitHub Profile
@Xor-el
Xor-el / .travis.yml
Created February 2, 2018 20:57 — forked from petrbel/.travis.yml
Travis-CI submodules
# Use https (public access) instead of git for git-submodules. This modifies only Travis-CI behavior!
# disable the default submodule logic
git:
submodules: false
# use sed to replace the SSH URL with the public URL, then init and update submodules
before_install:
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
@Xor-el
Xor-el / Base64_HMACSHA2_256
Created June 30, 2018 11:30
Sample Demo For Someone.
program Base64_HMACSHA2_256;
uses
SysUtils,
HlpIHashInfo,
HlpConverters,
HlpHashFactory,
SbpBase64;
var
@Xor-el
Xor-el / ULogicalCPUCount.pas
Last active February 25, 2019 07:47
Get True CPU Count For Windows, Linux and MAC OSX
unit ULogicalCPUCount;
// http://wiki.lazarus.freepascal.org/Example_of_multi-threaded_application:_array_of_threads#1._Detect_number_of_cores_available.
{ Copyright (c) 2018 by Ugochukwu Mmaduekwe
Distributed under the MIT software license, see the accompanying file LICENSE
or visit http://www.opensource.org/licenses/mit-license.php.
}
{$IFDEF FPC}
@Xor-el
Xor-el / result.txt
Created June 17, 2019 17:21
payload encryption result
For AES
AES Payload Length is 223, ENC is 240
AES Payload Length is 224, ENC is 256
Current KeyType Is "SECP256K1"
Base58 Public Key is "3GhhbosVBRMsQMvLY1Cn5guy2cNWzimvvDD1GACZ57sDCRCS7emamBWnCohZgT3C3WzryVqkxnLYC27cEjtzjh2hrcnza2ndWVyfmW"
Payload Length is 191, ENC is 247
Payload Length is 192, ENC is 263
@Xor-el
Xor-el / ECDSAKeyGenDemo.lpr
Created January 8, 2020 09:18
ECDSA KeyGen Sample using CryptoLib4Pascal
program ECDSAKeyGenDemo;
uses
SysUtils,
ClpSecureRandom,
ClpISecureRandom,
ClpRandomNumberGenerator,
ClpCryptoApiRandomGenerator,
ClpICryptoApiRandomGenerator,
ClpCustomNamedCurves,
@Xor-el
Xor-el / program.cs
Created August 13, 2022 23:38
StableSort
static class Program
{
static void Main()
{
var unsorted = new[] {
new Person { BirthYear = 1948, Name = "Cat Stevens" },
new Person { BirthYear = 1955, Name = "Kevin Costner" },
new Person { BirthYear = 1952, Name = "Vladimir Putin" },
new Person { BirthYear = 1955, Name = "Bill Gates" },
new Person { BirthYear = 1948, Name = "Kathy Bates" },
@Xor-el
Xor-el / BlogContext.cs
Created November 10, 2022 22:15 — forked from manoj-choudhari-git/BlogContext.cs
.NET Core - EF Core - Concurrency Check attribute and Fluent API
// Database Entity - User
public class User
{
public int Id { get; set; }
public string FirstName { get; set; }
// Data Annotation for specifying concurrency token
// Uncomment below line if you want to use data annotation instead of fluent API
// [ConcurrencyCheck]
@Xor-el
Xor-el / Program.cs
Last active June 19, 2023 13:52
GreatCircleDistance
const double EarthRadiusInKm = 6371; // km
double lat1 = 6.524379;
double lat2 = 6.342450;
double lon1 = 3.379206;
double lon2 = 5.633840;
Console.WriteLine(ComputeDistanceBetweenTwoPointsUsingHaversineFormulaModeA(lat1, lat2, lon1, lon2));
Console.WriteLine(ComputeDistanceBetweenTwoPointsUsingHaversineFormulaModeB(lat1, lat2, lon1, lon2));
Console.WriteLine(ComputeDistanceBetweenTwoPointsUsingSphericalLawOfCosines(lat1, lat2, lon1, lon2));
@Xor-el
Xor-el / QueryableExtensions.cs
Created September 15, 2023 18:53 — forked from jacobsimeon/QueryableExtensions.cs
IQueryable Extensions for ordering by a property specified by a string
using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace JacobSimeon.Extensions
{
public static class IQueryableExtensions
@Xor-el
Xor-el / IQueryableExtensions.cs
Created November 24, 2023 15:58 — forked from ErikEJ/IQueryableExtensions.cs
Replacement for EF Core .Contains, that avoids SQL Server plan cache pollution
using System.Linq.Expressions;
namespace Microsoft.EntityFrameworkCore
{
public static class IQueryableExtensions
{
public static IQueryable<TQuery> In<TKey, TQuery>(
this IQueryable<TQuery> queryable,
IEnumerable<TKey> values,
Expression<Func<TQuery, TKey>> keySelector)