Skip to content

Instantly share code, notes, and snippets.

View LucaRosaldi's full-sized avatar

Luca Rosaldi LucaRosaldi

View GitHub Profile
@LucaRosaldi
LucaRosaldi / get_user_ip.php
Last active September 25, 2019 07:42
PHP: Get User Geolocation with ipgeolocationapi.com
<?php
/**
* Get the user IP address from the server request.
*
* @return string
*/
function get_user_ip() : string {
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
return $_SERVER[ 'HTTP_CLIENT_IP' ];
@LucaRosaldi
LucaRosaldi / .htaccess
Created September 17, 2019 12:47
APACHE: Redirect to HTTPS
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@LucaRosaldi
LucaRosaldi / utils.js
Last active July 7, 2021 19:22
JS: utilities module
/**
* Check if passed argument is a callable function.
*
* @param {Callable} func
* @return {Boolean}
*/
export function isFunction( func ) {
return func && {}.toString.call( func ) === '[object Function]';
}
@LucaRosaldi
LucaRosaldi / copy-to-clipboard.js
Created November 16, 2018 14:53
JS: Copy to Clipboard
/**
* Copy text to clipboard.
*
* @param {String} text
* @return {void}
*/
const copyToClipboard = ( text ) => {
const activeElement = document.activeElement;
// create a dummy element for text selection and push it offscreen
@LucaRosaldi
LucaRosaldi / mouse-position.css
Created September 14, 2018 10:03
JS: Update mouse position CSS var
:root {
--mouse-x: 0px;
--mouse-y: 0px;
}
@LucaRosaldi
LucaRosaldi / wp-config.php
Last active July 26, 2022 10:05
WP: wp-config.php additional settings
<?php
/**
* Raise PHP memory limit.
*/
define( 'WP_MEMORY_LIMIT', '256M' );
/**
* Disable revisions, we don’t need them.
*/
define( 'WP_POST_REVISIONS', false );
@LucaRosaldi
LucaRosaldi / no-focus-outline.css
Last active November 7, 2017 11:29 — forked from davidgilbertson/user-tabbing-class.js
JS-CSS: Remove Outline on Focus (accessible)
html:not(.no-js):not(.user-is-tabbing) button:focus,
html:not(.no-js):not(.user-is-tabbing) input:focus,
html:not(.no-js):not(.user-is-tabbing) select:focus,
html:not(.no-js):not(.user-is-tabbing) textarea:focus {
outline: none;
}
@LucaRosaldi
LucaRosaldi / JSON.sublime-settings
Last active January 22, 2018 07:24
My Sublime Text Config
{
"tab_size": 2,
"translate_tabs_to_spaces": false,
"word_wrap": false
}
@LucaRosaldi
LucaRosaldi / app.js
Created August 5, 2016 10:53
Javascript: App boilerplate (ES2015)
/**
* App JS
*
* This is the main scripts file.
*
* Author: PubliOne S.r.l.
* Author URI: http://publione.it
*
* @version 0.1.0
*/
@LucaRosaldi
LucaRosaldi / wp-searchform.php
Last active April 19, 2019 21:57
WP: Search Form in Microdata Format
<?php
/**
* The search form in Microdata format.
*
* This is used by Google to display a fully functional
* search bar in the search results for your website,
* directly below the title.
*
* @link https://developers.google.com/webmasters/structured-data/slsb-overview
*/