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 / 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',
@roymanigley
roymanigley / setup.sh
Last active October 1, 2023 19:35
Setup after Endever OS installation
#!/bin/bash
echo "[+] SETUP STARTED"
echo "[+] SET VARIABLES"
NVM_VERSION=v0.39.3
JETBRAINS_TOOLBOX_VERSION=1.28.1.15219
JAVA_VERSION=21-open
GIT_USERNAME=royman
GIT_EMAIL='roy.manigley@gmail.com'
@roymanigley
roymanigley / selenium-python.md
Last active June 17, 2023 19:53
Selenium with Python

Selenium with Python

Setup

python -m venv .env
source .env/bin/activate
pip install selenium
pip freeze > requirements.txt
@roymanigley
roymanigley / jinja-exmple.md
Last active June 3, 2023 23:19
Jinja2 - Simple Template Engine

Jinja2 - Simple Template Engine

The Template

{% for name in names %}
{% if name | length == 3 %}
Hello {{ name[1:] | upper }}
{% else %}
Hello {{ name }}

{% endif%}