Skip to content

Instantly share code, notes, and snippets.

@DiogenesAnalytics
DiogenesAnalytics / Dockerfile
Created July 15, 2024 14:26
Coral Edge TPU test example executed in Docker for Coral USB Accelerator
# ref: https://www.jeffgeerling.com/blog/2023/testing-coral-tpu-accelerator-m2-or-pcie-docker
# base image
FROM debian:10
# setting workdir
WORKDIR /home
# setting home var
ENV HOME=/home
#!/bin/bash
cd /
sudo apt update
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
@DiogenesAnalytics
DiogenesAnalytics / rename_clips.py
Created June 18, 2024 13:22
Mass rename Nest Camera clips
import os
import re
from datetime import datetime
# Directory containing the files
directory = "."
# Compile a regex to match the date string within the filename
filename_regex = re.compile(r"Clip \((June \d+ \d+ at \d+ [APM]+)\)\.mp4")
@DiogenesAnalytics
DiogenesAnalytics / lognormal_distribution_example.ipynb
Last active June 5, 2024 13:49
Log-normal distribution example
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DiogenesAnalytics
DiogenesAnalytics / country-codes.csv
Last active May 31, 2024 19:19 — forked from ilyankou/country-codes
200 ISO2/ISO3 Country Codes
Country ISO2 ISO3
Afghanistan AF AFG
Albania AL ALB
Algeria DZ DZA
Andorra AD AND
Angola AO AGO
Antigua and Barbuda AG ATG
Argentina AR ARG
Armenia AM ARM
Australia AU AUS
@DiogenesAnalytics
DiogenesAnalytics / pop_us_state_2024.csv
Created April 10, 2024 16:03
Scraping US state population data from Wikipedia
Rank in states & territories 2020 Rank in states & territories 2010 State Census population April 1 2020 Census population April 1 2010 Percent change 2010–2020 Absolute change 2010-2020 Total seats in the U.S. House of Representatives 2023–2033 Census population per electoral vote Census population per House seat Percent of the total U.S. population 2020
1 1 California 39538223 37253956 6.1 2284267 52 732189 760350 11.80
2 2 Texas 29145505 25145561 15.9 3999944 38 728638 766987 8.70
3 4 Florida 21538187 18801310 14.6 2736877 28 717940 769221 6.43
4 3 New York 20201249 19378102 4.2 823147 26 721473 776971 6.03
5 6 Pennsylvania 13002700 12702379 2.4 300321 17 684353 764865 3.88
6 5 Illinois 12812508 12830632 −0.1 −18124 17 674343 753677 3.82
7 7 Ohio 11799448 11536504 2.3 262944 15 694085 786630 3.52
8 9 Georgia 10711908 9687653 10.6 1024255 14 669494 765136 3.20
9 10 North Carolina 10439388 9535483 9.5 903905 14 652462 745671 3.12
@DiogenesAnalytics
DiogenesAnalytics / housing_median_data_2024.csv
Last active April 9, 2024 21:09
Scraping US median housing price data from Wikipedia
State rank State or territory Median home price in US$
1 Hawaii 839013
2 California 765197
District of Columbia 610548
3 Massachusetts 596410
4 Washington 575894
5 Colorado 539151
6 Utah 509433
7 New Jersey 503432
8 Oregon 487244
1121626442617525638896469365204664247501599960310398038627990792596284687698743380622957
2209779188677188609150030608307967172253122239294586767384591202483591042846633577530824
0829901428881306806240345858146070760165464394277349438425259295985184033811932887512921
8874371253216938692354667898460679828857322845279172293050149627602996509432031528555129
0948951887436577983062851277410469745608567139909366579565288243103466469746111413792212
4711144924293674736658788279678045689527359272010093601818695480904492084305860025585377
8562784953961347444734826024699272536356963629620054217295680350211955074974059938429585
3505234086766542419121570129395853535498039722171718942708085014958104044477266404590953
5280346967027244804097593515797784038047871347787155300686957877243716606005943688292750
0572287609615343699498050300689672513862196215363250794576355157541984075414988216121807
@DiogenesAnalytics
DiogenesAnalytics / convert_2_mp4.sh
Created February 22, 2024 21:20
Converting all .webm to .mp4 using ffmpeg
for file in *.webm; do
# Generate output file name with mp4 extension
output_file="${file%.webm}.mp4"
# Convert webm to mp4 using ffmpeg, re-encoding the streams
ffmpeg -i "$file" -c:v libx264 -c:a aac "$output_file"
done
@DiogenesAnalytics
DiogenesAnalytics / cut.sh
Created February 22, 2024 16:05
Cut a video in half using ffmpeg.
duration=$(ffprobe -i $1 -show_entries format=duration -v quiet -of csv="p=0")
half_duration=$(echo "$duration / 2" | bc)
ffmpeg -i $1 -map 0 -c copy -f segment -segment_time $half_duration -reset_timestamps 1 output_half%d.mp4