Skip to content

Instantly share code, notes, and snippets.

View itsjavi's full-sized avatar

Javi Aguilar itsjavi

View GitHub Profile
@itsjavi
itsjavi / autofit_background_image_script.html
Created October 27, 2010 10:50
Script for filling the entire window with a background image at any resolution (auto-fit)
<!DOCTYPE html>
<html>
<head>
<title>Auto-fit background image script</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<style>
html,body{
padding:0;
margin:0;
height:100%;
@itsjavi
itsjavi / jquery-ui.declarative.js
Created May 26, 2011 11:48
Initialize jQuery UI widgets and behaviours using HTML5 declarative markup
(function($){
$(document).ready(function(){
$("*[data-ui-widget]").each(function(){
$this = $(this);
switch($this.data("ui-widget")){
case "button":{
$this.button($this.data("ui-widget-options"));
}break;
case "datepicker":{
$this.datepicker($this.data("ui-widget-options"));
@itsjavi
itsjavi / fn_group_every.php
Created June 1, 2012 08:40
PHP function for grouping elements in a loop
<?php
/**
* PHP function for grouping elements in a loop
* @param int $times Group max items
* @param array $items
* @param string $html_before Group start html
* @param string $html_after Group close html
* @param string $fn Callable function name that generates the item HTML
* @param int $offset
@itsjavi
itsjavi / bootstrap_subnav_stick.js
Created June 1, 2012 10:16
Stick bootstrap subnav on scroll
// fix sub nav on scroll
var $win = $(window)
, $nav = $('.subnav')
, navTop = $('.subnav').length && $('.subnav').offset().top - 40
, isFixed = 0
processScroll()
$win.on('scroll', processScroll)
@itsjavi
itsjavi / jsdatetools.js
Created August 8, 2012 10:38
js date tools
datetools = {
"inDateRange":function(date, time_from, time_to){
if(isNaN(time_from) || isNaN(time_to)){
return false;
}
var dfrom = new Date(parseInt(time_from)*1000);
var dto = new Date(parseInt(time_to)*1000);
dto = new Date(dto.getFullYear(), dto.getMonth(), dto.getDate(), 23, 59, 59);
var now = date.getTime();
@itsjavi
itsjavi / jquery-tpl.js
Created October 10, 2012 11:47
jQuery template plugin (using Mustache and data-template elements for templates)
/*
* Sample:
* HTML:
* <div data-template="greeting">hi, {{name}}</div>
*
* JavaScript:
* $("div").tpl("greeting", {'name':'Paul'});
*/
$.fn.tpl = function(name, vars, partials){
return $(this).tplParse($('*[data-template="' + name + '"]:first').html(), vars, partials);
@itsjavi
itsjavi / pdoiterator.php
Created October 23, 2012 12:35
PDOStatement Iterator classes (emulates an iterator, with minimum performance impact)
<?php
abstract class Record_Iterator_Abstract implements Iterator, Countable
{
/**
*
* @var string The record class (model)
*/
protected $recordClass;
@itsjavi
itsjavi / bootstrap_file_input.html
Last active October 13, 2015 05:57
Twitter Bootstrap CSS style for file inputs
<!-- DEMO: http://jsfiddle.net/javieranid/Dpgba/1/ -->
<label class="btn btn-file btn-mini">
<input type="file" /> <span>Examinar</span>
</label>
<style>
.btn-file{
position:relative;
overflow: hidden;
@itsjavi
itsjavi / htaccess_redirect_generator.php
Created January 8, 2013 19:26
Generates .htaccess redirect codes for a list of links
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>htaccess redirect generator</title>
<style>
html,body{
font-size:14px;
color:#222;
margin:0;
@itsjavi
itsjavi / githubapi_latestcommits_localstorage.js
Last active December 11, 2015 00:59
Fetch latest commits from Github API and store them on localStorage
/**
*
* Script for loading and caching commit history
*
*/
! function(root, $) {
/**
* Fetch latest commits from Github API and cache them
* @link https://gist.github.com/4520294
*