Skip to content

Instantly share code, notes, and snippets.

Iván Melgrati imelgrat

Block or report user

Report or block imelgrat

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@imelgrat
imelgrat / modifier.calculate_age.php
Created Apr 1, 2019
Smarty Modifier - Calculate age from birth date
View modifier.calculate_age.php
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
* Place this file inside the smarty/libs/plugins directory and invoke as any other modifier (e.g. {$birth_date|calculate_age} )
*/
/**
@imelgrat
imelgrat / limit-gist-box-size.css
Last active Feb 15, 2019
Limit width and height of embedded gists.
View limit-gist-box-size.css
/**
* Limit embedded gist window size. Show scrollbars when necessary.
* @link https://imelgrat.me/
*/
/* Limit width. Show scrollbars when exceeding width */
.gist {
max-width:350px;
overflow:auto;
}
@imelgrat
imelgrat / bulk-upload.php
Last active Feb 15, 2019
Register a WordPress custom post type and perform a bulk-upload from a MySQL database
View bulk-upload.php
<?php
/* Create custom posts in WordPress taking data from a MySQL database.
@link https://imelgrat.me/wordpress/bulk-upload-custom-posts-wordpress/
Load WordPress functions and plug-ins. Put correct path for this file.
This example assumes you're using it from a sub-folder of WordPress.
If you run it from somewhere else, adjust path to wp-load.php accordingly.
*/
require_once('../wp-load.php');
$database['hostname'] = 'SERVER';
@imelgrat
imelgrat / bootstrap-tab-collapse.css
Created Feb 15, 2019
Integrate Bootstrap's Tabs and Accordions into a single component
View bootstrap-tab-collapse.css
.panel-title {
cursor:pointer;
}
h4.tab-title
{
font-family: "avenirheavy", Helvetica, Arial, "sans-serif";
font-weight: normal;
font-size: 22px;
color: #ffffff;
}
@imelgrat
imelgrat / admob-banner.js
Last active Feb 15, 2019
Configure AdMob ads on a Phonegap application
View admob-banner.js
/**
* Create an AdMob banner ad using AdMob Plugin Pro (in Phohegap)
*
* @link https://imelgrat.me/phonegap/admob-effective-monetize-cordova-app/
*
* @link https://goo.gl/yTCAea AdMob Plugin Pro
*
*/
function createSelectedBanner()
{
@imelgrat
imelgrat / find-feeds.php
Created Feb 15, 2019
Use an open source PHP class to fetch articles from RSS, ATOM and OPML feeds
View find-feeds.php
<?php
/**
* Retrieve and parse OPML (Outline Processor Markup Language) Parser Class.
* Extracts the properties of content from OPML files using a PHP class
*
* @link https://github.com/imelgrat/opml-parser
*
* @link https://imelgrat.me/php/find-atom-opml-rss-feeds/
*/
require_once('opml-parser.php');
@imelgrat
imelgrat / 404.php
Created Feb 15, 2019
Redirect WordPress dead-links to the homepage
View 404.php
<?php
/**
* Redirect missing WordPress URLs .
*
* If you want to redirect the browser every time a page can’t be found while avoiding SEO impact, you can open your 404.php file
* in your theme’s folder and paste this at the top. If it doesn’t exist, then create a blank 404.php file.
*
* @link https://imelgrat.me/wordpress/dead-links-redirect-avoid-seo-impact/
*/
header("HTTP/1.1 301 Moved Permanently");
@imelgrat
imelgrat / convert-date-format.php
Created Feb 15, 2019
Date formatting: How to Detect and convert date formats in PHP
View convert-date-format.php
<?php
/**
* Convert date format.
*
* Use regular expressions to detect dates and convert the detected dates into a MySQL-compatible DATE format.
*
* @link https://imelgrat.me/php/date-formatting-detect-convert/
*/
function convert_date_format($old_date = '')
{
@imelgrat
imelgrat / collapsible-sets.js
Last active Feb 15, 2019
jQuery Mobile collapsible sets. Move content to the top
View collapsible-sets.js
/**
* Attach a handler to collapsible sets.
*
* Attach a handler to every collapsible (filtered by their jQM’s role) so that,
* every time a collapsible’s header is tapped, it will scroll to the top of the page (both header and content)..
*
* @link https://imelgrat.me/javascript/collapsible-scroll-jquery-mobile/
*/
$(document).on('pagebeforeshow', function()
{
@imelgrat
imelgrat / debouce-resize.js
Created Feb 15, 2019
Debouncing JavaScript events to prevent jerky action
View debouce-resize.js
/**
* Debounce window-resize events
*
* Debouncing JavaScript events to prevent jerky action during UI changes.
*
* @link https://imelgrat.me/javascript/debouncing-javascript-events/
*/
$(window).bind('resize', function(e)
{
window.resizeEvt;
You can’t perform that action at this time.