Posts by Leonel Sanches da Silva • 88,623 points
2,010 posts
-
5
votes1
answer152
viewsA: Bean and Annotations with Generics, how to do?
Answer: there is no way to do it without offering a type to the instance. What can be done is something like this: @Bean public RedisTemplate<String, MeuObjeto> redisTemplateMeuObjeto() {…
-
4
votes1
answer152
viewsQ: Bean and Annotations with Generics, how to do?
I am in a project with Spring 4 configuring the Redis and a construction like this has emerged: @Configuration @ComponentScan({"com.empresa.sistema.web.util"}) public class RedisConfig { @Bean…
-
5
votes1
answer721
viewsA: Transform int to python byte
Only use: valor = bytes([90]) See more here. To convert byte to integer, use: int.from_bytes(meus_bytes, byteorder='big') If it is big endian, and int.from_bytes(neus_bytes, byteorder='little') if…
-
7
votes2
answers218
viewsA: Could someone help me with this formal language?
{a^n b^m | n<= m <= 2n} that is to say: Accepted expression with N elements and A and M elements of B, M between N and 2N. In practice, the automaton accepts: AB ABB AABB AABBB AABBBB ... That…
computer-theoryanswered Leonel Sanches da Silva 88,623 -
5
votes1
answer1394
viewsA: Many-To-Many Relationship Mapping - EF Core - C#
No need to complicate so much. Let’s first look at your case: I have a class Person who represents any Person, an Employee, a Customer, a Supplier, in short, any type of Person, whether physical or…
c#answered Leonel Sanches da Silva 88,623 -
2
votes1
answer379
viewsA: How to read multiple lines in c++ without using file
I changed your code a little bit to get a result inside of what I imagine you want to do: #include<iostream> #include<string> using namespace std; int main() { string entrada;…
c++answered Leonel Sanches da Silva 88,623 -
2
votes1
answer71
viewsA: How to resolve c#debugging error?
Try installing on the machine the Visual Basic Power Packs 10. Here is another link, most recent.…
-
0
votes1
answer44
viewsA: Remove element in Interop
Instead, I would apply a regular expression to remove strange characters from the text: using System.Text.RegularExpressions; atividade.Range.Text = Regex.Replace(atividade.Range.Text,…
-
5
votes2
answers439
viewsA: Python graph does not display values correctly
In the picture, appeared to date today and, because of this, disappeared the points. Not gone. Try to enlarge the image. They are on the edges. I converted one of your dates to the suggested format…
-
2
votes3
answers725
viewsA: ASP.NET MVC Web - How to separate performance between the modules of a project?
If 300 people are using module A, it will impact the performance of module B, right? Yes, because it’s one system, but 300 people usually don’t even tickle the service if you use the right practices…
-
2
votes1
answer51
viewsA: Create Actionfilter for "Anonymous" login
The simple decoration of [Authorize] in their Controllers and methods already checks whether the user is anonymous or not. [Authorize] public class MeuController { ... } Or public class…
-
1
votes1
answer377
viewsA: Problem with the Requests package
See if the package is really installed: > pip show requests Name: requests Version: 2.16.4 Summary: Python HTTP for Humans. Home-page: http://python-requests.org Author: Kenneth Reitz…
pythonanswered Leonel Sanches da Silva 88,623 -
3
votes2
answers480
viewsA: Deleting lines only if any cell in the worksheet is empty (using a script)
I ran a test like this to simulate your blank cells: >>> x =…
-
1
votes1
answer32
viewsA: What’s this C#resource called
This is a object initializer. In practice, what C# does is transform the second form into the first when compiling its code. Note that this is not the same as a constructor. This code is executed…
c#answered Leonel Sanches da Silva 88,623 -
2
votes2
answers159
viewsA: Extracting Window and Time values from a network dump
Use the library pycapfile: > pip install pypcapfile Use: >>> from pcapfile import savefile >>> testcap = open('ataques.pcap', 'rb') >>> capfile =…
-
2
votes1
answer50
viewsA: Graph using local time instead of GMT time
Just change the conversion here: x1 = [datetime.now() + timedelta(microseconds=d/10) for d in x] To: x1 = [datetime.datetime.fromtimestamp(int(d)) for d in x]…
pythonanswered Leonel Sanches da Silva 88,623 -
6
votes3
answers2001
viewsA: Recursive function with strings - Python
I did so: def elefantes(n): if n <= 0: return "" if n == 1: return "Um elefante incomoda muita gente" return elefantes(n - 1) + str(n) + " elefantes " + incomodam(n) + ("muita gente" if n % 2…
-
5
votes1
answer358
viewsA: Graph of total connections per second during a denial of service attack
I did a test here like this: >>> import matplotlib.pyplot as plt >>> x =…
-
2
votes1
answer276
viewsA: Many To Many Entity Framework Update
Are you putting the Item twice in context, and Fornecedores also: entity.Fornecedores = _dbContext.TbItem .Where(p => p.Id == entity.Id).FirstOrDefault().Fornecedores; What I would do in your…
-
9
votes8
answers29160
viewsA: Duplicate visual line studio
Ctrl + D. Note that Resharper undoes this setting. If this happens: Resharper Options Keyboard & Menus Select the classic shortcuts option from Visual Studio.…
visual-studio-2015answered Leonel Sanches da Silva 88,623 -
1
votes1
answer68
viewsA: How to create a View for screens with width less than X
The simplest way to develop targeting by screen size is by using CSS: @media screen and (min-width: 480px) { body { /* Estilos caso a tela tenha 480px de largura ou mais */ } } Basically, you can…
-
2
votes2
answers1123
viewsA: Problem with lists - Python
First you calculate the average height: altura_alunos = [1.70, 2.0, 1.40, 1.55, 1.70] media_altura = sum(altura_alunos) / float(len(altura_alunos)) This loop is correct. Just put all the logic…
-
5
votes1
answer842
viewsA: __str__ and __unicode__methods
there’s a difference between them? __str__() is an older form (returns bytes). __unicode__() is a new shape (returns characters, usually in UTF-8). In Django, it’s good practice to do __str__() also…
-
2
votes1
answer87
viewsA: How to read the IPTC header of an image through C#?
In my view, System.Windows.Media.Imaging: var stream = new FileStream("arquivo.jpg", FileMode.Open, FileAccess.Read); var decoder = new JpegBitmapDecoder(stream, BitmapCreateOptions.None,…
-
3
votes4
answers8205
viewsA: How to get the highest value of a python array / vector?
Basically, that’s it for a line: max(linha) And for a matrix: max([valor for linha in matriz for valor in linha])
-
0
votes2
answers1052
viewsA: Unity installation is giving error
This error is not related to Unity, exactly. For some reason, your Visual Studio could not connect to Nuget. Try running the following command before trying to install Unity again in the Package…
-
3
votes1
answer58
viewsA: Difference in EF exclusion forms
I know that with both ways it is possible to delete. They have the same function? Yes. I can use any one at any time? Yes. Are there any specific cases for use of any? Remove() checks some more…
-
1
votes2
answers189
viewsA: mongodb getNextSequence error is not defined
Try to force loading of Mongodb shell functions using: > db.loadServerScripts(); See more here.…
-
5
votes2
answers190
viewsA: Class properties difference vs Instance
The idea is to always have the same set of properties for each class that is created, in the case of class properties. You are free to put the properties you want into your classes, but this will…
-
5
votes2
answers377
viewsA: 2 devices connected to the same address via Wireless
You must also allow the use of the address specifically for the IIS Express case by running the following in administrator mode: > netsh http add urlacl url=http://192.168.25.50:56987…
-
2
votes3
answers227
viewsA: EF Core - Partitioning Filter
On the date of this reply: There is a library that allows you to use dynamic filters, the Entityframework.Dynamicfilters, but it does not have EF Core support because the event chain for it to be…
-
3
votes1
answer285
viewsA: C# How to rename MANY files faster or at the same time?
You can use parallelism: var movesSimultaneos = 2; var moves = new List<Task>(); foreach (var filePath in Directory.EnumerateFiles(folderPath)) { var move = new Task(() => {…
-
4
votes1
answer599
viewsA: Fullcalendar displayed in wrong time
This is wrong Timezone problem. I imported the dates here (my time is GMT-5) and had different values too. A package that fixes that is the Moment Timezone. I did the following test and printed the…
-
3
votes1
answer290
viewsA: Simple example of p2p blockchain in python, anyone?
This library was written with a blockchain explorer. You can locate the information by identifying the currency or the block hash. Of course, more work than that will be needed. You may have to…
-
1
votes1
answer874
viewsA: How to use Curl with C#, windows Forms application
You don’t exactly need to use Curl to do this. You can use Restsharp which is simpler to use: var cookie = new CookieContainer(); var client = new…
-
0
votes2
answers1580
viewsA: Import CSV and convert date in dd/mm/yyyy format to yyyy-mm-dd
It is important to have familiarity with regular expressions: import re The sentence below changes the date format: re.sub('(\d{2})\/(\d{2})\/(\d{4})', r"\3-\2-\1", '19/05/2017') Upshot:…
-
8
votes2
answers83
viewsA: Design based on the VS2015 spa template. How the service is generated
The template SPA (Single Page Application, Single Page Application) is an application model whose presentation features a single page that performs Ajax calls to an API in ASP.NET Web API. The Web…
-
3
votes3
answers308
viewsA: Where does this notification "tooltip" come from
Are you sure you didn’t specify? This feature is part of HTML5. The canvas field should be like this: <input type="text" name="titulo_notificacao" required>…
htmlanswered Leonel Sanches da Silva 88,623 -
4
votes2
answers330
viewsA: Difference between Find, Exists and Contains of the List<T> class
Find: Looks for an element that matches the settings, and returns the first value of the list. Correct. Better said, it corresponds to the predicate passed as parameter. Exists: Determines whether…
-
2
votes1
answer272
viewsA: Dynamic attributes of an Entity Model
.MapToStoredProcedures() is one thing. Mapping a stored Procedure with dynamic return is another. We use .MapToStoredProcedures() when we want the Entity Framework to not generate SQL, but to…
-
0
votes2
answers444
viewsA: How to configure the Django environment and maintain settings?
I’ll give you the steps I made here: Check whether the virtualenv is working. > virtualenv env Here you have created a directory env as expected. Install > pip install Django Check if you put…
-
2
votes3
answers504
viewsA: Map Many to Many in the Entity Framework
Some things are missing: public class EmpresaProjeto { [Key] public Int32 Id { get; set; } [Index("IUQ_EmpresaProjeto_EmpresaId_ProjetoId", IsUnique = true, Order = 1)] public int EmpresaId { get;…
-
1
votes1
answer27
viewsA: Foreingkey is not updated
Incorrect way you are assigning the Address Type: TipoEndereco te = new TipoEndereco(); te.Id = 3; There are two ways to do it: either you select Address Type 3, or you create an address type 3 and…
entity-frameworkanswered Leonel Sanches da Silva 88,623 -
3
votes1
answer35
viewsA: Batch persisting in Many-to-Many Entity with extra fields
Just stick to the logic. var moedas = _context.Moedas.Where(...).ToList(); var produto = new Produto() { Nome = "Espécie" }; foreach (var moeda in moedas) { produto.ProdutoMoedas.Add(new…
-
23
votes1
answer6515
viewsA: Docker vs Vagrant, what are the main differences?
Vagrant It was created with the aim of creating preconfigured Vms. The idea of creating a VM to simulate environments and share with your peers is great, but it’s a big problem to spend hours…
-
3
votes1
answer7859
viewsA: Sql Server - View the View structure
Table is even a view, or is this just a description for some other kind of Material table Is a view yes. If it is a description, it will depend on its content. How to get more information about this…
-
6
votes1
answer83
viewsA: Doubt about Many-to-Many EF Relationship
It would be right to create a Pk for a table that was generated from an N-N and use as a relationship key in another table? Yeah, but that’s not how you’re gonna get it: HasKey(x => new {…
-
1
votes1
answer63
viewsA: Time table with 8 variables
Here’s what I’d do: public struct Estatistica { public int Pontos { get { return Vitorias * 3 + Empates; } } public short Vitorias; public short Empates; } public void AtualizarTabela() {…
c#answered Leonel Sanches da Silva 88,623 -
1
votes1
answer38
viewsA: Error while restoring external database from Asp.net mvc application
To Connection string it must be so: <connectionStrings> <add name="VendasDeTitulos" connectionString="Data Source=mssql913.umbler.com,5003;Initial Catalog=VendasDeTitulos;User…
-
1
votes2
answers63
viewsA: How do I get the usermanager property started in my Model
In Controller: var condominio = new Condominio { Nome = User.Identity.Name }; return View(condominio);