Skip to content

Instantly share code, notes, and snippets.

View kalamun's full-sized avatar

Roberto Pasini kalamun

View GitHub Profile
/*
* WORDPRESS: add a text field inside the post-thumbnail box in Gutenberg
*/
"use strict"
const el = wp.element.createElement;
const withState = wp.compose.withState;
const withSelect = wp.data.withSelect;
const withDispatch = wp.data.withDispatch;
@kalamun
kalamun / .htaccess
Last active March 18, 2019 22:34
.htaccess setup for performance and security
#php_value display_errors Off
#
# WEB PERFORMANCE
# Remove `ETags` as resources are sent with far-future expires headers.
# `FileETag None` doesn't work in all cases.
<IfModule mod_headers.c>
Header unset ETag
/*
* Load local files and stream it chunked
* Tested also with media and large files
*/
function stream_file( $file, $is_resume = true )
{
//First, see if the file exists
if (!is_file($file))
{
<?php
$provinces = [
"AG" => "Agrigento",
"AL" => "Alessandria",
"AN" => "Ancona",
"AO" => "Aosta",
"AR" => "Arezzo",
"AP" => "Ascoli Piceno",
"AT" => "Asti",
"AV" => "Avellino",
@kalamun
kalamun / italian-regions-and-provinces.php
Created October 25, 2017 16:07
Regioni e province d'Italia
<?php
$regions = [
"Valle d'Aosta" => ["AO"],
"Piemonte" => ["BI","CN","NO","TO","VB","VC"],
"Liguria" => ["GE","IM","SP","SV"],
"Lombardia" => ["BG","BS","CO","CR","LC","LO","MN","MI","MB","PV","SO","VA"],
"Trentino Alto Adige" => ["BZ","TN"],
"Veneto" => ["BL","PD","RO","TV","VE","VR","VI"],
"Friuli Venezia Giulia" => ["GO","PN","TS","UD"],
# COUNTRY LIST for WordPress' CONTACT FORM 7
# English
[select country "" "Afghanistan" "Albania" "Algeria" "American Samoa" "Andorra" "Angola" "Anguilla" "Antigua and Barbuda" "Argentina" "Armenia" "Armenia" "Aruba" "Australia" "Austria" "Azerbaijan" "Azerbaijan" "Bahamas" "Bahrain" "Bangladesh" "Barbados" "Belarus" "Belgium" "Belize" "Benin" "Bermuda" "Bhutan" "Bolivia" "Bonaire" "Bosnia and Herzegovina" "Botswana" "Bouvet Island (Bouvetoya)" "Brazil" "British Indian Ocean Territory (Chagos Archipelago)" "British Virgin Islands" "Brunei Darussalam" "Bulgaria" "Burkina Faso" "Burundi" "Cambodia" "Cameroon" "Cape Verde" "Cayman Islands" "Canada" "Central African Republic" "Chad" "Chile" "China" "Christmas Island" "Cocos (Keeling) Islands" "Colombia" "Comoros" "Congo" "Congo" "Cook Islands" "Costa Rica" "Cote d'Ivoire" "Croatia" "Cuba" "Curaçao" "Cyprus" "Cyprus" "Czech Republic" "Denmark" "Djibouti" "Dominica" "Dominican Republic" "Ecuador" "Egypt" "El Salvador" "Equatorial Guinea" "Eritrea" "Estonia" "Ethio
@kalamun
kalamun / reverse_geocode.sql
Created October 6, 2017 19:06
Reverse Geocode SQL table
This file has been truncated, but you can view the full file.
-- phpMyAdmin SQL Dump
-- version 4.6.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Oct 06, 2017 at 06:42 PM
-- Server version: 5.7.8-rc-log
-- PHP Version: 7.0.2RC1
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
@kalamun
kalamun / functions.php
Last active April 2, 2022 16:50
Add subtitle to wordpress pages, just after the title field nd before the content editor
/*
add to functions.php
then get the subtitle with the_subtitle() or get_the_subtitle() functions
*/
/* add subtitles */
add_action( "admin_footer-post.php", 'move_subtitle_after_title' );
add_action( "admin_footer-post-new.php", 'move_subtitle_after_title' );
function move_subtitle_after_title()
@kalamun
kalamun / init.css
Last active June 11, 2017 15:52
CSS init
* {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100% ;
vertical-align: baseline;
background: transparent;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
@kalamun
kalamun / grid.css
Last active June 4, 2020 08:13
CSS Lightweight Grid System - 12 cols
/* grid */
.row { max-width:1200px; position:relative; clear:both; margin:0 auto; opacity:1; }
.row:after { content: ''; display: block; clear: both; }
.row.full-width { max-width:100%; width:100%; }
.column { float:left; }
.grid { margin:0 15px; position:relative; }
.grid.center { margin:0 auto !important; }
.grid.nomargin { margin:0; }
.grid img,.grid object,.grid element,.grid iframe { max-width:100%; height:auto; }
.grid object,.grid element,.grid iframe { min-height:400px; }