Skip to content

Instantly share code, notes, and snippets.

View dmmeteo's full-sized avatar
🦄
I may be slow to respond.

Dmitry Sichkar dmmeteo

🦄
I may be slow to respond.
View GitHub Profile
@dmmeteo
dmmeteo / langswitcher.lua
Created November 4, 2023 20:21
Hammerspoon configuration to switch keyboard languages with shortcuts(left CMD, right CMD, right Option)
-- Hammerspoon configuration to switch keyboard languages with shortcuts
-- Table to keep track of the last modifiers and if another key was pressed
local lastModifiers = {}
local otherKeyPressed = false
-- Function to handle single taps on modifier keys
local function singleTapHandler(event)
local newModifiers = event:getFlags()
local keyCode = event:getKeyCode()

Keybase proof

I hereby claim:

  • I am dmmeteo on github.
  • I am dmmeteo (https://keybase.io/dmmeteo) on keybase.
  • I have a public key whose fingerprint is BD70 163E B7C2 2D0E 4D24 6D43 FD24 D397 6A4B 37B7

To claim this, I am signing this object:

@dmmeteo
dmmeteo / mem.py
Created July 15, 2020 13:28 — forked from britonad/mem.py
A dummy decorator function to measure memory usage of a Python function, method, etc.
import resource
from functools import wraps
def mem_it(func):
@wraps(func)
def wrapper(*args, **kwargs):
print(
'Pre-memory usage: {} (mb)'.format(
resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1024
@dmmeteo
dmmeteo / README.md
Last active September 30, 2020 22:14
Raspberry pi image boot setup

Raspberry PI setup image for remote access

Install image on SD

  • Go to downloads and select image
  • Use sudo lsblk -p to list all mounted devices, and select your SD
  • Use sudo umount /dev/your-SD-device
  • Use sudo dd if=image.img of=/dev/your-SD-device status=progress to install image on SD

More details you can find in documentation.

@dmmeteo
dmmeteo / docker-compose.yml
Created December 12, 2019 22:21
jenkins-dockerized
version: '3'
services:
docker-registry:
container_name: docker-registry
image: registry:2
ports:
- 5000:5000
restart: always
volumes:
@dmmeteo
dmmeteo / 1.srp.py
Last active April 23, 2024 15:09
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):

drf-cheat-sheet

A collection of anything from basics to advanced recommended methods and usages with Django REST Framework for creating browsable and awesome web API's. This could also serve as a quick reference guide.

Here is DRF's official documentation in case you need everything in detail.

Why Django REST Framework?

Summarized from the official docs:

  • Web browsable API
  • Serialization that supports ORM and non-ORM data sources.

This repository is trending on Github since some days now. Watch it, we will add many updates in the future. Thank you for your support.

Check the website.

Read this in other languages: English, Russian.

Table of Contents

Cheatsheet for Django QuerySets

Current Django Version: 2.2

Methods that return new QuerySets

Can be chained:

Entry.objects.filter(**kwargs).exclude(**kwargs).order_by(**kwargs)