Skip to content

Instantly share code, notes, and snippets.

View archatas's full-sized avatar

Aidas Bendoraitis archatas

View GitHub Profile
@yakky
yakky / pico.py
Last active March 16, 2018 09:36
Micro hello world Python Web Framework Royal Rumble @PyCon 7
import django
DEBUG, ROOT_URLCONF, DATABASES, SECRET_KEY = 1, 'pico', {'default': {}}, 'p'
urlpatterns = [django.conf.urls.url(r'^(?P<name>\w+)?$', lambda request,
name: django.http.HttpResponse('hello %s!' % (name or 'world')))]
@oinopion
oinopion / deco.py
Last active October 14, 2025 20:29
Use contextmanager to create a decorator
# Read docs here: https://docs.python.org/3/library/contextlib.html
>>> from contextlib import contextmanager
>>>
>>>
>>> @contextmanager
... def deco_and_cm():
... print('Hello')
... yield
... print('Goodbye')
...
@ojii
ojii / please-include-a-repro.md
Last active January 24, 2023 00:01 — forked from Rich-Harris/please-include-a-repro.md
Please include a repro

Please include a repro

You probably arrived here because of a curt message in response to an issue you filed on a repo that I contribute to. Sorry about that (particularly if you filed the issue long ago and have been waiting patiently for a response). Let me explain:

I work on a lot of different open source projects. I really do like building software that makes other people's lives easier, but it's crazy time-consuming. One of the most time-consuming parts is responding to issues. A lot of OSS maintainers will bend over backwards to try and understand your specific problem and diagnose it, to the point of setting up new test projects, fussing around with different Python versions, reading the documentation for build tools that we don't use, debugging problems in third party dependencies that appear to be involved in the problem... and so on. I've personally spent hundreds of hours of my free time doing these sorts of things to try and help people out, because I want to be a responsible maintainer and

@naotokui
naotokui / emoji_regex.py
Created May 19, 2017 04:21
find unicode emoji in python regex
import re
emoji_pattern = re.compile(
u"(\ud83d[\ude00-\ude4f])|" # emoticons
u"(\ud83c[\udf00-\uffff])|" # symbols & pictographs (1 of 2)
u"(\ud83d[\u0000-\uddff])|" # symbols & pictographs (2 of 2)
u"(\ud83d[\ude80-\udeff])|" # transport & map symbols
u"(\ud83c[\udde0-\uddff])" # flags (iOS)
"+", flags=re.UNICODE)
@Copser
Copser / messages.html
Created July 2, 2017 06:59 — forked from DmytroLitvinov/messages.html
[Django middleware for AJAX messages] Middleware for JSON responses. It adds to each JSON response array with messages from django.contrib.messages framework. It allows handle messages on a page with javascript. Django 1.10. #tags: django, python, ajax
<div id="messages">
{% for message in messages %}
<div {% if message.tags %}class="alert alert-dismissable alert-{{ message.tags }}"{% endif %}>
<a class="close" data-dismiss="alert" href="#">&times;</a>
{{ message }}
</div>
{% endfor %}
</div>
@archatas
archatas / emojis-for-git-commits.md
Last active August 15, 2020 06:09
Emojis for Git Commits

✨ - New feature

👾 - Bugfix

🎨 - UI and style

🔨 - Code refactoring, dependency upgrade, improving code quality

🚧 - Work in progress

@ejlp12
ejlp12 / gist:059373f1785c52114d778a4ee7277ccb
Created October 25, 2017 01:45
upgrade vagrant on mac os-x
brew cask reinstall vagrant
# this might take a long time
vagrant plugin update
# http://names.mooseroots.com/stories/5165/most-popular-gender-neutral-names
Avery
Riley
Peyton
Logan
Taylor
Ryan
Jordan
Cameron
@MarkusH
MarkusH / b64uuid.py
Created July 10, 2019 22:06
Base64 Encoding of UUIDs
>>> import base64, binascii, uuid
>>>
>>> def encode(uid: uuid.UUID) -> str:
... return base64.urlsafe_b64encode(uid.bytes).decode().rstrip("=")
...
>>> def decode(uid: str) -> uuid.UUID:
... return uuid.UUID(binascii.b2a_hex(base64.urlsafe_b64decode(uid_b64 + "==")).decode())
...
>>> uid = uuid.UUID("12546fd8-6dd9-4923-9c0a-f1fefadd3e2b")
>>> uid
@cjies
cjies / vapid_helper.py
Created November 22, 2019 04:44
Python based VAPID key-pair generator
import base64
import ecdsa
def generate_vapid_keypair():
"""
Generate a new set of encoded key-pair for VAPID
"""
pk = ecdsa.SigningKey.generate(curve=ecdsa.NIST256p)
vk = pk.get_verifying_key()