Posts by Bruno Costa • 5,878 points
147 posts
-
0
votes2
answers74
viewsA: Create a new record based on another with Entity
You can also make use of MemberWiseClone. This method exists in the class Object but you have access protected so if it is useful you can make it available in a method: public Market Clone(){ return…
-
6
votes1
answer1534
viewsA: Reference with a yellow triangle, what does it mean?
It depends. If you open your Lista de Erros should have a Warning that explains why these references are yellow. But it may be due to one of the following reasons: The package may have application…
-
16
votes3
answers2697
viewsA: What is reactive programming for?
The answer was drafted without focusing too much on the pillars of reactive programming, I left a dedicated section to explain how each of the pillars maps to each of the points of my answer…
-
1
votes1
answer71
viewsA: Automatic Cache Time Expiring
This may be due to a problem with timezones. Instead of DateTime.Now.AddMinutes(60) Prefer DateTime.UtcNow.AddMinutes(60)
-
2
votes3
answers634
viewsA: How to make my program consume less CPU without disturbing its execution?
Try decreasing Sleep duration Thread.Sleep(1); Or use a Timer var timer = new System.Timers.Timer(); timer.Interval = 10; timer.Elapsed += (ctx, arg) => /*chama a sua funcao aqui*/;…
-
6
votes1
answer280
viewsA: Doubt about Design Patterns - Idempotency Messages
This function does not do what Oce specified, but is closer to achieving its goal. It experiences performing the function action a certain number of times. If the action complete within the…
-
7
votes2
answers284
viewsA: How to perform the correct flow deviation in an integration with multiple systems?
Resource Service DAO Router I would say that flow is not correct. It’s more like this / Base de dados Resource - Service - Router __/ \ \ Web Service The fact that each Resource method has to have a…
-
1
votes2
answers994
viewsA: How to read Console strings?
You can use the prompt console.log(prompt('Input'))…
-
6
votes1
answer352
viewsA: How to allocate an immense amount of memory?
Obviously Voce is forbidden to read your entire file at once. The only alternative you have left is to process the file in blocks: public static void Encripta(string src, string dest){…
-
0
votes1
answer426
viewsA: Rijndael encoding based on 64 in C#
Either your encoding or the decryption is not right. You have to understand that to decrypt a cipher Rijndael Voce needs the same IV and the same key. Therefore Voce cannot encrypt the IV along with…
-
1
votes1
answer216
viewsA: C#: how to identify sheet title
I’ve decided to rewrite your algorithm. From the moment you get the column name you can check for duplicated columns as follows var nomeDasColunas = dsPlan1.Tables[0].Rows[0].Select(r =>…
-
1
votes1
answer58
viewsA: List is being filled in but the properties are null
The Binding of an array/list of elements through the query string has to follow a special rule. In your case the parameter is called pItens. Your query string must have the following format:…
-
1
votes5
answers1202
viewsA: How to perform a task at a precise time in time?
Javascript Can be done using setTimeout and some recursion. function setIntervalDelayed(delay, interval, cb){ setTimeout(function(){ cb(); setIntervalDelayed(interval, interval, cb); }, delay); }…
code-golfanswered Bruno Costa 5,878 -
4
votes5
answers1202
viewsA: How to perform a task at a precise time in time?
In C# the same can be done using a timer. The trickiest part is handling the case of when the timer should start. Since there is no simple API to do this Voce has to resort to other mechanisms like…
code-golfanswered Bruno Costa 5,878 -
5
votes1
answer84
viewsA: this inside a builder, what does it do?
The construction this inside the constructor serves to call another constructor. That is to say this(0,0,0); will call the builder public Tempo (int h,int m , int s){ SetTime(h,m,s); } It cannot be…
javaanswered Bruno Costa 5,878 -
11
votes8
answers5920
viewsA: Is it always guaranteed that a multi-threaded application runs faster than using a single thread?
According to the amdhal law, the maximum speed up of a task that runs on several Cpus, depends on the proportion of code that can be. That is, if the algorithm is highly parallelizable, increasing…
-
1
votes0
answers40
viewsQ: How does optimistic competition work?
In an application with pessimistic competition there is data containment usually involving Locking mechanisms. In optimistic competition no. Two clients can try to write but only one can. What are…
-
2
votes1
answer393
viewsA: How can I move an element from an Arraylist to the last element ?
Yes, it is to exchange the elements. public static <E> void swap(List<E> list, int idx1, int idx2){ E aux = list.get(idx1); list.set(idx1, list.get(idx2)); list.set(idx2, aux); } To…
-
1
votes1
answer201
viewsA: Using Sessao on a MVC controller returns error
Unable to access context via HttpContext.Current in a ApiController. To access the context use the following form: var context = Request.Properties["MS_HttpContext"] as HttpContext; Source Note:…
-
4
votes2
answers1113
viewsA: How to return the most appearing words in a column?
I found a solution online, I give all the credit to author of the article who found an ingenious solution to split a string into Mysql. However the solution of it requqer that Voce create a table of…
-
7
votes3
answers713
viewsA: foreach is a loop or iterator? Or can it be both?
As stated in @Maniero’s reply, foreach is a loop because it runs a block of code repeatedly, in a nonrecursive way, such as the while, for or do-while, or even goto in some scenarios. I don’t know…
-
6
votes2
answers408
viewsA: What is Strategy Pattern?
The strategy pattern is useful when you have several ways to accomplish a certain task. Its intention is to separate components with an equal purpose, however these components work differently. An…
-
6
votes2
answers68
viewsQ: How can I indicate the directory where my assemblies should be found?
My company has an installation that hits the gigabyte home. We have a set of applications in our installation that share the same libraries. By default, when . NET executes an application it looks…
-
12
votes3
answers1090
viewsQ: In programming, what is the actor model?
I have a co-worker who is an advocate of model actor (model of actors, in Portuguese). In general, it seems to be a software architecture to be applied in distributed systems or in the cloud. From…
-
5
votes3
answers8566
viewsA: What is CQRS and how to implement?
According to the default author it consists only of separating the read operations from the write operations. When Most people talk about CQRS they are really speaking about Applying the CQRS…
-
10
votes1
answer339
viewsQ: What allows a method to be intercepted in C#?
Interception of a method is a technique that can be used to execute a code snippet before executing a main action. That is, in a very simplified way this would also be an example of interception:…
-
1
votes1
answer137
viewsA: How does the request session work?
To contextualize, as the request session consists? To make a request to a database it is necessary to open a connection with the same database. You may consider that there is a session while this…
-
2
votes5
answers1106
viewsA: Is SOAP safer than REST?
It’s something that makes no sense to compare, just like that. REST defines a set of best practices that should be followed when making a web application. The protocol used at the application level…
-
3
votes2
answers4614
viewsA: Character size (ASCII vs other encodings) in bytes
TL;DR; Depends on encoding and some language/platform details. Each UTF-8 character occupies 1 to 6 bytes, Each UTF-16 character occupies 16 bits Each UTF-32 character occupies 32 bits Each…
-
11
votes2
answers13387
viewsA: What is the difference between "NULL", "0" and 0?
I wanted to make an addendum to @Maniero’s reply. The Standard C does not require that NULL is set with all bits to 0. §7.20.3.2 ... 2 The calloc Function allocates space for an array of nmemb…
-
1
votes2
answers283
viewsA: Modifying a list item shared by multiple threads
Well the problem is because you are changing the state of the object in a different thread than the one that reads it. More precisely this line is giving problems, as you have noted: dado.Colecao =…
-
0
votes1
answer117
viewsA: In an API url, what does "Scope" mean?
This API requires Oauth appliance. In Oauth a Scope is an aggregate of resources. To get access to these features the user has to confirm that he can get access to the corresponding Scope. For…
vb.netanswered Bruno Costa 5,878 -
18
votes3
answers218
viewsA: Doubt javascript Function t(n,t,i,r)
It is a javascript function with name dt and has 4 parameters n, t, i and r. It appears with these names because it is customary to minimize code to reduce the file size, thus saving traffic and…
javascriptanswered Bruno Costa 5,878 -
14
votes1
answer995
viewsQ: What is a Monad and what is it for?
I remember at the university it was explained to me what a monad, but time has passed and I no longer know what he is. This is also due to the little contact I have with functional languages. In…
functional-programmingasked Bruno Costa 5,878 -
3
votes1
answer61
viewsQ: How does the operating system distribute the processor across the various programs?
In current operating systems there is possibility of having several programs running. It is the work of the operating system to ensure that all programs have opportunity to perform work (process…
-
2
votes2
answers304
viewsA: How to Manipulate Objects in a Thread?
Right now your threads don’t have enough information. This is because threads need to know the state of the objects in the remaining threads (i.e., they need to share state). It may not be obvious,…
-
3
votes2
answers828
viewsA: Abort Thread through another C#process
In . Net threads are automatically recycled when they finish their work. The only thing Voce has to ensure is that the threads end as quickly as possible. Also there is no way easy to retrieve all…
-
24
votes4
answers8680
viewsQ: What are the differences between HTTP 2 and HTTP 1.1?
A very pertinent question was asked earlier to find out what the differences between the HTTP 1.1and the HTTP 1.0. I wish I knew exactly the same but between HTTP 2.0 and HTTP 1.1. Additionally,…
httpasked Bruno Costa 5,878 -
7
votes1
answer2302
viewsA: Difference between normal request/response, long-Polling, websockets, Webrtc and Server-Sent Events?
Request/Answer "normal" This is the protocol HTTP itself. It is the initiative of the client to make a request to the server. The server will give an answer. The server cannot take the initiative to…
-
7
votes5
answers1574
viewsA: Why do "Alert", "confirm" and "prompt" lock the loading independent of the definition order?
In fact this behavior depends on the browser Voce is using. I will now describe the behavior for the most used browsers: Chrome(1) - Chrome Version 54.0.2840.99 m (64-bit) Firefox(2) - Firefox…
-
2
votes3
answers5247
viewsA: System.Unauthorizedaccessexception in C#
You can run your application as an administrator. In fact, Voce can indicate that the application should be executed only with administrator rights. For this, Voce has to create a manifesto for its…
c#answered Bruno Costa 5,878 -
4
votes1
answer298
viewsA: Date validation with Dataannotation
You can do this by creating a class that derives from RangeAttribute: public class DateAttribute : RangeAttribute { public DateAttribute() : base(typeof(DateTime), DateTime.Now.ToShortDateString(),…
-
1
votes1
answer499
viewsA: Delete user session in ASP.NET MVC with [Authorize]
You have to implement your own Authorize Attribute. You can reuse the existing implementation and derive from the attribute authorize and make the modifications it needs: public class…
-
4
votes2
answers175
viewsQ: Should I make sure the threads end at Dispose?
There are already some questions about the interface IDisposable and the using, for example: What types of resources are released in a statement using I should always use Disposis Still I’m not sure…
-
4
votes2
answers477
viewsA: What types of resources are released in a "using" statement?
The @Maniero response already talks about everything about the IDisposable, I’ll just answer the question more directly. When it comes to resources that will be released, it refers to the use of…
-
11
votes2
answers325
viewsQ: Are DDD and Entity Framework mutually exclusive?
I was exchanging comments with two users here at SOPT about DDD and Entity Framework. I said that DDD and Entity Framework are not mutually exclusive. Or are they? References: What is really the…
-
7
votes2
answers312
viewsA: Who is who in the use of functions?
Function A function can be seen as an instruction container, it alone does nothing. It only executes the instructions when it is called. Parameters and arguments How @rray commented the difference…
-
3
votes2
answers220
viewsA: Inheritance problem
With the LazyLoad Voce can access the property Cliente content requires that the contexto is still alive. If you want access to the property Cliente after that will have to load form Eager. In your…
-
14
votes1
answer781
viewsQ: In distributed computing, how does the election of a leader work?
Election of leader is a problem in the area of distributed systems that seeks to select a process in a set of processes aiming to select a leader for a particular task wikipedia In distributed…
asked Bruno Costa 5,878 -
3
votes2
answers283
viewsA: What is the difference between using a comparison with >= or simply >?
There is another view that @Maniero did not mention. Imagine you have a data structure with maximum capacity. And you want to check if the list has exceeded that capacity: var list = new…