Skip to content

Instantly share code, notes, and snippets.

@fulippo
fulippo / .hgignore
Created September 3, 2012 07:48
.hgignore for WordPress
glob:.hgignore
glob:.htaccess
glob:.htpasswd
glob:wp-config.php
glob:wp-content/uploads/*
@fulippo
fulippo / gist:3664125
Created September 7, 2012 07:36 — forked from mataspetrikas/gist:2300296
Check if the DOM node is visible in the viewport
function elementInViewport(el) {
var rect = el.getBoundingClientRect()
return rect.top < (window.innerHeight || document.body.clientHeight) && rect.left < (window.innerWidth || document.body.clientWidth);
}
// and then you can use it:
alert(elementInViewport(document.getElementById('inner')));
// or
alert(elementInViewport($('#inner')[0]));​
`
@fulippo
fulippo / gist:3800324
Created September 28, 2012 14:48
Update di una tabella con select sulla stessa tabella
UPDATE data_table t, (SELECT DISTINCT ID, NAME, VALUE
FROM data_table
WHERE VALUE IS NOT NULL AND VALUE != '') t1
SET t.VALUE = t1.VALUE
WHERE t.ID = t1.ID
AND t.NAME = t1.NAME
@fulippo
fulippo / gist:3986307
Created October 31, 2012 10:26
Query to remove orphaned taxonomy terms from a WordPress DB
-- Replace %s with table prefix
DELETE tr
FROM %s_term_relationships tr
INNER JOIN %s_term_taxonomy tt
ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
WHERE tt.taxonomy != 'link_category'
AND tr.object_id NOT IN (SELECT ID FROM %s_posts);
@fulippo
fulippo / gist:4066855
Created November 13, 2012 16:41
Find duplicates in MySQL
SELECT <field_name>, COUNT(*) c FROM <table> GROUP BY <field_name> HAVING c > 1;
@fulippo
fulippo / web.config
Created September 18, 2014 14:20
WordPress web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json"/>
<mimeMap fileExtension=".ejs" mimeType="application/javascript"/>
</staticContent>
<rewrite>
<rules>
<rule name="Imported Rule 1"><match url="^(.+)\.(.+)\.(js|css)$" ignoreCase="false"/>
@fulippo
fulippo / gist:8c7643670f841cc2aaca
Created April 14, 2015 11:41
Calcolo esadecimale
Valore * base^posizione da destra + Valore * base^posizione da destra ....
es. 0xAF
F * 16^0 + A * 16^1
diventa
15 * 16^0 + 10 * 16^1
diventa
15 + 160
@fulippo
fulippo / gist:357bb775b676ee073e0a
Last active August 18, 2018 08:48
Convert coords from Google Maps (WGS-84) to Baidu Maps (BD-09)
/**
* Convert longitude and latitude from standard WGS-84 system
* to Baidu's BD-09
*
* @see http://stackoverflow.com/a/29512814/718811 for a detailed
* description of the problem.
*
* @param float lng Longitude
* @param float lat Latitude
* @return object Converted coords
@fulippo
fulippo / gist:cce6ee726e68ce9b7b77
Last active August 29, 2015 14:26
Check status code of URL taken from text file
#!/bin/bash
while read LINE; do
curl -o /dev/null --silent --head --write-out '%{http_code}' "$LINE"
echo " $LINE"
done < url-list.txt
<!-- Start of Brightcove Player -->
<div style="display:none">
</div>
<!--
By use of this code snippet, I agree to the Brightcove Publisher T and C
found at https://accounts.brightcove.com/en/terms-and-conditions/.
-->