Skip to content

Instantly share code, notes, and snippets.

🌴
Working from localhost

Stefan Pejcic stefanpejcic

🌴
Working from localhost
Block or report user

Report or block stefanpejcic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stefanpejcic
stefanpejcic / reset-wordpress-password.sql
Created Nov 12, 2019
reset WordPress password from the database
View reset-wordpress-password.sql
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('INSERT_USERNAME_HERE', MD5('INSERT_PASSWORD_HERE'), 'INSERT_FIRSTNAME_LASTNAME>', 'INSERT_EMAIL_HERE', '0');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
@stefanpejcic
stefanpejcic / calculator.py
Created Sep 25, 2019
Simple calculator with the operator instead of if
View calculator.py
import operator
ops = {
"+": operator.add,
"-": operator.sub,
"/": operator.truediv,
"*": operator.mul,
"**": pow
}
print(ops['-'](50, 25))
View string-functions.php
<?php
$statement1="the tree";
$statement2=" is growing";
$combination=$statement1;
$combination .=$statement2;
echo ucfirst ($combination);
echo ucwords ($combination);
echo strtolower ($combination);
echo strtoupper ($combination);
@stefanpejcic
stefanpejcic / clear-screen.py
Created Sep 21, 2019
Clear the screan in python
View clear-screen.py
import os
clear = lambda: os.system('cls')
clear()
@stefanpejcic
stefanpejcic / .htaccess
Created Sep 2, 2019
Disable 404 errors
View .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(robots\.txt|sitemap\.xml(\.gz)?)
RewriteCond %{REQUEST_FILENAME} \.(css|js|html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|swf|tar|tif|tiff|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$ [NC]
RewriteRule .* - [L]
View functions.php
<?php wporb_set_post_view(); ?>
View functions.php
function wporb_get_post_view() {
$count = get_post_meta( get_the_ID(), 'post_views_count', true );
return "$count views";
}
function wporb_set_post_view() {
$key = 'post_views_count';
$post_id = get_the_ID();
$count = (int) get_post_meta( $post_id, $key, true );
$count++;
update_post_meta( $post_id, $key, $count );
@stefanpejcic
stefanpejcic / .htaccess
Created Aug 29, 2019 — forked from joostvanveen/.htaccess
.htaccess Security
View .htaccess
######################################################################
## Word to the wise ##
## It is best to keep your htaccess files as clean as possible ##
## and set as many specs in your Apache config as you can. ##
## Htaccess slows down Apache. ##
## Review the entire file before use, especially the TODO sections. ##
######################################################################
Options -MultiViews
Options +FollowSymLinks
@stefanpejcic
stefanpejcic / .htaccess
Created Aug 29, 2019
brute-force disable
View .htaccess
RewriteEngine on
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{HTTP_REFERER} !^http://(.*)?example\.com [NC]
RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
RewriteRule ^(.*)$ - [F]
You can’t perform that action at this time.