Skip to content

Instantly share code, notes, and snippets.

Nicola usainicola

View GitHub Profile
View gist:18ff389e5f5ec9953fa2f73c07ebbc33
function distance(lat1, lon1, lat2, lon2) {
var p = 0.017453292519943295; // Math.PI / 180
var c = Math.cos;
var a = 0.5 - c((lat2 - lat1) * p)/2 +
c(lat1 * p) * c(lat2 * p) *
(1 - c((lon2 - lon1) * p))/2;
return 12742 * Math.asin(Math.sqrt(a)); // 2 * R; R = 6371 km
}
View gist:cee888a202d9f2e9a8692f7696225714
<?php
function distance($latitudeFrom, $longitudeFrom, $latitudeTo, $longitudeTo) {
$rad = M_PI / 180;
$theta = $longitudeFrom - $longitudeTo;
$dist = sin($latitudeFrom * $rad) * sin($latitudeTo * $rad) + cos($latitudeFrom * $rad) * cos($latitudeTo * $rad) * cos($theta * $rad);
return acos($dist) / $rad * 60 * 1.852;
}
View gist:3c16d891505641b45909f9eaa84e7a07
<?php
// column post image
function add_thumb_column($cols) {
$cols['thumbnail'] = 'Image';
return $cols;
}
function add_thumb_value($column_name, $post_id) {
$width = (int) 120;
View gist:d41d27c6d3b9e927f588a548e067819e
<?php
function ajax_get_template_part() {
check_ajax_referer('ajax_get_template_part','nonce');
$part = esc_attr($_POST['template_part']);
if (!$part) {return;}
get_template_part($part);
die();
}
add_action( 'wp_ajax_nopriv_ajax_get_template_part', 'ajax_get_template_part' );
View gallery_custom.php
View gist:61a80a3dc675a25e2b9c8ffc2509527a
.waves-effect {
position: relative;
overflow: hidden;
display: inline-block;
}
.ripple {
width: 0;
height: 0;
border-radius: 50%;
background: rgba(255, 255, 255, 0.4);
View gist:dc43411d20327f4bed48488fc0852079
.row {
display: grid;
grid-gap: var(--s11);
grid-template-columns: repeat(auto-fit, minmax(var(--s24), 1fr));
}
@media screen and (max-width: 600px) {
.row {
grid-template-columns: none;
}
View calendario.css
.cControls {
display: flex;
justify-content: space-between;
align-items: center;
margin: 20px 0;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
View calendario.js
function calendarioPrezzi(element,calData,year) {
var year = year ? year : new Date().getUTCFullYear();
var arrWeekdays = new Array('domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato');
//change feb days for a leap year
var arrMonths = new Array(['gennaio', 31], ['febbraio', 28], ['marzo', 31], ['aprile', 30], ['maggio', 31], ['giugno', 30], ['luglio', 31], ['agosto', 31], ['settembre', 30], ['ottobre', 31], ['novembre', 30], ['dicembre', 31]);
//================ leap year
function isLeapYear(year) {
You can’t perform that action at this time.