Skip to content

Instantly share code, notes, and snippets.

View j0lvera's full-sized avatar
🎯
Focusing

Juan Olvera j0lvera

🎯
Focusing
View GitHub Profile
var app = app || {};
//object literal
app = {
init: function(){
this.cache();
this.bind();
},
cache: function(){
this.anchor = $( 'a' );
@j0lvera
j0lvera / gist:4694537
Last active December 12, 2015 01:58
DoJS based on https://t.co/2swl4ne8
data:text/html,
<title>DoJS</title>
<style type="text/css">
#e{position:absolute;top:0;right:0;bottom:0;left:0;}
</style>
<div id="e"></div>
@j0lvera
j0lvera / last-posts.php
Created February 8, 2013 06:16
Last Posts on WP
<ul class="last-posts">
<?php
$args = array( 'numberposts' => 3 );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<li class='last-posts__post'>
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail('thumbnail', array('class' => 'last-posts__post-img'));
}
@j0lvera
j0lvera / shortcode.php
Last active December 12, 2015 07:29
Recent Posts Shortcode
<?php
// Recent Posts
function recent_posts($atts){
$q = new WP_Query(
array( 'orderby' => 'date', 'posts_per_page' => '4')
);
$list = '<ul class="recent-posts">';
// Source: http://ianstormtaylor.com/oocss-plus-sass-is-the-best-way-to-css/
// Sass
%separator
border-top: 1px solid black
hr
@extend %separator
.separator
@extend %separator

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
var app = app || {};
//object literal
app = {
init: function(){
this.cache();
this.bind();
},
cache: function(){
this.anchor = $( 'a' );
@j0lvera
j0lvera / pattern.js
Created February 26, 2013 22:44
JS pattern by Chris Coyier
var s,
app = {
settings: {
numArticles: 5,
articleList: $("#article-list"),
moreButton: $("#more-button")
},
init: function() {
<html>
<body style="padding:0; margin:0;">
<!-- reloader.html -->
<iframe id=reloader src="/" style="margin:0;border:none;padding:0;height:100%;width:100%"></iframe>
<script>
(function test() {
document.getElementById('reloader').src = document.getElementById('reloader').src;
setTimeout(test, 500); // 500ms = 1/2 second
})();
</script>
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();