Skip to content

Instantly share code, notes, and snippets.

package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"strings"
)
const msg = "The SHA256 for this sentence begins with: "
@erdnaxeli
erdnaxeli / example.py
Created July 27, 2023 15:41
Testing private methods vs composition
from unittest.mock import create_autospec, call
########################################
# Only one class with private methodes #
########################################
class Everything:
def do_something(self, x: int) -> int:
from unittest.mock import create_autospec, call
########################################
# Only one class with private methodes #
########################################
class Everything:
def do_something(self, x: int) -> int:
import matplotlib.pyplot as plt
import numpy as np
def plot(points, label):
dates = [p[0] for p in points]
y = 100
values = []
for _, augment in points:
y *= 1 + augment / 100
@erdnaxeli
erdnaxeli / matrix.py
Created November 19, 2020 14:35
Minimal Matrix example
#!/usr/bin/env python3
import logging
import requests
logging.basicConfig(level=logging.INFO)
def primal(n):
factors = []
d = 2
while n > 1:
while n % d == 0:
factors.append(d)
n = n / d
d += 1
@erdnaxeli
erdnaxeli / n.sh
Last active August 29, 2015 14:11
#!/bin/bash
function printDotted() {
echo -n $@
for i in $(seq $[$RANDOM % 10]); do
echo -n '.'
sleep 0.1
done
# -*- coding: utf-8 -*-
#
# Purpose:
# Extend the date parsing capabilities of Ruby to work with dates with international month names.
#
# Usage:
#
# Date.parse_international(date_string)
# DateTime.parse_international(date_string)
# date_string.to_international_date