Skip to content

Instantly share code, notes, and snippets.

View DurandA's full-sized avatar

Arnaud Durand DurandA

View GitHub Profile
@tothi
tothi / mitmproxy-jwt-refresh-addon.py
Created August 28, 2022 20:52
mitmproxy addon for handling oauth access and refresh tokens automatically
# run: mitmproxy -k -p 8090 -s mitmproxy-jwt-refresh-addon.py
# set burp upstream proxy to localhost:8090
#
# use case:
# - application authorization is implemented by OAuth 2.0
# - testing is performed using Burp as primary and mitmproxy as upstream proxy
# - mitmproxy takes care of the Authorization tokens using this addon
# - user gets an access_token and a refresh_token during the 1st login (e.g. password login)
# - mitmproxy addon caches access_token and refresh_token
# - mitmproxy addon adds Authorization: Bearer [access_token from cache] header for every request
@ryanburnette
ryanburnette / Caddyfile
Last active May 31, 2024 00:23
Caddy v2.1+ CORS whitelist
(cors) {
@cors_preflight{args.0} method OPTIONS
@cors{args.0} header Origin {args.0}
handle @cors_preflight{args.0} {
header {
Access-Control-Allow-Origin "{args.0}"
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
Access-Control-Allow-Headers *
Access-Control-Max-Age "3600"
@wilburx9
wilburx9 / dismissible_animated.dart
Last active January 16, 2023 07:02
Animated Flutter Dismissible
Tween<Offset> _offSetTween = Tween(
begin: Offset(1, 0),
end: Offset.zero,
);
...
@override
Widget build(BuildContext context) {
return Scaffold(
...
@gregdavill
gregdavill / ecp5_swap_idcode.py
Created October 1, 2019 12:25
Script for use with prjtrellis to swap the IDCODE of a ECP5 bitstream
#!/usr/bin/env python3
"""
This simple example uses PyTrellis to unpack, change the IDCODE, and pack a bitstream
"""
import pytrellis
pytrellis.load_database("/usr/share/trellis/database")
bs = pytrellis.Bitstream.read_bit("build/gateware/impl/top_impl.bit")
chip = bs.deserialise_chip()
@zspine
zspine / SuperAdminGroupContextBuilder.php
Last active March 23, 2023 08:46
API Platform custom ContextBuilder and Denormalizer
<?php
namespace App\Serializer\ApiPlatform;
use ApiPlatform\Core\Serializer\SerializerContextBuilderInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use App\Entity\User;
@591342534
591342534 / SimpleHTTPServerWithUpload.py
Created May 27, 2019 08:13 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@aliesbelik
aliesbelik / benchmarking-tools.md
Last active June 21, 2024 09:04
Benchmarking & load testing tools
#!/usr/bin/env python3
import sys
import textwrap
# Very basic bitstream to SVF converter, tested with the ULX3S WiFi interface
flash_page_size = 256
erase_block_size = 64*1024
@cr1901
cr1901 / clock_domains.md
Last active July 4, 2021 07:14
Migen Clock Domain Summary

Migen Clock Domains Summary

Terminology

  • Declaring a clock domain:
    • self.clock_domains.cd_mycd = ClockDomain()
  • Referencing a clock domain:
    • self.sync.mycd += []
    • ClockSignal("mycd")
  • Requesting an I/O signal:
  • platform.request("clk12")
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active June 27, 2024 11:24
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th