Skip to content

Instantly share code, notes, and snippets.

View jaicab's full-sized avatar
🏠
Staying home

Jaime Caballero jaicab

🏠
Staying home
View GitHub Profile
@jaicab
jaicab / favicon.html
Created June 16, 2014 16:49
Multi favicon in just 4 lines
<link rel="apple-touch-icon" href="/apple-touch-icon-152.png">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<meta name="msapplication-TileColor" content="#000">
<meta name="msapplication-TileImage" contet="/mstile.png">
@jaicab
jaicab / scrollTo hash fix
Last active August 29, 2015 13:56
Scroll to top on load unless there's a bookmark link
if(!window.location.hash) scrollTo(0,1);
@jjmu15
jjmu15 / in_viewport.js
Created January 27, 2014 10:19
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
// Determine if an element is in the visible viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);
@codepo8
codepo8 / redirect
Last active June 29, 2021 16:58
Simple redirect of hotlinked images in .htaccess
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
# allowed domains, add as needed
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?christianheilmann.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wait-till-i.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mozilla.org [NC]
# search engines and social sites and stuff
@ludder
ludder / slideDown.js
Created December 6, 2012 17:25
Vanilla JavaScript slideUp and slideDown functions
/*
Element to slide gets the following CSS:
max-height: 0;
opacity: 0;
overflow: hidden;
transition: max-height 0.4s ease 0s;
*/
/**
* Like jQuery's slideDown function - uses CSS3 transitions
@afeld
afeld / gist:1254889
Created September 30, 2011 20:28
YouTube video ID regex
# Parses YouTube URLs directly or from iframe code. Handles:
# * Address bar on YouTube url (ex: http://www.youtube.com/watch?v=ZFqlHhCNBOI)
# * Direct http://youtu.be/ url (ex: http://youtu.be/ZFqlHhCNBOI)
# * Full iframe embed code (ex: <iframe src="http://www.youtube.com/embed/ZFqlHhCNBOI">)
# * Old <object> tag embed code (ex: <object><param name="movie" value="http://www.youtube.com/v/ZFqlHhCNBOI">...)
/(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/
$5 #=> the video ID
# test it on Rubular: http://rubular.com/r/eaJeSMkJvo