Skip to content

Instantly share code, notes, and snippets.

View tg12's full-sized avatar
🏠
Working from home

tg12 tg12

🏠
Working from home
  • 36Hs6atY4XDwS8AK6qcSLtyVLCqX85fm1w
  • Earth
  • 21:11 (UTC +01:00)
  • LinkedIn in/jamessawyer12
View GitHub Profile
@dankrause
dankrause / ssdp.py
Last active April 25, 2024 13:14
Tiny python SSDP discovery library with no external dependencies
# Copyright 2014 Dan Krause
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@jtpaasch
jtpaasch / amazonctl.py
Created October 26, 2015 12:47
A collection of functions commonly used to do AWS stuff.
# -*- 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:
@johnstanfield
johnstanfield / fail2ban_amznlnx2.sh
Created May 13, 2021 17:59
install fail2ban on amazon linux 2
# 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
@rosenpin
rosenpin / protonmail-delete-all-in-folder.js
Created August 11, 2018 13:39
Delete all emails in an open folder in Protonmail
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)
@kwilczynski
kwilczynski / script.sh
Created March 23, 2021 10:35
Dump ad list (ad blocking list), whitelist and blacklist from Sqlite database on Pi Hole
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
@fazt
fazt / index.py
Created April 19, 2019 15:06
Python Simple Discord Bot
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()
@sudharsans
sudharsans / ec2-running-time.py
Created March 1, 2018 11:50
Python Boto3 script to find the number of minutes an instance has been running.
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 (
#!/bin/sh
# For debugging use iptables -v.
IPTABLES="/sbin/iptables"
IP6TABLES="/sbin/ip6tables"
MODPROBE="/sbin/modprobe"
RMMOD="/sbin/rmmod"
ARP="/usr/sbin/arp"
@rygorous
rygorous / hull.py
Last active June 25, 2021 10:30
Convex hull
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)
@TheSalarKhan
TheSalarKhan / gist:3cc8e61ee303cc032f4b62021722f3aa
Created January 11, 2021 14:16
Command to set DSCP flag on outgoing UDP packets
# iptable command to set DSCP flag on outgoing udp packets
iptables -t mangle -A OUTPUT -p udp -j DSCP --set-dscp-class ef