Skip to content

Instantly share code, notes, and snippets.

@lucnap
lucnap / Fix-Curl-SQLite3-in-PHP-7.4-under-Windows.md
Created May 19, 2025 16:44 — forked from alecos71/Fix-Curl-SQLite3-in-PHP-7.4-under-Windows.md
How to fix errors generated by PHP 7.4 related to CURL & SQLite3 under Windows

Fix for CURL & SQLite3 under Windows on PHP 7.4

If you have just downloaded and configured PHP 7.4 and you want to use CURL and SQLite3 you could run into a serious PHP-generated error for the reason that both CURL and SQlite3 make use of an external library located in the PHP directory. First SQLite3 was integrated into PHP but from version 7.4 no longer. The errors are these:

PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlite'

PHP Warning: PHP Startup: Unable to load dynamic library 'sqlite3'

PHP Warning: PHP Startup: Unable to load dynamic library 'php_curl'

@lucnap
lucnap / since2010.md
Created March 22, 2025 11:38 — forked from shawwn/since2010.md
"What happened after 2010?"

This was a response to a Hacker News comment asking me what I've been up to since 2010. I'm posting it here since HN rejects it with "that comment is too long." I suppose that's fair, since this ended up being something of an autobiography.

--

What happened after 2010?

@lucnap
lucnap / gist:4c63c94480a58806c98d0f623802200c
Created September 27, 2020 07:48
Python: map field names to indices in database cursor
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
@lucnap
lucnap / gist:fc3b67f6120fc26f8696064fec94de03
Last active September 26, 2020 08:34
Compile python programs to Widows executable
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
@lucnap
lucnap / gist:a4c755b779e6c40b70115a593c4c2167
Created August 25, 2020 16:13
Node.Js search and replace in files in directory recursively
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));
@lucnap
lucnap / lunaenergianaz.php
Created April 24, 2020 14:27
Blocks outgoing order confirmation email
<?php
if (!defined('_PS_VERSION_')) {
exit;
}
class LunaEnergiaNaz extends Module {
@lucnap
lucnap / gist:c250be1333475736ddd77ad2dea854ef
Last active April 23, 2020 07:31
Cloudflare htaccess restrict IP
SetEnvIF CF-Connecting-IP "10.20.30.40" MySecretIP
<Files index.php>
order allow,deny
allow from env=MySecretIP
</Files>
@lucnap
lucnap / gist:d4f8884b51d48d7af651bf3485fd2302
Last active June 25, 2019 17:25
Resizing and Padding image to keep a constant aspect ratio with ImageMagick
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
@lucnap
lucnap / note su mysql
Created June 5, 2019 18:25
mysql secure passwords on command line
# 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
@lucnap
lucnap / PrefixFromCountryISO
Created June 3, 2019 11:31
Seleziona il giusto prefisso in base al codice ISO
strNazione = Doc.CustomField(584)
prefisso = ""
Select Case strNazione
Case "HU", "HUN"
prefisso = "36"
Case "UA", "UKR"
prefisso = "380"
Case "CH", "CHE"
prefisso = "41"