Skip to content

Instantly share code, notes, and snippets.

View imelgrat's full-sized avatar

Iván Melgrati imelgrat

View GitHub Profile
@imelgrat
imelgrat / .htaccess
Last active August 23, 2017 19:42
Disable access to all file types except the following (to be placed inside a Wordpress wp-content directory). Full article at: http://imelgrat.me/security/wordpress-htaccess-file-protect/
# Disable access to all file types except the following
Order deny,allow
Deny from all
<Files ~ ".(xml|css|js|jpe?g|png|gif|pdf|docx|rtf|odf|zip|rar)$">
Allow from all
</Files>
@imelgrat
imelgrat / .htaccess
Last active August 23, 2017 19:42
Disable directory browsing using .htaccess. Full article at: http://imelgrat.me/security/wordpress-htaccess-file-protect/
# Disable directory browsing
Options All -Indexes
@imelgrat
imelgrat / .htaccess
Last active August 23, 2017 19:42
Use .htaccess to disable execution (and send files to the browser) of CGI-based files. Full article at: http://imelgrat.me/security/wordpress-htaccess-file-protect/
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
Options -ExecCGI
@imelgrat
imelgrat / .htaccess
Last active August 23, 2017 19:42
Protect .htaccess and .htpasswd files (current and child folders). Full article at: http://imelgrat.me/security/wordpress-htaccess-file-protect/
# Deny access to all .htaccess files
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>
@imelgrat
imelgrat / prevent-jerky-resize.js
Last active August 23, 2017 19:53
Prevent jerky motion upon resizing browser window by waiting until window resizing stops (no external libraries). Full article at: http://imelgrat.me/javascript/debouncing-javascript-events/
$(window).bind('resize', function(e)
{
window.resizeEvt;
$(window).resize(function()
{
clearTimeout(window.resizeEvt);
window.resizeEvt = setTimeout(function()
{
if($(window).width() != previous_width)
{
<?
#Include the class
require_once("iam_backup.php");
# Set the parameters: We only set the Database connection. The connection procedure could be in an include file
# This will dump the database and prompt the user to download it. No compression is applied here.
$conn = @mysql_pconnect("localhost","root","");
if(!$result) // If no connection, return 0
{
echo "An error has occurred. Could not connect to the server";
}
@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" );
?>
@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 / 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 / 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