Skip to content

Instantly share code, notes, and snippets.

View zedr's full-sized avatar
👾

Rigel Di Scala zedr

👾
View GitHub Profile
@zedr
zedr / streamlit0.py
Created February 14, 2025 10:53
Stream with Matplotlib
import time
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# Generate sample data
def generate_data():
np.random.seed(42)
@zedr
zedr / crawler.py
Last active February 12, 2025 17:01
Trivial crawler for books.toscrape.com
import sys
import time
import json
from pathlib import Path
import pandas as pd
import requests
from bs4 import BeautifulSoup
# Creo un set: https://docs.python.org/3/tutorial/datastructures.html#sets
@zedr
zedr / data.csv
Created February 5, 2025 11:26
data.csv
QuotaAmount Month Agent Username
150000 1 Chris Riley [email protected]
2000 2 Chris Riley [email protected]
500 3 Chris Riley [email protected]
50000 1 Harold Campbell [email protected]
1000 2 Harold Campbell [email protected]
150000 3 Harold Campbell [email protected]
4000 1 Jessica Nichols [email protected]
6000 2 Jessica Nichols [email protected]
0 3 Jessica Nichols [email protected]
@zedr
zedr / students.csv
Last active February 5, 2025 11:59
students.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 1 column, instead of 2 in line 3.
id;first_name;last_name;year_of_birth;gender;email;assignments
1;John;Doe;2000;M;[email protected];12
2;Jane;Smith;2001;F;[email protected];8
3;Sarah;Thomas;2000;F;[email protected],1
4;Frank;Brown;2000;M;[email protected];3
8;Mike;Davis;1999;M;[email protected];4
9;Jennifer;Wilson;2002;F;[email protected];3
10;Jessica;Garcia;2000;F;[email protected];4
11;Jane;Clark;2001;F;[email protected];
12;Bob;Lopez;2000;M;[email protected];1
@zedr
zedr / linked_lists_tests.py
Last active January 29, 2025 11:00
linked_lists_tests.py
# Implement a file named linked_lists.py
from linked_lists import LinkedList, Node
# Part 1 - tests for the nodes of a linked list
head_node = Node("Napoli")
assert head_node.next is None
head_node.next = Node("Rome")
@zedr
zedr / run.sh
Created November 28, 2022 08:09
Cam
#!/usr/bin/env bash
screen -dmS cam ffmpeg -i /dev/video2 -f v4l2 -pix_fmt yuv420p -filter:v "hflip,crop=460:320:100:120" -an /dev/video5
@zedr
zedr / bash.sh
Last active October 15, 2023 09:31
Bash defaults
#!/usr/bin/env bash
set -o pipefail
set -o errexit
set -o nounset
dir1=${1:-}
dir2=${2:-}
usage() {
@zedr
zedr / Makefile
Last active March 18, 2022 10:44
A make file for Python projects
.PHONY: default clean deps
ENV=.env
_PYTHON=python3
PYTHON_VERSION=$(shell ${_PYTHON} -V | cut -d " " -f 2 | cut -d "." -f1-2)
SITE_PACKAGES=${ENV}/lib/python${PYTHON_VERSION}/site-packages
PYTHON=${ENV}/bin/python3
IN_ENV=source ${ENV}/bin/activate ;
default: deps
@zedr
zedr / main.c
Created January 5, 2022 17:18
Simple bit counter for 32bit integers
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int
count_bits(int n)
{
int l, c;
l = 0;
c = 0;
@zedr
zedr / netbox.py
Last active September 10, 2020 04:47
Ansible AWX Inventory Script example for NetBox (Py2 and Py3 compatible)
#!/usr/bin/env python
from __future__ import print_function, unicode_literals
import six
import json
import argparse
from collections import defaultdict
from six.moves.urllib.parse import urlencode, urlparse