Sometimes you have a file with tens or hundreds of lines of text and you need to wrap each line with double quotes and a comma so that it can be easily put inside a javascript array. This can happen for example if your data is rows in a spreadsheet. Here’s how you can go from a list of lines to a quoted, comma separated list:
Continue reading “Convert lines of text to an array format”How to keep using port 10080 after many browsers block it as an unsafe port
If you have been doing web development using port 10080 you might have run into some issues recently since many browsers including Chrome and Firefox have decided to add that port to their blocked ports list.
I use a tool called InstantWP for WordPress development and it’s using port 10080 for http by default.
I first researched the option to change the ports IWP is using. It seems like it could be done from the config file which you can open from the “Advanced” tab by clicking “Edit Config File”. In the file that opens you should see a setting called PortOffset. I tried to change that but couldn’t get it to work even after trying many different numbers for the port offset.
I also tried to add a flag into Chrome’s startup parameters by right-clicking the Chrome icon and choosing properties. Then I replaced the value under “target” with the following string:
“C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” –explicitly-allowed-ports=10080
However that didn’t seem to fix the situation in my case. I still got the same “unsafe port” error from Chrome.
What finally helped was switching to Firefox and performing these steps:
- Type about:config to the address bar and click on the “accept the risk and continue” button.

Then paste in this string to the search bar:
network.security.ports.banned.override

Choose “string” as the type (I know, number would seem more logical), click on the + button and enter the port number you want to allow (in my case 10080).
Now you should be able to access applications via that port!
Increment integer value in a database field using WPDB
Sometimes you need to update values incrementally in your WordPress database. You might for example have an upvote feature to which you automatically add points in an incremental fashion.
It was surprisingly hard to find examples of how to do this using Wpdb. But here’s an example of doing just that:
/* Have to use wpdb->query instead of wpdb->update because the latter assumes strings */
$results = $wpdb->query($wpdb->prepare("UPDATE foodsenglish SET popularity = popularity + 1 WHERE dbID = %d", $foodIdToSendThePointFor), ARRAY_A);
Installing Duplicator packages in Instant WordPress
TIP: If you forgot to include the installer.php file, you can unzip the zipped archive and copy the “installer-backup.php” file from there and just rename it “installer.php”.
In the Duplicator FAQ they recommend uploading the packages through the “theme folder” button in IWP. That didn’t really make a difference in my tests though (I just uploaded the files by copy-pasting with SFTP Net Drive). Note that the installer will throw an error if there are other files present in the installation folder so make sure you delete the old WordPress files. Unfortunately even with these steps we seem to get stuck on Step 3. I recommend checking the error log if this happens. You might need to install php-xml with sudo apk add php-xml. Or you might have to update your PHP version if you are getting errors like this;
INSTALLER ERROR: [PHP ERR][FATAL] MSG:Uncaught Error: Call to undefined function token_get_all() in /var/www/localhost/htdocs/wordpress/duplicator/dup-installer/lib/config/class.wp.config.tranformer.php:387
That wasn’t the main problem in my case though (it seems like a function should be enabled “By web host”).
If you get an error when trying to install that the folder doesn’t have write permissions, do the following: Check the working directory you are in with “pwd” and the contents of the folder you are currently in with “ls”. You might have to elevate yourself to root user with sudo -s and the type in cd /var/. If you can see “var” in the list, then cd into it with cd var. You can cd into localhost even if it’s not listed with cd localhost. You shouldn’t need to change folder permissions here, but if you need to do that in some other situation, you can use chmod like in this example we are giving a folder called wp2 full permissions: chmod 777 wp2.
This is what you should fill in for the configuration:

If nothing else works, just stop the installation process. Things might still work (since it might have succesfully extracted the files and inserted the data into the database). Just delete all the duplicator files from the WordPress root folder. If you get a message saying “Briefly unavailable for scheduled maintenance. Check back in a minute.” you need to also delete the .maintenance file.
How to use Git with InstantWP
If you are using the amazing free InstantWP WordPress development package often, then you might start wondering how to properly use it with Git version control. The difficulty is that trying to add the entire Linux Alpine virtual operating system to Git is too heavy, but adding only the contents of the Theme folder will not keep track of your posts and other database related content. I will outline the steps I used to get Git working with IWP below:
Continue reading “How to use Git with InstantWP”Colorize or tint an SVG image with CSS
This is a quick example of how you can tint an svg image even if it’s added to the page externally (it’s not an inline svg):
Continue reading “Colorize or tint an SVG image with CSS”Increment number when creating multiple html elements using emmet
Sometimes you need to create many elements so that each one of them gets a unique, incrementing number. You probably already know about VS Code’s Emmet capabilities which let you type something like .myClass*5 to automatically create five divs with the class “myClass”. So the output of that would be:
Continue reading “Increment number when creating multiple html elements using emmet”How to create SVG image maps with Inkscape.
AAB to APK
Creating your first Python script in Blender
In this tutorial we take you through creating a python script that will perform the typical initial steps for setting up mirror-modifier based box modeling work:
Continue reading “Creating your first Python script in Blender”