Skip to content

Instantly share code, notes, and snippets.

View EgorBron's full-sized avatar

Egor Bron EgorBron

View GitHub Profile
@EgorBron
EgorBron / g4f.ipynb
Last active October 5, 2023 15:32
Usage of gpt4free in Google Colab
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@EgorBron
EgorBron / SieveOfEratosthenes.cs
Created February 4, 2023 16:52
Implementation of the "Sieve of Eratosthenes" algorithm for generating prime numbers up to N in C#
/// <summary>
/// Implementation of the "Sieve of Eratosthenes" algorithm for generating prime numbers up to N in C#
/// </summary>
public static class SieveOfEratosthenes {
/// <summary>
/// Checking for a prime number with <see cref="Sieve(int)"/>
/// </summary>
/// <param name="num">Number to check</param>
/// <returns>Is <paramref name="num"/> prime number or not</returns>
@EgorBron
EgorBron / pyasyncs_async.py
Last active November 17, 2022 16:31
Асинхронность в Pyhton на примере готовки завтрака
import asyncio, time
from typing import List
class Toast:
is_fried = False
with_butter = False
with_jam = False
def start_fry(self):
print("Начинаем готовить тост.")
def end_fry(self):
@EgorBron
EgorBron / AdvFormat.cs
Last active June 20, 2023 13:03
Advanced (and better) keyword-based format (with extension methods) for C# (and other .NET languages)
namespace AdvFormat;
/// <summary>
/// Advanced (and better) keyword-based format (with extension methods)
/// </summary>
public static class AdvFormat {
/// <summary>
/// Format string from dict with keywords
/// </summary>
/// <param name="srcStr">Source string (string to format)</param>
/// <param name="format">Dictionary, where keys is keyword for format, and values is values!</param>
@EgorBron
EgorBron / blockchain.py
Created September 24, 2022 17:44
"Blockchain" on Python. Created using lessons by Oleg Molchanov (but code here is slightly improved and minified).
import json as j, hashlib, os
def chinteg():
res = []
for f in [str(i) for i in sorted([int(ii) for ii in os.listdir('./blocks/')])][1:]:
h = j.load(fi:=open('./blocks/'+f, 'r'))['hash']; fi.close()
with open('./blocks/'+str(int(f)-1), 'rb') as fp: h2 = hashlib.md5(fp.read()).hexdigest()
res.append((int(f)-1, h2 == h))
return res
@EgorBron
EgorBron / random_password_in_1_line.py
Last active March 10, 2024 18:39
Generate random password using just one line of Python code!
# pyperclip is recommended (pip install pyperclip)
# you can replace `__import__("pyperclip").copy(...)` with just `print(...)`
# one line verson
__import__("pyperclip").copy("".join(__import__('random').choices(__import__('string').printable[:-6], k=24))) # ; print("Generated"); __import__("time").sleep(3)
# "prettier" version
__import__("pyperclip").\
copy(
"".join(
@EgorBron
EgorBron / Freecam.cs
Last active February 4, 2023 16:56
Simple Freecam (or "Noclip") camera for Godot C# API. Простая свободная (или "ноуклип") камера для Godot C# API.
using Godot;
/// <summary>
/// Freecam (or "Noclip") camera / Свободная (или "ноуклип") камера
/// </summary>
public class Freecam : Camera {
[Export]
public float speed = 1; // Cam movement speed / Скорость движения
[Export]
public float sensivity = .01f; // Mouse sensivity / Сенса (чувствительность) мыши
[Export]