Skip to content

Instantly share code, notes, and snippets.

View ivanmendoza's full-sized avatar

Iván ivanmendoza

View GitHub Profile
@ivanmendoza
ivanmendoza / 0_reuse_code.js
Last active August 29, 2015 14:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ivanmendoza
ivanmendoza / style-test.php
Created September 17, 2013 05:22
Demo page to test styles. Gets dummy content from loripsum.net API.
<!DOCTYPE html>
<head>
<title>Demo</title>
<meta charset="utf-8" />
</head>
<body>
<h1>Heading H1</h1>
<h2>Heading H2</h2>
<h3>Heading H3</h3>
<h4>Heading H4</h4>
@ivanmendoza
ivanmendoza / open-comments.sql
Created July 5, 2013 05:56
Wordpress - Open comments and pings
UPDATE wp_posts SET comment_status = 'open' WHERE comment_status != 'open';
UPDATE wp_posts SET ping_status = 'open' WHERE ping_status != 'open';
@ivanmendoza
ivanmendoza / filter_my_attachments
Last active March 21, 2020 12:39
Wordpress: Show only my attachments (current user) in media library. Admins can see everything. #php #wordpress
function filter_my_attachments( $wp_query ) {
if (is_admin() && ($wp_query->query_vars['post_type'] == 'attachment')) {
if ( !current_user_can( 'activate_plugins' ) ) {
global $current_user;
$wp_query->set( 'author', $current_user->id );
}
}
}
add_filter('parse_query', 'filter_my_attachments' );
@ivanmendoza
ivanmendoza / chrome-metadata.html
Last active December 14, 2015 00:19
Metada for Chrome apps/bookmark
<meta name=”application-name” content=”Greatest Website”/>
<meta name=”description” content=”The very best on the web”/>
<meta name=”application-url” content=”http://www.superfantasticgreatestweb.com”/>
<link rel=”icon” href=”great-icon_32×32.png” sizes=”32×32″/>
<link rel=”icon” href=”great-icon_48×48.png” sizes=”48×48″/>
@ivanmendoza
ivanmendoza / index.html
Last active December 13, 2015 22:18
Asynchronous load of social bookmarks using _snbx-socialx.js (https://github.com/ivanmendoza/snbx)
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>SNBX - MKT X</title>
<!-- LINKS -->
<style type="text/css">body{font:normal 1em verdana,helvetica,arial,sans-serif;font-size:16px;background:#fff;color:#000;margin:0;padding:0}pre,code,tt{font:normal 1/1.5 'Lucida Console','Consolas','Courier New',monospace}b,strong{font-weight:700}h1,h2,h3,h4,h5,h6{font:normal 2/.9 'gill sans','Century Gothic',verdana,sans-serif}em,i,dfn{font-style:italic}dfn{font-weight:700}p,code,pre,kbd{margin:0 0 1.5em 0}blockquote{margin:0 1.5em 1.5em 1.5em;font-style:italic}cite{font-style:italic}li ul,li ol{margin:0 1.5em}ul,ol{margin:0 1.5em 1.5em 1.5em}ul{list-style-type:disc}ol{list-style-type:decimal}ol ol{list-style:upper-alpha}ol ol ol{list-style:lower-roman}ol ol ol ol{list-style:lower-alpha}dl{margin:0 0 1.5em 0}dl dt{font-we
@ivanmendoza
ivanmendoza / icons.less
Created May 12, 2012 10:17
An approach to manage icons using mixins(LessCSS) and CSS Sprites
/*
*
* Icon index
* by @dic7 (github: ivanmendoza)
*
*/
/*
* SPRITE
* url: ../images/icons.png
@ivanmendoza
ivanmendoza / media-queries.css
Created May 12, 2012 07:24
Common media queries
/* SMARTPHONES */
@media only screen and (min-device-width : 320px) and (max-device-width : 480px) {
}
/* TABLETS */
@media screen and (min-width: 481px) and (max-width: 1024px) {
}
/* DESKTOP */
@ivanmendoza
ivanmendoza / scrollto.js
Created March 23, 2012 04:57
ScrollTo Function
// Example: scrollTo(jQuery('#footer'));
function scrollTo(target){
var targetOffset = target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 1000);
return false;
}
@ivanmendoza
ivanmendoza / relative-date-php
Created February 21, 2012 18:44
Get relative date (spanish)
// INPUT: $item_date
$item_date = date("D, d M o G:i:s T",strtotime($item_date));
$today = date(DATE_RFC822);
$diff_date=(strtotime($today) - strtotime($item_date));
$inMinutes=round($diff_date/60);
$inHours=round($diff_date/(60*60));
$inDays=round($diff_date/(24*60*60));
if($inMinutes==1){$txt_date="hace un minuto";}