Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Focusing

Prayson Wilfred Daniel Proteusiq

:octocat:
Focusing
View GitHub Profile
View poetry_setup.sh
#!/bin/bash
sudo apt update -y
sudo apt install git gcc make openssl libssl-dev \
libbz2-dev libreadline-dev libsqlite3-dev zlib1g-dev \
libncursesw5-dev libgdbm-dev libc6-dev zlib1g-dev libsqlite3-dev \
tk-dev libssl-dev openssl libffi-dev \
-y
# install
@Proteusiq
Proteusiq / datacache.py
Created July 10, 2021 06:42
Share objects
View datacache.py
import json
import zlib
from typing import Any, Optional, Dict
import diskcache as dc
class DataCache:
def __init__(
self,
cache_path: str,
View datavalidator.py
from datetime import datetime
from uuid import UUID, uuid4
from typing import Literal, Optional, Union
from pydantic import BaseModel, Field, ValidationError, validator, constr, confloat
class HouseDataValidation(BaseModel):
id: Union[int, UUID] = Field(default_factory=uuid4)
kind: Literal["villa", "apartment", "townhouse"]
View images_to_pdf.py
from pathlib import Path
from PIL import Image
# get all png images from folder `gotoslides`
SLIDES_IMAGES = Path("gotoslides").glob("*.png")
# maybe use a generator | convert RGB (since its png)
images = [Image.open(image).convert("RGB") for image in SLIDES_IMAGES]
with open("gotoslides.pdf", "wb") as pdf_file:
View pd_conventers.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View get_pdf.py
# Using pyPDF2 and requests(or httpx) to extract PDF data
import io
import requests
import PyPDF2
# my favorite Kierkegard's PDF book
URI = "https://antilogicalism.com/wp-content/uploads/2017/07/thesicknessuntodeath.pdf"
headers = {"user-agent": "Prayson W. Daniel: prayson*at*.com"}
View goodread.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View SMA.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View everything_conda.md
View compress_csv.py
from pathlib import Path
import pandas as pd
DATA_FOLDER = Path("data")
# get all csv files in data and its subfolders
for csv_file in DATA_FOLDER.rglob("*.csv"):
csv_full_path = csv_file.resolve()