Skip to content

Instantly share code, notes, and snippets.

View petskratt's full-sized avatar

Peeter Marvet petskratt

View GitHub Profile
# Display current K8S resource usage for a namespace (either first argument or current)
# Add to your ~/.profile, copy-paste results for analysis to https://docs.google.com/spreadsheets/d/1v___k9gYo4RI4wWIluJcdqOVHCFEccLQMOCGxvrZGtk/edit?usp=sharing
# peeter.marvet@vaimo.com / 2023-07-18
function resource_capacity() {
if [ -z "$1" ]
then
namespace=$(kubectl config view --minify -o jsonpath='{..namespace}')
else
@petskratt
petskratt / aliases.sh
Created April 27, 2023 07:53
aliases à la Zone.eu
#!/usr/bin/env bash
# should go into .profile
# from zone.eu shared server conf, with changes for MacOS
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
@petskratt
petskratt / curltime.sh
Created April 27, 2023 07:36
curltime and curloop
#!/usr/bin/env bash
# should go into .profile
#
# single timing:
# curltime https://example.com/
#
# with unique query argument to bypass cache:
# curltime https://example.com/?cachebuster=202304271033
#
# loop with increasing counter:
@petskratt
petskratt / wow_much_openssl.sh
Created November 1, 2022 19:29
Scan images deployed to a K8S cluster for OpenSSL versions
#!/usr/bin/env bash
# peeter.marvet@vaimo.com / 2022-11-01 ("Klytus, I'm bored. What plaything can you offer me today?")
# Scan images deployed to a K8S cluster for OpenSSL versions
#
# prerequisites:
# - kubectl
# - authenticated and authorised to access all namespaces of a cluster
# - Trivy installed https://aquasecurity.github.io/trivy/v0.34/getting-started/installation/
# - Trivy has access to your presumably private registries https://aquasecurity.github.io/trivy/v0.34/docs/advanced/private-registries/gcr/
#
@petskratt
petskratt / dumb-sec.php
Created May 15, 2021 08:43
Really dumb idea
<?php
/**
* A really dumb tool for ad-hoc PHP request logging - mostly useful to find malicious POST / cookie / etc payloads
*
* prepend with php.ini or .user.ini to cover all requests:
* auto_prepend_file = /[full-path-to-location]/dumb_sec.php
*
* @author : Peeter Marvet (peeter@zone.ee)
* @version 0.3
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL
@petskratt
petskratt / robots.txt
Last active January 27, 2020 13:06
WordPress robots.txt
# robots.txt for WordPress / v1.01 2020-01-27 / Peeter Marvet
# v1.01 - changed Crawl-delay to max allowed by Yandex e.g 2.0
#
# Uncomment and specify hostname (sitemap can be on different domain):
#Sitemap: https://example.com/sitemap_index.xml
#
# User-agents are not cumulative, e.g if a bot finds matching group * is ignored.
User-agent: *
Crawl-delay: 2.0
# All requests with parameters (search, WooCommerce filters etc):
@petskratt
petskratt / tables_and_indexes.sql
Last active November 22, 2018 17:51
List of all tables and indexes in db
-- created to find tables with missing indexes on a WordPress install
SET @db = 'some_database';
SELECT
tbl.table_name,
idx.indexes
FROM
information_schema.tables AS tbl
LEFT JOIN(
SELECT table_name,
<?php
/*
Plugin Name: Zone Updateall
Plugin URI: https://gist.github.com/petskratt/1d3e29fb4e6224e1a73b2422c8363044
Description: Allow automatic WP and plugin updates. No fancy settings, just does the job.
Author: Peeter Marvet
Version: 0.1
Author URI: https://www.zone.ee/
*/
<?php
/*
Plugin Name: Zone Cachebuster
Plugin URI: https://gist.github.com/petskratt/3acd7166297ff4451a606115b49ad22c
Description: Replace JS and CSS version parameters with hash - for obfuscation or quick cachebusting.
Author: Peeter Marvet
Version: 0.1
Author URI: https://www.zone.ee/
*/
@petskratt
petskratt / clinup
Last active March 12, 2024 23:21
Use wp-cli to clean up WordPress installs (force core & plugins reinstall, track changes in git allowing easy reverts etc)
#!/usr/bin/env bash
# for debug output, uncomment:
#set -x
function help {
echo "WordPress cleanup -v 0.5 2018-06-26 / peeter@zone.ee
Usage: