Skip to content

Instantly share code, notes, and snippets.

@promto-c
promto-c / Understanding_Python_Ellipsis.md
Last active March 28, 2025 11:26
Comprehensive Guide to the Ellipsis in Python: Usage, Examples, and Best Practices

Understanding the Ellipsis (...) in Python

Overview

The Ellipsis object, represented by ..., is a unique, singleton feature in Python's syntax, akin to None. It serves a variety of purposes in different contexts, ranging from a placeholder in code to a tool in advanced programming scenarios.

Table of Contents

  1. Placeholder for Incomplete Code
  2. Advanced Slicing in NumPy
  3. Type Hints for Variadic Parameters
  4. Custom Container Types
@Kludex
Kludex / main.py
Last active March 19, 2025 17:07
Run Gunicorn with Uvicorn workers in code
""" Snippet that demonstrates how to use Gunicorn with Uvicorn workers in code.
Feel free to run:
- `python main.py` - to use uvicorn.
- `ENV=prod python main.py` - to use gunicorn with uvicorn workers.
Reference: https://docs.gunicorn.org/en/stable/custom.html
"""
@meddokss
meddokss / Styled-components-error.md
Last active January 13, 2025 18:13
[Styled-components Error] Warning: React does not recognize the prop on a DOM element. #STYLED
Warning: React does not recognize the `isEditing` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `isediting` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
    in button (created by ForwardRef(Tab))
    in ForwardRef(Tab) (created by Context.Consumer)
    in StyledComponent (created by Styled(Component))
    in Styled(Component) (at App.js:14)

In the TextBox component you're passing all the props from the parent via {...props}. Considering that TextField itself doesn't have 'isEditing' property, I assume it passes it down to the underlying input DOM element, which doesn't recognise that prop.

@Hakky54
Hakky54 / openssl_commands.md
Last active April 25, 2025 10:21 — forked from p3t3r67x0/openssl_commands.md
OpenSSL Cheat Sheet

OpenSSL Cheat Sheet 🔐

Install

Install the OpenSSL on Debian based systems

sudo apt-get install openssl
@avinmathew
avinmathew / index.jsx
Created August 8, 2017 11:54
Multiple layouts with React Router v4
import React from "react"
import { Route, Switch } from "react-router-dom"
const AppRoute = ({ component: Component, layout: Layout, ...rest }) => (
<Route {...rest} render={props => (
<Layout>
<Component {...props} />
</Layout>
)} />
)
@nlm
nlm / macaddr.py
Created May 12, 2017 09:31
mac address <=> integer conversions in python
import re
def mac_to_int(mac):
res = re.match('^((?:(?:[0-9a-f]{2}):){5}[0-9a-f]{2})$', mac.lower())
if res is None:
raise ValueError('invalid mac address')
return int(res.group(0).replace(':', ''), 16)
def int_to_mac(macint):
if type(macint) != int:
@aviskase
aviskase / Postman.desktop
Last active January 22, 2025 01:08
Install Postman
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman
Icon=/home/USERNAME/Postman/app/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;
@logston
logston / env.py
Created August 8, 2016 01:50
A snippet for getting Alembic to recognize multiple model classes in multiple modules
# Inspired by http://liuhongjiang.github.io/hexotech/2015/10/14/alembic-support-multiple-model-files/
def combine_metadata():
from sqlalchemy import MetaData
import models # models file into which all models are imported
model_classes = []
for model_name in models.__all__:
model_classes.append(getattr(models, model_name))
@ostashevdv
ostashevdv / offer.md
Created February 13, 2016 12:54 — forked from greabock/offer.md
офферы

#"Немного о магазинах" или "Нам нужен еще один слой абстракции"

Дисклеймер :
-- А давай забацаем e-commerce! Нету же e-commerce на Ларе! Ну давай забацаем!
-- Уговорил - давай забацаем! А ты не сдуешься на пол-пути?
-- Да ну! Я же могу то и это - я вообще крутой. Будет самое крутое решение в истории php!
-- Ну ок, давай начнем...

И так... начнем с самого "ничего". Как обычно происходит сделка покупки, в самом обчном супермаркете? Покупатель заходит в торовый зал, выбирает товар, проходит на кассу и оплачивает его. Он отдает деньги, получает чек, после чего он имеет право вынести товар из торгового зала. Что тут необходимо, для полного цикла? Нужно некоторое множество товаров-сущностей, оплата-сделка(процесс), и чек(сделка-сущность). Для простоты, будем считать, что корзина реализована куками на стороне клиента. То есть: >

@major
major / ca.py
Last active February 27, 2025 09:45
Making a certificate authority (CA) with python cryptography
from cryptography import x509
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.x509.oid import NameOID
import datetime
import uuid
one_day = datetime.timedelta(1, 0, 0)
private_key = rsa.generate_private_key(
public_exponent=65537,