Skip to content

Instantly share code, notes, and snippets.

@wapiflapi
wapiflapi / pydantic_validators_test.py
Created November 7, 2023 15:33
A test showing how to handle empty string == null in different scenarios.
import typing
import pydantic
class TestBaseModel(pydantic.BaseModel):
@pydantic.validator('*', pre=True)
def empty_str_to_none(cls, v):
if v == "":
return None
#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
TEMPLATE_GIT=$SCRIPT_DIR
TEMPLATE_PATH=something/censored/
GIT_DIR=$TEMPLATE_GIT/.git git ls-files $TEMPLATE_PATH |
while read file;
do diff $TEMPLATE_GIT/$file "${file//"$TEMPLATE_PATH"/}";
@wapiflapi
wapiflapi / decrypt.py
Created October 9, 2019 10:02
@wapiflapi's solution for RektSA from https://qual.rtfm.re 2019
"""
@wapiflapi's solution for RektSA from https://qual.rtfm.re 2019
This simply uses z3 which takes about a second longer than the challenge
timeout: Keeping the connection alive is enough to circumvent the timeout.
~/Projects/ctf/rtfm$ time ./decrypt.py
Congratulations: sigsegv{th1s_1s_4_cr1m3...4_mult1cr1m3!!!}
real 0m2,741s
# @wapiflapi gqldl early draft.
#
# The goal of this is to manage dataloaders for multiple types while
# at the same time providing an easy integration for relay-compliance.
# - There will be full utility support for the relay spec.
# - Integration with ariadne WILL be easy and documented.
# - Integration with graphene MIGHT be documented.
#
# Feel free to comment, but documentation, tests and a proper release
# are comming soon(tm).
# @wapiflapi gqldl early draft.
#
# The goal of this is to manage dataloaders for multiple types while
# at the same time providing an easy integration for relay-compliance.
# - There will be full utility support for the relay spec.
# - Integration with ariadne WILL be easy and documented.
# - Integration with graphene MIGHT be documented.
#
# Feel free to comment, but documentation, tests and a proper release
# are comming soon(tm).
# @wapiflapi gqldl early draft.
#
# The goal of this is to manage dataloaders for multiple types while
# at the same time providing an easy integration for relay-compliance.
# - There will be full utility support for the relay spec.
# - Integration with ariadne WILL be easy and documented.
# - Integration with graphene MIGHT be documented.
#
# Feel free to comment, but documentation, tests and a proper release
# are comming soon(tm).
<!DOCTYPE html>
<html lang="en">
<head><title>Self Share Screen</title></head>
<body><video id="video" autoplay></video></body>
<script>
navigator.mediaDevices.getDisplayMedia({
video: { cursor: "never" },
audio: false
}).then(function (stream) {
document.getElementById("video").srcObject = stream;
@wapiflapi
wapiflapi / pxe.sh
Created October 31, 2018 20:00
Quick and dirty PXE boot server.
#!/bin/bash
mkdir -p /tmp/tftp
wget https://boot.netboot.xyz/ipxe/netboot.xyz.efi -O /tmp/tftp/netboot.xyz.efi
# /!\ Make sure the router is OK.
ROUTER=$(ip r | grep default | cut -d ' ' -f3)
# Make sure interface is the right one,
# and dhcp-range should be a subset of the real range.
@wapiflapi
wapiflapi / tracing.py
Created September 12, 2018 08:51
Graphql Tracing Middleware for Apollo Engine.
from graphql.execution import ExecutionResult
from .schema import schema
import datetime
import dateutil.parser
import dateutil.tz
import monotonic
{
repositoryOwner(login: "github") {
login
avatarUrl
repositories(first: 10, isFork: false, orderBy: {field: CREATED_AT, direction: DESC}) {
edges {
node {
description
createdAt
stargazers {