Skip to content

Instantly share code, notes, and snippets.

@Marlysson
Marlysson / ZeroMQProvider.py
Last active February 16, 2022 09:00
Integrating ZeroMQ with Masonite
from masonite.providers import Provider
class ZeroMQProvider(Provider):
def __init__(self, application):
self.application = application
def register(self):
print("Starting zeromq")
import zmq
@Marlysson
Marlysson / celledit-override.js
Last active March 29, 2022 18:42
tabCell function overriding
if (PrimeFaces.widget.DataTable) {
PrimeFaces.widget.DataTable.prototype.tabCell = function(celula, frente){
var celulaAlvo = frente ? celula.nextAll("td.ui-editable-column:first") : celula.prevAll("td.ui-editable-column:first");
if (celulaAlvo.length == 0) {
var linha = frente ? celula.parent().next() : celula.parent().prev();
celulaAlvo = frente ? linha.children("td.ui-editable-column:first") : linha.children("td.ui-editable-column:last");
}
@Marlysson
Marlysson / replica.py
Last active June 15, 2022 19:55
Replica de dados
from django.core import management
from pathlib import Path
class Command(management.base.BaseCommand):
def handle(self, *args, **options):
apps = ["core"]
models = ["core.ModelA", "core.ModelB"]
fixture_name = "audit"
@Marlysson
Marlysson / fields.py
Created August 14, 2022 14:24
Custom fields django
from django.db import models
class ZipField(models.Field):
def __init__(self, length=8, *args, **kwargs):
self.length = length
super().__init__(*args, **kwargs)
def db_type(self, connection):
return f"char({self.length})"
@Marlysson
Marlysson / slugfy.php
Last active February 27, 2023 20:51
Script php para criar slug de um texto dado
<?php
class Slugfy{
public static function getSlug($string){
$string = stripslashes($string);
$string = preg_replace('/[[:punct:]]+/',' ',$string);
$string = preg_replace('/[[:space:]]+/',' ',$string);
$string = ltrim($string,". ");