Skip to content

Instantly share code, notes, and snippets.

View mateuslopes's full-sized avatar

Mateus Lopes mateuslopes

View GitHub Profile
@mateuslopes
mateuslopes / wp-empty-widget.php
Created June 22, 2012 04:34 — forked from jonathonbyrdziak/CustomWidgetFile.php
Wordpress+Widget: EMPTY WIDGET Plugin code to create a single widget in wordpress.
<?php
/**
* @package RedRokk
* @version 1.0.0
*
* Plugin Name: Empty Widget
* Description: Single Widget Class handles all of the widget responsibility, all that you need to do is create the html. Just use Find/Replace on the Contact_RedRokk_Widget keyword to rebrand this class for your needs.
* Author: RedRokk Interactive Media
* Version: 1.0.0
* Author URI: http://www.redrokk.com
@mateuslopes
mateuslopes / cleanQuery.php
Created June 3, 2012 18:29 — forked from boopathi/cleanQuery.php
MySQL+Security: Escape MySQL queries preventing injections
<?php
/** Function to sanitize values received from the form. Prevents SQL injection */
function clean($str) {
$str = @trim($str);
if(get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}
?>
@mateuslopes
mateuslopes / mysql_backup.sh
Created June 3, 2012 18:26 — forked from stabenfeldt/mysql_backup.sh
MySQL: Backup a database in one command line
mysqldump -u USER -p PASSWORD database | gzip -9 > BACKUP/prod-`date +%Y.%m.%d`c.gz
@mateuslopes
mateuslopes / EmptyWidget.php
Created June 3, 2012 16:38 — forked from jonathonbyrdziak/CustomWidgetFile.php
Plugin code to create a single widget in wordpress.
<?php
/**
* @package RedRokk
* @version 1.0.0
*
* Plugin Name: Empty Widget
* Description: Single Widget Class handles all of the widget responsibility, all that you need to do is create the html. Just use Find/Replace on the Empty_Widget keyword to rebrand this class for your needs.
* Author: RedRokk Interactive Media
* Version: 1.0.0
* Author URI: http://www.redrokk.com
@mateuslopes
mateuslopes / gist:2864082
Created June 3, 2012 16:25 — forked from jlengstorf/gist:2864077
.htaccess: Increase max upload file size
php_value upload_max_filesize 20M
php_value post_max_size 20M
@mateuslopes
mateuslopes / wp-dbquery-output.php
Created June 3, 2012 16:23 — forked from bradp/gist:2863967
WordPress: DB Query Output Monitor
<?php
function performance( $visible = false ) {
$stat = sprintf( '%d queries in %.3f seconds, using %.2fMB memory',
get_num_queries(),
timer_stop( 0, 3 ),
memory_get_peak_usage() / 1024 / 1024
);