Skip to content

Instantly share code, notes, and snippets.

View andresgallo's full-sized avatar

Andres Gallo andresgallo

View GitHub Profile
@andresgallo
andresgallo / gist:3755044
Created September 20, 2012 10:06
localStorage test
if('test' in localStorage)alert('s');
else localStorage.test = 's';
alert(localStorage.test);
@andresgallo
andresgallo / gist:3797078
Created September 27, 2012 23:29
printR GET
<?php
//The function print_r allows you to print the content of an array
//www.domain.com?param1=value1&param2=value2
print_r($_GET['awesome']);
/***HERE IS THE ACTUAL USE OF THIS*****/
$nested = array(
"test" => array ()
);
@andresgallo
andresgallo / gist:3802663
Created September 28, 2012 23:55
Ajax sample
<div id="hiddenContent" style="display:none;"></div><!--content will be temporarily added here-->
<script>
var myContent = document.getElementById('myDdiv'),
hiddenDiv = document.getElementById('hiddenContent');
$(document).on('click','a[data-openpostid]',function(e){
var postId = this.getAttribute('data-openpostid');
var passThisObj = {//Object containin my parameters
<html>
<head>....
<body>
<a href="#nonsense" data-openPostID="11">11</a>
<a href="#nonsense" data-openPostID="5">5</a>
<div id="myDiv" style="background:red;">
<!--PUT ALL WORDPRESS CALLS HERE..THE 4 or so lines for wordpress -->
</div>
@andresgallo
andresgallo / TempConstructor
Created October 14, 2012 20:52
constructor
function myClass(params){
if(typeof params === 'undefined')params = {};
if( !('someOtherParam' in params)params.someOtherParam = 'blah';//Neat way to set default params in stuff :)
this.params = params; //bind params to this instance
this.set = function(){
//Do your thing
if(typeof this.params.callback === "function")this.params.callback();
@andresgallo
andresgallo / gist:4982191
Created February 19, 2013 01:04
AUGMENTATION PATTERN
var CLASSNAME = function(){
var first = "firstvar",
second = "secondvar";
//Expose private vars
return {
first :first
};
})();
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
@andresgallo
andresgallo / Guillete.js
Created December 17, 2014 17:23
Guillete.js
document.addEventListener("DOMContentLoaded", function(){
window.Mustache = null;//Because its what can be expected of Guillete
});
(function(){
function patch(){//ACTUAL PATCH
$('.VideoItem[data-jnj-inlinevideo="brightcove"]').each(function(){//FLAG RELEVANT PLAYeRS
var $this = $(this),
$imgArea = $this.find('.video_trigger'),
ratio = Math.floor( ( $imgArea.width() / $imgArea.height() ) * 100);//CHECK IF RATIO IS MESSED UP THEREFORE A baD IMAGE
if(ratio != 177){
$this.attr('data-using-default-image',ratio);
}
});