Coding
Articoli nella categoria Coding. Tutto il blog
Uno strumento gratuito per creare quiz da usare a scuola
Software open source per fare semplici quiz vero/falso da utilizzare a scuola.
Esperimento, barriera laser
Lezione n.6 del corso di Arduino per scuole medie. Costruzione di una barriera laser.
Esperimento, una resistenza un led e un pulsante
Un pulsante per accendere un led.
Esperimento, lucine
Alcuni led con resistenza.
Come creare un agente AI per interrogare un database MySQL con PHP e Neuron AI
Come interrogare un database in linguaggio naturale usando PHP e il framework Neuron AI. Un progetto passo-passo per costruire un data analyst virtuale capace di esplorare i dati di un CRM/ERP senza scrivere query manuali.
Testing an image gallery library in javascript
Testing a simple lightbox javascript in my wordpress theme.
PenguinBotLib, my library for Elegoo Penguin bot
An Arduino library to program the Penguin Bot by Elegoo in an easier way,
Venn’s diagram applied to web agency life and software development
Thoughts about Venn’s diagram and making software.
Can you tell me why scrolling page with the scrollbar causes text selection?
A nice solution found by chatGPT
The Quantcast CMP broke my sites
A javascript error in CMP blocks my site.
WP Gutenberg notes
Collection of notes and thoughts on Wordpress Gutenberg blocks development.
Optimizing LCP, Largest Contentful Paint result
Notes about Core Web Vitals optimization challenge
Find values recursively inside complex json objects in PHP
A PHP function to to quickly search complex, nested php structures for specific values.
Scroll to DIV by ID without jQuery
Use scrollIntoView instead of jQuery animate.
React links
Collection of links and notes while approaching React.js, next.js and related topics.
Come realizzare in PHP un bot per il controllo di accesso ad un gruppo Telegram
Una serie di appunti per la realizzazione di un bot di controllo di un gruppo Telegram, non è un vero e proprio tutorial, ma è sicuramente utile per ripercorrere il progetto.
Updating a metabox after Gutenberg updates
When press on “Update” refresh a custom metabox under gutenberg editor.
Reti neurali, corso base (2/2)
Corso base su reti neurali, elenco slide:
Reti neurali, corso base (1/2)
Seconda parte
Count coloured cells on Google Sheets with reference
Google sheet trick to count cells
WP doesn’t send email? try this
Snippets for sending emails with Wordpress
Two post types share the same taxonomy in WordPress
Sharing a taxonomy between different post types
MYSQL add counter in a query
Use mysql variables to create a counter in SQL, PHP code to use an SQL counter and what does the i mean in mysqli?
Modify the language attribute based on category in WordPress
How to modify the language attribute in your Wordpress theme using a specific value
WordPress Fatal error: Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
How I’ve beat the php mysterious fatal error unknown in Wordpress caused by caching plugin WP Fastest Cache
WordPress Gutenberg doesn’t parse Istagram oembed url
Sometimes Instagram embed doesn’t work, why?
Hacking del sistema di irrigazione Claber
Modificare il sistema di irrigazione della Claber per utilizzarlo con Arduino e una app realizzata ad hoc
Stop sending email to new user in WordPress admin registration
A code snippet to prevent WordPress to send notification emails when you manually create new users. It uses a pluggable function.
A new avatar generator for WordPress with get_avatar and Flathash
Brand new avatars for WordPress Gravatar service
3 ways to add author’s image in WordPress
Add author’s image in WordPress without a plugin
Orari trenord, corri solo quando ce n’è bisogno
Hai presente quando corri in stazione per prendere il treno al volo e, quando arrivi, ti accorgi che il treno ha 12 minuti di ritardo?
Add Internet Explorer class to body to detect old browser
Old browser go home! :-)
Add filter on wp_title not working with Yoast SEO plugin
A SEO filter on wp_title
Generate all old PDF preview images with WordPress 4.7
PDF previews needed in media gallery?
Highlight text for search results in PHP
Useful code to highlight text occurences in search results or in a text. How to highlight text in a string…
Remove or change the view link in WordPress posts list admin
If you want to remove the row action ‘view’ from the admin posts list within a specific custom post type…
Modify list counter in :before pseudo class with jQuery using start attribute
Custom li list item with pseudo classes
Modify wp_query for a specific category in category.php
Order by meta field in category.php
Customize your site icon for new WordPress 4.4 embeds
Customize your wordpress embed
Clean up and optimize WordPress head tag
A mess in Wordpress head tag?
How to bring back tweet counters
Twitter doesn’t want you to see how many tweets your links did.
Twitter counter no longer works
Bye bye twitter
How to add rel=”nofollow” to links with preg_replace()
Adding rel=”nofollow” to external link is a good SEO practice.
Social buttons: the fastest way for WordPress, without plugins
Social buttons for wordpress
Optimize WordPress, a long list of tips
Wordpress is optimizable?
Limit the number of categories for posts in WordPress
Just one category for each post
Remove archive pages in WordPress, how to
Archives go home! :-)
WordPress anyone can register, but no email confirmation
Email problems with wordpress
WordPress 4.1.1 is available! Please update now.
Sometimes you find messages like “WordPress 4.1.1 is available! Please update now.“, in italian it is: “È disponibile WordPress 4.1.1! Aggiorna…
Fix for WP SUPER CACHE home not refreshing
WP SUPER CACHE is one of the most used WordPress plugin for cache, but probably there is a small bug…
Add client logo to wordpress login
If you want to add your logo or the logo of your client above the wordpress login you have to…
Force WordPress to use Italian date
To get date with get_the_time in Italian you should specify italian (it_IT) in the WP_LANG constamt in your wp_config.php file.…
VK Social metrics, Top Stories plugin now with support for Vkontakte
VK SOCIAL METRICS VK.COM, also known as Vkontakte, is an important russian social network, which has over 270 million users.…
Get Google Plus Follower count from PHP in WordPress
I’ve found a similar function to retrieve the number of followers of a Google Plus page, inside WordPress, but it…
How to Fan Gate a page in wordpress?
You can use my plugin, which is totally custom for layout (you can change the image of the pop up…
Lazy post
Hi, I’ve made this tool for fast reblogging. It helps lazy authors to download images and upload directly in your…
8 rules to become a better developer
I’ve found this article by Shawn McCool and I think it’s good for every developer, if you’re an expert probably…
Reordering rows records on a mysql table with PHP
This PHP function lets you reorder records on a table when you have a field used for save the position.…
Scraping content with PHP as if it was jQuery
Building a spider or a bot needs some knowledge of regular expressions, you must know and use preg_match or preg_match_all…
Embedding images in HTML or CSS with PHP
This small function returns an encoded string to embed images, inline, inside your html/css code and reduce the number of…
Block junk emails, spammers and temporary emails
If you need an Email Validator Function, consider this version that includes also the check against common temporary mail services…
Get instagram data without official api in PHP
Instagram has an official API to interact with its database of images and users. If you have enough time to…
How to build a spider… uh, well an email scraper
What is a spider? A spider is a program that automatically navigates web pages to find informations. These informations can…
MySQL fulltext search always empty
If you’ve just switched to FULLTEXT indexes and you’ve just started playing with MATCH… AGAINST syntax, but you always get…
Push notifications from php to Android devices with Minibots Class
More than two years ago I wrote a post about sending push notifications from php to an iOS app called…
Programming with CodeIgniter MVC
Codeigniter (aka CI) is an MVC framework that helps you building websites. You don’t know what is MVC? Bad. It’s…
Make a cron job with IFTTT
Cron is a software utility, a time-based job scheduler in Unix-like computer operating systems. People who set up and maintain…
Refresh a Google Adsense banner with Javascript
Often bloggers and site owners use galleries to have a greater number of pages, adding pages means adding clicks. Each…
User agent detect with PHP
Small PHP code snippet to make a quick detect if the browser that requests your page is on a mobile…
Detect if is mobile with Javascript, read user agent
How to detect if your user is using a mobile device in Javascript? You can do it by checking the…
Top Social Stories plugin and widget for WordPress
Just released a plugin for WordPress that can be used to track your posts on Facebook, Twitter and Google+. When…
How to import comments from WordPress to DISQUS
Disqus is a very nice tool to handle comments better and probably I will add it here soon, but I’ve…
How to remove custom fields from WordPress
Ok. You’ve added custom fields in wordpress, but how can you remove them? How to delete custom fields wordpress Two…
W3tc plugin feed problem
When your WordPress site has a great number of requests it could happen that your server can’t handle all the…
13 mysql tips that you don’t know
Here is a list of thirteen tips that can be usefull for your queries. If you know more tips send…
How many times a web link has been shared on Twitter
Twitter share button and Facebook share button are the most used buttons to share links on Internet. You can read…
Updated version of the the Facebook Connect Tutorial
I’ve written un updated version of the Facebook Connect Tutorial, you can find it in the top menu of Barattalo.it.…
How to read facebook likes count from PHP
When you add facebook like button to your site, probably, you also want to save the number of likes of…
Mini log functions for PHP
When you have to log something with php you can use fopen to create a file and then use fwrite…
Unobtrusive javascript to add an overlay banner
If you have to add an overlay to a site, here is a fast way to do it with an…
PHP code to check if remote mp3 exists
Hi, I’ve a big table with thousands of mp3 links. Sice these links come from an old database, many of…
New Facebook Invite all friends hack
So, you want to invote all your friends but the old hack doesn’t work anymore? With the last facebook friends…
How to use Instagr.am photos on your site
UPDATE: 2013-12-04 I’ve made a method in the Mini Bots PHP Class that lets you retrieve images from instagram without…
get MySpace events with a PHP function
Here is a function to read the concerts for a myspace band page. This code retrieves the “shows page” for…
PHP Geocoding function, from address to coordinates lat long
This is a small function included in the Minibots Class that converts an address to a couple of coordinates Latitude,…
PHP find previous monday from a date
This small function returns the date (with the format you want) of the previous monday from a given date. If…
Get URL parameter in javascript
Sometimes in javascript you have the variable that you need to use in the url, as a parameter passed in…
Get file name in javascript
How to get the file name of the page? When you need to read the file name of the current…
Php Function to resize video from YouTube and Vimeo
When you make a web application that let the user insert video embeds coming from YouTube or from Vimeo, or…
How to integrate phpbb forum login
I have had to install phpbb forum on a website that already had a user table and I want to…
How to change twitter status with php and curl without oAuth
Twitter api authentication Since the 31 of august 2010, twitter made its API more secure, stopping basic authentication calls. So,…
PHP bot to get wikipedia definitions
Wikipedia, the collaborative and multilingual encyclopedia project, has a lot of usefull terms defined in its database, you can find…
Send push notification to iPhone with PHP and pushme.to
UPDATE: 2013/11/18 This code no longer works, but you can check a similar function here: Sending push notifications with php…
PHP to post on a Facebook page
Hi, I’ve modified the Mini Bot Class, I’ve fixed the Facebook status update and I’ve implemented the function to post…
Parsing Flickr Feed with PHP tutorial
I’ve spent about 30 minutes to find a javascript embed to print out a custom thumbs list of flickr photos,…
10 htaccess usefull tips
The “.htaccess” is a configuration file that works at directory level on the web servers (on Apache, not on Microsoft…
Correct headers to download a CSV from PHP
With these headers you can force a download from php, for example, to let the user download a csv frmatted…
Always remove slashes from GET and POST
This is a small piece of code that I use since many years. It removes all slashes from $_GET and…
Mini Bot Class Updated
Now there are 17 bots included in this class! Well I’ve updated the mini bots class with some new things:…
PHP google images mini bot
UPDATE 2013/12/12: Now, in the Mini Bot Class there is a version of this function that is still working. You…
PHP parse url, mailto, and also twitter’s usernames and arguments
This small function receive a text as input and returns an html text with links if the source text contains…
How to write a text description into html input type password
Sometime designers put form labels and instrucions into html inputs. One of the common uses is for login boxes when…
PHP curl bot to update Facebook status
I’ve found this great mini bot from Alste blog, and I’ve decided to add it to the mini bot class.…
PHP to get twitter infos and avatar
I’ve just updated the Mini Bot Php Class with an improved version of the twitterInfo function, here is the code…
Ping pingomatic.com services with PHP
Ping-o-matic is a service that calls (ping) server engines and popular services to notify them that you have new contents…
Reading mp3 informations with php (id3 tags)
Inside mp3 files there are often some usefull informations stored. Those data are called “id3 tags” and deal with Author…
How to capture enter key pressed in a form (JavaScript)
Suppose you have a login form and you want to send the form when user press enter on his keyboard…
Mixing bots to gain new services
Spiders and bots let you take services from other web sites, this could be very cool, but also this could…
PHP function to fix collation on database fields of MySQL
This PHP function search for tables in the active db, match table’s name with the regular expression passed as first…
PHP how to calculate age from date of birth
This is a very simple script that starts from a string date in format yyyy-mm-dd and return the age. To…
ASP equivalent to PHP strip_tags
I’ve found those functions around in the internet and I put them here just to remind how to strip tags…
ASP Function to count files in a folder
This ASP function counts files of a specified extension inside a folder: this is done by creating a file system…
Fix html tags, close tags, repair bad quotes and more
This class can solve many problems coming from user generated html content or to fix html content before making some…
Recursive remove directory (RMDIR) in PHP
This small php function is a recursive remove directory that remove non empty dirs recursively. It enters every directory, removes…
Calculate dir size recursively with PHP (and count files)
This small PHP function lets you calculate the dir size entering each sub dir and making the sum of the…
10 PHP usefull functions for MySQLi stuff (mysql improved)
I’ve modified the previous post to use mysqli instead of mysql. Was it necessary? I think it was good step…
10 PHP usefull functions for MySQL stuff
Here is my personal collection of 10 php function that I always include in my database function library. I think…
Using REPLACE in an UPDATE statement to fix data on MSSQL and MySQL
Sometimes it’s necessary fix data on the database. I had to fix on a Microsoft database: /* MSSQL syntax */…
New version of Mini Bots PHP Class (v.1.4)
I’ve added three more bots to the Mini Bots Php Class, now the version number is 1.4 and it has…
PHP to get enum/set values from mysql field
This function returns an array with the elements allowed in a ENUM or SET mysql field. This can be usefull…
Recursive chmod on files and directory
It has happened to me that files uploaded with a small CMS cannot be downloaded with a FTP client for…
Posting to Facebook from website with Facebook Connect
This post is part of the Facebook Connect Tutorial and it will show how to add “post to wall” function…
PHP Web page to text function
I’ve found this nice small bot on the www.php.net site, thanks to the author of the script on the preg_replace…
Copying remote files on your server with PHP
UPDATE: This function has been inserted in the Mini Bots PHP Class Here is a function that let you copy…
Bot that retrieves url meta data and other infos
From a given url this function retrieves page title, meta description, keywords, favicon, and an array of 5 images to…
Sending HTML emails with attachment with PHP
This function allows you to send an HTML email with a file attachment. To do this it’s necessary to read…
Test if a remote url exists with PHP and CURL
If you have to test if a local file exists you will probably use the php file_exists function, but if…
Tiny url encode and decode with PHP
The first functions make short urls using tinyurl.com service. It’s a very popular function on the web, you can find…
Validate email with smtp
This function validate a mail address in a smart way: if the address to validate has a correct syntax (checked…
Decimal Degrees conversion and distance of two points on google map
Those two functions are usefull when you’re making Google Maps applications: When you show the coordinates of a point, it’s…
PHP bot to grab meteo information from Google
Google has many usefull functions that give you data fast, such as cinema infos, or for meteo forecasts. I think…
ASP web bot that get exchange rates
Thanks to Bank of Italy (Banca d’Italia), there are free exchange rates data that are easy to retrieve and parse,…
PHP Session class with crypted cookies.
This class was built to handle session variables, I made this class because once I had to use session variables…
Javascript Ruler for Google Maps v3 to measure distance on map
Javascript example for measuring distances on a Google Maps with a ruler.
Min height cross browser CSS
In CSS version 2 there is a “min-height” property, but it doesn’t work in the same way in every browser,…
Detect user language with PHP
This function uses php server variables to detect the “possible” language of the browser of the connected user. This let…
Mini gallery/slideshow with PHP and JQuery
Sometimes I’ve had to quickly put in a page a simple slideshow, the first times I’ve searched a lot around…
Clustering many markers with Google Maps v3
I’ve found this blog where Matthias Burtscher converted the Marker Cluster (like the Phoogle2) for Google Maps API v.3. Since…
For next project: Google Analytics API
This is a memo, because at the moment I don’t need to use this new API from Google, but since…
How many users are connected?
This two function returns the number of users connected to your site. Since HTTP is asyncronous, the only way to…
Truncate string preserving some words in PHP
When you search in Google for a string, Google highlights with bold text the words you’ve searched in the results…
Click links with JavaScript
If you want to click on objects, anchors, table cells or any other html element to emulate the javascript behaviour…
Set “write here” on input type text?
If you are using JQuery framework and you want to set up the default value of some text box in…
How do I print the elements of an object in Javascript?
This function is similar to the print_r php function: it runs over the elements of an object recursively and put…
Full Screen GControl for Google Maps
Use with phoogle modified class: (see an example here) To use it in the phoogle modified class just turn it…
How do I get the value from a combo in Javascript?
If you don’t use any javascript framework such as jquery.js or prototype.js the combo object isn’t so easy to use,…
Cross browser opacity
Is there a css definititon to make cross browser opacity? Yes. I found this, and it seems to work: div.opacized…
PHP Day add function
How to add 2 days to a date in PHP? There are many ways to add days to a string…
ASP equivalent to PHP Ucfirst function
This code does the same thing that Ucfirst function makes in PHP. “Ucfirst” means “Uppercase first letter”. ASP doesn’t have…
ASP equivalent to PHP ereg_replace function
I’ve used so many time the php function ereg_replace that when I have to use ASP (‘cause sometimens you have…
OnKeyUp Fix Alphanumerical Chars
When you have an html form and you want only alphanumerical [a-z0-9] chars in your input, you can use this…
Do spelling using google spell checker
If you have a user input that may contains some error you can try to check the spelling using Google…
Parse a float number in javascript
This small code parse a javascript float number to a string. It converts the number to a string and let…
Phoogle Modified Class for Google Maps
I was looking for a php class to use on Rockit.it to geo reference band, festivals, labels and other stuff.…
Make square thumbs or cropped thumbs with php
This is a thumb generator php class. I’ve been searching a lot for some code to make good thumbs on…
Stop UTF8 problems with special characters
I’m italian and I always need to use special chars like è é à ù. The same need belongs to…
Execute Scalar and Execute Row for Php
A couple of simple functions thar returns the first value and the first row of a result set. Very usefull.…
Javascript to make some links blink
Mark each anchor tag (<a href…) with rel=”blinking” to make the tag blink (not very clever, but sometimes useful). This…
Is Empty Dir?
Php function that return true if the directory specified is empty. $bool = is_emptydir("./images"); function is_emptydir($which){ $dh=dir($which); $emptydir=true; while ($file=$dh->read())…
Load File into a String
Simple old function to load a file into a string. $s = loadStrFile("file.txt"); function loadStrFile($filename) { $handle = fopen ($filename,…