Skip to content

Instantly share code, notes, and snippets.

@angelyordanov
angelyordanov / BulstatEikValidation.cs
Created February 9, 2024 10:27
Bulstat EIK validation implemented in C# in T-SQL
using System.Text.RegularExpressions;
namespace Erpy.Domain;
// based on https://tsvetanv.wordpress.com/2011/04/01/eik/
public partial class BulstatEikValidation
{
private static readonly int[] FIRST_SUM_9DIGIT_WEIGHTS = [1, 2, 3, 4, 5, 6, 7, 8];
private static readonly int[] SECOND_SUM_9DIGIT_WEIGHTS = [3, 4, 5, 6, 7, 8, 9, 10];
private static readonly int[] FIRST_SUM_13DIGIT_WEIGHTS = [2, 7, 3, 5];
@angelyordanov
angelyordanov / disk.sh
Created June 23, 2023 08:58
Check macbook SSD life
brew install smartmontools
smartctl -a disk3s1
@angelyordanov
angelyordanov / OrdinalNumbers.cs
Last active November 16, 2022 08:44
числителни редни имена
public class OrdinalNumbers
{
public static string GetOrdinal(int number)
=> $"{number}{GetOrdinalSuffix(number)}";
public static string GetOrdinalSuffix(int number)
=> number < 0
? ""
: (number % 100) switch
{
@angelyordanov
angelyordanov / NonClosingStreamWrapper.cs
Last active October 26, 2021 11:32
.NET Standard 2.1 version of Jon Skeet's NonClosingStreamWrapper
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Tools
{
// based on NonClosingStreamWrapper class from Jon Skeet's MiscUtil library
// https://jonskeet.uk/csharp/miscutil/
@angelyordanov
angelyordanov / Update-machine-certificate-private-key-permissions.ps1
Created June 1, 2021 14:59 — forked from milesgratz/Update-machine-certificate-private-key-permissions.ps1
PowerShell example of updating machine certificate private key permissions (CAPI vs CNG)
# Get cert on local computer by thumbprint
$thumbprint = '89D3FC64B6405E161EDC7A4CF14E111F5F6895AA'
$Cert = Get-ChildItem Cert:\LocalMachine\My | Where-Object { $_.Thumbprint -eq $thumbprint }
###################################################
# Manage private key of CAPI cert
###################################################
# Find private key
$privKey = $Cert.PrivateKey.CspKeyContainerInfo.UniqueKeyContainerName
@angelyordanov
angelyordanov / concatenate.vb
Last active January 21, 2020 10:44
Concatenate a range selection(number of rows) into the top rows' cells
Option Explicit
Sub Concatenate()
Dim rSelected As Range
Dim col As Range
Dim c As Range
Dim first As Boolean
'Prompt user to select cells for formula
On Error Resume Next
@angelyordanov
angelyordanov / bnb_USDBGN_Q1Q2Q3Q4.sh
Created January 11, 2020 11:14
BNB USDBGN excels exports Q1,Q2,Q3,Q4 of a given year
year=2019
curl "https://www.bnb.bg/Statistics/StExternalSector/StExchangeRates/StERForeignCurrencies/index.htm?downloadOper=true&group1=second&periodStartDays=01&periodStartMonths=01&periodStartYear=$year&periodEndDays=31&periodEndMonths=03&periodEndYear=$year&valutes=USD&search=true&showChart=false&showChartButton=true&type=MS-Excel" \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36' \
-H 'Sec-Fetch-User: ?1' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
-H 'Sec-Fetch-Site: same-origin' \
-H 'Sec-Fetch-Mode: navigate' \
@angelyordanov
angelyordanov / curl_webpage.sh
Created December 23, 2019 10:27
cUrl get webpage html every 2 seconds
while :; \
do \
curl 'https://google.com/' \
-H 'Connection: keep-alive' \
-H 'Upgrade-Insecure-Requests: 1' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36' \
-H 'Sec-Fetch-User: ?1' \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
-H 'Sec-Fetch-Site: none' -H 'Sec-Fetch-Mode: navigate' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9,bg;q=0.8' \
--compressed \
@angelyordanov
angelyordanov / build_signTextJS.md
Last active December 27, 2022 13:38
BTrust MacOS setup

Building signTextJS

  1. Clone https://github.com/angelyordanov/signTextJS
  2. Run travis/osx..install script or open it and run the steps manually
  3. Run travis/osx..script
  4. If all goes well you'll have a signtextjs_plus-0.0.0-macos.dmg in the repo root