Skip to content

Instantly share code, notes, and snippets.

@badcrc
badcrc / run.tpl
Created July 7, 2022 07:23 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name {{printf "%q" .Name}} \
{{- with .HostConfig}}
{{- if .Privileged}}
--privileged \
{{- end}}
{{- if .AutoRemove}}
--rm \
{{- end}}
{{- if .Runtime}}
@badcrc
badcrc / nyancat-shell.sh
Created October 26, 2017 14:45
nyancat-shell
^[[31m`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*^[[0m
^[[33m^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`^[[0m
^[[32m'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,^[[0m ,---/V\
^[[34m*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^^[[0m ~|__(o.o)
^[[35m,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.,*'^`*.^[[0m U U U U
@badcrc
badcrc / clippy.py
Created June 23, 2017 17:38
RO-Clippy
from datetime import date
import time
import calendar
def ro_friday():
date_today=date.today()
if calendar.day_name[date_today.weekday()] == 'Friday':
print '\t __'
print '\t/ \ _________________ '
print '\t| | / \ '
@badcrc
badcrc / gist:af8cb6e9bf9ac82ef4b3f45e43dd3dbf
Created January 18, 2017 10:46
Check certificates vs private keys
openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl rsa -noout -modulus -in privateKey.key | openssl md5
openssl req -noout -modulus -in CSR.csr | openssl md5
@badcrc
badcrc / gist:4303bae0643f5675bee6
Created May 6, 2014 08:08
Behind a proxy which sends the protocol of the request in the header X-Forwarded-Protocol, redirect to https if the request is in plain http.
RewriteCond %{HTTP:X-Forwarded-Protocol} !^https$
RewriteRule ^some/url/(.*)$ https://%{HTTP_HOST}/some/url/$1 [L]
@badcrc
badcrc / gist:8977386
Last active August 29, 2015 13:56
Block wordpress bruteforce wp-login.php attack when the apache is behind a proxy and send the real IP in the X-Forwarded-For header.
<Files wp-login.php>
Order deny,allow
Deny from all
#Single IP
SetEnvIF X-Forwarded-For "x.x.x.x" AllowIP
#IP Range (example for a XXX.XXX.0.0/16)
# http://stackoverflow.com/questions/17967294/how-can-i-make-a-regular-expression-for-ip-address-with-subnetmask
SetEnvIF X-Forwarded-For "^XXX\.XXX\.(?:[0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.(?:[1-9][0-9]?|1[0-9]{2}|2[0-4][0-9]|25[0-4])$" AllowIP
@badcrc
badcrc / gist:8110132
Created December 24, 2013 07:57
Reorganize MySQL Partitions
ALTER TABLE TABLE_NAME
REORGANIZE PARTITION pmax INTO (
PARTITION p201401 VALUES LESS THAN ('2014-01-01 00:00:00'),
PARTITION p201402 VALUES LESS THAN ('2014-02-01 00:00:00'),
PARTITION p201403 VALUES LESS THAN ('2014-03-01 00:00:00'),
PARTITION p201404 VALUES LESS THAN ('2014-04-01 00:00:00'),
PARTITION p201405 VALUES LESS THAN ('2014-05-01 00:00:00'),
PARTITION p201406 VALUES LESS THAN ('2014-06-01 00:00:00'),
PARTITION p201407 VALUES LESS THAN ('2014-07-01 00:00:00'),
PARTITION p201408 VALUES LESS THAN ('2014-08-01 00:00:00'),
@badcrc
badcrc / htaccess-for-wplogin
Created October 10, 2013 10:14
Block wordpress bruteforce wp-login.php attack
<Files wp-login.php>
order deny,allow
Deny from all
# Allow from this IP address
allow from x.x.x.x
</Files>
@badcrc
badcrc / gist:6162525
Created August 6, 2013 06:30
One-liner gzip to bzip2, for FreeBSD
find . -name "*.gz" | perl -pi -e 's/\.gz$//g;' | awk '{printf("gunzip %s.gz && bzip2 %s\n",$1,$1)}' | csh
@badcrc
badcrc / gist:5713022
Created June 5, 2013 10:35
Send data to ganglia using gmetric.py
import Gmetric
def send_gmetric_data(metric_name,metric_value,metric_group):
parser = optparse.OptionParser()
#gmond configuration
options = {}
options['host'] = "your_server"
options['protocol'] = "udp"
options['port'] = 8649