Skip to content

Instantly share code, notes, and snippets.

View BlackHacked's full-sized avatar
📷
Hello World

Latin BlackHacked

📷
Hello World
View GitHub Profile
@BlackHacked
BlackHacked / tegra-cam.py
Created May 16, 2022 01:38 — forked from jkjung-avt/tegra-cam.py
Capture and display video from either IP CAM, USB webcam, or the Tegra X2/X1 onboard camera.
# --------------------------------------------------------
# Camera sample code for Tegra X2/X1
#
# This program could capture and display video from
# IP CAM, USB webcam, or the Tegra onboard camera.
# Refer to the following blog post for how to set up
# and run the code:
# https://jkjung-avt.github.io/tx2-camera-with-python/
#
# Written by JK Jung <[email protected]>
@BlackHacked
BlackHacked / README.md
Created May 16, 2022 04:01 — forked from bangonkali/README.md
Jetson Xavier NX Notes

Docker Snippets

Create a deepstream-l4t docker container instance.

sudo docker run -it \
  --rm \
  --net=host \
  --runtime nvidia \
 -e DISPLAY=$DISPLAY \
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
# GStreamer SDK Tutorials in Python
#
# basic-tutorial-2
#
"""
basic-tutorial-2: GStreamer concepts
http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+2%3A+GStreamer+concepts
"""
@BlackHacked
BlackHacked / mongo-docker-compose.yml
Created August 30, 2022 08:56 — forked from gbzarelli/mongo-docker-compose.yml
Initializing mongo db in docker-compose with init script
version: '3.8'
services:
# Database - Mongo DB
mongo:
image: mongo
environment:
MONGO_INITDB_ROOT_USERNAME: helpdev
MONGO_INITDB_ROOT_PASSWORD: 123456
@BlackHacked
BlackHacked / README.md
Created August 30, 2022 09:05 — forked from craig-m-unsw/README.md
Learn MongoDB with docker-compose
@BlackHacked
BlackHacked / README.md
Created August 30, 2022 09:06 — forked from WeltonThomasFerreira/README.md
MongoDB: Basic Shell and CRUD
@BlackHacked
BlackHacked / poetry-convert.py
Created September 5, 2022 02:29 — forked from tigerhawkvok/poetry-convert.py
Convert a requirements.txt file to a Poetry project
#!python3
"""
Convert a requirements.txt file to a Poetry project.
Just place in the root of your working directory and run!
"""
sourceFile = "./requirements.txt"
import re
import os
@BlackHacked
BlackHacked / logger.py
Created September 9, 2022 10:14 — forked from nkhitrov/logger.py
Configure uvicorn logs with loguru for FastAPI
"""Configure handlers and formats for application loggers."""
import logging
import sys
from pprint import pformat
# if you dont like imports of private modules
# you can move it to typing.py module
from loguru import logger
from loguru._defaults import LOGURU_FORMAT
@BlackHacked
BlackHacked / about.txt
Created November 3, 2022 10:01 — forked from jessejlt/about.txt
nginx, flask, and file downloads
Okay so here's the setup:
[-] The primary server API is exposed via Flask (Python) and all static files, including all html, css, js is served by nginx.
[-] Python is exposing an API at url http://domain.com/api/download/<file_id>, where file_id is a database id for the file that we're interested in downloading.
1. User wants to download a file, so we spawn a new window with the url '/api/download/<file_id>'
2. Nginx intercepts the request, sees that it starts with /api/, and then forwards the request to Flask, which is being served on port 5000.
3. Flask routes the request to its download method, retrieves the pertinent data from the file_id, and constructs additional header settings to make nginx happy and to force the browser to see the file stream as a download request instead of the browser just trying to open the file in a new window. Flask then returns the modified header stream to nginx
4. Nginx is finally ready to do some work. While parsing the headers for the incoming request, it encounters "X
# https://pawamoy.github.io/posts/unify-logging-for-a-gunicorn-uvicorn-app/
import sys
import logging
from loguru import logger
__all__ = ("setup_logging",)
_LOG_FORMAT = "{time:YYYY-MM-DD HH:mm:ss} <lvl>| {level: ^6} |</> {message}"