Posts by Omni • 6,077 points
132 posts
-
2
votes1
answer1018
viewsA: How to run more than one command in the powershell?
Can use a array and pass it to the command to execute: @("RF73", "RF73A", ...) | % { aws s3 cp s3://rfcarga/$_ . --recursive } In this example, we create a array with the name of the images to be…
powershellanswered Omni 6,077 -
1
votes2
answers30
viewsA: Upload image and grab its dimensions
Quite possibly your image is not being loaded correctly. Try the following: var img = new Image(); img.onerror = function() { console.warn("Ocorreu um erro ao carregar a imagem"); } // esta imagem…
javascriptanswered Omni 6,077 -
0
votes1
answer147
viewsA: Chocolatey in Windows Powershell
Confirm that there is a system variable called ChocolateyInstall and that its value is the correct path to the folder where the Chocolatey is installed. Example: $env:ChocolateyInstall =…
-
1
votes1
answer38
viewsA: Error creating tables with foreign keys
There are two mistakes in yours script. First, create tables without foreign keys first. As is, when trying to create the table Filme will fail given that tables director and genero do not yet…
-
0
votes1
answer1633
viewsA: How to click a link from a frame using Selenium Webdriver?
You can use the switch_to_frame of driver to change the context to the frame: // usando o nome da frame driver.switch_to_frame(["nome da frame"]) // usando um localizador (vulgo find_element_by)…
-
3
votes3
answers251
viewsA: How to separate in pairs the digits of a variable in C#?
If you want to split any integer number, do not convert to string, and with support for arbitrary cluster size: using System.Collection.Generic; long[] DividirNumero(long valor, int tamanhoGrupo) {…
-
0
votes2
answers192
viewsA: Compile a. NET application into a self-contained executable
You can use the Costura to join all app dependencies into one .exe. Just add to your project, that when installing the package, a file .xml with the fusion configuration and a new import at the…
-
4
votes3
answers87
viewsA: How do I make a conditional if by comparing only the last 2 digits?
You can compare the last two characters of your string without manipulating and create a new string: If(textBox1(textBox1.Length - 2) = "5"C And textBox1(textBox1.Length - 1) = "2"C) Comando…
-
3
votes1
answer3316
viewsA: How to create a local SSL certificate in Windows?
You can create a certificate in the following ways: Powershell (Windows 10 and Server 2016): Open the Powershell; Use the command New-SelfSignedCertificate -DnsName "endereço do seu site", "outro…
-
2
votes1
answer258
viewsA: Get url parameter via Angularjs
One way would be to use the ngRoute. Through the $routeProvider can configure the routes of your site, and with this extract the parameters of the Urls and inject them directly into your controller.…
-
3
votes2
answers257
viewsA: Angular filter html
Can do: <tr ng-repeat="[objecto] in [colecção] | filter: {[propriedade]: '[texto]'}"> Where propriedade is the name of the property of the object you want to filter, and texto is the text you…
-
2
votes1
answer175
viewsA: How to work with Angular Arrays with screen printing?
You can use the *ngForOf to print the attributes: <!-- Assumindo que o seu controlador tem uma variavel `cidades` onde guarda o resultado da sua promessa --> <ul> <li *ngFor="let…
-
3
votes2
answers42
viewsA: How to create a date header but in the form of ISO 8601
The header should be amended as follows:: httpWebRequest.Date = DateTime.UtcNow; Take an example here.…
-
2
votes1
answer109
viewsA: Keep characters in replace with regex in gedit
You need to use a Lookahead positive: \n(?=[^0-9]) This operator does with the regular expression see if the following character matches the given expression. In this case, check that the character…
-
1
votes2
answers82
viewsA: Filling Label with Linq using Tolist()?
You can use the Aggregate(...) (alias reduce): var garantias = (from p in db.T_GarantiasLocaticias where p.imovelID == 5 select p.GarantiasTipos) .ToList() .Aggregate(string.Empty, (actual, novo)…
-
3
votes2
answers961
viewsA: Transactionscopeoption what is the difference between the options?
Starting with your final question, Suppress, on its own, not much use: using(TransactionScope ambiente = new TransactionScope()) { using(TransactionScope suprimida = new…
-
3
votes3
answers390
viewsA: Get specific application memory usage
If you want to get the memory of another process, of which you know the PID, you can use GetProcessById: var mem = System.Diagnostics.Process.GetProcessById(1234).PrivateMemorySize64; // valor em…
-
6
votes1
answer187
viewsA: There is no variable c#
Cannot make assignments in the body of a class separate from the declaration. This doesn’t work: public class Test { Banco BBanco; BBanco = new Banco(); } It may, however, make the allocation at the…
-
1
votes2
answers1054
viewsA: How to remove the background in a select option?
With regard to amending the select when browsing the options, it is not possible to do so. However, you can use libraries like Select2 or the selectize to stylize the select as you wish. Follow an…
-
1
votes5
answers10407
viewsA: Identify if there is an uppercase letter in the string
Can do: p = "Jon Snow" for x in p: c = ord(x) if c >= 65 and c <= 90: print("Maiscula encontrada")
-
0
votes1
answer1462
viewsA: Set margins and paper size with Printdocument
You can do it as follows: private void btnImprimir_Click(object sender, EventArgs e) { // ... Documento.DefaultPageSettings.Landscape = true; // Para configurar as margens int margemIn =…
-
1
votes1
answer121
viewsA: Convert a text file to PDF without saving to a physical location
Replace the FileStream by a MemoryStream: using(MemoryStream memStream = new MemoryStream()) { PdfWriter writer = PdfWriter.GetInstance(doc, memStream); // o seu codigo return memStream.ToArray(); }…
-
7
votes3
answers16084
viewsA: How can I send an email via Gmail?
A simplified version for sending emails via Gmail: using (SmtpClient client = new SmtpClient("smtp.gmail.com", 587) { Credentials = new NetworkCredential("[email protected]", "password"), EnableSsl…
-
2
votes1
answer1339
viewsA: Automate enter input in command line while running a bash script
Can do: echo | [o seu comando que necessita de input] An example. Imagine you have a directory called OMeuDirectorio and wishes to delete it with rm OMeuDirectorio -ri (note the i so that the rm is…
-
1
votes2
answers410
viewsA: Factorial C# Calculator
Note that the calculation you are doing is only valid for integers. So: private void btnfact_Click(object sender, RoutedEventArgs e) { int numeroConvertido = int.Parse(janela.Text); int resultado =…
-
0
votes1
answer51
viewsA: Problem with Phonegap
You need to add the variable ANDROID_HOME to the system. Open Powershell and write the following: [Environment]::SetEnvironmentVariable("ANDROID_HOME", "C:\ installation location \android-sdk",…
apache-cordovaanswered Omni 6,077 -
2
votes1
answer215
viewsA: Take the result of ng-repeat and use in Moment.js
You can make a filter that receives the date and format as you wish: angular.module("app", []); angular.module('app').controller("myctrl", function() { var ctrl = this; ctrl.names = [{tempoEspera:…
-
8
votes2
answers1589
viewsA: How to nested Tables with bootstrap?
Assuming the use of jQuery can do the following: function esconderLinha(idDaLinha) { // procura o elemento com o ID passado para a função e coloca o estado para o contrario do estado actual $("#" +…
-
5
votes3
answers884
viewsA: List of Exceptions
Can use the AggregateException to do what you want: try { List<Exception> excepcoes = new List<Exception>(); excepcoes.Add(new ArgumentException("argumento", "argumento invalido"));…
-
1
votes1
answer628
viewsA: Rename files in Powershell based on destination folder
You can do the following (the explanation is in the form of comments): # Primeiro defina a pasta onde estao os ficheiros a copiar $caminhoFonteFicheiros = Resolve-Path ".\A" # Depois defina uma…
powershellanswered Omni 6,077 -
2
votes1
answer1307
viewsA: Rename all files in a folder to random names
You can do the following: $caminho = Get-Location # Pode alterar se quiser outro caminho que não o actual # Lista todos os ficheiros que existam no caminho actual foreach($ficheiro in…
-
6
votes3
answers171
viewsA: How to simplify this comparison?
In C# you can do the following, using LINQ: bool b = new string[] {"a", "b", ...}.Any(s => s == variavel); Behold here an example of the code.…
-
6
votes1
answer1911
viewsA: #if DEBUG always runs, even in release mode
Instead of resorting to logic reversal (if !DEBUG), set your own symbol in the settings that need it. To do this, go to the project properties. In the project properties click on the tab Build.…
-
3
votes2
answers758
viewsA: Check for installed components
Using this answer as a basis: // Dicionario que contem os prerequisitos necessarios. Por cada prerequisito, // contem uma flag que indica se foi encontrado. No fim da pesquisa, se foram todos //…
-
4
votes2
answers55
viewsA: Get information stored in an "attribute"
You can do the following: public static string GetTableName() { TableAttribute myAttribute = (TableAttribute)Attribute.GetCustomAttribute(typeof(Cliente), typeof(TableAttribute)); // versao pre C#6…
-
4
votes5
answers8511
viewsA: Reverse array order
You can use a cycle for and exchange elements of the elements: var array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; alert(array); var length = array.length; var left = null; var right = null; for (left = 0,…
javascriptanswered Omni 6,077 -
0
votes1
answer28
viewsA: Determine the index of a numerical character
You can do the following: $NomeEstacao = "Atendimento05" if ($NomeEstacao -match "(?<digito>\d)") { $pos = $NomeEstacao.IndexOf($Matches.digito) Write-Host $pos } The -match looks for the…
powershellanswered Omni 6,077 -
2
votes3
answers2520
viewsA: Search for file with only part of its name in C#
As a curiosity, you can also use EnumerateFiles(...). Unlike GetFiles(...) who makes the search in its entirety and only then returns a string[], EnumerateFiles(...) returns a IEnumerable that can…
-
1
votes2
answers179
viewsA: Doubt about using the Inner Join
[Assuming] Without specifying which of the two forms you want, you can do the following: SELECT 'O ip ' + C.IP + ' esta na porta ' + CAST(P.numero_porta AS nvarchar) + ' do Switch ' + s.Model FROM…
-
3
votes3
answers1791
viewsA: Is there any way to convert a string to base 64 in javascript?
As mentioned, atob and btoa do not work in versions prior to IE10. You can do your own conversion function (withdrawal from here): var Base64 = { _keyStr:…
-
4
votes5
answers1656
viewsA: Create objects within a list without for/foreach C#
Can use Enumerable.Range() to generate a sequence of values and with a .Select() create the new instances and finally pass them on to the list constructor as follows: private List<Compra>…
-
0
votes2
answers590
viewsA: Open subdirectories with explorer in C#
If you need to find all directories and your children can use the method Directory.Getdirectories(...): string pastaInicial = "C:\teste"; string pastaAEncontrar = "aMinhaPasta"; string[]…
-
4
votes2
answers460
viewsA: Display HTML text in Twitter-Bootstrap popover
Appendage html: true the definition of popover: $("#pass_ca").popover({ title:'A senha deve conter entre 8 e 16 caracteres, incluindo:', content:'<ul><li>Letras…
-
3
votes4
answers579
viewsA: Get the date and time the computer called
You can consult the performance counter which indicates how long the system is active (I mean, how long has it been since the last time Windows started and subtract that time from the current date:…
-
2
votes2
answers346
viewsA: Shell Failure C#
Add quotes and escape them as follows: strScript = "sqlcmd -S server -i \"D:\\Sandboxes\\Projeto CIA\\3-Desenvolvimento\\Scripts\\DDL\\DDL_T_DDW_CIA_PRODUTO_INDEXADOR.sql\"" Note that must escape…
-
16
votes4
answers47253
viewsA: How to insert a line break inside the echo shell script?
Try echo -e "Bom dia\nfulano" The option e makes the character of newline be interpreted.
-
2
votes2
answers104
viewsA: Understanding a delegate’s lambda parameters in a function
The X represents the parameter that is passed to the function calcFib. If you rewrite the function calcFib how a method would look: public int calcFic(int x) { return x - 1 + x -2; } In the case of…
-
3
votes1
answer196
viewsA: Error placing other parameters in Shell() function
Your problem is calling the function Shell with parentheses and without assigning the function value to a variable. You can solve the problem by taking parentheses: Shell programa, vbNormalFocus Or…
-
7
votes2
answers830
viewsA: Conversion from date string to datetime C#
You can use the method TryParse(...) of the structure DateTime: DateTime data; bool resultado = DateTime.TryParse("June 15, 2001", out data); // 6/15/2001 12:00:00 AM The value of the variable…
-
4
votes1
answer1334
viewsA: How to read all bytes of a file
Can use File.ReadAllBytes(string) for what you want: byte[] todosOsBytes = File.ReadAllBytes(ARQUIVO);…