Skip to content

Instantly share code, notes, and snippets.

View fgilio's full-sized avatar

Franco Gilio fgilio

View GitHub Profile
@fgilio
fgilio / testing-carbon-fields.php
Created July 27, 2016 14:58
Testing Carbon Fields
<?php
use Carbon_Fields\Container;
use Carbon_Fields\Field;
Container::make('theme_options', 'thisThing Options')
->add_fields([
Field::make('complex', 'thisThing_options')
->set_min(1)
->set_max(1)
->add_fields('Basic', [
@fgilio
fgilio / wpscan-tests.sh
Created October 16, 2016 03:03
WPScan Tests
// Directly executing ruby
wpscan.rb --url https://website.com --wordlist darkc0de.lst --username admin
ruby ./wpscan.rb --url https://website.com --wordlist darkc0de.lst --username admin
ruby ./wpscan.rb --url https://website.com
ruby ./wpscan.rb -u https://website.com --wordlist darkc0de.lst --username admin threads 50
ruby wpscan.rb --url https://website.com --wordlist passwords.txt threads 50
@fgilio
fgilio / gitcheats.txt
Created September 26, 2016 15:34 — forked from chrismccoy/gitcheats.txt
git cheats
# shortform git commands
alias g='git'
# get most modified files and counts
git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk 'BEGIN {print "count\tfile"} {print $1 "\t" $2}' | sort -g
# Locally checkout all remote branches of a repository
git branch -r | cut -d '/' -f2 | grep -Ev '( |master)' | xargs -Ibranch git checkout -b branch origin/branch
# Open current Git repository URL
@fgilio
fgilio / wp-delete-transients.sql
Created August 16, 2016 18:11
WordPress - Deletes all Transients
DELETE FROM `wp_options` WHERE `option_name` LIKE ('%\_transient\_%')
@fgilio
fgilio / wp_post_char_lenght_monthly.sql
Created August 2, 2016 13:53
WordPress average post character length for a given month
SET @start = '2016-1-01';
SELECT AVG(CHAR_LENGTH(post_content)) AS avgLength
FROM wp_posts
WHERE post_type = 'post'
AND post_status = 'publish'
AND post_date >= @start
AND post_date < @start + INTERVAL 1 MONTH;
@fgilio
fgilio / blockusers_init.php
Created June 13, 2016 18:21
WordPress block user from /wp-admin
add_action( 'init', function () {
global $current_user;
$username = $current_user->user_login;
if ( ($username == 'the-username') ) {
if ( is_admin() && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
wp_redirect( home_url() );
exit;
}
}
@fgilio
fgilio / WordPress-bulk-disable-comments.sql
Created March 2, 2016 01:11
WordPress bulk disable comments
UPDATE wp_posts SET comment_status = 'closed', ping_status = 'closed';
@fgilio
fgilio / Disable trackbacks in WordPress.sql
Created March 1, 2016 15:37
Disable trackbacks in WordPress
# As stated here: https://www.siteground.com/kb/how_to_disable_trackbacks_in_wordpress/
UPDATE wp_options SET option_value = 'closed' WHERE wp_options.option_id =20 AND wp_options.blog_id =0;
@fgilio
fgilio / output-buffer-to-string.php
Created February 7, 2016 20:24
PHP - Save Output Buffer to $string
<?php
ob_start();
// Run code with here, must include 'echo' or alike
$output = ob_get_contents();
ob_end_clean();
@fgilio
fgilio / microtime-benchmarking.php
Created February 7, 2016 20:22
PHP - Use microtime to benchmark scripts
<?php
$time_start = microtime(true);
// Run code here
$time_end = microtime(true);
$time = $time_end - $time_start;
echo '<br> <h1> Time = '.$time.' seconds. </h1> <br>';