Skip to content

Instantly share code, notes, and snippets.

@douglascabral
douglascabral / jwt.php
Last active July 25, 2023 03:44
Example of JWT with Pure PHP
<?php
$key = 'your-secret-key-here';
$header = [
'typ' => 'JWT',
'alg' => 'HS256'
];
$header = json_encode($header);
$header = base64_encode($header);
if (preg_match('~MSIE|Internet Explorer~i', $_SERVER['HTTP_USER_AGENT']) || (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false)) {
//is IE 11 or below
}
@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]
<?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 / 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;
}
@douglascabral
douglascabral / .htaccess
Last active May 28, 2020 21:54
Parâmetros de segurança para o Apache
#bloqueia o acesso ao git
RedirectMatch 404 /\\.git(/|$)
#bloqueia o acesso em arquivos e pastas ocultas
RedirectMatch 404 (?i)/\..+
#bloqueia o acesso ao node_modules e vendor
RedirectMatch 403 (?i)/View/node_modules
RedirectMatch 403 (?i)/vendor
[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"
archlinux-keyring
archlinux-wallpaper
ark
atom
bluez
bluez-utils
darktable
dialog
dnsutils
docker
for line in `cat file.csv | sed -e 's/\r//g'`; do qrencode -o ${line}.png -s 10 ${line}; done