Skip to content

Instantly share code, notes, and snippets.

@oscarychen
oscarychen / Django_hierarchical_tree_data.md
Last active April 22, 2024 05:50
Storing and retrieving tree data structure efficiently in Django - the materialized path approach

Working with hierarchical / tree data structure in PostgresSQL and Django

There are two typical models for dealing with tree data structure in SQL databases: adjacency list model and nested set model. There are several packages for Django that implements these models such as django-mptt, django-tree-queries, and django-treebeard.

In this article, I want to explain a different approach I took in a project for storing hierachichal data, as well as search and retrieval of sub-trees. This approach is similar in principle to materialzed path, which django-treebeard package also provides an implementation. This article will show you how I achieved this without any of the specific packages, and using on

@ih2502mk
ih2502mk / list.md
Last active July 26, 2024 05:14
Quantopian Lectures Saved
@amir734jj
amir734jj / confluent-interview-questions.txt
Last active July 17, 2024 09:16
confluent-interview-questions
Glassdoor questions:
- Given a game to you which is running on an instance and hasMySQL installed on it locally, now with the game popularity increasing, suggest ways that it stays highly secure and highly available and then with every step he was adding more things on it, like we want to use JWT on it, should we use it? session maintenance etc.
- URL shortener in Go
- MRU cache implementation in java or Go
- Distributed Systems, Coding Comprehension
- garbage collection in Java
- SFDC related experience
- debounce function
- Memory management for Java applications
@alukach
alukach / app.yaml
Last active July 24, 2024 13:54
An example Github Actions for Python + Pipenv + Postgres + Pyright
# .github/workflows/app.yaml
name: My Python Project
on: push
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 10
services:
@hakib
hakib / admin.py
Last active January 22, 2024 15:18
How to Turn Django Admin Into a Lightweight Dashboard
# https://hakibenita.com/how-to-turn-django-admin-into-a-lightweight-dashboard
from django.contrib import admin
from django.db.models import Count, Sum, Min, Max, DateTimeField
from django.db.models.functions import Trunc
from . import models
def get_next_in_date_hierarchy(request, date_hierarchy):
@william8th
william8th / .tmux.conf
Last active July 22, 2024 12:43
Tmux open new pane in same directory
# Set the control character to Ctrl+Spacebar (instead of Ctrl+B)
set -g prefix C-space
unbind-key C-b
bind-key C-space send-prefix
# Set new panes to open in current directory
bind c new-window -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
@kanhua
kanhua / README.md
Last active February 1, 2023 17:08
A template of writing C or C++ extension for python and numpy

This gist demonstrates how to setup a python project that process a numpy array from C language.

To compile the project, run

make all

To test it, run

make test