Skip to content

Instantly share code, notes, and snippets.

View dojekon's full-sized avatar

Alexander dojekon

  • Saint-Petersburg
View GitHub Profile
@dojekon
dojekon / func.f90
Created February 10, 2022 19:27
Find Determinant
REAL(dp) FUNCTION FindDet(matrix, n)
IMPLICIT NONE
REAL(dp), DIMENSION(n,n) :: matrix
INTEGER, INTENT(IN) :: n
REAL :: m, temp
INTEGER :: i, j, k, l
LOGICAL :: DetExists = .TRUE.
l = 1
!Convert to upper triangular form
DO k = 1, n-1
@dojekon
dojekon / main.cs
Last active March 31, 2020 17:22
C#: Generate "Sec-WebSocket-Key"
static string GenerateWebSocketKey() {
byte[] code = new Byte[16];
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetBytes(code);
return Convert.ToBase64String(code);
}
@dojekon
dojekon / source.cs
Created December 12, 2019 23:49
Text frequency analysis C#
var Alphabet = Enumerable.Range('А', 32).Select(x => (char)x).ToArray();
string txt = Regex.Replace(text, "[#-.?!)(,: ]", "");
txt = txt.ToUpper();
Dictionary<char, double> Analysis = new Dictionary<char, double>();
int count = 0;
for (int i = 0; i < Alphabet.Length; i++) {
count = 0;
foreach (char letter in txt) {
if (letter == Alphabet[i])