Skip to content

Instantly share code, notes, and snippets.

View viseshrp's full-sized avatar
👨‍💻
If it ain't broke, try fixing it.

Visesh Rajendraprasad viseshrp

👨‍💻
If it ain't broke, try fixing it.
View GitHub Profile
@fjsj
fjsj / celery_settings.py
Last active May 12, 2024 12:37
Recommended Celery Django settings for reliability. For more details, check the DjangoCon 2023 talk "Mixing reliability with Celery for delicious async tasks" by Flávio Juvenal: https://youtu.be/VuONiF99Oqc
# Recommended Celery Django settings for reliability:
# (use `app.config_from_object('django.conf:settings', namespace='CELERY')`
# in proj/celery.py module)
from decouple import config # use python-decouple: https://github.com/HBNetwork/python-decouple
# Prefer RabbitMQ over Redis for Broker,
# mainly because RabbitMQ doesn't need visibility timeout. See:
# https://blog.daftcode.pl/working-with-asynchronous-celery-tasks-lessons-learned-32bb7495586b
# https://engineering.instawork.com/celery-eta-tasks-demystified-424b836e4e94
@kconner
kconner / macOS Internals.md
Last active July 7, 2024 19:42
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@rolisz
rolisz / mic_check.py
Created February 2, 2023 15:41
Script to alert on microphone loudness
import time
from collections import deque
import numpy as np
import sounddevice as sd
from beepy import beep
from infi.systray import SysTrayIcon
last_alert = time.time() - 10
q = deque(maxlen=200)
@michalc
michalc / sqlite.py
Last active April 3, 2024 17:26
Use libsqlite3 directly from Python with ctypes: without using the built-in sqlite3 Python package, and without compiling anything
# From https://stackoverflow.com/a/68876046/1319998, which is itself inspired by https://stackoverflow.com/a/68814418/1319998
from contextlib import contextmanager
from collections import namedtuple
from ctypes import cdll, byref, string_at, c_char_p, c_int, c_double, c_int64, c_void_p
from ctypes.util import find_library
from sys import platform
def query(db_file, sql, params=()):
@dnburgess
dnburgess / gist:e00fc05a567f278828ff72b3e35ed3cc
Last active October 17, 2023 16:36
DB Tech Media Server Setup
---
version: "2"
services:
emby:
image: linuxserver/emby
container_name: emby
environment:
- PUID=998
- PGID=100
- TZ=America/Denver
@timothywarner
timothywarner / az900sg.md
Created October 15, 2020 12:31
AZ-900 Microsoft Azure Fundamentals Study Blueprint
@viseshrp
viseshrp / migrate-django.md
Last active June 24, 2019 15:43 — forked from sirodoht/migrate-django.md
How to migrate Django from SQLite to PostgreSQL

How to migrate Django from SQLite to PostgreSQL

Dump existing data:

python3 .\manage.py dumpdata --indent 2 --natural-primary --natural-foreign -o dump.json

[...........................................................................]

Change settings.py to Postgres backend.

@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active July 20, 2024 05:29
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
"""
Django ORM Optimization Tips
Caveats:
* Only use optimizations that obfuscate the code if you need to.
* Not all of these tips are hard and fast rules.
* Use your judgement to determine what improvements are appropriate for your code.
"""
# ---------------------------------------------------------------------------
@douglasmiranda
douglasmiranda / django-media-permissions.md
Last active May 16, 2023 10:33
Fix Django Media Folder Permissions

Check your current file/directory permission with:

stat -c "%a" /path/to/dir_or_file

To recursively give directories read&execute privileges:

find /path/to/base/dir -type d -exec chmod 755 {} +