Skip to content

Instantly share code, notes, and snippets.

<?php
add_filter( 'rest_endpoints', 'disable_default_endpoints' );
function disable_default_endpoints( $endpoints ) {
$allowed = ['/some/route/here'];
foreach ( $endpoints as $maybe_endpoint => $object ) {
if ( ! in_array($maybe_endpoint, $allowed) ) {
@douglascabral
douglascabral / wordpress-security.htaccess
Last active June 29, 2020 20:29
Improve WP Security
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
RewriteRule (vendor|node_modules) - [R=404,L,NC]
RewriteRule Gruntfile.js - [R=404,L,NC]
RewriteRule gulpfile.js - [R=404,L,NC]
RewriteRule package.json - [R=404,L,NC]
@douglascabral
douglascabral / wp-content-uploads-.htaccess
Created June 25, 2020 14:00
improve security in WP Upload folder
<files *.ini>
order allow,deny
deny from all
</files>
<files *.sh>
order allow,deny
deny from all
</files>
@douglascabral
douglascabral / function.php
Created June 25, 2020 00:32 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
for line in `cat file.csv | sed -e 's/\r//g'`; do qrencode -o ${line}.png -s 10 ${line}; done
@douglascabral
douglascabral / ImageToBase64.swift
Created November 22, 2018 20:40
Transform UIImage to Base64
// drawnImage : UIImage
let imgData = drawnImage.jpegData(compressionQuality: 1.0)
let base64 = imgData?.base64EncodedString()
@douglascabral
douglascabral / ImageRotate.swif
Created November 22, 2018 20:26
Rotate UIImage
import UIKit
extension UIImage {
public func imageRotatedByDegrees(degrees: CGFloat, flip: Bool) -> UIImage {
let radiansToDegrees: (CGFloat) -> CGFloat = {
return $0 * (180.0 / CGFloat.pi)
}
let degreesToRadians: (CGFloat) -> CGFloat = {
return $0 / 180.0 * CGFloat.pi
for SERIAL in $(adb devices | grep -v List | cut -f 1); do adb -s $SERIAL install -r nome-do-arquivo-do-app.apk; done
<?php
header('Content-Type: application/json');
$body = file_get_contents("php://input");
$bodyjson = json_decode($body);
$number1 = $bodyjson->queryResult->parameters->number1;
$number2 = $bodyjson->queryResult->parameters->number2;
$action = $bodyjson->queryResult->action;
$result = 0;