This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run as root or sudo everything below | |
# install epel | |
amazon-linux-extras install epel -y | |
# install fail2ban | |
yum -y install fail2ban | |
# configure fail2ban (just adding enabled=true in the sshd section) | |
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sqlite3 gravity.db.backup -header -csv 'select * from adlist' > adlist.csv | |
sqlite3 gravity.db.backup -header -csv 'select * from vw_whitelist' > whitelist.csv | |
sqlite3 gravity.db.backup -header -csv 'select * from vw_blacklist' > blacklist.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# iptable command to set DSCP flag on outgoing udp packets | |
iptables -t mangle -A OUTPUT -p udp -j DSCP --set-dscp-class ef |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
# Determinant predicate (line sidedness test) | |
def det3x3_pt(p, q, r): | |
a = (q[0] - p[0], q[1] - p[1]) | |
b = (r[0] - p[0], r[1] - p[1]) | |
return a[0]*b[1] - a[1]*b[0] | |
def convex_hull(points): | |
# sorts points by x then y which works for us (we only need the sort by x part here, but it doesn't hurt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import discord | |
from discord.ext import commands | |
import datetime | |
from urllib import parse, request | |
import re | |
bot = commands.Bot(command_prefix='>', description="This is a Helper Bot") | |
@bot.command() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
# Return CPU temperature as a character string | |
def getCPUtemperature(): | |
res = os.popen('vcgencmd measure_temp').readline() | |
return(res.replace("temp=","").replace("'C\n","")) | |
# Return RAM information (unit=kb) in a list | |
# Index 0: total RAM | |
# Index 1: used RAM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
async function deleteAllMails(){ | |
for (var i = 0;i<100;i++){ | |
setTimeout(function(){document.getElementById("selectAll").click()},1000); | |
setTimeout(function(){document.getElementsByClassName("moveElement-btn-delete")[0].click()},3000); | |
setTimeout(function(){document.getElementById("confirmModalBtn").click()},5000); | |
await sleep(10000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
from datetime import datetime, timezone | |
from functools import reduce | |
import operator | |
ec2 = boto3.client('ec2') | |
cloudtrail = boto3.client('cloudtrail') | |
def get_events(instanceid): | |
response = cloudtrail.lookup_events ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
arr = [10, 386, 479, 627, 20, 523, 482, 483, 542, 699, 535, 617, 577, 471, 615, 583, 441, 562, 563, 527, 453, 530, 433, 541, 585, 704, 443, 569, 430, 637, 331, 511, 552, 496, 484, 566, 554, 472, 335, 440, 579, 341, 545, 615, 548, 604, 439, 556, 442, 461, 624, 611, 444, 578, 405, 487, 490, 496, 398, 512, 422, 455, 449, 432, 607, 679, 434, 597, 639, 565, 415, 486, 668, 414, 665, 763, 557, 304, 404, 454, 689, 610, 483, 441, 657, 590, 492, 476, 437, 483, 529, 363, 711, 543] | |
elements = numpy.array(arr) | |
mean = numpy.mean(elements, axis=0) | |
sd = numpy.std(elements, axis=0) | |
final_list = [x for x in arr if (x > mean - 2 * sd)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
"""A simple tool to document how to control AWS resources. | |
AWS AUTHENTICATION | |
------------------- | |
In order to run any of the code below, you need a profile with AWS credentials | |
set up on your computer. It's very easy to do this. Google how to configure | |
your profile with boto3, or visit the docs: |
NewerOlder