Skip to content

Instantly share code, notes, and snippets.

View imelgrat's full-sized avatar

Iván Melgrati imelgrat

View GitHub Profile
@imelgrat
imelgrat / README.md
Last active August 23, 2017 19:55
Move content to the top in jQuery Mobile collapsible sets. Full article at: http://imelgrat.me/javascript/collapsible-scroll-jquery-mobile/

Move content to the top in jQuery Mobile collapsible sets

A simple way to make sure content in jQuery Mobile collapsible sets remains visible when expanding each section by bringing the section being opened to the top. This way, people have to scroll less, improving their user experience on the website.

A Pen by Iván Melgrati on CodePen.

License.

@imelgrat
imelgrat / convert-dates.php
Last active August 23, 2017 20:10
A PHP function to detect and convert dates from different formats into a MySQL-compatible format (YYYY-MM-DD). Full article at: http://imelgrat.me/php/date-formatting-detect-convert/
<?php
/**
* @author Ivan Ariel Melgrati
* @copyright 2015
*/
function convert_date_format($old_date = '')
{
$old_date = trim($old_date);
@imelgrat
imelgrat / redirect.php
Last active August 23, 2017 20:22
Redirecting WordPress to the homepage. Full article at: http://imelgrat.me/wordpress/dead-links-redirect-avoid-seo-impact/
<?php
// 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. If it doesn’t exist, then create a blank .php file. Paste the following code in there:
header("HTTP/1.1 301 Moved Permanently");
header("Location: " . get_bloginfo('url'));
exit();
?>
@imelgrat
imelgrat / admob.js
Last active August 23, 2017 21:39
JavaScript code to configure Cordova's AdMob Plugin Pro. Full articlle at: http://imelgrat.me/phonegap/admob-effective-monetize-cordova-app/
// select the right Ad ID according to platform
var admobid = {};
if( /(android)/i.test(navigator.userAgent) ){ // for android
admobid = {
banner: 'ca-app-pub-xxx/zzz', // or DFP format "/6253334/dfp_example_ad"
interstitial: 'ca-app-pub-xxx/kkk'
};
}
else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)){ // for ios
admobid = {
@imelgrat
imelgrat / createSelectedBanner.js
Last active August 23, 2017 21:39
Create an AdMob ad using AdMob Plugin Pro. Full articlle at: http://imelgrat.me/phonegap/admob-effective-monetize-cordova-app/
function createSelectedBanner()
{
AdMob.createBanner( { adId:admobid.banner,
bgColor: '#XXYYZZ', overlap:false,
adSize: 'SMART_BANNER',// Available sizes are SMART_BANNER, BANNER,MEDIUM_RECTANGLE,FULL_BANNER,LEADERBOARD and SKYSCRAPER
position:8 //1 => Top Left, 2 => Top Center, 3 => Top Right, 4 => Left, 5 => Center, 6 => Right, 7 => Bottom Left, 8 => Bottom Center, 9 => Bottom Right
@imelgrat
imelgrat / admob-intersitial.js
Last active August 23, 2017 21:39
JavaScript code to display an intersitial ad on Cordova Apps using AdMob Plugin Pro. Full articlle at: http://imelgrat.me/phonegap/admob-effective-monetize-cordova-app/
function prepareInterstitial()
{
AdMob.prepareInterstitial({ adId:admobid.interstitial, autoShow:true });
}
@imelgrat
imelgrat / plugins.properties
Last active August 24, 2017 02:49
Cordova configuration file with external repositories. Full article at: http://imelgrat.me/phonegap/apache-cordova-compile-faster-netbeans/
org.apache.cordova.device=https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
org.apache.cordova.network-information=https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git
org.apache.cordova.geolocation=https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git
org.apache.cordova.splashscreen=https://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git
org.apache.cordova.file=https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
org.apache.cordova.dialogs=https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
org.apache.cordova.file-transfer=https://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git
@imelgrat
imelgrat / plugins.properties
Last active August 24, 2017 02:49
Cordova configuration file with local repositories. Full article at: http://imelgrat.me/phonegap/apache-cordova-compile-faster-netbeans/
org.apache.cordova.device=C:\\git-repos\\cordova-plugin-device
org.apache.cordova.network-information=C:\\git-repos\\cordova-plugin-network-information
org.apache.cordova.geolocation=C:\\git-repos\\cordova-plugin-geolocation
org.apache.cordova.splashscreen=C:\\git-repos\\cordova-plugin-splashscreen
org.apache.cordova.file=C:\\git-repos\\cordova-plugin-file
org.apache.cordova.file-transfer=C:\\git-repos\\cordova-plugin-file-transfer
org.apache.cordova.dialogs=C:\\git-repos\\cordova-plugin-dialogs
@imelgrat
imelgrat / feed-finder.example.php
Last active August 24, 2017 13:04
RSS feeds, ATOM and OPML link retrieval with a PHP Class. Full article at: http://imelgrat.me/php/find-atom-opml-rss-feeds/
<?php
# Add the feed finder class
require_once('find_feeds.php');
# Create a new class instance
$find_links= new Find_RSS_Links('http://www.cleverclogs.org/2006/10/opml_autodiscov.html');
$links = $find_links->getLinks();
Display the RSS, ATOM and OPML links found on the page
print_r ($links);
?>
@imelgrat
imelgrat / download-example.php
Last active October 27, 2022 14:49
CSV export of a MySQL query using a PHP class. Full article and function source at: http://imelgrat.me/php/csv-exports-using-php-class
<?php
#Include the class. This class takes the results of a SQL query and outputs in the CSV (comma separated values) format.
require_once("iam_csvdump.php");
# Set the parameters: SQL Query, hostname, databasename, dbuser and password
$dumpfile = new iam_csvdump;
# Call the CSV Dumping function and THAT'S IT!!!! A file named export.csv is sent to the user for download
$dumpfile->dump("SELECT * FROM `tablename`", "export", "csv", "mysql", "root", "", "localhost" );
?>