This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I needed this function because the `connect` function of the `sqlite3` python module DOES NOT, | |
# and I repeat DOES NOT, verify that the file passed as a parameter is really an sqlite3 database file! | |
# If you open grandma's soup recipe in recipe.txt the `connect` function will not raise an error!!! | |
# The only way I found to REALLY determine if a file is, or isn't, an sqlite3 dbase file, is the following method: | |
# IF the first 16 bytes match the string b'SQLite format 3\x00' then it REALLY is a sqlite3 file!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Having recently approached Nim's language, I'm bringing back some 'goodies' that I will surely need in the future. | |
The first is the `connect` function of the `std/db_sqlite` library | |
If you try to open a sqlite3 database file with: | |
var dbase = open("DBase/IChing.db") | |
you will have a lot of problems. For Nim the correct way to open a sqlite3 database file is: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Disk volumes CONSTANTS sets | |
# | |
Disco01="/Volumes/1st Time Capsule/" # Mount point first device: adapt | |
Device01="4AB05D67-2513-4EAB-8AC0-C258A4FBE1E4" # UID for first device | |
Disco02="/Volumes/2nd Time Capsule/" # Mount point second device: adapt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
def countdown(t): | |
''' | |
Defines a countdown and prints always in the same position che counter | |
''' | |
while t: | |
mins, secs = divmod(t, 60) | |
timer = '{:02d}:{:02d}'.format(mins, secs) | |
print(timer, end="\r") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isSQLite3(filename: str) -> bool: | |
``` | |
I needed this function because the `connect` function of the `sqlite3` python module DOES NOT, | |
and I repeat DOES NOT, verify that the file passed as a parameter is really an sqlite3 database file! | |
If you open grandma's soup recipe in recipe.txt the `connect` function will not raise an error!!! | |
The only way I found to REALLY determine if a file is, or isn't, an sqlite3 dbase file, is the following | |
method: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# Why importing tons of functions, when I can import the only the 6 I need? | |
from sys import exit | |
from random import choice | |
from string import ascii_letters, digits, punctuation | |
# | |
# Using try - except trap to verify if input data is a number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function recurDir dir, ext | |
set the defaultFolder to dir | |
repeat for each line fi in the files | |
if fileExt(fi) = ext then | |
put the longfilepath of fi & cr after fileList | |
end if | |
end repeat | |
repeat for each line di in the folders | |
if di is not "." and di is not ".." then | |
put recurDir((dir & slash & di), ext) & cr after fileList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
try: | |
import pymysql | |
except: | |
print("Devi installare la libreria di MySQL.") | |
print("Esegui: pip install pymysql da terimale") | |
exit(-9) | |
print(f'Libreria SQLite3 e PyMySQL caricate!) | |
return() |