Skip to content

Instantly share code, notes, and snippets.

Avatar
🟠
MIA

Daniel Dusek dusekdan

🟠
MIA
View GitHub Profile
View SecurityHeadersConstant.php
<?php
header('X-XSS-Protection: 1; mode=block');
header('X-Content-Type: nosniff');
header('X-Frame-Options: DENY');
// If you have sensitive information in any of your URLS, use 'no-referrer' as a value instead)
header('Referrer-Policy: no-referrer-when-downgrade');
?>
View LaravelSecurityHeadersMiddleware.php
<?php
namespace App\Http\Middleware;
use Closure;
class SecureHeaders
{
// Enumerate headers which you do not want in your application's responses.
// Great starting point would be to go check out @Scott_Helme's:
// https://securityheaders.com/
private $unwantedHeaderList = [
@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.
View Parenthesis-String-Validator.py
"""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 / message_sender.py
Created March 15, 2019 20:26
Sending Messages to Game Windows Through DirectInput and Win32API
View message_sender.py
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),
@dusekdan
dusekdan / XPath selector - All URLs from HTML attributes
Last active November 22, 2021 12:52
Extracts URLs from HTML attributes with type of URI.
View XPath selector - All URLs from HTML attributes
-- When fed to XPath selects all URLs from HTML document
-- from within HTML attributes designated to hold URL
-- One-line version
"//a/@href | //applet/@codebase | //area/@href | //base/@href | //blockquote/@cite | //body/@background | //del/@cite | //form/@action | //frame/@src | //frame/@longdesc | //head/@profile | //iframe/@longdesc | //iframe/@url | //img/@longdesc | //img/@usemap | //input/@src | //input/@usemap | //ins/@cite | //object/@classid | //object/@codebase | //object/@data | //object/@usemap | //q/@cite | //img/@src | //link/@href | //source/@src | //embed/@src | //script/@src | //audio/@src | //button/@formaction | //command/@icon | //html/@manifest | //input/@formaction | //video/@poster | //video/@src"
-- Multi-line version (readable)
"//a/@href
| //applet/@codebase
| //area/@href
| //base/@href
@dusekdan
dusekdan / scrape-quotes.py
Created August 1, 2021 09:58
Small script to scrape quotes from azquotes.com
View scrape-quotes.py
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 / window_helper.py
Created March 15, 2019 16:59
Snippet of python code to help working with Windows under win32gui.
View window_helper.py
import win32gui
import re
class WindowMgr:
"""Encapsulates some calls to the winapi for window management"""
def __init__ (self):
"""Constructor"""
self._handle = None
@dusekdan
dusekdan / README.md
Last active February 17, 2020 05:03
Resume Browser Work from File
View README.md

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.

View ips_in_net.py
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
View Šablona emailu pro Credit Now | České Aukce | AB Partners
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