Skip to content

Instantly share code, notes, and snippets.

View petskratt's full-sized avatar

Peeter Marvet petskratt

View GitHub Profile
@petskratt
petskratt / humpty-dump.php
Created November 14, 2017 12:46
Humpty-dump - dump WP or Magneto 1.x database from PHP
<?php
// dump database - either using WordPress config from same directory or locally configured parameters
// ... or Magento's local.xml
// v 1.3 (2015-03-18) Peeter Marvet, http://tehnokratt.net
// v 1.4 (2017-11-14) added autorenamer
if ( basename( __FILE__, '.php' ) === 'humpty-dump' ) {
@petskratt
petskratt / .htaccess
Last active May 22, 2019 07:10
Perishable Press 6G firewall with slight modifications (archive.org bot enabled, no IP blocking part)
# 6G FIREWALL/BLACKLIST
# @ https://perishablepress.com/6g/
# 6G:[QUERY STRINGS]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} (eval\() [NC,OR]
RewriteCond %{QUERY_STRING} (127\.0\.0\.1) [NC,OR]
RewriteCond %{QUERY_STRING} ([a-z0-9]{2000}) [NC,OR]
RewriteCond %{QUERY_STRING} (javascript:)(.*)(;) [NC,OR]
<?php
/**
* Parse Nimbusec JSON raport
* User: petskratt (peeter@zone.ee)
* Date: 26.08.2016
* Time: 11:07
* v1.0
* - initial version (a quick hack and proof of idea)
*/
@petskratt
petskratt / .gitignore
Last active March 30, 2024 15:02
Group file change times by inode ctime
.Idea
.DS_Store
<?php
/**
* HTTP 1.1 vs HTTP/2 test
* User: petskratt
* Date: 06/05/16
* Time: 12:53
*/
$merchants = [
'kuivtoit.ee' => '/img/Kuivtoit2.jpg',
@petskratt
petskratt / xkcd_pwd_gen.php
Last active March 20, 2023 15:17
Generate xkcd style password using most common 1000 Estonian words (Ansip and Savisaar excluded)
<?php
/*
* Generate xkcd style password using most common 1000 Estonian words (Ansip and Savisaar excluded)
* based on http://www.eki.ee/tarkvara/wordlist/soned2013_top1000.txt (removed names, countries, words with umlauts)
*
* http://xkcd.com/936/
*/
function xkcd_password_generator() {
@petskratt
petskratt / robots.txt
Last active March 5, 2023 16:03
Magento robots.txt
# robots.txt for Magento 1.9.x & 2.x / v1.7 2023-01-30 / peeter.marvet@vaimo.com
# - original version from 2015 for 1.9.x, but these rules are OK for M2 as well
# - edited in 2017 to add filter query parameter disallow samples + some wildcards
# - edited in 2018 to add query params blocking to Yandex as named User-agent does not read *
# - edited in 2023 to remove unneeded stuff (license.txt, crawl-delay) and make all rules use */ prefix
# based on:
# https://inchoo.net/ecommerce/ultimate-magento-robots-txt-file-examples/
# https://www.hypernode.com/nl/blog/magento-robots-txt/
# https://astrio.net/blog/optimize-robots-txt-for-magento/
#
@petskratt
petskratt / Codeacademy-edit-bookmarklet.md
Last active August 29, 2015 13:56
Edit Exercise bookmarklet for Codeacademy

Bookmarklet for easy access to edit mode on Codeacademy course exercises (where you have author / contributor rights).

Based on SCT viewer.

Drag editCA to the bookmarks bar, edit to replace the target with this code.

@petskratt
petskratt / wp-config-sample.php
Created February 1, 2013 10:23
WordPress config file that I have been using in both dev and live - based on innumerable examples... that I'll try to recall and properly attribute later.
<?php
define( 'PROD_HOST', '' );
define( 'CURRENT_HOST', $_SERVER['SERVER_NAME'] );
define( 'CURRENT_IP', $_SERVER['SERVER_ADDR'] );
define( 'WP_DEBUG', false ) ;
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', '' );
$table_prefix = 'wp_';