Let me pick the toothpaste for you
- Clone repository to
~/tpmand make it
Unix(Ubuntu):
make
Windows:
nmake.exe /f .\Makefile.msc
- Define available toothpastes in CSV format file with path
~/tpm/toothpastessee~/tpm/toothpastes.samplefor format details - Put TPM in daily crontab or task scheduler task to run it daily(or twice a day)
Windows:
schtasks /create /tn "TPM" /tr "C:\Program Files\tpm\tpm.exe" /sc daily /st 09:00
Unix(Ubuntu):
crontab -e
then add this line:
00 9 * * * /usr/local/bin/tpm
- Enjoy machine doing it for you
Tiny simple terminal console C program with maximum utility and zero maintenance burden
Good Morning Serenity Welcome to the toothpaste picking manager
Already picked today
Pick type: Default
Toothpaste: >>> SENSODYNE (150g) [100/100] <<< Day: Saturday 20512 Toothpaste index: 1/3
Total picks: 7 Last pick time: 1772266460
Press any key to continue . . .
{
"who":"Anonymous",
"toothpaste":"Unknown",
"tube_mass_g":666,
"rating":50
}
Because working with JSON without special library is complicated it outputs only 4 fields JSON
Basically it automatically answers the question "What toothpaste I should use today?" by picking it from predefined available toothpastes linked list using total epoch days mod total available toothpastes as list index I started coding it when found 3 different toothpaste tubes in the bathroom
It supports 8 toothpaste picking methods calling picking types:
Default, Random, By index, By Brand, Max rating, Max tube mass, Min rating, Min tube mas
Here is analog sqlite query that do default picking type:
SELECT * FROM toothpastes WHERE id=mod((SELECT CAST(unixepoch('now') / 86400 AS INTEGER)), (SELECT COUNT(*) FROM toothpastes)) LIMIT 1;Also pick.sql contains other sql queries for different pick methods.
The point is in fact you do not need sqlite postgres or lmdb to perform a single pick and sometimes even the single pick is more than enough
How many sqliters does it take to pick the toothpaste? NULL
-a pick toothpaste with highest rating
-w pick toothpaste with highest tube weight
-j output JSON with last pick info instead toothpaste picking string
-v show toothpaste picking manager version
-x perform random toothpaste pick
-q more quiet toothpaste pick
-l list available toothpastes
-r reset total toothpaste picks counter
-o pick_output_file output toothpaste picking string or JSON to text file pick_output_file
-c config_file load custom configuration file config file
-t pick_stats output pick stats to pick_stats file
-s [counter_value] set total toothpaste picks counter
-p [toothpaste_pick_type_value] set toothpaste pick type value
-i [toothpaste_index] pick toothpaste by index
-b [toothpaste_brand] pick toothpaste by brand
-z [delta_hours] set the timezone hours [-11,11] lag manually
-d [delta_days] pick toothpaste with default method in the future or the past
toothpastes_path path to toothpastes CSV file
Configuration is located in ~/tpm/tpm.conf file
It's options:
LOAD_CONFIG loads configuration file tpm.conf from specific path
USERNAME override username
PICK_TYPE set toothpaste pick type [0,7] number for Default, Random, By index, By brand, Max rating, Max tube mass, Min rating, Min tube mas
VERBOSE 0 for quiet toothpaste pick
TOOTHPASTES toothpastes list CSV full file name
LAST_PICK last pick file location
PICK_STATS pick stats file location
LIST_TOOTHPASTES 1 to list available toothpastes
OUTPUT_JSON 1 to output JSON with toothpaste pick
OUTPUT_FILE 1 to output to file ~tpm/last_pick
PICK_INDEX pick toothpaste by this index if PICK_TYPE=2
BRAND pick toothpaste by this brand if PICK_TYPE=3
RESET_COUNTER 1 to reset toothpaste pick counter
SET_COUNTER not 0 to set toothpaste pick counter
TIMEZONE set the timezone hours [-11,11] lag manually
DELTA_DAYS pick toothpaste with default method in the future or the past
[CONSTANTS]
LOAD_CONFIG="C:\Users\Anonymous\tpm\tpm.conf"
DEFAULT=0
TRUE=1
FALSE=0
[GENERAL]
USERNAME="Anonymous"
PICK_TYPE=DEFAULT
VERBOSE=TRUE
TOOTHPASTES="C:\Users\Anonymous\tpm\toothpastes"
LAST_PICK="C:\Users\Anonymous\tpm\last_pick"
PICK_STATS="C:\Users\Anonymous\tpm\pickstats"
LIST_TOOTHPASTES=FALSE
OUTPUT_JSON=FALSE
OUTPUT_FILE=FALSE
PICK_INDEX=0
RESET_COUNTER=FALSE
SET_COUNTER=0
BRAND=Unknown
TIMEZONE=0
DELTA_DAYS=0
~/tpm/toothpastes CSV toothpastes list
~/tpm/tpm.conf TPM configuration file
~/tpm/pickstats toothpaste pick stats binary file
~/tpm/last_pick last toothpaste pick output message string or JSON file
`
#Index,Brand string,Tube mass grams,Rating
0,Random Toothpaste 1,100,85
1,Random Toothpaste 2,50,90
2,Random Toothpaste 3,150,100
3,Random Toothpaste 4,50,100
4,Nothing,0,0
Sure you can pick anything this way not only toothpastes Food drink clothes gym exercises meds even linux commands moreover you can recursively pick the toothpaste pick type(method) itself but there is no meaning in it
P.S. Do not forget to brush your hard disk with dd and rm -rf / toothpastes twice a day