Skip to content

Instantly share code, notes, and snippets.

View shmalex's full-sized avatar

Alexei Matusevski shmalex

View GitHub Profile
@shmalex
shmalex / wald_test-shift.py
Last active April 14, 2024 13:11
Wald Test
import numpy as np
import matplotlib.pyplot as plt
def simulate_bernoulli_trials(p, n):
return np.random.binomial(1, p, n)
def wald_test_statistic(data, p_null):
p_hat = np.mean(data)
se = np.sqrt(p_hat * (1 - p_hat) / len(data))
return (p_hat - p_null) / se
// Даны три целые числа a, b, c больше 0.
// Есть два варианта либо добавлять b к a (a+=b), либо добавлять a к b (b+=a).
// В результате получаются новые значение а и b.
// Напишите программу, которая выведет YES или NO в зависимости от того можете ли получить значение c, добавляя a к b или b к a друг к другу.
var a = 5;
var b = 7;
var c = 123;
/*
@shmalex
shmalex / docker.md
Last active November 7, 2023 16:45
docker
@shmalex
shmalex / users.md
Last active November 7, 2023 14:33
Ubuntu User Management

List users

https://www.godaddy.com/help/remove-a-linux-user-19158

cat /etc/passwd

Each row represents a user and the fields separated by the colon (:) has the following meaning:

  • User name
  • Password, x means that a password is set for the user
  • User ID (UID)
  • User's group ID (GID)
@shmalex
shmalex / ssh bp.md
Created August 28, 2023 14:03
ssh keys and stuff

Add key to agent

run the agent process

eval $(ssh-agent)

ssh-add [key]

redo when restated

@shmalex
shmalex / config.md
Last active November 7, 2023 11:03
ssh config help

Generate your key and copy to server

ssh-keygen

Copy to server

linux:

ssh-copy-id -i ~/.ssh/mykey user@host -p 22

windows:

@shmalex
shmalex / git.sh
Created August 24, 2023 09:37
GitHub Routines
# New github ssh key
ssh-keygen -t rsa -b 4096 -C "fancy-email@banana.com" -f outputfile
# calculate the SHA265 of the public key
ssh-keygen -lf outputfile.pub
@shmalex
shmalex / random_password.py
Created August 24, 2023 09:09
random password generator
import numpy as np
import time
import sys
import argparse as ap
from collections import Counter as cnt
def rule_inrow(psw):
p = ''
for i in psw:
if p == i:
@shmalex
shmalex / sum_of_matrix.py
Last active August 15, 2023 13:29
Sum of Ones in Matrix 2^n by 2^(n+1)
import numpy as np
def sum_of_bins_greater_then(n):
print("n =",n)
left = []
for i in range(2**n):
left += [sum(int(x) for x in bin(i)[2:])]
up = []
for i in range(2**(n+1)):
up += [sum(int(x) for x in bin(i)[2:])]
print("Matrix shape", len(left),'x',len(up))
import pandas as pd
import numpy as np
import math
from matplotlib import pyplot as plt
# data file should have one column with price data
df = pd.read_csv('../data/ninja-trade/data.txt')
col = 'close'
period = 9