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
  • 17:17 (UTC +01:00)
  • LinkedIn in/jamessawyer12
View GitHub Profile
#!/bin/sh
# For debugging use iptables -v.
IPTABLES="/sbin/iptables"
IP6TABLES="/sbin/ip6tables"
MODPROBE="/sbin/modprobe"
RMMOD="/sbin/rmmod"
ARP="/usr/sbin/arp"
@dideler
dideler / titles.md
Created August 9, 2012 07:46
IT Titles as described by Joel Spolsky

Programmer emphasizes the coding aspect of the job.

Software developer can be seen to encompass other aspects of the software creation process, such as software design, architecture, design, testing, documentation, deployment, and maintenance.

Engineer has some regional variations. In some places it implies an accredited or licensed professional. In other places (including Silicon Valley) it does not. However engineer also encompasses other technical roles in the organization such as systems administrator, network administrator, database administrator, and so forth.

Hacker adds a facet of pragmatism. A hacker, it is implied, gets things done with limited resources and leverages other work to "hack" together a working, valuable solution.

Code-monkey is insulting but is most often used in a self-deprecating way to indicate a programmer who is expected simply to write code without thinking about the larger picture (such as the code architecture or the business needs).

@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:
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)]
@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 (
@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)
@dannycroft
dannycroft / pi-stats.py
Last active October 1, 2019 12:40
PI Stats
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
@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()
@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)