Skip to content

Instantly share code, notes, and snippets.

Create an app to display comment threads with Django 🧵

We'll build a simple app to display comment threads using Django in 10 minutes.

This includes:

  • creating a form for users to add comments.
  • using the Gravatar API to give users profile images.
  • adding data into the Django database from yaml to seed the app with comments using the Django loaddata management command.
  • using an LLM to generate the comment data.
#![crate_type="lib"]
#![crate_name="btree"]
const BTREE_ORDER: usize = 5;
const MEDIAN_NODE: usize = (BTREE_ORDER - 1) / 2;
pub trait TreeNode<T, K, N: TreeNode<T, K, N>> {
fn insert(&self, key: T, value: K) -> (T, N);
}
pub struct InteriorNode<T, K, N: TreeNode<T, K, N>> {
impl OptimizedQuery {
pub fn new(query: &Query, lengths: &Vec<u32>) -> OptimizedQuery {
let mut offsets = vec![];
let mut last_length = 0;
for length in lengths {
offsets.push(last_length + length);
last_length = *length;
}
OptimizedQuery {
let mut records = vec![];
while reader.read_line(&mut s).unwrap() > 0 {
let line = s.clone();
let line: Vec<&str> = line.trim().split("\t").collect();
let mut matched = true;
for (column, filter_types) in &filters {
let exact = filter_types.get("exact").unwrap();
let contains = filter_types.get("contains").unwrap();
let col = header_map.get(column).unwrap();