on-internet

How to unit test a component that depends on parameters from ActivatedRoute?

I am unit testing a component that is used to edit an object. The object has an unique id that is used in order to grab the specific object from an array of objects that are hosted in a service. The specific idis procured through a parameter that is passed via routing, specifically through the ActivatedRoute class. The constructor is as follows: constructor(private _router:Router, private _curRoute:ActivatedRoute, private _session:Session) {} ngOnInit() { this._curRoute.params.subscribe(params => { this.userId = params['id']; this.userObj = this._session.allUsers.filter(user => user.id.toStrin

Join the discussion →

Getopt::Long multiple arguments with optional parameter

I'm trying to solve this scenario with Getopt::Long. ./myscript -m /abc -m /bcd -t nfs -m /ecd -t nfs ... -m is mount point and -t is type of file system (can be placed, but it is not mandatory). Getopt::Long::Configure("bundling"); GetOptions('m:s@' => \$mount, 'mountpoint:s@' => \$mount, 't:s@' => \$fstype, 'fstype:s@' => \$fstype) This is not right. I'm not able pair proper mount and fstype: ./check_mount.pl -m /abc -m /bcd -t nfs -m /ecd -t nfs $VAR1 = [ '/abc', '/bcd', '/ecd' ]; $VAR1 = [ 'nfs', 'nfs' ]; I need to fill unspecified fstype, e.g., with "undef" value. The best solution for me

Join the discussion →

Python PIL image open and save changes image file size?

I used PIL to open and save the same jpg image, but the size reduces significantly. Could somebody explained what's going on under the hood? I run a = Image.open('a.jpg') a.save('b.jpg') a.jpg has the size 5MB, whereas b.jpg is only 600KB. and I enlarge them and compared side by side and basically see no differences in the picture quality. Could somebody explain this? Much appreciated!

Join the discussion →

Changing the background color of an ASP DropDownList using only CSS

I'd like to be able to change the dropdownlist background colors on my C# web app, can I do this with CSS instead of having to name each dropdown separately? In other words, I want to avoid having to do this: private void Form_Load(object sender, EventArgs e) { comboBox1.BackColor = Color.Aqua; comboBox2.BackColor = Color.Aqua; comboBox3.BackColor = Color.Aqua; etc . . . }

Join the discussion →

Touch controls using pointer lock controls in three.js

I tried using Pointer lock controls for normal First Person keyboard setup, now i wanted to know if i can include touch settings in pointer lock controls file for moving forward on touch and to look around using swipe. Is it possible to do this using pointer lock controls ?

Join the discussion →

How to implement Role Permission based system in Spring Boot

I am trying to implement role permissions based system using spring boot and spring security. For this, I have taken an example from http://www.baeldung.com/role-and-privilege-for-spring-security-registration , but failed to do that. Efforts SpringSecurity Configuration package com.insight; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.authentication.dao.DaoAuthenticationProvider; import org.springframework.security.config.annotat

Join the discussion →

Moving text with CSS

I'm trying to move a line of text back and forth inside a colored background box. I can do this beautifully with the marquee tag, but as I heard its usage is not recommended so I decided to use CSS instead. Although I copied the form of the animation function from CSS tutorials but I can't figure out why the line doesn't move. Could you show me what's wrong with my code? My HTML code: <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html" charset="UTF-8"> <title>Part 1</title> <link rel="stylesheet" content="text/css" href="part1-2.css"> </head> <body> <div class="ba

Join the discussion →

VLC - How to play a MJPEG Stream

I have a server broadcasting the video generated by a USB webcam using GStream with the following gst-launch command: gst-launch-1.0 v4l2src ! video/x-raw,width=352,height=288 ! jpegenc! rtpjpegpay ! udpsink host=239.255.12.52 port=5004 Now i need a client to play that broadcast with VLC. I tried playing the following: rtsp://239.255.12.52:5004 But I only get the following error: SDP required: A description in SDP format is required to receive the RTP stream. Note that rtp:// URIs cannot work with dynamic RTP payload format (96). Then i searched trying to find a sdp file that could help me pla

Join the discussion →

Counting the number of elements

I need to count the number of elements which in this case the number of products held by each customer. My attempt for solving this is by counting the number of "li" tag, then accessing "ticket-type". Any suggestion on how this can be achieved?: List<WebElement> labels = driver.findElements(By.xpath("//label[@class='ticket-type']")); int ProdNum = labels.size(); String strI1 = Integer.toString(ProdNum); System.out.print("Number of products on this card:" + strI1); // getting the name of the last product String LastProd = labels.get(labels.size() - 1).getText(); System.out.print("The last order

Join the discussion →

Pointer as a parameter in C

Let's say a have a pointer as a parameter, why doesn't it's value remain modified after the and of a function, and i have to use this syntax: void function_name (int **p) { // code } and in main(): int *v; function_name (&v); I want to specify that i use a pointer to a struct type as a parameter.

Join the discussion →

Call child method from parent

I have two components: Parent component Child component I was trying to call Child's method from Parent, I tried this way but couldn't get a result: class Parent extends Component { render() { return ( <Child> <button onClick={Child.getAlert()}>Click</button> </Child> ); } } class Child extends Component { getAlert() { alert('clicked'); } render() { return ( <h1 ref="hello">Hello</h1> ); } } Is there a way to call Child's method from Parent? Note: Child and Parent components are in two different files.

Join the discussion →

Passing data to handlebars - node.js

I am new to node.js , so basically I am making a get request in my router(index.js) and then after I get the result (I could see that I obtained the right result by dumping it in console.log) I am parsing it into a json object and passing it to a render function so that I could use it there, however, I am getting errors. I will post the code segments and the JSON fragment below . Is this the right way to use handlebars? Router (index.js) router.get('/getusers', function(req, res) { wrapRequestAsCallback(req.cookies.TOKEN_CACHE_KEY, { onSuccess: function(token) { var all_users = {}; // get all

Join the discussion →

Auto-increment ID with Prefix

I want to achieve an auto increment ID with prefix but resetting the number if it has different prefix. The output I want looks like this: ID PREFIX PROJECTID 1 PID_ PID_1 2 PID_ PID_2 3 RID_ RID_1 4 RID_ RID_2 But the result I got with my script is this: ID PREFIX PROJECTID 1 PID_ PID_1 2 PID_ PID_2 3 RID_ RID_3 4 RID_ RID_4 Here's my script to create the table CREATE TABLE PROJECTS (ID INT IDENTITY(1,1) NOT NULL, PREFIX NVARCHAR(10) NOT NULL, PROJECTID AS ISNULL(PREFIX + CAST(ID AS NVARCHAR(10)), '') PERSISTED) INSERT INTO PROJECTS(PREFIX) VALUES('PID_'),('PID_'),('RID_'),('RID_') I'm using

Join the discussion →

MySQL query to find Products that were sold on both the days [closed]

I have to write a MySQL query: Find products that were sold on both the days (01-JUL-11 and 02-JUL-11) and number of total product sold. The table looks like: Date, Order_id, Product_id, Quantity '01-JUL-11',O1,P1,5 '01-JUL-11',O2,P2,2 '01-JUL-11',O3,P3,10 '01-JUL-11',O4,P1,10 '02-JUL-11',O5,P3,5 '02-JUL-11',O6,P4,6 '02-JUL-11',O7,P1,2 '02-JUL-11',O8,P5,1 '02-JUL-11',O9,P6,2 '02-JUL-11',O10,P2,4 Output: P1 17 P2 6 P3 15 So far I have tried is: SELECT PRODUCT_ID, TOTAL FROM (SELECT PRODUCT_ID, COUNT(PRODUCT_ID) AS COUNTER, SUM(TOTAL) TOTAL FROM (Select ORDER_DAY, PRODUCT_ID, SUM(QUANTITY) AS TO

Join the discussion →

Calling a JavaScript function on Contact Form 7 submission

I'm using Contact Form 7 in Wordpress, with Skin Beauty as the theme. What I want to do is to call a specific JavaScript function when the form I created is submited. In my HTML code I am creating a form like this: <form onsubmit="checkvalue()"> ... </form> And at the end of the body of my HTML code, I am creating a JavaScript function with the validation I want to do on the form: <script language="JavaScript" type="text/javascript"> function checkvalue() { ... } </script> I tried the code in another theme (Twenty Thirteen) - with Contact Form 7 - and the weird thing is that there was no probl

Join the discussion →

Printing a datagridview

I am trying to print a datagridview which will get values from the database, I was able to do that but I don't know why the columns name are not showing up after I print it. Below is the code that I am currently using: This one is for the printdocument: Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage With DataGridView3 Dim fmt As StringFormat = New StringFormat(StringFormatFlags.LineLimit) Dim text As String = ("TrashCollection - Estatísticas") fmt.LineAlignment = StringAlignment.Center fmt.Trimming = StringTrimming.Elli

Join the discussion →

Bad version of java when running maven exec plugin

My current version of java is 7: java -version java version "1.7.0_80" Java(TM) SE Runtime Environment (build 1.7.0_80-b15) Java HotSpot(TM) Server VM (build 24.80-b11, mixed mode) and I have command mvn8 where is set java_home to 8: mvn8 -version Java HotSpot(TM) Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0 Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100) Maven home: /home/.../apache-maven-3.0.3 Java version: 1.8.0_66, vendor: Oracle Corporation Java home: /home/.../jdk1.8.0_66/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", vers

Join the discussion →

kotlin logging with lambda parameters

In log4j2 we have a handy feature which is described as // Java-8 style optimization: no need to explicitly check the log level: // the lambda expression is not evaluated if the TRACE level is not enabled logger.trace("Some long-running operation returned {}", () -> expensiveOperation()); my attempt to use this in kotlin log.debug("random {}", { UUID.randomUUID() }) which will print random Function0<java.util.UUID> How do we use lambda argument logging with kotlin? Or how do we explicitly tell kotlin what method to call?

Join the discussion →

How to convert JsonNode to Map

using play framework java on the server i'm using graphiql to make requests, when i do final JsonNode variables = request().body().asJson().get("variables"), a JsonNode with a value "{\"id\":\"bar\"}" , now i want to convert this JsonNode to a Map, i tried Json.mapper().convertValue(variables, new TypeReference<HashMap<String, Object>>() { }); but i keep getting this exception Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [map type; class java.util.HashMap, [simple type, class java.lang.String] -> [simple type, class java.lang.Object]] from S

Join the discussion →

CodeIgniter login session

I'm new in CodeIgniter and I tried to create a login system on my website. When I try to enter on page Overview, it sends me on login page but after I put my correct email and password nothing happens. Login.php - controller <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Login extends CI_Controller { function __construct() { parent::__construct(); } function index() { $this->load->helper(array('form')); $this->load->view('login'); } } ?> Overview.php - controller <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Overview extends

Join the discussion →

CloudFront redirect all requests with path prefix

I have a static web site which makes requests to an API server. I'm hosting this static pages with S3 and I'd like to use CloudFront to redirect the api calls to the api server. Api calls can be distinguished by a path prefix of api: domain.com/index.html s3/index.html domain.com/js/index.js s3/js/index.html domain.com/api/request api_server/api/request domain.com/api/other/request api_server/api/other/request I currently have two origins set up - one S3 origin for my S3 bucket (which is working) and another custom origin for my api server (which is not working). The custom origin settings are

Join the discussion →

Cannot connect to RabbitMQ server

I'm trying to run the sample code, provided by the official page: https://www.rabbitmq.com/tutorials/tutorial-one-dotnet.html I'm using this code: using RabbitMQ.Client; using RabbitMQ.Client.Events; using System; class Send { public static void Main() { var factory = new ConnectionFactory() { HostName = "[email protected]" }; var connection = factory.CreateConnection() //this throwing exception var channel = connection.CreateModel() } } The problem is, that I get these exceptions always: 'RabbitMQ.Client.Exceptions.ConnectFailureException' in RabbitMQ.Client.dll 'RabbitMQ.Client.Excepti

Join the discussion →

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (default) on project mavenproject2:

I am beginning the initial attempt to use Vert.x in Java. IDE is Netbeans version 8.1. Vert.x is version 3.0.0. The code for this project is shown below. The pom.xml file is also listed below. This code will run in Netbeans IDE but the Build (for jar file) will not complete without the error shown in the BUILD REPORT below. Thus, the generated jar file will not execute. I have researched every resource I could locate on the internet and cannot find an adequate solution/answer. I would appreciate any help anybody can offer to resolve this problem. The POM file is generated by Netbeans IDE when

Join the discussion →

Excel: Plotting multiple series in a scatter plot

I have several different students and I'd like to plot their test scores changing over time. There are multiple students but only a few tests each. Name Date Score Afaf 10/1/2014 2 Afaf 4/15/2015 3 Ahmed 10/8/2015 1 Ahmed 2/16/2016 1 Ahmed 3/5/2016 1 Arie 11/3/2015 -1 Arie 3/23/2016 1 So far I've found that the scatter graph gives me what I want: However, I have to manually select each individual student when I'm adding new series to the graph. I can't get Excel to recognize the 'Name' column as categorical (i.e. each name is its own series): This is really slow because there's over a hundred

Join the discussion →

datatype of marriage status? (java)

May I know what datatype to use for Marriage Status? as far as I know Marriage status is either married or not married, is it possible to use boolean in this case? true/false else what am I supposed to use? Thanks!! boolean marriageStatus; if(marriageStatus = true) { // }

Join the discussion →
Older stories