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 generatefieldmap(cursor): | |
""" Given a DB API 2.0 cursor object that has been executed, returns | |
a dictionary that maps each field name to a column index; 0 and up. """ | |
results = {} | |
column = 0 | |
for d in cursor.description: | |
results[d[0]] = column | |
column = column + 1 |
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
Install PyInstaller | |
if using Virtual Env (very likely) compile spcifying the folder of the modules | |
Example: | |
pyinstaller main.py --paths venv\Lib\site-packages --onefile | |
otherwise you will get an error of module not found when moving the executable to another machine | |
This is very useful when using libraries like MySQLdb for example | |
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
const fs = require('fs'); | |
const path = require('path'); | |
const walkSync = (dir, filelist = []) => { | |
fs.readdirSync(dir).forEach(file => { | |
filelist = fs.statSync(path.join(dir, file)).isDirectory() | |
? walkSync(path.join(dir, file), filelist) | |
: filelist.concat(path.join(dir, 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
<?php | |
if (!defined('_PS_VERSION_')) { | |
exit; | |
} | |
class LunaEnergiaNaz extends Module { |
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
SetEnvIF CF-Connecting-IP "10.20.30.40" MySecretIP | |
<Files index.php> | |
order allow,deny | |
allow from env=MySecretIP | |
</Files> |
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
Resizing and Padding image to keep a constant aspect ratio with ImageMagick | |
This command center any given image in an area of 768x1024 and resize to fit the aspect ratio 768x1024 | |
magick mogrify -resize 768x1024 -background "#fff" -gravity center -extent 768x1024 *Copia.jpg | |
Example Batch file, ResizeAndPadImage.bat |
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
# impostare la password in modo sicuro con il seguente | |
mysql_config_editor set --login-path=mypath1 --host=localhost --user=username --password | |
# questo al fine di poter utilizzare mysqldump in modo sicuro con | |
mysqldump --login-path=mypath1 nomeDelDataBase > /path/dove/metto/i/backup/nomeDelDatabase.sql |
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
strNazione = Doc.CustomField(584) | |
prefisso = "" | |
Select Case strNazione | |
Case "HU", "HUN" | |
prefisso = "36" | |
Case "UA", "UKR" | |
prefisso = "380" | |
Case "CH", "CHE" | |
prefisso = "41" |
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
<?php | |
$host = 'localhost'; | |
$user = 'root'; | |
$pass = '--------------'; | |
$db = 'rmadata'; | |
$conn = new mysqli($host, $user, $pass, $db); | |
$thisword = "\r\n"; |
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
<?php | |
/* | |
Generic functions to paginate data from a database select and from json data | |
thanks to | |
https://stackoverflow.com/a/23910460 | |
https://stackoverflow.com/a/3707457 | |
http://www.sqlitetutorial.net/sqlite-sample-database/ | |
*/ |
NewerOlder