Skip to content

Instantly share code, notes, and snippets.

View mateuslopes's full-sized avatar

Mateus Lopes mateuslopes

View GitHub Profile
@mateuslopes
mateuslopes / numerology.php
Created May 14, 2021 22:13
PHP Numerology Calculator
<?php
class NumerologyCalc {
const BASE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const VALID_FINAL_NUMBERS = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44];
public $numerology = null;
function __construct($input = "", $show = false) {
@mateuslopes
mateuslopes / apache2-block-git-folders-access.conf
Created September 28, 2020 17:11
Block access .git folders and files on Apache2 servers
# Put this into your httpd.conf to block access to any server .git folders and files
<DirectoryMatch "^/.*/\.git+/">
Order deny,allow
Deny from all
</DirectoryMatch>
<Files ~ "^\.git">
Order allow,deny
Deny from all
</Files>
@mateuslopes
mateuslopes / clear-linux-memory-cache.sh
Created December 3, 2015 17:30
ShellScript: Clear linux cache memory
#!/bin/sh
# http://www.unixmen.com/how-to-clear-memory-cache-on-linux-servers/
NOW=$(date +"%F %T")
sh -c "free -mt >> /root/drop_caches.log"
echo "$NOW" >> /root/drop_caches.log
echo "--------------------" >> /root/drop_caches.log
sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"
@mateuslopes
mateuslopes / goo.sh
Created December 3, 2015 17:22
ShellScript: Open Google
#!/bin/sh
url="https://www.google.com.br/?q=$1"
open "$url"
@mateuslopes
mateuslopes / backyp-mysql-db.sh
Created December 3, 2015 17:04
ShellScript: Backup MySQL Database
#!/bin/sh
NOW=$(date +"%F")
sh -c "mysqldump -u <UserName> -p<Password> <DatabaseName> | gzip -9 > <DatabaseName>-$NOW.sql.gz"
echo "MYSQL DATABASE BACKUP GENERATED AT $NOW"
@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 / 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];
}
@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 / 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 / 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);
}
?>