Skip to content

Instantly share code, notes, and snippets.

View rudwolf's full-sized avatar

rudwolf

View GitHub Profile
@rudwolf
rudwolf / wpse_70758.php
Last active August 29, 2015 14:26 — forked from brasofilo/wpse_70758.php
WordPress plugin : Prevent Categories Deletion
<?php
/*
Plugin Name: Prevent Category Deletion
Plugin URI: http://wordpress.stackexchange.com/q/70758/12615
Description: Prevent deletion of categories. Modify the $undeletable array to suit your setup. Use Category SLUGS.
Author: brasofilo
Version: 1.0
Author URI: http://wordpress.stackexchange.com/users/12615/brasofilo
*/
@rudwolf
rudwolf / zip.php
Created November 19, 2015 15:47 — forked from jonmaim/zip.php
PHP script to remotely create zip archives of your FTP
<?php
/*
*
* This script will backup your web site by remotely archiving all files on the root FTP directory.
* It will work even if your web server is memory limited buy splitting zips in several arhive files it they are too many files.
* All zip files will be stored in a directory called temporary which must be writable.
*
* How to use it:
* - Place the script at the root of your FTP.
@rudwolf
rudwolf / estados.php
Last active August 10, 2016 17:55
Array associativa de estados brasileiros com sigla pra chave e nome para valor para uso em PHP
<?php
$estados = array(
"AC"=>"Acre",
"AL"=>"Alagoas",
"AM"=>"Amazonas",
"AP"=>"Amapá",
"BA"=>"Bahia",
"CE"=>"Ceará",
"DF"=>"Distrito Federal",
"ES"=>"Espírito Santo",
@rudwolf
rudwolf / category-archive.php
Created July 14, 2016 17:57
Get the archive for specific category
<?php
global $wpdb, $wp_locale;
$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts, $wpdb->term_taxonomy, $wpdb->term_relationships
WHERE $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post'
AND $wpdb->term_taxonomy.term_id = 11
AND $wpdb->posts.ID = $wpdb->term_relationships.object_id
AND $wpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id
GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC";
@rudwolf
rudwolf / Sublime Text 3 Build 3103 License Key - CRACK
Created May 2, 2017 18:35
Sublime Text 3 Build 3103 License Key - CRACK
I use the first
—– BEGIN LICENSE —–
Michael Barnes
Single User License
EA7E-821385
8A353C41 872A0D5C DF9B2950 AFF6F667
C458EA6D 8EA3C286 98D1D650 131A97AB
AA919AEC EF20E143 B361B1E7 4C8B7F04
function validateEmail(email) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
emailCaptured = false;
(function($) {
$("input[type='text']").on('keyup', function (e) {
$jsString = ob_get_contents();
ob_end_clean();
$unescaped = array("'", '"');
$escaped = array("\\x27", "\\x22");
echo str_replace($unescaped, $escaped, $jsString);
@rudwolf
rudwolf / AbstractRequest.php
Created July 6, 2017 20:02
Request and Controllers
<?php
namespace App\Http\Requests;
use App\Http\Requests\Request;
use Illuminate\Contracts\Validation\Validator;
class AbstractRequest extends Request
{
@rudwolf
rudwolf / DbTraits.php
Created December 1, 2017 18:23
app/Traits/DbTraits.php
<?php
/**
* Trait to handle commom function used by DynamicController or anything that needs to access or run query in any Database
*/
namespace App\Traits;
use Config;
use Db;
@rudwolf
rudwolf / probleminha.php
Created April 3, 2018 15:26
Probleminha do HackerRank
<?php
$handle = fopen ("php://stdin", "r");
function equalizeArray($arr) {
$diff = 0;
$d = [];
foreach($arr as $item) {
@$d[$item]++;
}