Skip to content

Instantly share code, notes, and snippets.

View mateuslopes's full-sized avatar

Mateus Lopes mateuslopes

View GitHub Profile
@mateuslopes
mateuslopes / css-vertical-align-center.css
Created June 3, 2012 16:11
CSS: Vertical align center (without line-height)
.v-center, .vertical-center, .v-middle, .vertical-middle {
display: table-cell;
vertical-align: middle;
}
@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
);
@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 / 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 / wp-change-site-url.sql
Last active February 19, 2020 13:43
SQL+Wordpress: Changing WP Site Url
SET NAMES 'utf8mb4';
SET CHARACTER SET 'utf8mb4';
SET @origin_url = 'http://localhost/origem';
SET @destiny_url = 'http://localhost/destino';
UPDATE wp_options
SET option_value = REPLACE(option_value, @origin_url, @destiny_url)
WHERE option_value LIKE (CONCAT('%',@origin_url,'%'));
@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 / 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 / css-box-model.css
Created June 4, 2012 02:35
CSS3: Complete CSS3 Box Properties example
#box-wrap-inner {
display: -webkit-box;
display: -moz-box;
display: box;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
box-orient: horizontal;
-webkit-box-align: stretch;
@mateuslopes
mateuslopes / image-better-quality.php
Created June 5, 2012 03:48
PHP+Image: Image Better Quality Filter
$img_r = imagecreatefromjpeg($src);
imagefilter($img_r, IMG_FILTER_BRIGHTNESS, 5);
imagefilter($img_r, IMG_FILTER_CONTRAST, -10);
$sharpenMatrix = array
(
array(-2, -1, -2),
array(-1, 40, -1),
array(-2, -1, -2)
@mateuslopes
mateuslopes / jquery-get-url-vars.js
Created June 12, 2012 20:03
jQuery: Get URL GET vars from page url (jQuery Extension)
$.extend({
getUrlVars: function(){
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}