Skip to content

Instantly share code, notes, and snippets.

View EgorBron's full-sized avatar

Egor Bron EgorBron

View GitHub Profile
@JNNGL
JNNGL / generator.py
Last active April 19, 2024 01:47
Animated emojis in vanilla Minecraft
#!/usr/bin/python3
import math
import argparse
from PIL import Image
def build_frames(gif, animation_seconds):
num_frames = math.floor(gif.n_frames)
frame_width, frame_height = gif.size
@fergdev
fergdev / SegmentedButtons.kt
Last active April 26, 2024 15:57
SegmentedButtons implementation for M3
package ferg.segmented.buttons
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.core.tween
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
@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(
@itspacchu
itspacchu / handle_smear.gd
Created September 4, 2022 15:27
Smear effect in godot
extends MeshInstance
var mat;
var prev_position;
var zpos = 10;
func _ready() -> void:
mat = self.get_active_material(0)
prev_position = translation
print(mat)
@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]
@genekogan
genekogan / scrapeImages.py
Created February 22, 2017 11:49
scraping full size images from Google Images
from bs4 import BeautifulSoup
import requests
import re
import urllib2
import os
import argparse
import sys
import json
# adapted from http://stackoverflow.com/questions/20716842/python-download-images-from-google-image-search
@eevee
eevee / perlin.py
Last active March 2, 2024 08:48
Perlin noise in Python
"""Perlin noise implementation."""
# Licensed under ISC
from itertools import product
import math
import random
def smoothstep(t):
"""Smooth curve with a zero derivative at 0 and 1, making it useful for
interpolating.