Skip to content

Instantly share code, notes, and snippets.

View Davis-3450's full-sized avatar
🐱
meow

Davis Davis-3450

🐱
meow
View GitHub Profile
@Davis-3450
Davis-3450 / download_mp4.sh
Created October 24, 2025 19:50
ytd commands
-S res,ext:mp4:m4a --recode mp4
class WorkHour(int, Enum):
WORK_START = 8
LUNCH_START = 12
LUNCH_END = 13
WORK_END = 17
def is_working_hour(self) -> bool:
t = date.time()
morning_ok = time(WorkHour.WORK_START.value, 0) <= t < time(WorkHour.LUNCH_START.value, 0)
afternoon_ok = time(WorkHour.LUNCH_END.value, 0) <= t < time(WorkHour.WORK_END.value, 0)
@Davis-3450
Davis-3450 / conversions.txt
Created September 16, 2025 02:11
hormone conversion factors
## Universal
- nmol/L -> pmol/L = 1000
- pmol/L -> nmol/L = 0.001
- ng/mL -> ng/dL = 100
- ng/dL -> ng/mL = 0.01
- ng/mL -> pg/mL = 1000
- pg/mL -> ng/mL = 0.001
## Hormone specific
import argparse
import os
import re
import subprocess
import sys
from pathlib import Path
def repo_root() -> Path:
return Path(__file__).resolve().parent
@Davis-3450
Davis-3450 / structs2.rs
Created August 17, 2025 00:13
Rustlings structs 2
// Clone trait
// structs by default don't allow cloning, if we add this trait we can allow it and implement an alternative fix to this
#[derive(Debug, Clone)]
struct Order {
name: String,
year: u32,
made_by_phone: bool,
made_by_mobile: bool,
made_by_email: bool,
@Davis-3450
Davis-3450 / dfs.py
Created August 15, 2025 21:18
DSA snippets
def dfs(obj, key) -> dict | list | None:
"""
Finds an item and returns values
Args:
obj (dict | list): object
key (str): target key
Returns:
dict | list | None
"""
# Handle dicts
@Davis-3450
Davis-3450 / ModeToggle.tsx
Last active August 7, 2025 05:11
Theme switch for astro.
import * as React from "react";
import { Moon, Sun } from "lucide-react";
import { Button } from "@/components/ui/button"; // shadcn button
export function ModeToggle() {
const [theme, setThemeState] = React.useState<"light" | "dark">("light");
// Initialize theme from localStorage or DOM
React.useEffect(() => {
---
description: "Use shadcn/ui components as needed for any UI code"
patterns: "*.tsx"
---
# Shadcn UI Components
This project uses @shadcn/ui for UI components. These are beautifully designed, accessible components that you can copy and paste into your apps.
## Finding and Using Components
// 1) Abre el diálogo de compartir
const openBtn = document.querySelector('div[role="button"][aria-label="Send this to friends or post it on your profile."]');
if (openBtn) {
const e1 = new MouseEvent('click', {bubbles: true, cancelable: true, view: window});
openBtn.dispatchEvent(e1);
// 2) Espera un momento a que aparezca el botón “Share now”
setTimeout(() => {
const shareBtn = document.querySelector('div[role="button"][aria-label="Share now"]');
if (shareBtn) {
const e2 = new MouseEvent('click', {bubbles: true, cancelable: true, view: window});
from stem import Signal
from stem.control import Controller
import requests
class TorController:
def __init__(self, control_port=9051):
self.control_port = control_port
self.local_ip = f"127.0.0.1{control_port}"