Search This Blog

Monday, June 24, 2019

Print call stack in javascript

From https://til.hashrocket.com/posts/478143b559-print-call-stack-on-javascript

Print call stack on Javascript

If you want to print the javascript **call stack** you can use:

```javascript
console.log(new Error().stack);
```

Here it is an **example**:

```javascript
function firstFunction() {
    secondFunction();
}
function secondFunction() {
    thridFunction();
}
function thridFunction() {
    console.log(new Error().stack);
}
firstFunction();

//=> Error
//    at thridFunction (<anonymous>:2:17)
//    at secondFunction (<anonymous>:5:5)
//    at firstFunction (<anonymous>:8:5)
//    at <anonymous>:10:1
```

h/t @rondale_sc

viniciusnegrisolo
June 10, 2016

Sunday, May 19, 2019

Turning off .net core Transfer-Encoding Chuked automatic header

                var objectContent = new ObjectContent<Dictionary<string, DataTable>>(dataTablesDic, new JsonMediaTypeFormatter(), "application/json");
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(dataTablesDic);
                //setting request's content ContentLength's header was the only way I found to turn off .net core automatic Transfer-Encoding=Chunked setting, which was resulting in web api post object binding failure
                objectContent.Headers.ContentLength = Encoding.UTF8.GetByteCount(json);
                var result = httpClient.PostAsync($"http://localhost:65000/File/GetExcel?bucketDestinationPath={fileName}&S3bucketName=myBuketName", objectContent)?.Result;

Tuesday, March 26, 2019

Breakpoints in .net core library will not be hit when debugging consuming WinForms app

https://stackoverflow.com/q/55359599/1219280

Check the project's Debug information property found here: Properties > Build > Advanced (button at bottom) > Debugging information



Retrieving Jenkins Credentials passwords using Jenkins Script Console


https://github.com/tkrzeminski/jenkins-groovy-scripts/blob/master/show-all-credentials.groovy


import jenkins.model.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey
import com.cloudbees.jenkins.plugins.awscredentials.AWSCredentialsImpl
import org.jenkinsci.plugins.plaincredentials.StringCredentials
import org.jenkinsci.plugins.plaincredentials.impl.FileCredentialsImpl

def showRow = {
    credentialType, secretId, username = null, password = null, description = null - >
        println("${credentialType} : ".padLeft(20) + secretId ? .padRight(38) + " | " + username ? .padRight(20) + " | " + password ? .padRight(40) + " | " + description)
}

// set Credentials domain name (null means is it global)
domainName = null

credentialsStore = Jenkins.instance.getExtensionList('com.cloudbees.plugins.credentials.SystemCredentialsProvider')[0] ? .getStore()
domain = new Domain(domainName, null, Collections. < DomainSpecification > emptyList())

credentialsStore ? .getCredentials(domain).each {
    if (it instanceof UsernamePasswordCredentialsImpl)
        showRow("user/password", it.id, it.username, it.password ? .getPlainText(), it.description)
    else if (it instanceof BasicSSHUserPrivateKey)
        showRow("ssh priv key", it.id, it.passphrase ? .getPlainText(), it.privateKeySource ? .getPrivateKey(), it.description)
    else if (it instanceof AWSCredentialsImpl)
        showRow("aws", it.id, it.accessKey, it.secretKey ? .getPlainText(), it.description)
    else if (it instanceof StringCredentials)
        showRow("secret text", it.id, it.secret ? .getPlainText(), '', it.description)
    else if (it instanceof FileCredentialsImpl)
        showRow("secret file", it.id, it.content ? .text, '', it.description)
    else
        showRow("something else", it.id, '', '', '')
}

return