Skip to content

Instantly share code, notes, and snippets.

View baseDTO.java
public String toJson() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(this);
}
public PessoaFisica toModel() {
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(df);
return mapper.convertValue(this, OBJ.class);
@Marlysson
Marlysson / csv.csv
Last active Sep 16, 2021
Challenge of pre process a csv file comma separated values with money cents with comma too
View csv.csv
ITEM1 1 11 COMPRA1 444444 00 3312 22
ITEM1 1 11 COMPRA3 444444 00 3312 22
ITEM1 1 13 COMPRA2 444444 00 3312 22
ITEM1 1 90 COMPRA3 444444 00 3312 22
ITEM2 1 20 COMPRA2 444444 00 3312 22
ITEM2 2 19 COMPRA1 444444 00 3312 22
ITEM2 1 11 COMPRA1 444444 00 3312 22
ITEM2 1 12 COMPRA2 444444 00 3312 22
ITEM3 1 11 COMPRA1 444444 00 3312 22
ITEM3 5 60 COMPRA3 444444 00 3312 22
@Marlysson
Marlysson / models.py
Created Jul 16, 2021
Renderizando erro na view.
View models.py
class ModelA(models.Model):
a = models.CharField()
b = models.CharField()
c = models.CharField()
def save(self, *args, **kwargs):
c = self.a + self.b
super().save(*args, **kwargs)
View serializer.py
def validate(self, attrs):
whatsapp = attrs.get('whatsapp', self.object.whatsapp)
whatsapp_h = attrs.get('whatsapp_h', self.object.whatsapp_h)
prontuario = attrs.get("prontuario", self.object.prontuario
try:
obj = tb_Paciente.objects.filter(whatsapp=whatsapp, whatsapp_h=whatsapp_h, prontuario=prontuario).exists
()
View VacinaBean.java
package bean;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import dao.VacinaDao;
import entidades.Vacina;
import java.util.List;
@Marlysson
Marlysson / componente.js
Created Dec 10, 2020
Chamada à métodos de uma classe ainda não carregada.
View componente.js
// Modelo
class Championship{
static ranking = []
static rounds = []
static new(){
Championship.ranking = TeamGenerator.generate()
return Championship
@Marlysson
Marlysson / RouteCompileProvider.py
Created Nov 9, 2020
How add a new Route Compile
View RouteCompileProvider.py
from masonite.provider import ServiceProvider
from masonite.routes import Route
class RouteCompilerProvider(ServiceProvider):
wsgi = False
def boot(self, route: Route):
route.compile('any', r'(.+)')
View primeiraTentativaDeRefatoracao.java
// Método que chama a geração de relatório
public void visualizarRelatorio(){
// Montando o Map pra passar para o query interna.
HashMap<String, Object> argumentos = new HashMap<>();
argumentos.put("unidade", sessaoUsuarioMB.getUnidadeSelecionada());
View web.py
ROUTES = [
RouteGroup([
Get('api/projects',"ProjectController@list").name('all'),
Post('api/projects',"ProjectController@create").name('create'),
Delete('api/projects',"ProjectController@delete").name("delete")
], name="project."),
RouteGroup([
Get('projects',"ClientController@index").name('all'),
View ContaCorrente.java
class ContaCorrente{
private String agencia;
private String conta;
private String correntista;
private double saldo;
// getters and setters