on-internet

Resolve dynamic path in wireMock

Hi there I've relativley new to the Wiremock framework. I've got a test enviroment working but I need to for our integration testing need to resolve a dynamic path such as /test/dynamic/{dynamicpath}/help where dynamic path is going to be a variable that I want to resolve and then present different data from using a subset of a json file such as { dynamicpathA : "hello", dynamicpathB "world" } at the moment I have : stubFor(get(urlPathMatching("/test/dynamic/{dynamicpath}/help")) .withHeader("accept", equalTo("application/json")) .willReturn(aResponse().withBody(readFile(RESOURCES + "test.json

Join the discussion →

Scheme - Iterating Over Two Lists

Hi all I am new at learning Scheme and often have issues with making parallels between an imperative language and a functional language. For example if I had had two arrays. A = [1 2 3] B = [4 5 6] If I wanted to create a new array with the elements of A multiplied by each element in B I could simply do something like (pseudo-code): for(int i = 0; i < A.length; i++) for(int j = 0; j < B.length, j++) arr.push(A[i]*B[j]) Which would give back: arr = [4 5 6 8 10 12 12 15 18] What would be some ways to approach this problem in a functional language?

Join the discussion →

How to do isomorphic types in TypeScript

I have a file file.ts: let a: Message = "foo" let b: Message = "bar" let c: Message = "baz" Now I have a second file file2.ts type Message = string function fun(abc: Message): void { } Now function fun will allow me to pass stringto it, instead of Message, because it is only a type alias. Is there some way to isomorphic types, that is, a type that is just like another type, but there will be a strict check. So basically like Haskells newtype.

Join the discussion →

Exclude specific path from routing in Angular

My Angular route config is as below: export const routes: Routes = [ { path: 'mgmt', ... }, { path: 'about', ... }, { path: '**', component: PageNotFoundCmp } ]; But now on a page, there's a link to help pages, which are static resources hosted on the same server: <a href="/help/en/index.html" target="_blank"> With the above route config, apparently it will be matched to others ** - page not found. If we cannot host help resources in another domain, is there any way to exclude /help/** path from Angular routing?

Join the discussion →

exclude specific path from routing in angular 2+

My angular route config is as below: export const routes: Routes = [ { path: 'mgmt', ... }, { path: 'about', ... }, { path: '**', component: PageNotFoundCmp } ]; But now on a page, there's a link (<a href="/help/en/index.html" target="_blank">) to help pages, which are static resources hosted on the same server. With the above route config, apparently it will be matched to others ** - page not found. Let's say we cannot host help resources in another domain, is there any way to exclude /help/** path from angular routing? or do you think this is a valid feature request for angular to support?

Join the discussion →

C# post JSON data to REST API

I am new to REST API JSON but have been able to consume a few API with asp.net. Here is the problem I am currently facing. I have been able to send JSON data to an API using this method. public void PostData() { string sName = sysName.Text; string sDescrip = sysDescrip.Text; var httpclient = new HttpClient(); httpclient.BaseAddress = new Uri("http://33.248.292.99:8094/bizzdesk/sysconfig/api/"); var sys = new Bizsys(){name= sName, description= sDescrip}; httpclient.PostAsJsonAsync("system", sys); } it work just fine. Now I modify the code in order to accommodate more values thus: var httpclient

Join the discussion →

How to solve System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() Exception

I have a C# application who read in an SQL Server Database. Sometimes i get an error and the apps crash. If i look on the EventViewer, i got this : Application : XXXXXXXXX_CLI.EXE Version du Framework : v4.0.30319 Description : le processus a été arrêté en raison d'une exception non gérée. Informations sur l'exception : System.ComponentModel.Win32Exception Informations sur l'exception : System.Data.SqlClient.SqlException à System.Data.SqlClient.SqlConnection.OnError(System.Data.SqlClient.SqlException, Boolean, System.Action`1<System.Action>) à System.Data.SqlClient.TdsParser.ThrowExceptionAndW

Join the discussion →

Error: read ENOTCONN: Nodejs, error after running the project

Node project worked fine couple of months ago, now after implementation of sockets, when trying to run the app, i see the following error: Error in console(git bash) I'm using win 10, tried changing Node versions(4.7, 6.10, 7.2, 7.9), No result there. The port I'm using is not busy. We are using socket.io, tried to remove the part of code, that uses the module, but unexpectedly, it did not help. Any ideas ? Update: Works fine on OS X, and doesn't work on 3 different win 10 oter computers.

Join the discussion →

Run "rabbitmq-plugins enable rabbitmq_management" .. failed

Firstly, installed erlang rabbitmqserver Then, try to run command to enable plugin like the following: C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.6.9\sbin>rabbitmq-plugins enable rabbitmq_management Plugin configuration unchanged. Applying plugin configuration to rabbit@PVGN50886410A... failed. Could not contact node rabbit@PVGN50886410A. Changes will take effect at broker restart. Options: --online - fail if broker cannot be contacted. --offline - do not try to contact broker. C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.6.9\sbin>rabbitmq-plugins enable --offline rab

Join the discussion →

Don't see logs on the server side when using console.log

This is the first time in my life I touch js or node so please bear with me. I am trying to make my app output logs on the server side. getUser.onclick = function () { console.log('Server running at http://127.0.0.1:1337/'); var req = new XMLHttpRequest(); req.onreadystatechange = function () { if (req.readyState === 4 && req.status === 200) { var user = JSON.parse(req.responseText); results.innerText += user.firstName + ' ' + user.lastName + '\n'; } }; req.open("GET", "/user"); req.send(); Now according to this: Node js console.log is not showing anything this should work. However, this sheds

Join the discussion →

Travel from Dallas to Toronto

I'm a US citizen and I wish to travel from Dallas to Toronto to Boston. I assume that I'll need my passport for this trip – Is this correct? And how much time (roughly) will it take to go through immigration and customs in Toronto and Boston?

Join the discussion →

Where is Python's home directory?

I have Python 2.7 installed, Im looking at trying tensorflow and for windows it looks like it only works on python 3.5, I downloaded the python installer and it is apparently installed, but where? Python 2.7 has a Python27 directory in C:, but I cant locate 3.5 anywhere. I tried the installer again and it asked if I wanted to repair or remove. EDIT: Im really trying to find pip3, which I assume is in the python35/scripts directory

Join the discussion →

Jenkins : Host key verification failed while executing ssh

I am trying to create a build with basic configuration on the slave node. Only command the needs to be executed from Execute shell option is doing ssh to the slave. While executing the build the following error is observed: Building remotely on slave 1 in workspace /home/jenkins/workspace/slave job 1 [slave job 1] $ /bin/sh -xe /tmp/hudson4772532626468045261.sh + ssh [email protected] Pseudo-terminal will not be allocated because stdin is not a terminal. Host key verification failed. Build step 'Execute shell' marked build as failure In order to solve the issue of Pseduo-Termial, added th

Join the discussion →

rabbitmq when to use basic reject over basic nack?

Basic nack provides facility to return negative acknowledgement for one or multiple messages. Basic reject has facility to return negative acknowledgement for only one message. Do we have any use case where we definitely need basic reject?

Join the discussion →

Is appsettings.json protected by IIS?

In legacy ASP.NET applications, *.config files cannot be downloaded by navigating to the URL. But the new convention is to use appsettings.json. Now, if I have a ASP.NET Core website called contoso.com and it's served by IIS from a directory called C:\inetpub\websites\contoso.com, and there is a file located at C:\inetpub\websites\contoso.com\appsettings.json... Is IIS smart enough to know not to serve this file over HTTP if someone navigates to https://contoso.com/appsettings.json?

Join the discussion →

Opening Image file from url with PIL for text recognition with pytesseract

I am facing a confusing problem trying to download image and open it with BytesIO in order to extract text from it using PIL & pytesseract. >>> response = requests.get('http://abc/images/im.jpg') >>> img = Image.open(BytesIO(response.content)) >>> img <PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=217x16 at 0x7FDAD185CB38> >>> text = pytesseract.image_to_string(img) >>> text '' Here it gives an empty string. However if i save the image and then open it again with pytesseract, it gives the right result. >>> img.save('im1.jpg') >>> im = Image.open('im1.jpg') >>> pytesseract.image_to_stri

Join the discussion →

Template inheritance in Angular

I have the following child component and its inheritance parent component: @Component({ template: `<p>child</p>` }) export class EditChildComponent extends EditViewComponent{ constructor(){ super(); } } @Component({ template: `<p>parent</p>` }) export class EditViewComponent{ constructor(){ } } Now is there any way to place the template of the EditViewComponent in the ChildComponents template like you would do with ng-content in nested components? How would I get the following result: <p>parent</p> <p>child</p>

Join the discussion →

Does anyone know how can I convert JavaScript file to typescript file?

I have my JavaScript files in project. Now I want to convert my whole JavaScript code into typescript. So is there any tool or converter that converts my js code to ts. I got npm command from google to convert JavaScript to typescript $ npm install javaScript-to-typescript from the following link https://www.npmjs.com/package/javascript-to-typescript Can anyone help me how can I use above command??

Join the discussion →

Form Directive on submit is being ignored

I have an index.php which is my Main. It contains links to Login.php, Register.php and AboutUs.php. They are linked via hyperlinks so it works fine even though they not in the same folder as expected. Each 'called' page contains a form. Each calls a dal, to login or register or read about website. Therefore Login.php calls plogin.php which is a dal that resides in another folder for dals. The form action="common/dals/plogin.php" method="post". These paths are 100% correct. When I submit the form, the following error is generated: 404: Not found ......common/dals/index.php I do not understand t

Join the discussion →

ClosedXML Excel filter rows by values in multiple columns

I have a Excel file with several thousand rows and columns up to "BP". I need to filter all of these rows by specific values in columns C and BP. I tested the filter functionality in ClosedXML as per the code below. When I apply a filter to one column all works well and the data is saved in the new file. When I try to apply two filters, the last one executed is the one that is applied. I have tried to use the worksheet as a Range/Table, same filtering problem. I eventually created the "rows" expression, that works, but the 1st row (header) is filtered out. public static void Filter(string sour

Join the discussion →

'QML Connections: Cannot assign to non-existent Property' despite the opposite being true

So, I checked the following questions, which seemed most similar to my existing problem: QML: Using cpp signal in QML always results in "Cannot assign to non-existent property" Unfortunately that did not help. (Nor did any other solution that I could find on stackoverflow/google/qt forums, etc) I kept getting the following two errors: qrc:/view.qml:30:9: QML Connections: Cannot assign to non-existent property "onNewFrameReceived" qrc:/view.qml:31: ReferenceError: imageProvide is not defined Here is my code (edited down to make it, into a 'Minimum Working Example'). The only files important sho

Join the discussion →

What does --network=host option in Docker command really do?

I'm a little bit beginner to Docker. I couldn't find any clear description of what this option does in docker run command in deep and bit confused about it. Can we use it to access the applications running on docker containers without specifying a port? As an example if I run a webapp deployed via a docker image in port 8080 by using option -p 8080:8080 in docker run command, I know I will have to access it on 8080 port on Docker containers ip /theWebAppName. But I cannot really think of a way how --network=host option works.

Join the discussion →

Installing openpyxl in python 2.7

I am currently using Python 2.7 and I want to work on Excel sheets. So I found a package called openpyxl 2.4.0. I tried installing it by using pycharm and pip commands. The commands I tried are pip install openpyxl and pip install openpyxl==2.4.0 Also I tried installing using Pycharm. Both didn't work.* But it shows the following error: Could not find a version that satisfies the requirement openpyxl (from version s: ) No matching distribution found for openpyxl Should I go for another version of Python? *Copied from comment

Join the discussion →

REST API - Use the "Accept: application/json" HTTP Header

When I make a request, I get a response in XML, but what I need is JSON. In the doc it is stated in order to get a JSON in return: Use the Accept: application/json HTTP Header. Where do I find the HTTP Header to put Accept: application/json inside? My guess is it is not suppose to be inside the URL-request, which looks like: http://localhost:8080/otp/routers/default/plan?fromPlace=52.5895,13.2836&toPlace=52.5461,13.3588&date=2017/04/04&time=12:00:00

Join the discussion →

NoSuchSessionException when starting chromedriver

I am trying to create a simple test, just open the page and verify its title. I thought it could not be simpler, but... my test opens a new tab in a currently opened Chrome browser and fails on driver.get(myUrl); with the org.openqa.selenium.NoSuchSessionException I tried upgrading and downgrading chromedriver and upgrading downgrading selenium, but no luck so far. Currently I'm on selenium-java 3.3.1, chromedriver 2.28 and chrome 57.0.2987.98. Any help appreciated. Bonus question, last time I used chromedriver it opened a new browser window, any way to get back to that? I'd prefer my tests in

Join the discussion →

The supplied credential is invalid when using LdapConnection

I am attempting to connect to a LDAP server and do some searches. I am using LdapConnection and NetworkCredential objects to do this. Here is a sample of my code. When I attempt to do the Bind, I get an error that states "The supplied credential is invalid." I think my problem is I am not passing an expected value of Domain correctly. This is my first time programming using these objects, and I have struggled to find an example that works for me. Any help you can provide would be greatly appreciated! string myServerName = "111.22.333.444:389"; string myUserName = "MyLogin,ou=Systems,ou=LOCATIO

Join the discussion →

Driver not found connecting to oracle DB with jaydebeapi

Trying to connect to a db but getting error: conn = jaydebeapi.connect('oracle.jdbc.driver.OracleDriver', jdbc:oracle:thin:@mydomain.com:1234:GP1', [ 'user', 'pass'], 'C:\Program Files\Java\jdk1.8.0_121\ojdb6.jar') Gives the error File "C:\Anaconda2\Lib\site-packages\jpype\_jclass.py", line 55, in JClass raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name) java.lang.RuntimeExceptionPyRaisable: java.lang.RuntimeException: Class oracle.jdbc.driver.OracleDriver not found My JAVA_HOME variable is set to C:\Program Files\Java\jdk1.8.0_121, and in that directory I have the ojdb6.jar file, but

Join the discussion →

Employee Classes - Python

Write a class named Employee that holds the following data about an employee in attributes: name, ID number, department, and job title. Once you have written the class, write a program that creates three Employee objects to hold the following data: Susan Meyers - 47899 - Accounting - Vice President Mark Jones - 39119 - IT - Programmer Joy Rogers - 81774 - Manufacturing - Engineer ^ This is the problem I'm stuck on. I believe I have the first part of the code correct, but I don't understand what to do for the second part of the program to create Employee objects. Here is my code so far... emp.p

Join the discussion →

how to configure kotlin-logging logger

For logging purposes in my Kotlin project I am using kotlin-logging which is really nice to use however I am missing a very central point: How can I configure the log level of the logger? Per default it is set to info and I would like to set it to debug. As there is nothing about that on the Github page nor is there any method to set the level programmatically I had a look into slf4j as kotlin-logging is a wrapper around that. Apparently I have to set a System Property like this: -Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG However I have no idea how to do this in Kotlin. Anyone can help me

Join the discussion →

PHP / MySQL: Display all rows matching specific value in column

I have a database table which looks something like this: dev_id dev_name cat_id subcat_id 1 Apple iPhone 6 1 1 2 Apple iPhone 6s 1 1 3 Apple iPad Air 1 2 dev_id is the primary key, cat_id is different for each brand (Apple = 1, Samsung = 2 etc.) and subcat_id indicates if the device is either a phone (1) or a tablet (2). I want to echo all the devices of one brand which have subcat_id == 1 assigned to them in one list with the header Smartphones. All the rows where the column subcat_id == 2 need to go in a list below that one with the header Tablets. Both lists need to be sorted by the primary

Join the discussion →
Older stories