Skip to content

Instantly share code, notes, and snippets.

View andreascarpello's full-sized avatar
🏠
Working from home

Andrea andreascarpello

🏠
Working from home
View GitHub Profile
@andreascarpello
andreascarpello / touch_screen_detection.js
Created July 25, 2013 22:55
Detect touch screen device
// Detect touch device
function is_touch_device() {
return !!('ontouchstart' in window)
|| !!('msmaxtouchpoints' in window.navigator);
};
@andreascarpello
andreascarpello / document-head.html
Created August 2, 2013 14:16
HTML head snippet
<meta property="og:url" content="http://domain.com" />
<meta property="og:image" content="http://domain.com/logo.png" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Pagename" />
<meta property="og:site_name" content="MyBrandname" />
<meta property="og:description" content="Lorem ipsum dolor sic amet..." />
<meta name="twitter:url" content="http://domain.com/login" />
<meta name="twitter:description" content="Lorem ipsum dolor sic amet..." />
<meta name="twitter:image" content="http://domain.com/logo.png" />
<meta name="description" content="Lorem ipsum dolor sic amet..." />
@andreascarpello
andreascarpello / bind input text.js
Created September 24, 2013 10:40
Check input change and prevent submit with whitespace
$('#textinput').bind('input', function(e){
if( $(this).val().length > 0 && !/^\s+$/.test($(this).val()) ){
$('#submit').removeClass( 'disabled' );
} else {
$('#submit').addClass( 'disabled' );
}
});
@andreascarpello
andreascarpello / wget_offline_navigable_site.sh
Created October 17, 2013 10:23
Download entire site navigable offline
wget --mirror -p --html-extension --convert-links -e robots=off -P . http://www.websiteurl
-webkit-tap-highlight-color: rgba(0,0,0,0);
(function findDuplicateIds() {
var ids = {};
var all = document.all || document.getElementsByTagName("*");
for (var i = 0, l = all.length; i < l; i++) {
var id = all[i].id;
if (id) {
if (ids[id]) {
console.log("Duplicate id: #" + id);
} else {
ids[id] = 1;
# Create 'Lavori' folder under media
cd /media
sudo mkdir Lavori
sudo chown ascarpello:ascarpello Lavori/
sudo chmod 775 -R Lavori
# Edit fstab
sudo /etc/fstab
# and add following line
<video autoplay poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/polina.jpg" id="bgvid" loop>
<!-- WCAG general accessibility recommendation is that media such as background video play through only once. Loop turned on for the purposes of illustration; if removed, the end of the video will fade in the same way created by pressing the "Pause" button -->
<source src="//demosthenes.info/assets/videos/polina.webm" type="video/webm">
<source src="//demosthenes.info/assets/videos/polina.mp4" type="video/mp4">
</video>
<div id="polina">
<h1>Polina</h1>
<p>filmed by Alexander Wagner 2011
<p><a href="//demosthenes.info/blog/777/Create-Fullscreen-HTML5-Page-Background-Video">original article</a>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porta dictum turpis, eu mollis justo gravida ac. Proin non eros blandit, rutrum est a, cursus quam. Nam ultricies, velit ac suscipit vehicula, turpis eros sollicitudin lacus, at convallis mauris magna non justo. Etiam et suscipit elit. Morbi eu o
@andreascarpello
andreascarpello / script.js
Created January 22, 2015 14:41
Replace all SVG images with inline SVG REPLACE IMG SVG TO INLINE SVG FOR OLD ANDROID
// REPLACE IMG SVG TO INLINE SVG FOR OLD ANDROID
$('img[src*=".svg"]').each(function(){
var $img = $(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
$.get(imgURL, function(data) {
// Get the SVG tag, ignore the rest
var $svg = $(data).find('svg');
@andreascarpello
andreascarpello / style.css
Created January 27, 2015 09:14
Removing input background color for Chrome autocomplete
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0 1000px white inset;
-webkit-text-fill-color: #6e110d !important;
}