Posts by Miguel Angelo • 28,526 points
429 posts
-
5
votes3
answers1346
viewsA: How to replace all attributes using jQuery/Javascript?
You can use a regex to replace the string "__prefix__" by the desired number, from the HTML of the original element: $(function() { var original = $('.form-modelo'); var num = 1; // replace…
-
15
votes3
answers5066
viewsA: What is parallel programming?
What is it? When to use? Whenever two processes are independent, by definition, parallelization can be used. So far no news... the hard thing is to ensure an environment where parallelization does…
-
2
votes2
answers3046
viewsA: jQuery validate submitHandler does not work on firefox
I poked around here with your code and I came to the conclusion that the event.preventDefault() causes a malfunction between Firefox and Chrome. If the code contains a event.preventDefault() so it…
-
2
votes2
answers334
viewsA: CSS heritage in Divs
If you can close and open another div with class conteudo the other elements will continue to inherit whatever. You will need to change the attribute id for class, if you want to keep the HTML…
-
0
votes2
answers19485
viewsA: Bootstrap dropdown menu not working
Make sure you’re not missing the <!DOCTYPE html> at the top of the HTML document. If I don’t have it, it’s gonna get weird anyway: By placing the DOCTYPE correctly will stay like this:…
twitter-bootstrapanswered Miguel Angelo 28,526 -
4
votes1
answer153
viewsA: Advanced sorting of array items
You can’t put all the sort logic inside the custom method? usort($classificacao_items, function($a, $b) use ($items) { // 'etapa_num', SORT_ASC if ($a['etapa_num'] < $b['etapa_num']) return -1;…
-
0
votes3
answers6557
viewsA: How to search for words with javascript?
You can use a regexp to do this: Example: I put in the middle of the text two expressions in the format you indicated to exemplify: [1]=> string(24) "<nodo name="background">" [1243]=>…
javascriptanswered Miguel Angelo 28,526 -
1
votes1
answer1140
viewsA: How to change formatNoMatches in Lect2 4.0.0?
It seems that the standard way to do this in version 4 is by language file. However I did a little bit and I ended up developing a work-Around that works: $(function() { var id_categoria =…
-
4
votes1
answer78
viewsA: Move Image Browser
Add e.preventDefault() in all mouse events, so the default behavior of the browser will be suppressed for sure. There is a Firefox bug about this. That’s how it works (jsfiddle): var svg =…
-
4
votes1
answer413
viewsQ: How to know if an intersection contains another intersection?
If I and J are two sets formed by intersections, how to know if I contains J, knowing that: I = i1 i2 ... in J = j1 j2 ... jn nor I nor J are empty, therefore nox or jx the saint I know the answer…
logicasked Miguel Angelo 28,526 -
3
votes1
answer413
viewsA: How to know if an intersection contains another intersection?
Here’s what I believe is the answer, or at least part of it: I contains J for sure One of the ways to make sure I contains J is below (maybe there are more conditions, I’m not sure) all in contain…
logicanswered Miguel Angelo 28,526 -
6
votes3
answers2688
viewsA: How to identify and print perfect squares with Javascript?
Knowing that perfect squares are located at well-defined intervals: Q1 = 0 + 1 = 1 Q2 = 1 + 3 = 4 Q3 = 4 + 5 = 9 Q4 = 9 + 7 = 16 Q5 = 16 + 9 = 25 Simplifying: Q1 = 1 Qn = Qn-1 + 2n - 1 We can print…
javascriptanswered Miguel Angelo 28,526 -
4
votes2
answers390
viewsA: Why can’t an anonymous method be assigned to a var or Dynamic?
Enough for you to ask yourself what kind of var then? In the case of your example: var mostra = delegate(string x) { Console.WriteLine(x); }; mostra("teste"); mostra would be a delegate of what…
-
3
votes1
answer116
viewsA: Working with Regular Expression
Your code is just having some syntax problems and some wrong property names... fixing these, works perfectly: private void button1_Click(object sender, EventArgs e) { Colorir("if",…
-
1
votes2
answers1803
viewsA: How to recover the number of characters via regular expression?
I guess there’s no way to do it with RegExp. Here comes a Javascript to detect duplicate points in your string. Make sure it fits: function DetectarRepeticoes(str) { var obj = {}; for (var itL = 1;…
-
3
votes2
answers1266
viewsA: Regex time greater than 00:00
Use the regular expression ^((?!0+:00)\d{1,}:[0-5][0-9])$ As you can see it’s pretty much the same as yours, with an addition that prevents the match from being "0:00" nor "00:00" and neither…
-
3
votes2
answers168
viewsA: How to select with regex?
Use the regex /,(?=[^,]*,)/g and the method replace: var a = "123,345,234"; //tem que ficar 123345,234 var b = "abc,def,adf"; //tem que ficar abcdef,adf var c = "123,345,678,abc,qualquer,coisa";…
-
19
votes5
answers1879
viewsA: What is the difference between an explicit cast and the operator as?
The cast explicitly throws exception if the object is not of type. private void textBox1_Leave(object sender, EventArgs e) { TextBox textBoxTemp = (TextBox)sender; // lança exceção se não for…
-
0
votes5
answers24461
viewsA: Using jQuery Validation Engine and CPF validation
Try using a custom checker with function: "cpf": { "func": function(field, rules, i, options) { var regex = /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/; if (!regex.test(field.val()) return false; //…
-
1
votes2
answers202
viewsA: Layout adjustment with elements that are automatically generated
A very simple solution would be to put the style overflow: hidden in the element that is the block container. And for these blocks, use the float: left. See in this example if that’s what you want:…
-
3
votes2
answers406
viewsA: Windows form c# identify which Bindingnavigator button was clicked
I don’t know if I understand the question very well... but if you are using Visual Studio, just double click on the desired button of BindingNavigator that it will create and associate a method to…
-
6
votes1
answer135
viewsA: Use of Waitall in C#
It is possible to solve this problem using: one Mutex (lock) two meters, one for A and one for B and two manual reset events ManualResetEventSlim The ManualResetEventSlim serves to stop execution…
-
4
votes1
answer2211
viewsA: Does Localstorage have any storage limits?
The localStorage has yes limit, and depends on the browser the rules. In Chrome the limit is 5MB of data, by source. Opera will ask the user if he allows the site to use more data when the limit is…
-
6
votes2
answers925
viewsA: How to add Static methods in interface?
Unable to implement an interface method using a static method. Interfaces exist to define a contract between the class and users of object instances. For this to happen, it is allowed to type-cast…
-
1
votes1
answer1682
viewsA: Check if a series of directories of a path exists in VB.NET
No need to check each subdirectory... the method Directory.CreateDirectory will create all levels of the directory passed automatically for you. Also there is no safe way to check with…
vb.netanswered Miguel Angelo 28,526 -
6
votes2
answers90
viewsA: Problems Embarrassingly Parallel?
Image rendering An algorithm of this kind is the rendering of three-dimensional scenes, in which each pixel is rendered completely without relying on any other pixel rendering. That’s why today’s…
parallelismanswered Miguel Angelo 28,526 -
1
votes2
answers330
viewsA: How is the find function implemented?
Build a parser LR from the production: s -> .*minha_regex minha_regex -> sua regex original When production minha_regex is reduced for the first time, you will have found. Converting parts of…
-
6
votes3
answers936
viewsA: HTML Helpers in ASP.NET MVC 4
Purpose of the parâmtero x => x.... This parameter is used so that the helper, in the case LabelFor know what is the property of your object Model for which it must render a label. From that…
-
11
votes1
answer13726
viewsA: How to Treat Variable Filled by NAN Javascript
To detect the occurrence of a NaN (Not a number) you must use the function Number.isNaN passing the value. var nan = 0 / 0; var eNaN = Number.isNaN(nan); // eNaN vai ser true, pois zero sobre zero…
javascriptanswered Miguel Angelo 28,526 -
7
votes1
answer311
viewsA: What is a Reflection?
Overview Reflection is the ability of a program to know of which parts it itself is composed, without requiring the programmer to enter this data manually, that is, the data on the program structure…
reflectionanswered Miguel Angelo 28,526 -
4
votes1
answer685
viewsA: Inline-block element drops when filled
The problem is because the browser is aligning the DIV's inline-block the baseline of the text contained therein. There are two solutions I can think of now: add vertical-align: bottom; in class…
-
4
votes1
answer619
viewsA: Calculate the number of elements with CSS
There is a way to do using CSS transformations (transform), as I discovered in the Stackoverflow (english), with a few cons: is not compatible with all browsers: Can I use CSS Transforms I had to…
-
51
votes4
answers49363
viewsA: What is console.log?
This writes any message in the browser’s LOG, which can be viewed at any time. These messages can be used for various purposes: assist in programming (like when you give a alert just to see if a…
javascriptanswered Miguel Angelo 28,526 -
17
votes5
answers910
viewsA: Operator "||" in Javascript variables
In a similar response, I explained what this operation means. It is called colescence. There goes an excerpt of this answer that answers your question (your question, however, is not a duplicate):…
javascriptanswered Miguel Angelo 28,526 -
3
votes3
answers407
viewsA: How to implement the standard presented in C# with Entityframework?
What you’re calling a repository is not quite the repository standard, because you’re leaking Iqueryable... but I don’t want to go into too much detail about nomenclature, because that would be too…
-
3
votes1
answer537
viewsA: How not to serialize some attributes in Restful calls (C# + WCF + JSON)?
Try to use the attribute IgnoreDataMemberAttribute on the property. Example with the property ID of your class: public class SomeFakeClass { [IgnoreDataMember] public int ID { get; set; } public…
-
6
votes2
answers429
viewsA: How to filter a list asynchronously using LINQ?
The method Where builds an object that represents a query to be executed, and no query has been executed yet. That’s why does not make sense that the method Where is executed asynchronously. What…
-
0
votes1
answer1215
viewsA: 'Object' does not contain a definition for 'Action'
The error is probably in the place where the partial view call is made, which is passing an object that does not own the property Action for the view _ExternalLoginsListPartial.cshtml. Probably in…
-
3
votes1
answer91
viewsA: How to add concrete elements in Runtime in the Visitor project pattern?
Perhaps it is enough to create a method that serves to visit any object that implements an interface, rather than the final concrete type. Thus, a single abstract method would be responsible for…
-
7
votes3
answers233
viewsA: nullable on the models?
I like to think of Dataannotation`s validation in the models as being "messages" intended for the end user, which indicate what it is necessary to do in order for the entered data to be considered…
-
5
votes5
answers9265
viewsA: Search judicial process data on the TJSP website
I worked at a company that did this... I don’t remember about this court specifically, but what was normally done was to contact the court by phone, with the technical area, and then ask if this is…
-
28
votes3
answers21251
viewsA: What is a virtual class, attributes and methods?
First, in C# it is not possible to use the keyword virtual directly in the class. It is possible to use, yes, abstract to indicate an abstract class. Also in the world . Net, it is usually called…
-
1
votes4
answers313
viewsA: Changing a random string of characters using Stringbuilder
You will not need a Builder string to replace one character with another... you can use an array: var rnd = new Random(); var str1 = "12****3*59**100*"; var str2 = "12345768"; var chars =…
-
4
votes2
answers84
viewsA: Is there a LINQ method that returns a default value of my preference?
Use the null coalescence operator: return context.pessoaFisica.FirstOrDefault(p => p.CPF.Equals(cpf)) ?? meuValorDefault; As you indicated you want the ID, you could do so: return…
-
16
votes2
answers1173
viewsA: Is it safe to minify HTML?
White spaces can have meaning dependent on CSS, for example when using white-space: pre. Therefore, an HTML mini-scanner, which does not take into account the CSS styles applied to it, will be…
-
3
votes5
answers1054
viewsA: Contains in Class List
The Any works, however you are probably comparing different specialty objects, but they seem to be the same, by having the same values in the properties. Try to compare a property that identifies…
c#answered Miguel Angelo 28,526 -
13
votes5
answers2270
viewsA: Using unused affect performance?
Usings are only shortcut definitions for type naming (class/struct/Enum/delegate)... so it is possible to use type names directly under the namespaces indicated by usings: using System; // agora…
-
5
votes2
answers672
viewsQ: Event fires second only, after sequence of user actions
I have a form where there’s a table. At the bottom of this, there are buttons to manipulate the table rows, and only the selected ones will be affected. Steps to play problem jsfiddle to check the…
-
12
votes3
answers1858
viewsA: How to know the right measure of comments?
A serious problem I’ve had with too many comments is that not all programmers who participate in a project are so methodical as to change comments when the code changes, and this problem is…
-
14
votes2
answers5203
viewsA: Methods and properties in C# - advantages and disadvantages
The @Maniero response is already perfect, so I’ll just add a few points that I consider good practice, and make notes on the ones already mentioned: estates force the get and set to stay close…