Posts by Omni • 6,077 points
132 posts
-
6
votes2
answers6301
viewsA: Remove an item from a List<>
You can use the method Except(System.Linq) to solve the problem: private IEnumerable<Carros> GetCarros(long userId, List<Carros> list) { var retornaCarros =…
-
14
votes1
answer447
viewsA: Instruction to add value to AX
Without more information, I’d say you want it and the instruction MOV: MOV AX, 55d…
-
5
votes2
answers3387
viewsA: Finish a process programmatically
If you want to finish a set of processes that share the same name: var processes = Process.GetProcessesByName(string); foreach(var p in processes) p.Kill(); The method .GetProcessesByName(string)…
-
5
votes1
answer18229
viewsA: Fill a vector with random values (C language)
The problem is in the following line: srand(time(NULL)); Function time(NULL) has a resolution in seconds, that is, if you call it several times in the space of a second, the value returned will…
-
1
votes3
answers133
viewsA: Where are the elements selected by LINQ stored?
They don’t stay stored because they don’t exist yet. When you write IEnumerable<int> numerosPares = from n in numeros where (n % 2) == 0 select n; Try to think of the following terms…
-
1
votes2
answers54
viewsA: Force the subclass
Adding the modifier virtual in the base class method and then doing the override in the derived class: public class Transporte { public virtual void exibeDados() { Console.WriteLine("classe…
-
2
votes1
answer379
viewsA: Add N items to a Numericupdown-based Textbox
You can do it as follows: // No clique de um botão, ou num outro evento que queira private void button1_Click(object sender, System.EventArgs e) { // Remove as passwords que existirem na ListBox…
-
1
votes1
answer880
viewsA: How to execute a method inside a textbox only if the user gives enter?
If only when the key is used Enter may use the following: private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { // Seu codigo aqui } } Here, the event KeyDown…
-
1
votes1
answer221
viewsA: C# and mysql paging
One way would be to store the last requested position and increment it according to the desired number of records: int numeroDeRegistos = 5; int totalRegistos = 50; for(int ultimaPosicao = 0;…
-
11
votes1
answer395
viewsA: Concat() VS Union()
The operator Union() returns the elements of both collections that are distinct. Assuming we have two lists: List<int> primeiraLista = new List<int>{1,2,3,4}; List<int>…
-
1
votes2
answers1303
viewsA: Picking up content within a string
While the @Maniero solution largely solves the issue, the version is left with regular expressions to solve the problem: private static Regex regex = new Regex("^.*\\((?<login>.*)\\)$",…
-
2
votes2
answers40440
viewsA: How to resize image to container size?
You can do it this way: img { max-width: 100%; max-height: 100%; } .minha-div { height: 50px; width: 50px; } A minha div <div class="minha-div"> <img…
-
2
votes2
answers4720
viewsA: how to pick up an object from an array through id with Angularjs
Let’s go in pieces. To find the object using the ID you can simply: var idParaEncontrar = $stateParams.id; var objectoEncontrado = undefined; for(var i = 0; i < minhaColeccao.length: ++i){…
-
3
votes1
answer12945
viewsA: Fixed Bar at the top
Can use position: fixed to that end: .barra { background-color: black; position: fixed; top: 0; left: 0; right: 0; height: 35px; } <div class="barra"></div>…
-
4
votes1
answer758
viewsA: Pass Type parameter for generic Runtime method
You can use the following code to pass a generic type during Runtime: public static class CustomJson<T> where T : class, new() { public static T Deserialize(string data) { try { if…
-
1
votes1
answer608
viewsA: How to request administrator permission in Visual Basic.NET
If the entire application needs to run with high privileges, you do not need to make changes to the code. Just add a manifesto that informs Windows that your application should be run with high…
-
3
votes4
answers7268
viewsA: Get a Youtube video ID from the URL
Can use regex to extract the ID: $patternRegex = "/http[s]?:\\/\\/www\\.youtube\\.com\\/watch\\?v=(\\w+)/"; $urlYoutube = "https://www.youtube.com/watch?v=jNQXAC9IVRw"; preg_match($patternRegex,…
-
3
votes2
answers3318
viewsA: Take the directory route
You can use the class FolderBrowserDialog: // Instancia a classe. using (FolderBrowserDialog dirDialog = new FolderBrowserDialog()) { // Mostra a janela de escolha do directorio DialogResult res =…
-
1
votes3
answers2790
viewsA: Read a string with line break
A solution, rather than changing one of the strings and remove line breaks, can go through implementing a comparison your. An example of this comparison would be (based slightly on this reply): //…
-
5
votes1
answer789
viewsA: Total month to month with previous months
Like the @gmsantos confirmed no analytical functions available in MySQL. The solution then is to run a query within the query which calculates the required results month by month: SET @totalagregado…
-
6
votes1
answer355
viewsA: How to check if there is an already installed Source
You can use the class InstalledFontCollection and find out if your source is in the collection: public bool FonteExiste(string aMinhaFonte) { var fonts = new InstalledFontCollection(); return…
-
5
votes1
answer91
viewsA: Dynamize title with Angularjs
You can create an event on $rootScope on the page workspace-admin.html and subscribe to this event on index.html: That is, in the controller of workspace-admin.html: // emissao do evento…
-
3
votes1
answer709
viewsA: How to print the entire string if the length exceeds the page
What you need to do and measure the text you print: int caracteresNaPagina = 0; int linhasPorPagina = 0; e.Graphics.MeasureString(textoFinal, font, e.MarginBounds.Size,…
-
2
votes1
answer112
viewsA: Print matrices with line break
Your problem occurs due to this piece of code: e.Graphics.DrawString(impressao, Fonte, Brushes.Black, e.MarginBounds, StringFormat.GenericTypographic); How it’s always passing the same value of…
-
18
votes1
answer20517
viewsA: Compare two strings in C
Your problem is in the comparison: if (info[i].nome == busca.nome){ return i; } In reality it is comparing the pointers and not the contents of the vectors, hence the fact that even strings were…
-
2
votes1
answer4074
viewsA: The 'X' type initializer has triggered an exception
Your problem, as the exception says, is in class initialization Constantes. Check that ConfigurationManager.AppSettings["CaixaTrashPath"] exists. If it does not exist, an exception will be made,…
-
0
votes4
answers7370
viewsA: Validate content from Textbox
Can use a MaskedTextBox for what you want. The property Mask allows you to define which are the inputs accepted. In your case the Mask would be: txtValorCompra (98,90) => 00,00 (Required to enter…
-
1
votes1
answer223
viewsA: How do I find the unique values of a matrix?
To obtain the singular values of a matrix you can do the following: v = svds(SuaMatriz); This function calculates the six largest singular values of the matrix, as well as the associated vectors. If…
-
1
votes1
answer102
viewsA: Ondisconnected event in Signair does not work right
Exception Concerning the exception, the method for doing override of the class method Hub has the signature public virtual Task OnDisconnected(bool stopCalled) {...} Thus, your override will stay:…
-
3
votes1
answer78
viewsA: When do I have to unsubscribe (unsubscribe) events?
The opposite of reply is the scenario in which it will be necessary to cancel the subscription, that is, when the life times of the objects are different. Take the example of a static event: public…
-
6
votes1
answer2698
viewsA: C# - Import configuration file (.ini)
The idea in .net and use XML configuration files, so there is no native way to read the files .INI. That said, and given that sometimes business needs may require the use of a .INI, may use a…
-
4
votes2
answers768
viewsA: String of characters inside the scanf. Why and how does it work scanf("Day %d",&dia);?
What happens in this case is that the scanf(...) a format string. This format string indicates to scanf(...) how to process the read input, ie is a formatting directive. If processing the input the…
-
4
votes2
answers1234
viewsA: How to generate a file in the same exe directory
Can use Environment.CurrentDirectory: string caminho = Path.Combine(Enviroment.CurrentDirectory, "filmes.xml"); Extra: If you have to work with paths please use the Path.Combine in order to abstract…
-
8
votes2
answers19497
viewsA: How to get a snippet of a string?
(Despite the reply of the Maniero being quite good, and always interesting to add other possibilities.) An alternative solution would be to use regular expressions to capture the text you need:…
-
4
votes1
answer3962
viewsA: How to bring only results from the last 30 minutes
Using DATEADD(): select dateadd(minute, -30, getdate()) In your case your query will be something like: select * from tabela where data >= dateadd(minute, -30, getdate()) Example in Sqlfiddle…
sql-serveranswered Omni 6,077 -
4
votes2
answers8784
viewsA: VBA Set ie = Createobject("Internetexplorer.Application")
Yes, it is possible. ' Cria um novo objecto do IE Set IE = CreateObject("InternetExplorer.Application") Set WshShell = WScript.CreateObject("WScript.Shell") ' Indica ao IE que deve navegar para a…
-
1
votes2
answers1524
viewsA: How to display two different database tables in php
You can use the CROSS JOIN: SELECT * FROM tabela1 CROSS JOIN tabela2
-
4
votes2
answers428
viewsA: Problem with IF Shell Script Syntax
Your script is fixed: RESPOSTA=$(asterisk -rx "sip show peers" |grep 4003 |awk -F" " '{print $6}') if [[ "$RESPOSTA" = "OK" ]]; then echo "$RESPOSTA" elif [[ "$RESPOSTA" == "Unmonitored" ]]; then if…
-
3
votes1
answer1937
viewsA: How to remove mask from a Maskedtextbox
You can get the value of MaskedTextBox in two ways, depending on what you need: Permanent In your Maskedtextbox change the property value TextMaskFormat for ExcludePromptAndLiterals. This way you…
-
4
votes2
answers1729
viewsA: How to pass values of controls between different windows?
You can pass on the necessary information to the second form through the constructor and store this information in private fields so that they can then be used by the method…
-
2
votes4
answers1593
viewsA: Changing connectionStrings from the app.config physically in Runtime
If you want to change the connection string during the Runtime: var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var connectionString = (ConnectionStringsSection)…
-
2
votes4
answers3435
views -
11
votes1
answer1726
viewsQ: Difference between Stathread and Mtathread
What is the difference between Stathread and Mtathread and when I should use one or the other? Why and how do they only concern the COM?
-
5
votes3
answers3859
viewsA: Count the columns of a Mysql table using PHP
To count the columns one-table: SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'nome_da_sua_base_de_dados' AND table_name = 'nome_da_sua_tabela'; Example in Sqlfiddle…
-
6
votes2
answers197
viewsA: Nomenclature or language in lambda
You should read the relationship of x with the Where and the minhatable and not the relationship x => x.meu_campo. That is, as an SQL query would read, 'For each x in minhatable where x.meu_campo…
-
1
votes1
answer1055
viewsA: How to implement a thread queue to run one after the other?
Instead of creating a thread queue, why not create a message queue that will be written? So you could have a unique thread that wrote the messages and avoided the access problem, thus creating a…
-
2
votes1
answer1774
viewsA: How to group by 2 properties and sum the values
The query to group each product per hour and calculate the quantities sold will be: var vendasPorProduto = vendas.GroupBy(v => v.DataHora.Hour) .Select(g => new { Hora = g.Key,…
-
2
votes2
answers67
viewsA: Consider null and empty strings as equivalent to each other
If you’re only interested in a binary result, whether they’re the same or not, why not: bool iguais = string.IsNullOrEmpty(primeiraString) && string.IsNullOrEmpty(segundaString); Thus, if…
-
0
votes1
answer384
viewsA: Exception when trying to authenticate SSL connection
Let’s divide the problem into parts. Concerning the error RemoteCertificateNameMismatch, this is due to the fact that the name that should pass in the AuthenticateAsClient(...) is the server name.…
-
2
votes1
answer376
views