Skip to content

Instantly share code, notes, and snippets.

View pedroserrudo's full-sized avatar
👨‍💻
Working Anywhere

Pedro Serrudo Silva pedroserrudo

👨‍💻
Working Anywhere
View GitHub Profile
@pedroserrudo
pedroserrudo / dataclasses.py
Created February 24, 2023 10:08
dataclasses field validation similar to django
from dataclasses import dataclass
class Validations:
def __setattr__(self, prop, val):
if (validator := getattr(self, f"validate_{prop}", None)):
object.__setattr__(self, prop, validator(val) or val)
else:
super().__setattr__(prop, val)
@pedroserrudo
pedroserrudo / validate_dataclass.py
Created February 24, 2023 08:54 — forked from mikybars/validate_dataclass.py
Generic solution for `@dataclass` validation in Python with custom setters
from dataclasses import dataclass
class Validations:
def __setattr__(self, prop, val):
if (validator := getattr(self, f"validate_{prop}", None)):
object.__setattr__(self, prop, validator(val) or val)
else:
super().__setattr__(prop, val)
@pedroserrudo
pedroserrudo / redis.log
Created October 13, 2022 12:29
redis log
cybsafe-redis-1 | === REDIS BUG REPORT START: Cut & paste starting from here ===
cybsafe-redis-1 | 1:M 12 Oct 2022 17:56:00.125 # Redis 6.2.6 crashed by signal: 11, si_code: 1
cybsafe-redis-1 | 1:M 12 Oct 2022 17:56:00.126 # Accessing address: 0x3a227270657273
cybsafe-redis-1 | 1:M 12 Oct 2022 17:56:00.126 # Crashed running the instruction at: 0x4000049b23
cybsafe-redis-1 |
cybsafe-redis-1 | ------ STACK TRACE ------
cybsafe-redis-1 | EIP:
cybsafe-redis-1 | redis-server *:6379(dictAddRaw+0x163)[0x4000049b23]
cybsafe-redis-1 |
cybsafe-redis-1 | Backtrace:
def get_user_scores_block(user) -> list:
header = [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":trophy: SCOREBOARD :trophy:",
"emoji": True,
},
{'af': 'S2_as-395718787_940', 'ip': '0.0.0.1', 'created_at': timezone.now(), 'revenue': 0,'campaign_id': '31234', 'user_agent': 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5', 'extra': {'af':'dasdfasdas', 'g':1, 's':3, 'o':2}, 'referer': 'http://google.com', 'offer_id': '1533','affiliate_id': '3'}
class cracklepop:
def __init__(self,min=1, max=10, crackle=3, pop=5):
print "Lets play the Crackle(%s)Pop(%s) Game between %s and %s" \
% (crackle,pop,min,max)
self.range = range(min, max+1)
self.crackle = crackle
self.pop = pop
var Tabuleiro = Class.extend({
config: null,
canvas: null,
embarcacoes: null,
player: null,
tirosRecebidos: null,
init: function(canvas, config){
this.config = $.extend({}, Tabuleiro.defaultConfig, config);
this.canvas = $(canvas);