Skip to content

Instantly share code, notes, and snippets.

View 11philip22's full-sized avatar
👽
planet rider

Philip 11philip22

👽
planet rider
  • /dev/chaos
View GitHub Profile
@11philip22
11philip22 / install.ps1
Last active November 5, 2019 13:26
install ssh in powershell on windows aws ec2
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
C:\ProgramData\chocolatey\bin\choco.exe install openssh
mkdir C:\ProgramData\ssh
cp 'C:\Program Files\OpenSSH-Win64\sshd_config_default' C:\ProgramData\ssh\sshd_config
cd "C:\Program Files"
.\OpenSSH-Win64\ssh-keygen.exe -f C:\ProgramData\ssh\ssh_host_dsa_key -t dsa
.\OpenSSH-Win64\ssh-keygen.exe -f C:\ProgramData\ssh\ssh_host_rsa_key -N '' -t rsa
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
.\OpenSSH-Win64\sshd -D
@11philip22
11philip22 / TelegramBot.py
Last active January 13, 2021 09:04
Simple Class to add to your script for telegram notifications
from json import loads
from requests import post
class TelegramBot:
def __init__(self, id_):
self.id = id_
@staticmethod
def post_request(request):
from pathlib import Path
from os import listdir
from torf import Torrent
trackers = [
"udp://tracker.coppersurfer.tk:6969/announce",
"udp://tracker.leechers-paradise.org:6969/announce",
"udp://tracker.opentrackr.org:1337/announce",
"udp://tracker.internetwarriors.net:1337/announce",
FROM golang:1.9
# Install Jupyter Notebook
# `hash -r pip` is a workaround of pip v10 related issue (https://github.com/pypa/pip/issues/5221#issuecomment-382069604)
RUN apt-get update && apt-get install -y libzmq3-dev python3-pip && rm -rf /var/lib/apt/lists/*
RUN pip3 install --upgrade pip && hash -r pip && pip3 install -U jupyter jupyterlab && jupyter serverextension enable --py jupyterlab --sys-prefix
# Install lgo Jupyter lab extension to support code formatting.
# Please remove this line if you do not use JupyterLab.
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VMware/"
sudo /usr/src/linux-headers-`uname -r`/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vmmon)
sudo /usr/src/linux-headers-`uname -r`/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vmnet)
sudo mokutil --import MOK.der
reboot
FROM ubuntu:19.10 as build-env
RUN sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
RUN apt-get update
RUN apt-get install wget -y \
&& apt-get build-dep nmap -y
RUN wget https://nmap.org/dist/nmap-7.80.tar.bz2 \
&& bzip2 -cd nmap-7.80.tar.bz2 | tar xvf - \
&& cd nmap-7.80 \
&& ./configure \
&& make
function read_env() {
if builtin cd "$@"; then
local env="$PWD/.zenv"
if [ -f "$env" ]; then
if [ -z "$CURRENT_ENV" ]; then
builtin source "$env"
export CURRENT_ENV="$env"
elif [ ! "$CURRENT_ENV" = "$env" ]; then
if [ "$(type -t deactivate)" = "function" ]; then
deactivate
@11philip22
11philip22 / autogit.ps1
Created February 20, 2020 09:52
git for lazy people
$date = Get-Date -Format "yyyy-MM-dd_HH:mm:ss"
if (! $args ) {
$msg = $date
} else {
$msg = $args
}
git add .
git commit -m "$msg"
#!/bin/bash
c=0
for f in *.zip; do
x="$(zipinfo -t "$f" | awk '{print $1}')"
c=$(( $c + $x ))
done
echo "The total file count is:" $c
from os import walk, path
def get_folder_size(start_path):
""""Output size of folder in bytes"""
total_size = 0
for dir_path, dir_names, file_names in walk(start_path):
for f in file_names:
fp = path.join(dir_path, f)
# skip if it is symbolic link
if not path.islink(fp):