Skip to content

Instantly share code, notes, and snippets.

View dusekdan's full-sized avatar
🟠
MIA

Daniel Dusek dusekdan

🟠
MIA
View GitHub Profile
@dusekdan
dusekdan / user.script.js
Last active March 18, 2024 13:59
YoutubeShortsRemover for desktop front page
// ==UserScript==
// @name YoutubeShortsRemover
// @match https://youtube.com/*
// @match https://www.youtube.com/*
// @match https://*.youtube.com/*
// @version 0.1
// @author Daniel Dusek (github: dusekdan)
// @grant none
// ==/UserScript==
@dusekdan
dusekdan / README.md
Last active December 28, 2023 12:46
Simple HTTPS Server in Python for quick testing

Simple HTTPS Server in Python for quick testing

We got used to running python -m http.server command to quickly spin up a local http server that we could grab some files over. A lot of use cases these days require HTTPS to be used, however, so some of the quick and dirty testing operations now turn a bit more painful. This is a ready-made script that spins up a simple http server with SSL/TLS on, using the self-signed certificate.

If file cert.pem is not detected, script will try to create it during startup. It will contain both certificate and private key, and the private key is not passphrase protected. While it is acceptable for testing locally quickly, it is completely unreasonable and unacceptable for anything even remotely exposed to real life scenarios.

If you wan't to generate your own own cert.pem, or need to regenerate the new one (default expiration is set to 365 days), run the following command:

openssl req -newkey rsa:2048 -x509 -days 365 -nodes -out cert.pem -keyout cert.pem
@dusekdan
dusekdan / Parenthesis-String-Validator.py
Created June 26, 2022 18:22
Implement a function that validates whether given bracket-string (both single-type and multiple-type) is valid.
"""Implement function(s) to validate whether specified bracket string is valid.
For a string to be valid, it has to have the same amount of the brackets of the
same type (naive, simple implementation) and these bracket types cannot cross
(complex string/implementation) - just like they couldn't in a math. equation.
Solution to this exercise typically uses stack and pushes symbols onto it as
they are read, and pops them from its top as their counter parts are read.
"""
@dusekdan
dusekdan / scrape-quotes.py
Created August 1, 2021 09:58
Small script to scrape quotes from azquotes.com
import json
import logging as LOG
import requests
from bs4 import BeautifulSoup
LOG.basicConfig(level=LOG.INFO)
QUOTES_BASE_URL = 'https://www.azquotes.com/top_quotes.html?p='
OUTPUT_FILE = 'quotes-better.json'
@dusekdan
dusekdan / README.md
Last active February 17, 2020 05:03
Resume Browser Work from File

Why and What?

When I am working on something that I know I will get back to in a while and have to switch context (sometimes even a machine and an environment), I want to save all the relevant opened tabs from my browser to reopen them later. Ideally, I would like to avoid saving them to my bookmarks and rather save them together with a project (context) I was working on.

Before I wrote this small utility, I used to store the links in markdown format as a list with description of what I can find under given links. That was rather impractical and took a long time to initially write down, and also open later on.

With the utility, I can now save the links into the sources.txt file, one link per line. Then I just check-in the file together with the project into the VCS. When the time comes to start where I left of, I just run python resume.work.from.file path/to/directory/with/sources.txt/file and it opens all the tabs in my default browser.

def ips_in_net(ip='192.168.1.8', subnet='255.255.255.0'):
from ipaddress import ip_address, ip_network
hosts = list(ip_network(f"{ip}/{subnet}", strict=False).hosts())
return [f"{host}" for host in hosts]
@dusekdan
dusekdan / Šablona emailu pro Credit Now | České Aukce | AB Partners
Last active August 17, 2019 17:55
Šablona emailu k poslání na platby@credit-now.info a info@abpartners.cz
Stali jste se obětí podvodných praktik firem České Aukce popřípadě Credit Now a morálně zpochybnitelných praktik jejich
zastupující advokátní kanceláře AB Partners (Mgr. Petr Bílý, Mgr. Jan Ambrož)? Využijte tuto šablonu pro email, který
povede na ukončení celé záležitosti.
Níže naleznete šablonu emailu, který zaslat na emailové adresy:
- info@abpartners.cz
- platby@credit-now.info
Tuto šablonu, ani její části nepovažujte za právní radu. Text šablony si PŘEČTĚTE A UPRAVTE, ABY VAŠE INFORMACE SEDĚLY
@dusekdan
dusekdan / prepare_for_github.py
Last active June 30, 2019 15:09
Fragments files in the directory so they can be pushed into Github.
# Recursively goes through the TARGET directory and zips files that are
# over SIZE_LIMIT bytes into PART_SIZE_7z parts, deleting the originals.
#
# Uses 7zip utility that needs to be ADDED INTO THE $PATH.
#
# Results in a directory structure that can be pushed into
# the GitHub without issues with oversized files.
import os, sys, subprocess
from time import sleep
@dusekdan
dusekdan / MuellerReportScaper.py
Created April 21, 2019 04:43
Scrapes the Mueller report from the wired's embedded article reader.
"""
Wired Article with embeded web-reader: https://www.wired.com/story/mueller-report-russia-redacted-trump-barr-read/
How to use this script:
- Python3 & installed requests package (run: 'pip install requests')
- Create "report" folder in the same directory as this script
- run: 'python MuellerReportScraper.py'
"""
import os
import requests
@dusekdan
dusekdan / message_sender.py
Created March 15, 2019 20:26
Sending Messages to Game Windows Through DirectInput and Win32API
import os
import ctypes
import win32api
w = WindowMgr()
PUL = ctypes.POINTER(ctypes.c_ulong)
class KeyBdInput(ctypes.Structure):
_fields_ = [("wVk", ctypes.c_ushort),
("wScan", ctypes.c_ushort),