Skip to content

Instantly share code, notes, and snippets.

View livercake's full-sized avatar

Felipe Parada livercake

View GitHub Profile
<![CDATA[
Within this Character Data block I can
use double dashes as much as I want (along with <, &, ', and ")
*and* %MyParamEntity; will be expanded to the text
"Has been expanded" ... however, I can't use
the CEND sequence (if I need to use it I must escape one of the
brackets or the greater-than sign).
]]>
<!--
<script>
var dontdothis = function() {
document.documentElement.style.backgroundColor = '#'+(Math.random()*0xFFFFFF<<0).toString(16);
};
setInterval(dontdothis, 1000 / 10);
</script>
@livercake
livercake / mq_all.css
Created December 15, 2014 20:44
Media Queries
/* Smartphones (portrait & landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
@livercake
livercake / gist:3dd7919fc0fd881a26c1
Created October 7, 2014 14:57
the proper <video> element
<video autoplay="autoplay" muted="muted" poster="poster.jpg" style="height: auto; visibility: visible;">
<source src="mp4version.mp4" type="video/mp4">
<source src="webmversion.webm" type="video/webm">
</video>
@livercake
livercake / gist:5c3e5c2f11d80719c5a5
Created September 22, 2014 18:58
dead-simple client-side mail validation for form fields
function validateEmail($email){
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(!emailReg.test($email)){
return false;
} else {
return true;
}
}
$(function(){
@livercake
livercake / gist:409555b49bcff3f494f6
Last active August 29, 2015 14:06
Very simple FB Login w/javascript+fb sdk
// This is called with the results from from FB.getLoginStatus().
// Welcome: I am the Gatekeeper. Are you the Keymaster?
function theGatekeeper(response) {
console.log('FB Login object response:');
console.log(response);
// FB.getLoginStatus() responds
if (response.status === 'connected') {
// logged into FB + permissions OK: You are the Keymaster
console.log('login OK, running ');
@livercake
livercake / gist:a08a2e42110d521cf4b0
Created September 4, 2014 15:58
jQuery on click
$( "#target" ).click(function() {
alert( "Handler for .click() called." );
});
@livercake
livercake / gist:8a60a127848933d8071f
Created August 6, 2014 15:57
Pixels scroll'd trigger (with scrolltop)
var $document = $(document),
$element = $('.description'),
className = 'dark';
$document.scroll(function() {
$element.toggleClass(className, $document.scrollTop() >= 77);
});
@livercake
livercake / gist:c4bed0f8fa94d9dd488a
Created August 6, 2014 15:57
javascript image randomizer (with array)
var bgArray = ['bg1.jpg', 'bg2.jpg', 'bg3.jpg', 'bg4.jpg', 'bg5.jpg'];
var bg = bgArray[Math.floor(Math.random() * bgArray.length)];
var path = 'http://localhost/img/';
$('#welcome').css('background-image', 'url('+path+bg+')');
@livercake
livercake / gist:428009fc59420ae88ef0
Created August 6, 2014 15:48
Video embeds: Aspect ratio fluid resizer
$(function() {
$allVideos = $(".video iframe, .video object, .video embed");
$fluidEl = $("div.video");
$allVideos.each(function() {
$(this).attr('data-aspectRatio', this.height / this.width)
.removeAttr('height')
.removeAttr('width');
});