Skip to content

Instantly share code, notes, and snippets.

View roymanigley's full-sized avatar
💭
...still coding

Roy Manigley roymanigley

💭
...still coding
View GitHub Profile
@roymanigley
roymanigley / config
Last active July 21, 2024 10:52
i3 config file
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
@roymanigley
roymanigley / views.py
Last active July 16, 2024 23:04
Django ModelForm Template Views
from core.models import Person, Address
from django.forms import ModelForm, widgets
from django.views.generic.edit import UpdateView, CreateView, DeleteView
from django.views.generic.list import ListView
class PersonForm(ModelForm):
class Meta:
model = Person
@roymanigley
roymanigley / styles.css
Last active July 16, 2024 23:05
Simple CSS styling for Django Templates
/*
{% load static %}
<html>
<head>
<link rel="stylesheet" href="{% static 'styles.css' %}">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<nav>
<h1>My App</h1>
@roymanigley
roymanigley / Dockerfile
Created June 22, 2024 17:45
Python - Jupiter Notebook using Docker
FROM python:3.9-alpine
RUN apk update && apk upgrade
RUN apk add gcc python3-dev musl-dev linux-headers
RUN pip install pip --upgrade
RUN pip install jupyter pandas matplotlib seaborn
RUN adduser -S jupyter
RUN mkdir /opt/jupyter
@roymanigley
roymanigley / example-test.md
Created April 6, 2024 06:23
Python UnitTest

Unit Testing with python

run a unit test

by defailt il looks for files starting with test

python -m unittest

if you want to check for othepatterns you can pass them like this:

@roymanigley
roymanigley / django-profiling.md
Created March 26, 2024 06:35
Django Profiling

Django Profiling

Dependencies

requirements.txt

django-cprofile-middleware==1.0.5
django-silk==5.1.0
snakeviz==2.2.0
pyprof2calltree==1.4.5
@roymanigley
roymanigley / sorting.py
Last active January 2, 2024 13:57
Sorting Algorithms
import time
import os
import random
def main():
LENGTH = 185
MAX = 50
arr = [random.randint(1,MAX) for i in range(LENGTH)]
HeapSort.sort(arr)
@roymanigley
roymanigley / Simple-JWT.md
Last active December 25, 2023 13:06
Django Rest Framework Simple JWT setting tokens in cookie

Django Rest Framework Simple JWT

Installation

django-admin startproject simple_jwt
cd simple_jwt

python -m venv .env
source .env/bin/activate
@roymanigley
roymanigley / pika_helper.py
Created October 24, 2023 17:57
A helper class to initialize pika consumers and publisher
import logging
from pika import BlockingConnection, ConnectionParameters, PlainCredentials
from concurrent.futures import Executor
LOG = logging.getLogger(__name__)
class RabbitMqConnection(object):
@roymanigley
roymanigley / angular-content-projection.md
Last active October 3, 2023 21:27
Angular Content Projection and debounce time

Angular Content Projection and debounce time

dropdown.component.ts

import { Component, ContentChild, Input, OnDestroy, OnInit, TemplateRef } from '@angular/core';
import { EMPTY, Observable, Subject, catchError, debounceTime, map, tap } from 'rxjs';

@Component({
  selector: 'app-dropdown',
  templateUrl: './dropdown.component.html',