JSON get and show on html page

Question: i'm making a web app, and i need to get data from JSON files and print them in form of a table.
Problem is that i'm getting a 404 error, JSON file (actually i work on local and doing a Node.js).
Edit 1:
while looking to network tab i get to see the 404 error. the JSON File is in text/file.json and the index.ejs is in views/index.ejs . So my question is that i can't get any data when trying to get the JSON file (doesn't find it).
the app is on a local server made with node.js and express.
the tree of my files

text/allfiles.json
public/
routes/index.js
views/index.ejs
app.js

Here are my files :
index.ejs
<!DOCTYPE html>

.
.
.

      Topic
      Page

my json file
  [{"topic": "INTRODUCTION", "page": 8}, {"topic": "THE UNIVERSE", "page": 10}]

thanks.
Comment: Did you try pressing f12 in a browser and looking at the network tab?
Comment: Where is your index file in relation to your json file?
Comment: What is the question?
Comment: Are you serving the json file through node.js as well? There's a good possibility that this is a server side error, so we'll need details on your server setup (which you seem to indicate is the local machine running node.js, which is fine, but without the server-side code we're only seeing half the equation.
Comment: @ChristopherPeart while looking to network tab i get to see the 404 error.
the JSON File is in text/file.json
and the index.ejs is in views/index.ejs .
So my question is that i can't get any data when trying to get the JSON file (doesn't find it).
Comment: @ashbygeek for now it's a local server made with node.js, which server code do you want to see exactly ? routes ? thanks.
Comment: yes, definitely post any `app.get(...)` routes and if you're using express, then any `app.use(...)` statements. Also, if you could describe the pertinent bits of your file tree that would be good. And please edit your original post with the new details rather than putting them in a comment, these details will be pertinent to anyone else who might try to give an answer.
Comment: do i need to create a app.get (...) in order to return the JSON file so i can use it ? or can i load it directly with JQuery ?
Comment: your node.js app must serve it some way or another. More details in my answer that I will post shortly.
Comment: Also, for future reference, if you had posted the contents of your app.js file at the beginning we would have gotten to the answer a lot sooner. Every webpage has two sides, the client side (the html and javascript running in your browser), and the server side (in this case nodejs and your app.js script)
Answer: Try adding a base to your head tag:
<base href="http://localhost/" target="_blank">

If you still faced 404 post the request header here.
Answer: I would check if you can view/download the json file by putting its url directly into the browsers url window.
If that doesn't work (404 strongly suggests this), your express app is not serving the json file and you have to either add static file providing or add a route for the json file.
Also: is your app hosted at the root of the webserver? Because a url starting with / adresses files at the root of the webserver.
Answer: It looks like the problem is that you aren't actually serving the json file. When your code calls $.getJSON("/text/global_summary.json"...); the browser doesn't magically know where to get the file, it asks your server to send it that file. Your server doesn't know either, so it just says 'error 404', which means 'I don't know'.
So you must tell your server how to serve that static file. Since you are using express, this is really easy. Just add
app.use('/text', express.static('text'))

to your app.js file and any time your server gets a request for any '/text/somefile.extension' it will try to find it in your text folder. There's a really good rundown of how to serve files this way here: https://expressjs.com/en/starter/static-files.html.

JSON get and show on html page


How to solve gtk-warning on using gedit?

Question: I'm new in using ubuntu. I got the following error for several lines after changed 'grub' in /etc/default
(gedit:2996): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: Failed to create file '/root/.local/share/recently-used.xbel.NXBRZV': No such file or directory
During installation, I created 2 disk partition for ubuntu. One is swapspace. Another is for '/'.
Is this a big issue? How to solve? Thx in advance
Answer: Right. You're running gedit as root, and root has its home in /root. But since root isn't a normal user, it doesn't have the normal directories like /home/user/.local/share/. In your case, it means that it can't store the list of recently edited files for gedit.
It is of absolutely no importance. But if you want that warning to go away, you can type "sudo mkdir /root/.local/share/". That will also let you open files that root has recently edited in gedit. But everything is fine :)


Smartsheet - get data from Teradata or/and Power BI

Question: I know it is reversed logic to get data from Power BI into smarthseet but is it possible?
Also, can I get connection from Teradata to smartsheet?
Answer: As long as the systems that you're interested in getting data from have APIs that enable you to retrieve the data you need, the scenario you've describe would be possible. For example, you could use the Power BI API to retrieve data from Power BI and then use the Smartsheet API to add that data to Smartsheet.


Issue with Singleton

Question: I am new to Android development. We are currently trying to port our existing framework on to Android. We have a core library (existing one) which exposes a singleton instance which provides us a set of flags based on which certain operations are performed. Now when i perform certain operations and flags of the single instance are modified. When i exit the application and restart it, my expectation was that these flags should have been reset to the default values, but it fails.. :-(. Ive read in several posts that the reference would still be active until the application is killed by the OS. Can someone suggest me how to overcome this issue. Any work around?
Answer: I suspect you aren't actually exiting the application. In Android, simply navigating away from the Activity doesn't close an application. In fact, you shouldn't really close applications in Android, as the VM manages that task rather efficiently. If you need to reset a default set of parameters for an application, you could do so in the Activity's onResume() method.
Answer: A quick workaround is to call System.exit(1) in onDestroy which kills the whole application.
But its not a good practice.

Issue with Singleton


Connection for C wire on Mastertrol Mark V zone control panel

Question: I have spent hours searching the web for information on this 20+ year old zone control panel, which supports 3 zones of Heat and A/C.
The thermostat I'm replacing (on Zone 3) connects to T4/T5/T6 as W, R, Y respectively (the wire colors do not match because it's sharing a cable with Zone 2, which go the matching colors).   I need a C (Common) wire to supply power to the thermostat, and found 24VAC across M2 and T5  (M1/M2 are the power leads to the zone damper, and seem to be connected internally to "1" and "2", the 24VAC supply.
However, when I connect the C terminal on the thermostat to the M2 connection, there is a click from some of the zone relays and the transformer hums as if it's overloaded.  I removed power after a few seconds and disconnected the wire (now hanging off to the right of the picture).
I've disconnected the wire from the C terminal at the thermostat, and measure 24VAC across it and the Rh terminal on the 'stat, so I don't believe the issue is in the wiring.
The thermostat is a Filtrete 3M50; I've read that it draws less than .1 Amp, so I don't think this should be enough to put the system over some maximum current draw.
I'm looking for ideas on how to troubleshoot this.
Comment: Do you have the wiring diagrams for the HVAC system, and the control panel? Don't forget, sometimes you can't use the latest and greatest technology with a 20+ year old system. This [answer](http://diy.stackexchange.com/a/10527/33) might be helpful.
Comment: No, it appears to date from the 80s, and I can't find anything that quite matches.
Comment: Every document I find on Honeywell MABS controllers, shows `M1` as `C`.
Answer: It appears according to the manual for the Mastertrol Automatic Balancing System (MABS) EZ Zone (EZ-2 and EZ-4) Control Panels (PDF), that M1 is used for C.

Click for larger view
This does not appear to be the manual for your device, so this information may not be correct.
The manual for the MABS 2 Zone Panel (PDF), also shows M1 being used for C.

UPDATE:
After further review, you should be able to connect the C wire directly to the transformer terminals. Measure for Voltage between the T5 terminal of the zone you're working in, and the 1 and 2 terminals in the 24V 40VA Transformer section. One should measure 24 Volts, while the other measures 0 Volts. The one that gives you 24 Volts, should be able to be used as C.
Comment: @Tester- I've seen other comments pointing to M1, and one other person with the Mark V that couldn't get it to work on M1. Like them, I get 0V across T5 (thermostat's R) and M1, and 24V from T5 to M2.  Perhaps there was a change made after the Mark V to the newer panels like you show.  +1 for finding and including the diagrams.  If a Mark V diagram doesn't surface, I may have to go with an external power supply.
Comment: @TomG After working on [this question](http://diy.stackexchange.com/q/49913/33) a possible solution to your problem has finally struck me. Please see the Update section of my answer, which hopefully helps.
Comment: @TomG I think you're right. I tried to contact Honeywell with no success, but looking at the wiring of others it appears `M2` is more likely to be used as `C` on the Mark V.
Answer: I have just successfully installed a Honeywell RTH6500WF Wi-Fi Series thermostat on Zone 1 of my Mastertrol Mark V zone control system.  I used a separate 120VAC to 24VAC transformer (AUX) with one lead of the AUX 24VAC hooked to Zone 1 terminal T5 of the Mark V panel (R terminal on the thermostat) and the second lead of the AUX 24VAC hooked to the wire (4th thermostat wire) that goes to C on the thermostat.  A separate 24VAC transformer is required for each zone thermostat that needs a C connection.
Answer: I used the spare Green and Orange wire from my 3 wire system.  On the Master Control unit I connected Green to 2 and Orange to 1.
I then connected Green to C and Orange to RC.  I removed the jumper.
So far so good!
Answer: I have a Mastertrol Mark V and successfully attached 2 Nest thermostats (2 zones).  In my system the T terminals correspond to current color coded wires as such:
T6 = Y (cool)
T5 = W (heat)
T4 = R (24v power)
The nest works when only attached to RWY, but the Nest kept buzzing its zone relay when using only 3 wires (RWY).  It also complained about power availability.  Amp meter only showed ~60ma.  I believe the buzzing was the Nest intermittently sipping power from the R line.  I could get the relay to buzz by manipulating the settings on the Nest and the relay would buzz with each manipulation (even just checking it on the phone).
Connecting a C line to terminal 2 was partially successful, in that it did provide power but also created an alarming continuous clicking in the zone relay.  Note, removing the W wire (in heat mode) from T5 eliminated the relay noise, but that makes the system useless. I suspect the clicking was due to the power for the T terminals being supplied by a different transformer than the transformer on connections 1 and 2 (24V 40VA Transformer).  It's AC power, and AC cares about phase synchronization.  The two transformers will not be in sync.
Anyway, the solution was to detach the R wire for the Nest, in my case that was from T4, and attach the R wire from the Nest to terminal 2 (24V 40VA Transformer) and connect the C wire to terminal 1 (24V 40V Transformer).  This means T4 has no wire attached to it.  Note, I learned from HVAC research, and as mentioned by a previous post here, that the C wire is meant as the return path for power from R.  So on my setup this leaves us with:
T6 = Y (cool)
T5 = W (heat)
T4 = empty
2  = R (power)
1  = C (return)
Note, it's AC, so it really doesn't matter if you attach R to 1 or 2 and the same for C, but the convention seems to be that R should be on whatever the hot leg is.
Now, Reboot the Nest!  If you end up updating the wiring info in the Nest, be sure to reboot it again just for good measure.
Everything should work and the Nest should have no complaints on the screen.  Because the Nest is attached to the 24V 40VA transformer terminals, it will receive power even when the master mode selector switch next to the Mastertrol is set to OFF.  In the 3 wire setup, setting the mode selector to Off removed power from the Nest, which is not what you want.
I hope this helps someone.
The following are photos of my unit as well as the wiring I put in place to supply 24V to my nest thermostats.
Answer: I have a MasterTrol Mark V Trol-A-Temp zone controller and successfully installed Nest Gen 3 thermostats.  After much difficulty getting it to work I discovered the following issues.

The R wire on a conventional A/C system is directly connected to the 24v transformer.  On the MasterTrol this is NOT the case, it is connected to the relay.  As a result it is NOT possible to use the C wire to provide supplementary power to the Nest thermostat and still support both A/C and Heat.  The C wire will just cause the MasterTrol relay to chatter.
The MasterTrol has small relays for each zone that only require 60ma of current to operate. This is a marginal level of current for the Nest power stealing circuitry to stay fully charged.

Solution:
Do not use a C wire from the MasterTrol. The only connections to the nest are:

Y1 - A/C
W1 - Heat
RH - Relay

Add a bypass resistor in parallel with each zone relay to raise the current needed to energize the relay.  This allows the Nest to steal sufficient power from the MasterTrol to operate normally.
This can be accomplished by adding three 220 ohm 5 watt resistors between each of the three "T5" connections and the "1" (transformer) connection.
Hope this helps someone…
Answer: Go to the transformer and see what wire is common, it will be opposite of RED going to the thermostat on R or Red. Common is the side of 24 v power that every 24 v circuit terminates upon to complete its path.  You will read 24 volts across every wire with Red , only with a call for heat will white not read 24 volts to red from white  as the switch  between red and white will be closed in the stat.  open switch will read 2 sides of power  closed switches read only 1 leg of power.


Does SAM Lambda auto-versioning using AutoPublishAlias work when code URL changes but the code that it points to doesn't?

Question: Simple question:
Does SAM Lambda auto-versioning using AutoPublishAlias work for AWS::Serverless::Function when code CodeUri changes but the actual code that it points to doesn't?
Background
We are deploying several Lambda@Edge functions using the SAM AWS::Serverless::Function resource type.
Our deployment runs via dropping code into an S3 bucket and then triggering a CloudFormation stack update. Our stack contains other things in addition to these Lambdas.
With this, we often have deployments that occur where the lambda code doesn't change.
Every deployment, however, the code URI changes to our newest deployment's bucket which, as intended, triggers a new version attempted to be published which is inline with note in SAM documentation (pasted below for context)

NOTE: AutoPublishAlias will publish a new version only when the CodeUri changes. Updates to other configuration (ex: MemorySize, Timeout) etc will not publish a new version. Hence your Alias will continue to point to old version that uses the old configurations.

The reason I am asking is because we've had some transient CloudFormation deployment issues that I've been trying to root cause that may be related to this. The error we get on the SAM generated version in the CloudFormation stack update is as follows:

A version for this Lambda function exists ( {some number} ). Modify the function to create a new version.

I've taken a look at the SAM code where the version is created and most of their documentation but couldn't find a clear answer.
We could likely manually create the AWS::Lambda::Function and AWS::Lambda::Version with a different logical ID on the version each time which should(?) fix the issue but we were trying to utilize SAM for auto-versioning of our Lambdas.
Any help is appreciated!
Answer: Yes, SAM will create a new version when CodeUri changes, however, Lambda will not allow you to create a new version if there have been no changes.
Comment: Thanks!

Ended up doing the following:
1) Using `AWS::Lambda::Function` and `AWS::Lambda::Version`
2) Adding `__REPLACE_WITH_LAMBDA_SHA__` to the name of the  `AWS::Lambda::Version`
3) Added some custom Rake build logic to generate a SHA-256 of the Lambda code using `Digest::SHA256.file` and then go and replace `__REPLACE_WITH_LAMBDA_SHA__` with that SHA
Answer: To workaround on that, I have a hack which is to create a NOUNCE environment variable with a random value that changes for every deploy. So CloudFormation believes that's a change on the code and deploy a new version of that Lambda and we have no more that version error.


Inverse Fourier Transform and Convolution Theorem

Question: I am trying to understand the following question on Inverse Fourier Transform and use of convolution theorem. I am unable to understand the step boxed in red. Will be grateful if some guidance is provided to understand it
Answer: It is actually straight forward (if this is your only problem):
$H(x)$ is the Heaviside step function, which is
$$
H:x\mapsto \begin{cases}0:&x<0\\1:&x\geq 0\end{cases}
$$
and sometimes different values for $H(0)$, but this is surely defined in your book. Anyhow, now just look at the first case where $x>0$ and hence $H(\tau-x)=0$ until $\tau\geq x$, then we have $\tau>\tau-x\geq 0$ (if $\tau-x>0\implies \tau>0$) and therefore
$$
H(\tau-x)H(\tau)=H(\tau-x)
$$
In the second case where $x<0$ you the exact same reasoning, but this time
$\tau<\tau-x$ and hence the argument switches (if $\tau>0\implies \tau-x>0$) and you get
$$
H(\tau-x)H(\tau)=H(\tau)
$$
Comment: Thank you, it is indeed very simple when explained...but I could not get it until then
Comment: Sure thing, just watch out for the exact definition of your Heaviside function.
Comment: @SAK PS if your question has sufficiently well been answered you could mark it as "answered", this let's other people see that you don't need any further assistance (and also gives the answerer some reputation points)
Comment: Noted. I was not aware of this..will certainly do it for this and in future.. but I am unable  mark it "answered". How do I do that?
Comment: On the left side of any answer you can find a checkmark and up/down arrows. You can upvote or downvote with the arrows, if you click on the checkmark it will become green and accepted
Comment: Thanks...done ...and will do so in future too!


Are wireless mice still a no-no for gaming?

Question: I remember when I tried a wireless mouse years back and it was horrible. It did not feel responsive enough in games. Should I consider buying a wireless mouse if it otherwise seems good?
Comment: I think you'll find that this is a subjective question. Many people swear even now that the latency or accuracy of a wireless mouse makes them insufficient for gaming. Others claim that they have absolutely no issues. In addition, a large factor of this would involve the quality of the hardware product. At that point, we're diving into providing shopping recommendations, which are also subjective.
Comment: Mmmm, [Nachos](http://xkcd.com/654/)
Comment: Not to mention the type of game.  I wouldn't use a wireless mouse for an FPS, but I have no problems playing slowly-paced games with them.
Comment: It depends on if it operates in the gigahertz range instead megahertz. And laser or optical. And hundreds of dollars instead of tens. All the former of which is what you want if you can afford it.
Answer: I've had no issues with lag/responsiveness, but this is very hit or miss depending on the user (the same reason why some people use gaming CRTs).
The only downside I've had is that the batteries make the mouse a little heavier, which causes faster fatigue for long periods of gaming.
Also, you run the risk of batteries dying on you in the middle of a frag fest.
Answer: Wireless mice can be fine for gaming if you spend enough. I purchased a Wireless Logitech G7 5 years ago and used it for competitive gaming with no problems. I never had interference, never lost connection (as far as I can remember) and its response was great. But I also paid for that. I think at the time I spent between 60 and 70 dollars on it.
Something you may want to ask yourself is: do I play games so competitively that it's not worth the risk of interference or loss of responsiveness? If you're competing or just fear the thought of that happening, then I'd get a wired mouse. Otherwise, spend a little more, do some research and you'll be fine.
Hope that helps.
Comment: You do indeed get what you pay for. And $200 gets you a Logitech V550 Nano Cordless Laser Mouse, [Review on Gigaom.com](https://gigaom.com/2008/10/14/logitech-v550-nano-cordless-laser-mouse/), that lasts 18 months on 2AA, on which the "tracking is excellent. All presumably thanks to the 2.4 GHz RF wireless technology which Logitech says provides an exceptionally robust signal that exchanges data 300 times faster than conventional 27 MHz wireless."
Comment: See also, [Why did trackballs disappear?](https://retrocomputing.stackexchange.com/questions/8787/why-did-trackballs-disappear) on Retrocomputing.SE for an extended discussion about a "freewheeling-track-nub" mouse (the Nano, in my answer and its comments)


Different C++ include statements throws errors in the Objective-C header

Question: I'm trying to use OpenCV in Objective-C++ code which I will call from Swift. First I used this answer for connecting Objective-C and Swift. So after these manipulations I get three files:
Bridging-Header.h:
#import "opencvtest.h"

opencvtest.h:
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#include <opencv2/core/core.hpp>
//#include <dlib/image_loader/load_image.h>

@interface CustomObject : NSObject

- (cv::Mat)cvMatFromUIImage:(UIImage *)image;

@end

opencvtest.mm:
#import "opencvtest.h"

Error:
/Users/user/Documents/XcodeProjects/Swift_HelloWorld/Swift_HelloWorld/Swift_HelloWorld-Bridging-Header.h:5:9: note: in file included from /Users/user/Documents/XcodeProjects/Swift_HelloWorld/Swift_HelloWorld/Swift_HelloWorld-Bridging-Header.h:5:
#import "opencvtest.h"
        ^ /Users/user/Documents/XcodeProjects/Swift_HelloWorld/Swift_HelloWorld/opencvtest.h:23:4: error: expected a type
- (cv::Mat)cvMatFromUIImage:(UIImage *)image;    ^ <unknown>:0: error: failed to import bridging header '/Users/user/Documents/XcodeProjects/Swift_HelloWorld/Swift_HelloWorld/Swift_HelloWorld-Bridging-Header.h'

Also, if I add line #include <dlib/image_loader/load_image.h> in the opencvtest.h then I get:
/usr/local/include/DLIB/string/string.h:7:10: error: 'sstream' file not found
#include <sstream>
         ^
<unknown>:0: error: failed to import bridging header '/Users/user/Documents/XcodeProjects/Swift_HelloWorld/Swift_HelloWorld/Swift_HelloWorld-Bridging-Header.h'

I want to note that all these errors occurs only when I put these include statements in this header, when I used it in .mm file all works fine. But I need them in the header for declarations.
So, how can I fix it?
Answer: The interface of your Objective-C objects usable in Swift and thus visible in the bridging header cannot reference any C++ types.  You need to write an Objective-C++ wrapper in such a way that C++ types are only mentioned in your .mm files and in headers used in the .mm files.  You can hide the parts of the interface that use C++ by using extensions in Objective-C++ code.  Please see the following question and questions referenced there for examples of how to do that:
objective C opencv wrapper for swift project does not see STL headers
Comment: Hm... I didn't think about that. Absolutely clear, thanks! :)


What are the different types of shrines and their effects in Diablo 3?

Question: So far I've noticed a shrine that offers a speed increase, gold find and magic find increase, and damage reduction. What are the other types and their effects?
Answer: From my personal experience, there are four types of shrines that I can confirm:

Shrine of Enlightenment - +25% Experience.
Shrine of Fortune - +25% Magic and Gold Find.
Shrine of Protection - Reduces damage taken by 25%.
Shrine of Frenzy (Not sure if that is the real name) - Increases attack speed by 25%.
Comment: I just tested with a frenzy shrine and it did not increase my crit damage
Comment: That was patched out a couple of patches ago (this answer is from just two days after release). I'll edit it in :)


Matching wildcard/dictation in Microsoft Speech Grammar

Question: I'm using Microsoft Speech API to load a grxml grammar:
Grammar grammar = new Grammar(file);
grammar.Enabled = true;

SpeechRecognitionEngine sre = GetEngine();
sre.LoadGrammarAsync(grammar);

Based on MSDN I can not find tag to match a wildcard / spoken text like:
<item>My message is {dictation}</item>

It seems to be availalble with code with a DictationGrammar and appendDictation(). It's also available with WSRMacro XML using * but I do not how to do it in XML ?
The  skip text but I need to recognize it.
Am I missing something ?
Answer: For my project SARAH

I load all XML grammar
Then I create a dictation grammar
Some user's action enable/disable the dictation mode

I know there should be a better way to do it since WSRMacro use '*' but I don"t know how to do it.
Might be a clue
Answer: If you're using the Kinect speech engine, you cannot use dictation at all; the engine simply doesn't support it.
For more details, you can look at my answer to this question.
Comment: But in the C# API there is a DictationGrammar and WildcardGrammar. I could archive my goal if I "harcode" it. In fact I activate a Dictation grammar for som special case (even if it is bad I agree)
Comment: The C# API works with both the desktop engine *and* the server engine.  The desktop engine supports DictationGrammar and WildcardGrammar; the server engine does not.
Comment: Kinect uses Microsoft.Speech, not System.Speech as it seems, although you could probably grab the audio from Kinect and use it with System.Speech somehow (but I think you need training of the recognition engine if you go with System.Speech)
Comment: Btw, it seems Microsoft united their previously separate installers for their Server (accessed via Microsoft.Speech in .NET) and Client (accessed via System.Speech in .NET) Speech Runtimes into Microsoft Speech Platform Runtime (Version 11), found at http://www.microsoft.com/en-us/download/details.aspx?id=27225. The respective SDK is at http://www.microsoft.com/en-us/download/details.aspx?id=27226. The speech runtime version that was labeled in the past "for servers" is non-trainable (has setting for acoustic model adaptation on/off though) and doesn't accept free speech, only commands


Java json response shows date in numeric value

Question: @Data
public class Reponse {

    private String event;

    @Temporal(TemporalType.TIMESTAMP)
    private Date eventDate;

    private Double amount;
}

Json response is like
{
  event: "transcation',
  eventDate: 1213123434,
  amount: 100
}

Here, eventDate is showing numeric value 1540317600000 instead of 2018-10-23
Comment: The number 1540317600000 is milliseconds since the Unix epoch (equal to Tuesday 23. October 2018 18:00:00 GMT according to https://www.epochconverter.com, please try yourself). What's the problem? Does the client object to the response? Have you got a requirement for what the event date should look like in the response, and if so, how?
Comment: How are you serializing the response to JSON? Are you using Jackson, gson or some other library? Please tag your question accordingly.
Answer: You can annotated the field with @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm"). Then, response time format will be like "yyyy-MM-dd HH:mm"
import com.fasterxml.jackson.annotation.JsonFormat;

public class Reponse {

    private String event;

    @Temporal(TemporalType.TIMESTAMP)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
    private Date eventDate;

    private Double amount;
}

Answer: If you use Spring boot 2.x instead 1.x ,the default behavior has changed
add spring.jackson.serialization.write-dates-as-timestamps=true to your configuration to return to the previous behavior
Spring Boot 2.0 Migration Guide
Answer: spring 2.x flipped a Jackson configuration default to write JSR-310 dates as ISO-8601 strings. If you wish to return to the previous behavior, you can add
spring.jackson.serialization.write-dates-as-timestamps=true

to your application-context configuration file.
Answer: I suppose you are using rest framework such as spring boot or jersey which in turn
converts your java date into epoch format before sending it to the client. So while
sending response you can format you date into the format you want. Please refer
the code below.

import java.text.SimpleDateFormat;

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
sdf.setLenient(false);
String responseDate = sdf.format(date);

Comment: Please don't teach the young ones to use the long outdated and notoriously troublesome `SimpleDateFormat` class. At least not as the first option. And not without any reservation. Today we have so much better in [`java.time`, the modern Java date and time API](https://docs.oracle.com/javase/tutorial/datetime/) and its `DateTimeFormatter`.


Aptana Studio 3 - variable highlighting enable

Question: All,
Somehow, I have managed to disable 'variable/ element highlighting' in Aptana Studio 3.
Online search brought up someone's advice to enable 'Highlight current line option in the General > Editors > Text Editors section of the Preferences dialog', which is already enabled and I think is actually for line highlight, not variable highlight.
Thanks,
Comment: I have managed to figure out where the problem is. Upon install, Studio 3.0.5 has highlighting enabled, however, upon installing the latest update from the server, the highlighting gets disabled.
Answer: Since last release it's turned off by default, to activate it click on little marker icon on toolbar.
Found answer:  Minor Highlighting bugs on Mac, see comments:

As noted on attached ticket, we've turned off mark occurrences by default until we are able to make some performance improvements.

If you want it on, you can turn it on by clicking the Hightlight Pen icon in the toolbar == shortcut key Alt-Shift-O on Windows.
Comment: Just to be very clear how to enable it: go to Window -> Preferences -> Aptana Studio -> Editors -> [choose language i.e. PHP], then check Mark occurrences with background color
Comment: While that works, there should be a toolbar button to enable/disable this for all editors - http://stackoverflow.com/questions/15866022/aptana-studio-3-mark-occurrences-button
Comment: You are spot on Marcoo. Just tried it and it did work. Many thanks!


moreNavigationController not displaying image for an instant

Question: I have a UITabBar that is working properly but when I add more elements and the more button appears it is showing a strange behavior.
If I select one item and then come back by pressing again the "more" button, the selected item does not show the image for a few seconds and then is shown again.
I have created the the UITabBar programmatically and I have change the UITableView of the moreNavigationController colors programmatically to.
If I remove the personalization of the moreNavigationController the behavior is there to.
My first guess was the tint color of the UITabBar (is white) but I change it to red and the behavior is the same.
Then I though it was the image but the unselected image is grey and the selected image is blue.
This is the code I use to create the UITabBar:
- (void)createTabBar
{
    tabController = [self.storyboard instantiateViewControllerWithIdentifier:@"cCustomTabController"];
    dValue = [dConfiguration objectForKey:@"Buttons"];
    NSMutableArray  *aControllers = [[NSMutableArray alloc] init];
    int i = 0;
    for (NSString* sProperty in dValue) {
        NSString* d = @"Details";
        NetworkStatus internetStatus = [_reachabilityInfo currentReachabilityStatus];
        NSData *itemData = Nil;
        if (internetStatus != NotReachable)
            itemData = [util getSpecificJsonData:[sProperty valueForKeyPath:@"Item"]];
        if(itemData != nil){
            UIStoryboard *aStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:[NSBundle mainBundle]];
            UIViewController *vcCustom = [aStoryboard instantiateViewControllerWithIdentifier:[util getControllerName:[sProperty valueForKeyPath:@"ViewController"]]];
            [vcCustom setValue:itemData forKey:@"JsonData"];
            [vcCustom setValue:[sProperty valueForKeyPath:@"Item"] forKey:@"Item"];
            [vcCustom setValue:d forKey:@"Details"];
            [util saveJSON:itemData withName:[NSString stringWithFormat:@"%@%@",[sProperty valueForKeyPath:@"Item"],[CommonsUtils getCommonUtil].getAppLanguage]];
            [[vcCustom navigationController] setNavigationBarHidden:NO animated:NO];
            vcCustom.navigationItem.leftBarButtonItem = Nil;
            vcCustom.navigationItem.hidesBackButton = YES;
            UIImage *imageBtn = [self changeImageSize:[UIImage imageNamed:[util getImageName:[sProperty valueForKeyPath:@"Image"] andRetrina:[sProperty valueForKeyPath:@"ImageRetina"]]] scaledToSize:CGSizeMake(30, 30)];
            UIImage *imageBtnPress = [self changeImageSize:[UIImage imageNamed:[util getImageName:[sProperty valueForKeyPath:@"ImageHeighlighted"] andRetrina:[sProperty valueForKeyPath:@"ImageRetinaHeighlighted"]]] scaledToSize:CGSizeMake(30, 30)];
            UITabBarItem *tab = [[UITabBarItem alloc] initWithTitle:[sProperty valueForKeyPath:@"Title"] image:imageBtn selectedImage:imageBtnPress];
            UIImage * iSelected = imageBtnPress;
            iSelected = [iSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
            [tab setSelectedImage:iSelected];
            tab.tag = i;
            if([[sProperty valueForKeyPath:@"Title"] isEqualToString:@"Notificaciones"])
                tab.badgeValue=[sProperty valueForKeyPath:@"Badge"];
            [vcCustom setTabBarItem:tab];
            [vcCustom setTitle:[sProperty valueForKeyPath:@"Title"]];
            UINavigationController *navigationController = [[cCustomNavigationController alloc] initWithRootViewController:vcCustom];
            navigationController.navigationBar.tintColor = NAVBAR_TINTCOLOR;
            UIColor *uicText = NAVBAR_TEXTCOLOR;
            navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:uicText forKey:NSForegroundColorAttributeName];
            [aControllers insertObject:navigationController atIndex:i];
            i++;
        }
    }
    tabController.delegate = self;
    tabController.viewControllers = aControllers;
    tabController.tabBar.tintColor = TABBAR_TINTCOLOR;
    UIColor *uicTabBar = TABBAR_BACKGROUND_COLOR;
    [[UITabBar appearance] setBarTintColor:uicTabBar];

    tabController.customizableViewControllers = @[];
    tabController.moreNavigationController.navigationBar.tintColor = NAVBAR_TINTCOLOR;
    UIColor *uicText = NAVBAR_TEXTCOLOR;
    tabController.moreNavigationController.navigationBar.barTintColor = NAVBAR_BACKGROUND_COLOR;
    tabController.moreNavigationController.navigationBar.translucent = YES;
    tabController.moreNavigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:uicText forKey:NSForegroundColorAttributeName];
}

And this is how I personalize the UITableView of the moreNavigationController:
UITableView *tView = (UITableView*)tabController.moreNavigationController.topViewController.view;
if ([[tView subviews] count]) {
    for (UITableViewCell *cCell in [tView visibleCells]) {
        cCell.textLabel.textColor = TABLECELL_TEXT_COLOR;
        cCell.textLabel.highlightedTextColor = TABLECELL_TEXT_COLOR_HIGHLIGHTED;
        cCell.contentView.backgroundColor = TABLECELL_BACKGROUND_COLOR;
        cCell.backgroundColor = TABLECELL_BACKGROUND_COLOR;
        UIView * selectedBackgroundView = [[UIView alloc] init];
        UIColor *uicCell = TABLECELL_BACKGROUND_COLOR_SELECTED
        [selectedBackgroundView setBackgroundColor:uicCell];
        [cCell setSelectedBackgroundView:selectedBackgroundView];
    }
}

In this image you can see what is happening:

Thanks in advance.
Answer: As I saw here:
MoreNavigationController images disappearing on select
I have added this line to my code:
navigationController.tabBarItem = vcCustom.tabBarItem;

Thanks for the help.


Form looks good in Firefox but a mess in Chrome

Question: Please see attached images. The second image is from Firefox, which looks great, the first is from Chrome, which is a mess.
Anywhere I have a label and input field, in Chrome it goes messy.

Both have exactly the same code.

       First Name *
       <input type='text' name='Contact0FirstName' value='<?=$_POST['Contact0FirstName']?>'>

       Last Name *
       <input type='text' name='Contact0LastName' value='<?=$_POST['Contact0LastName']?>'>

As an example.
Comment: Not related, but you have a typo: `Sumbit Order` !
Comment: Not really related but you're using tables for layout when tables should only be used to display tabular data.
Comment: If you're floating the input field try adding overflow: auto; or overflow:hidden; to that specific class.
Comment: What are the CSS rules for the TD elements?  (Incidentally, using tables for layout like this is generally frowned upon.)
Comment: Is the width of your firefox window different to chrome's?
Comment: Thank you for the typo. Missed that :)
Comment: The width is the same for Chrome and Firefox. What's the first step I should take?
Comment: The form code on here is snapped from an ecommerce platform. I just added the divs in there.
Answer: Usually, will render horizontally:
+--------------+------------+
| First Name*  | [_________]|
+--------------+------------+

and this both in Chrome and FF. Since FF is rendering this as
+--------------+
| First Name*  |
+--------------+
| [_________]  |
+--------------+

this is either not the same code or there's an CSS which is handling the table-data tags for FF in a way Chrome doesn't understand - ore vice versa.
Check both original HTML and included CSS, use firebug and developer tools on both browser to see what actually is applied to these elements
Comment: _Check both original HTML and included CSS, use firebug and developer tools on both browser to see what actually is applied to these elements_
Comment: He is using wrong table div structure. http://readiness-plan.com/firetest/form1.php
Comment: So what should I do here?
Comment: optionally, you may post the related full html and css code here
Answer: It looks like you're trying to render two cells ( elements) of the same row (
 element) as if they were on different rows.  The correct way to do this is to actually put them in separate rows (i.e., wrap them in separate
 elements):

   First Name *

   <input type='text' name='Contact0FirstName' value='<?=$_POST['Contact0FirstName']?>'>

   Last Name *

   <input type='text' name='Contact0LastName' value='<?=$_POST['Contact0LastName']?>'>

Better still, stop using tables for layout and adopt a pure CSS approach instead.
__
A couple of unrelated notes:

Directly including unsanitized user input (like $_POST variables) into your response leaves you vulnerable to XSS attacks.
Consider using  elements to mark up the form control labels and indicate semantically which elements they relate to.  This will aid accessibility and also some browsers will focus the target form control if you click on its label.
Answer: You need to set the style sheet and give particular spaces for each tags in the html.
Don't give fixed sizes. Manage to do with reletive, absolute, and set the front view one after the other. z-index to show them above or below. Start setting in order. Its little messy in the beginning... Good luck. It might help. If you try to open in other browsers as well It might shock you..


Yii2: Path issue while redirecting with pretty url from login

Question: i have enabled pretty url in url manager & tried login with. When logs in successfully to my dashboard, i am getting problem w.r.t CSS & JS loading for that page as the path makes problem i have analyzed the problem in network problem the screen shots are below.

First screen shot is the image when i am trying login without enabling pretty UR...works fine
How to fix this issue.
Second:This is the login page when i enabled pretty url & opened login view
Third: This is the third image when i logs in where the path issue occurs. the path to load css & JS differs & hence i am getting 404 error in network panel
Comment: How are you including your CSS and JS files?
Comment: $this->registerJsFile('js/plugins/sparkline/jquery.sparkline.min.js');
Comment: i am adding through this way in the view
Comment: why not using a assetBundle for this?
Comment: do you mean AppAsset.php???
Comment: For sure he mean that
Comment: Show us your urlManager config
Comment: 'urlManager' => [
        'enablePrettyUrl' => true,
        'showScriptName' => false,
        ],
Comment: well i was using asset bundle still i was not working so i switched to registering locally the CSS & JS files in the view itself
Answer: It doesn't really have much to do with the fact that your urlManager is enabled, but rather how you are registering your assets.
You could just add the js and css files to your Asset Bundle e.g. /frontend/assets/AppAssets.php and make sure that your bundle is published in the layout file e.g. /frontend/views/layout/main.php view.
You could also just try:
$this->registerJsFile(Yii::$app->request->baseUrl.'/js/plugins/sparkline/jquery.sparkline.min.js');

Instead of
$this->registerJsFile('js/plugins/sparkline/jquery.sparkline.min.js');

which looks for the file relative to the url, that's why it's not working with the urlManager enabled.
Comment: well even this doesnot work...for now i have stopped using yii2 as am frustrated a little on these silly issues. i am developing my project in core-php.
Comment: This is the right answer. @Shaggie you are lacking basic understanding of how paths work. No framework will help you. Some might do what you want but that is just covering a lack of knowledge.


How do I repair or cover up this crack/gap in the drywall on the ceiling?

Question: I assume this split apart because of expansion or the house settling. I haven't really noticed if it gets shrinks when it's warmer out.
What's a good way to fix this to where it won't open back up in the future?
Comment: It looks like a shrinkage crack. You can apply a flexible sealant to fill the gap. However, most importantly, it looks like the space is too dry. Maintaining the space with moderate humidity could help to minimize the chance of reoccurrence.
Comment: Doesn't help this is directly above a window and a floor vent.
Answer: Standard repair
Re-tape the affected areas with drywall tape and cover with drywall compound.
For a small section like this, you can try to recreate the texture by hand.  Hardware stores sells texture in a spray can, but it may or may not match the particular look and feel of your walls.  The last time I used the can, it was more of an  orange peel texture.  Looks like your surfaces are coarser, with larger chunks.  You can also buy a super soaker sized texture gun, I've used this and you can dial in the chunk size.  It costs a lot more than the spray can though.
Then there is the hassle of paint matching.  Looks like you have three colors converging here.
Quick repair, no painting
Fill the gap with drywall compound or caulk, but no tape.  It will likely crack again as the walls expand and contract with seasonal temperature changes.  Hopefully, a much smaller crack that is not so noticeable.  Clean up carefully so that the only new material that shows is the gap fill itself.
For the paint flaking up section, carefully peel back and "glue" it back down.  Try not to pull back to far, or it will crack off.  Can use any paint you have around as glue, but wipe up the excess before it dries, unless the paint is an exact match.
Answer: Aesthetic Repair with Gesso
Assuming there is no underlying paneling issue or structural issue, the cracking and brittling can be aesthetically mitigated by applying several coats of a heavy acrylic primer such as "acrylic gesso".
Acrylic gesso forms a soft flexible and paintable surface over the existing drywall substrate.
Reinsert any loose or brittle parts to keep the original texture. Remove grime, dust and other dirt. Apply several coats of acrylic gesso and roll out to fill cracks deeply but maintain the bumpy look. Deeper cracks can be pre-filled with acrylic caulking, a.k.a "painters caulking".
Then paint with your favourite acrylic paint.
Acrylic gesso is available from arts stores. Make sure you get the "acrylic" variant, not some sort of traditional/original Italian canvass glue.


iPhone: How to Share/Move Files from App Directories to Other Devices

Question: I have an app which generates some files in the app directories
I need users to be able to access the files from another device/computer via file sharing over wifi, using a web browser, a ftp client or some similar method.
Can the iPhone act as a http server and ftp server by itself or do I need to do some programing to make the http server and ftp server by myself?
Thanks
interdev
Answer: The code examples for Erica Sadun's rather excellent 3.0 edition of the iPhone Developer's Cookbook are downloadable at github. She has two chapters on various modes of networking including an example HTTP server.
Answer: The iPhone has no built-in web or ftp server. So if you want this functionality to be part of your application then you will have to include one in your code.
Answer: CocoaHTTPServer is an excellent library for this purpose, widely used also in iPhone apps. It has a good documentation and working example projects, even for iPhone.


Moving objects in the most current swift

Question: How would I go about moving an object to follow touch in the newest version of swift. So if you touch the object it will follow your finger around until you remove your finger.
Answer: You should use the touchesBegan and touchesMoved methods.
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

    for touch in touches {

        thing.center = (touch.locationInView(self.view))

    }

}

override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {

    for touch in touches {

        thing.center = touch.locationInView(self.view)

    }
}

For more info, watch this video. Hope this helps.
Comment: This should be more helpful now.


Issue with loss of pressure in shower

Question: There's an issue with our en suite shower that is currently puzzling us, and our plumber.
Our en suite shower is making a high pitched 'squealing' sound after about a minute of operation, this is accompanied by an apparent loss of pressure, as the water comes out at a slower rate.
To make it slightly more complicated, it seems to only be at certain temperatures. I have a warm shower, rather than hot, and that's when it occurs. My wife has a hot shower (ridiculously hot in fact, steam everywhere) and it doesn't affect her.
However to make things really confusing, if I have a shower on warm before my wife, and then she has hers, the issue will likely occur for her too.
And finally, we've found if we run the tap in our en suite sink at a decent rate whilst the shower is on, it fixes the problem.
We have 2 showers in our house, and altogether 4 sinks, along with a washing machine that is piped in, and none of them have any issues with water flow.
Our plumber replaced the shower [head], but that didn't help, and actually seemed to make it worse, with it occurring pretty much immediately. The shower [head] he replaced ours with has since worked fine in another house.
He did say our water pressure is extremely high, and indeed when we turn a tap on the water shoots out, so he wasn't sure if that had anything to do with it.  He's stumped and he's now asking around to see if anyone he knows might have any ideas.
I was wondering if anyone else has had a similar problem, and has any ideas how to solve it?
Our house is only about 10 years old (we've been in it about 3 years), and we've only had this problem for the last 6 months or so without anything obvious changing.
I should probably mention that I'm not great with DIY, so explaining in layman's terms might be best.
Comment: Does your shower have a tub spigot - perhaps with a diverter (the lever that send water to the shower rather than the tub)?  Often times the diverters vibrate (making a squeal) when the pressure is "just right".  If you have one, wiggle it to see if the pitch changes.
Comment: When you say "en suite" are you intending to say that it's plumbing is connected to other plumbing fixtures?  or just a normal bathroom that is part of your master bedroom?  -  *en suite: adverb & adjective -
    In or as part of a series or set. --
    In a set or connected series; forming a series or set with something else in the same style: as, apartments to be let en suite or singly. -
    adj. - As part of a set or series*.
Comment: Is the valve one that has an anti-scald adjustment?
Comment: Sorry for the late reply, only just got an email just now to tell me this has had so many comments and answers, I mean en suite as in a bathroom next to the master bedroom, and it doesn't have a spigot for a bath, it's just a shower. I don't think the valve has any anti scald adjustment, just one for the temperature and one for the flow.
Answer: I know this is going to sound crazy but I had a similar problem with a cold water shower valve. It would squeal and then the pressure would drop. I ended up removing the valve stem and found a very loose washer. I replaced it and never had the problem again.....
Comment: +1 I agree that the first step should be disassembling the valve(s) and having a look-see.
Comment: Thanks, I will have a look at the washers in the valve when I get chance. Like I said the plumber did change the shower, so really should get a new plumber if it is this.
Answer: It could also be the mixing valve.  The way that showers adjust the temperature is via different openings of 'ports' in the mixing valve, and they can get clogged with stuff in the lines; turning them differently or different amounts of pressure could also affect the mixing valve.
Try unscrewing the cover and removing the cartridge -- I've had this problem with a sink faucet in the past.
Comment: Thanks, I will check the mixing valve too when I get chance to take the shower apart.
Answer: Get a new Plumber and I agree with gbronner. The mixing valve or anti-scald protection of the valve is the extremely usual cause of what you describe very well.
With the age of your home and therefore the shower valves, both baths' shower valve cartridges should be replaced. We're dealing with plastic and 10-years is the normal expected failure frequency of the "wonderful" garbage.
Yes, I said both showers. It doesn't matter how frequent or infrequent the valves are used, they're both always under pressure. Either one's failure allows hot and cold water to contaminate the other or take over entirely. A loss in pressure means one is taking over and traveling into the other that it stole the pressure from before making it out into the shower.
Comment: Thanks, will try gbonner's solution, and keep it in mind if the other shower displays the same behaviour. We do use that a lot less though.
Comment: Just so I'm clear. I'm only agreeing that the mixing valve is the culprit and not that they need a cleaning in both baths. You won't be able to see nor repair the damage that matters even if you find debris to remove. And, the other shower may be causing the problem. Replacement of the cartridge in only your shower may just fix the problem halfway if both are failed or the other may fail next week. That's another Plumber charge or trip to a Home Improvement store to do the other shower later.
Answer: Sounds like low flow in the hot supply is giving rise to turbulence at some restriction. When you turn on the lavatory tap and it abolishes the squealing, do you turn on both hot and cold taps or just one, and if just one, which one? Turning on the lavatory taps will lower the pressure in the lines.
Maybe you should get a pressure reducer installed at the water service entrance to your house. This would lower the pressure in both the hot and the cold lines. What pressure does the city water provider say that they supply?
What kind of water heater do you have and what is its temperature setting? Setting the temp on the heater at a lower temp will mean that you set the hot faucet in the shower to a higher flow and this may abolish the squealing.
What kind of shower heads are you using? Specifically what is the rated flow from the head? This will be written on the face of the head and it will be something like 2.8 gal/min or 2.0 gpm or 1.4 gpm. It will probably also give it in L/min.
Comment: Thanks for the reply. When we turn the tap on it's the cold one, although it's a mixer tap, and so it's turned to cold.

I've not checked the pressure with our water supplier, I will do though, and see their response.

We have a combi boiler, so heats the water as it comes into the house. I've checked and it's set to 5 our of 7, although I think that's only for the radiators. We have it serviced every year, and never had any mention that the heat should be adjusted.

Our shower heads don't give any rating that I can see, I'll have a look tomorrow more closely to see if I can find one.
Answer: I had a proper look at this a couple of weeks ago, checking the head, and pipe connections to the wall, and nothing looked amiss. I cleaned the filters, and any loose parts, put them back in, and still had the same problem.
I did however notice by chance when testing it, that if I didn't turn the pressure (or power) tap fully round, it would still give a good flow (pretty much full), and wouldn't have the annoying sound and loss of pressure.
We spoke to our plumber about something unrelated this week, and he mentioned that he'd had a think about our shower, and come up with a theory.The water pressure in our house is high, so when the hot water comes through, it pushes so hard behind the shower, it pushes the cold water back away from the shower in the pipes.
This makes sense, as it would explain the pressure loss, why it takes a while to happen (it takes a while for the hot water to push the cold back), and would explain why turning the power and therefore pressure on the shower fixes the issue.
So we could have an expensive job of fixing our water pressure, but it hasn't caused any other issues, so for now, we'll just continue the cheap solution of only turning the tap halfway.
Comment: Thanks for answering your question in such detail. If you do learn more, it would be great if you added it here.

Issue with loss of pressure in shower


I Got error Like this in Angular

Question: In my angular 2 project i used SEO when i include ng2 timeout plugin and run the Project using 'npm start' i got this error

ts-node src/server.ts

(function (exports, require, module, __filename, __dirname) { export { ShTimeoutModule } from "./src/timeout.module";
                                                              ^^^^^^
SyntaxError: Unexpected token export
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (E:\project\src\app\app.module.ts:28:1)

npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.11.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! email@example.com start: `ts-node src/server.ts`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the firstname.lastname@example.com start script 'ts-node src/server.ts'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the project package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ts-node src/server.ts
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs project
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls project
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:

Comment: are you using webpack
Comment: no.. how to use that
Answer: replace you ts-node with node where ever you're using and install webpack
add this in you package.json
"prestart": "ng build --prod --no-sourcemap && ngc && webpack",
"start": "node dist/server.js"

Create a webpack.config.js at package.json level and following content
const path = require('path');
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
    entry: {
        server: './src/server.ts'
    },
    resolve: {
        extensions: ['.ts', '.js']
    },
    target: 'node',
    plugins: [
    new webpack.NormalModuleReplacementPlugin(/\.\.\/environments\/environment/, '../environments/environment.prod')
    ],
    externals: [nodeExternals({
        whitelist: [
        /^ng2-timeout/
        ]
    })],
    node: {
        __dirname: true
    },
    output: {
        path: path.join(__dirname, 'dist'),
        filename: '[name].js'
    },
    module: {
        rules: [
        { test: /\.ts$/, loader: 'ts-loader' }
        ]
    }
}

add all other libraries in whitelist of externals which are causing errors.
And do npm start
follow this issue for more detailed explanation and solutions
https://github.com/ngx-translate/core/issues/581
Comment: I tried ths but i error like this " Error: Cannot find module 'webpack-node-externals' "
Comment: you need to install that `npm install webpack-node-externals --save-dev`
Comment: yup installed but having this error while running the project by npm start --ERROR in Entry module not found: Error: Can't resolve 'ts-loader' in 'E:\newpre\Project'
Comment: `npm install ts-loader --save-dev`, for other same errors also please install them first
Comment: again some unknown error like this -
ERROR in ./src/app/service/cognito.service.ts
Module not found: Error: Can't resolve '../environments/environment.prod' in 'E:\newpre\Backup\Praba_07-09-2017 v2.0\premierx\src\app\service'
 @ ./src/app/service/cognito.service.ts 10:20-61
 @ ./dist/ngfactory/src/app/app.server.module.ngfactory.ts
 @ ./src/server.ts
Comment: In before i am not getting that error now only i got this... ok i will try to fix it
Comment: do you have a environments folder ?
Comment: and before this whatever error you were getting you could not possibley solve that just by `ts-node` so you done good improvements by using webpack now it's different issue
Comment: it should be be outside app folder, see this repo and modify your code accordingly https://github.com/SergiusSidorov/cli-universal-demo
Comment: Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/153942/discussion-between-aravinthan-m-and-rakeschand).
Comment: yup moved to outside but same problem
Comment: okay download the repo link i sent you, see how it is done in that and follow same for your app too

I Got error Like this in Angular


Phone/cat3 equivalent of network switch

Question: I want to split the incoming phone wire across 5 rooms. For ethernet, I use a simple Netgear switch fed from my cable modem and then 5 ethernet connections going out of the utility room to each room of the house. But when I searched "phone switch" on both Google and Amazon, I was getting Netgear ethernet switches in results and nothing for phone/cat3.
What is the phone/cat3 equivalent of an ethernet switch? I want it to have female cat3 jacks just like the Netgear has femalele cat5 jacks. I want it to be exactly the same as Netgear except phone/cat3.
Comment: One point I haven't seen others address: With old-style phones at least, you had to give the phone company the "ringer equivalence numbers" if you were going much beyond three instruments, so they could be sure the line could supply enough current to ring all those mechanical bells. Electronic phones and modems and other modern phone equipment generally has RENs down  around 0.1 so this isn't generally an issue now -- but if you want to use Grandpa's old rotary dial  phone, or something even older, you may need to talk to the phone company about this parameter.
Comment: A single phone line can be tied together, but it is not switched in the way that TCP/IP is. All lines use the same data (think broadcast traffic), so anyone picking up any phone would hear anyone else on any of the five phones. Why do this at all? Much telephony is not power outage resistant now and wireless phone bases eliminated the need to wire every room 25 years ago.
Comment: Phone and Cat3 are not the same thing.   Phone wires use RJ11 plugs and sockets connected by any wire at all, not Cat (Category) anything with connections that can be anything at all, even twisting and taping wires together.      Ethernet uses RJ45 plugs and sockets and the wires, connectors, and connection methods all have to be to certain specifications.   Cat3 is one of those specifications, highly outdated that serves no purpose any longer.  So: what are you actually trying to do?
Comment: I hadn't even considered REN these days, forgotten all about it - this links to a British Telecom document explaining how the standard maximum REN is 4, but you can juggle that all the way up to 11 using hardware 'extension booster' boxes. https://shop.bt.com/content/uni2/documentation/4kqv/bt-ren-booster.pdf
Comment: Most modern telephone services will take pulse dialing, but your phone has to be well adjusted, as the tolerances on the pulses are much tighter now that they are digitally analyzing them rather than using them mechanically.  The trickier part is their mechanical bells. They tend to work on services provided by actual traditional telephone companies designed for whole houses (like FiOS), but cable and VoIP only companies tend to use systems that truncate the sine wave and/or don't provide the full voltage necessary to drive the bell striker, even with enough REN support.
Comment: Some context would be helpful.  In 2023, the only approach I would take to installing new "home phones" would be a DECT6 base station plugged directly into my ISP's terminal or VOIP terminal, with handsets where needed.  Maybe there are scenarios I'm not aware of, but it would be useful to know what yours is.
Comment: @jay613 wire phone in every room
Comment: The traditional, easy and most economical way to run wired phones to every room is to daisy chain them.  You don't use a hub at all, just connect each room to the next one using the screw terminals in the phone jacks.  Anything you do beyond that is purely decorative.
Comment: water under the bridge. I already did a centralized branching. but i get your point and agree with it
Comment: (I'm not even sure modern PBXes still recognize rotary/pulse dialing. If not, I'm sure someone on the web has a hack that will accept pulse streams and turn them into touch tone pairs...)
Answer: You are over thinking this. POTS (Plain Old Telephone Service) doesn't need a switch, a modem or a router.  You just connect all the cat 3 (RJ11 jacks presumable) in parallel from one to the next. POTS wiring has been doing it this way for decades.
OK, that said:  If you want to do any "future proofing" you should consider running cat-5 or cat-6 with each jack going to a central point (star config) where the POTS service comes in.  Then simply connect all the POTS lines in parallel. If you wanted to get a bit more fancy, get a low voltage cabinet and a punch down block to make the connections.   So if you eventually give up on POTS service, which many of us have, you'll have the wiring in place to upgrade to LAN/ethernet/internet.
Again, if you want to keep it super simple, just run the cable from one POTS (RJ11) jack to the next. It won't be future proof though.
Comment: Yeah, using actual CAT3 wire (if you can even find it these days) is a bit nuts. Heck, the last two jobs I worked even the 25-pair phone cable was Cat5e. That'll run 6 gigabit ethernet connections and *still* have the slate-violet pair available to run POTs on.
Comment: The oldest cables in my building look like they were installed by Alexander Bell himself, sticky fabric-wrapped monstrosities. Newer ones are just bell wire (no relation;) Even the newer ones are decades old. I've never replaced one & I've been here 30 years; reconfigured twice as the house layout was changed, but never went to the trouble of replacing one. All still works, one odd occasion we have need to use the landline. [For the past 20 years it's been unplugged unless we want to dial out. It gets used for 'hanging on the phone'-type consumer services free calls only.]
Answer: Waste of money, but feel free.
A pair of wirenuts will do the job, unless you have more than one phone line coming in, and phones that understand more than one phone line on a single jack. In that case 4 or 6 wirenuts will do the job.
Or you could get a 6-port surface mount box with 6 jacks and hide the pair of wirenuts inside it. That would "look like" (vaguely) an ethernet switch.

Connect wires to the green/red or white-with-blue/blue connection points on your jacks, and connect all the blue or red and all the green or white-with-blue wires. Or spend ~12 or more times the price on a manufactured item you can plug in to. I don't recommend that, as it's an extreme waste of money, but PT Barnum is widely alleged to have known why they make it.

If you're not dead set on having jacks (which it seems you might be) you can simply use a junction box to run all 6 cables into, and hide the wirenuts joining the appropriate wires.
Comment: this is exactly what I want. what is it called?
Comment: A 6-port surface mount box. With or without additional descriptors like "keystone jack" that are not usually required to find them. They tend to come as 1, 2, 4, 6, 8,  or 12 ports, typically, though other numbers are not impossible, just not the usual.
Answer: Plain Old Telephone Service (POTS) doesn't use a switch like ethernet wiring.  Telephone wires are all just connected together - red to red, green to green, etc.  Usually it's installed in a daisy chain manner with the incoming cable run to the first location, then on to the next, until all the locations are served.  It sounds like you've run the incoming cable to a central location, and then run individual cables to each service point.  To connect them together you can use a phone block such as [this] which you can order online 1.
If you haven't run the wiring yet, you might want to use Cat 5 or Cat 6 wiring and terminations.  This will allow it to be used for either telephone or ethernet in the future, including VOIP.
Answer: A DuckDuckGo search for "phone line splitter" (or "duplex phone jack", for a more "correct" term) comes up with a multitude of responses. They all look like this little beauty:

images courtesy of homedepot.com. No endorsement intended or implied. Click all images to embiggen.
The HD also sells triplex versions for one in, three out. I'm sure that, at some point in time, one could purchase 4- or 5-output versions of them, too, but fewer people need that many land-line jacks anymore, so they're becoming a bit of a dinosaur.
Internally, these are nothing more than incoming lines to a punchdown block that the outgoing lines are connected to. There are absolutely no smarts inside this thing at all. That's what allows you to pick up two handsets and have a "conference" call at your end.
The good news is that the duplex one (currently) lists for less than $3, so you don't have to pay expensive network switch prices.
If you need more lines, you simply daisy chain more devices.
The other option is to install a puchdown block like this one:
image courtesy of amazon.com. No endorsement intended or implied
You put your incoming line into the blocks on the left (using a punch down tool), then run one line from each of the blocks on the right to wherever you need them. This, plus the tool, are considerably more expensive than the little outlet duplexer above, but are probably more reliable.
For a dirt cheap, DIY solution:

Drill 4 holes into a piece of wood.
Epoxy a nut over each hole.
Run a bolt and two flat washers through each nut.
Strip your phone wires

Clamp all the red wires between one pair of washers
Repeat for the blue, yellow & green wires, each on their own nut/washer/bolt set

You've made your own "punchdown" block. This is, literally, all there is to it.
Comment: So make/buy/customize a box. There's _nothing_ about splitting POTS that's rocket science.
Comment: @Criggie i want the flexibility
Comment: I need a box that will encapsulate all this
Comment: In the US for "actual phone two-pair" it's green/red and black/yellow and for a one-line system it's only green/red (or white-with-blue, blue on network wiring)
Comment: For years, @amphibient, I had a screw down block (equivalent to a punchdown block, but with, you guessed it, screws) in my basement splitting my incoming line into 3 or 4 outgoing connections so I could feed jacks throughout the house. I never had a cover over it, and finally removed it a couple of years ago (despite having given up on a land line nearly a decade ago). A box/cover is purely decorative and only necessary for WAF.
Comment: i don't like punchdown because I want it to be plug-n-play
Comment: Nothing more plug-n-play than the duplexers at the top of the answer!
Comment: @amphibient  There's no plug-and-play because that implied unplugging occasionally in the future.  Punch it down once and it won't need to be touched again.
Comment: @amphibient easy - make the wiring permemant and put RJ11/12 or BT jacks in each room.  Users can move phones about easily without having to touch the wiring.   Remember phone lines are analog, whereas ethernet is digital.  They're a different mindset.
Answer: 'POTS' doesn't use switching at all, unlike Ethernet.
Ethernet is point to point, every cable must be terminated at a 'host'.
POTS can be split, joined, starred, anything. So long as all the wires connect eventually to all the end points, it works.
All of these will work…
Comment: You just run them all into a bit of junction strip/box. POTS is really not fussy at all. At a push you could just twist them all together & wrap some tape round it [I wouldn't, but you could].
Comment: Don't compare POTS to ethernet. They are 100 years apart in technology. It doesn't need to be modular, it doesn't need jacks & sockets [other than where it comes out of the wall to the actual phone.] It doesn't need nice punch-down connectors. It's Victorian. All it needs is continuity on two wires.
Comment: What's wrong with a bit of connector strip? Stick half the wires in one side, half in the other. Done. You're not going to be putting this on the mantlepiece for all to admire.
Comment: You're seriously over-thinking this. All you need is continuity on two wires to all end-points. Anything more is just decoration, fluff, frippery. It's not like you're going to be reconfiguring it every other weekend. Also bear in mind it's harder to re-use punchdown connectors $2 each [+$25 for the tool] than terminal block $0.20 for a dozen. It's also considerably tougher to get more than one wire in any punchdown.
Comment: how do I split one incoming line into 5 cables going out ?
Comment: I want that junction box that is as encapsulated as a network switch
Comment: i need it for neatness. I am a neat freak
Comment: I want it to be plug-n-play, not splice/wire in and play
Answer: I concur with everyone saying it's a waste of money, but a Google search for "telephone distribution tap" produced a bunch of options, like:

This Leviton block, which lets you punch down a single incoming line into a 110 block and turn it into 7 RJ11 jacks:

This slightly cheaper block that does away with the RJ11 jacks and lets you punch down up to ten cables onto interconnected 110 blocks:

And the same box Ecnerwal posted.

Phone/cat3 equivalent of network switch


Spawning Sugar Cane

Question: I can't find any sugar cane anywhere on my map.
How do I make sugar cane spawn if I currently have none?
Comment: create new world and there you will find all new resources(added after update).
Comment: Related: [When surveying a new world what do I need to check exists that I can't create later?](http://gaming.stackexchange.com/questions/82743/)
Answer: You can't. Since the world isn't infinite, and sugar cane is a natural resource, you can't create it.
Answer: You can also get it when you make the nether reactor
Answer: Well, you can't spawn it. Answer found from this post on the Minecraft Forums
Link to the post.
-Ways of finding it or getting it
Now each world has every material in a x amount of quantities. This means if you continue following the coast you should find sugar cane. Once you got your first sugar cane, plant it and expand the farm. If your lazy to look you can go into custom mode and open up your inventory and just get a stack of 64 sugar cane or whatever amount you need and go back to normal mode, and start you farm.
Comment: Not all worlds in Pocket Edition will have sugar cane since it is randomly generated and PE worlds are not infinite.

Spawning Sugar Cane


MYSQL Query, Horizontally with avg and sum

Question: I need to take these rows and output horizontally with the Dates as the column headers. I have looked at other solutions but I am a newbie and cant figure it out.
     ENV      | SUM_TRX | TRX_DATE
    ------------------------------------------
    mfg_Dev   | 392     |  2018-05-01
    mfg_Dev   | 2848    |  2018-05-02
    mfg_Dev   | 4024    |  2018-05-03
    mfg_Dev   | 92261   |  2018-05-04
    mfg_Dev   | 428     |  2018-05-05
    mfg_Dev   | 406     |  2018-05-06
    mfg_QA    | 278134  |  2018-05-01
    mfg_QA    | 485122  |  2018-05-02
    mfg_QA    | 882138  |  2018-05-03
    mfg_QA    | 1207312 |  2018-05-04
    mfg_QA    | 1258550 |  2018-05-05
    mfg_QA    | 981031  |  2018-05-06
    mfg_Stress| 0       |  2018-05-01
    mfg_Stress| 4       |  2018-05-02
    mfg_Stress| 1       |  2018-05-03
    mfg_Stress| 6       |  2018-05-04
    mfg_Stress| 0       |  2018-05-05
    mfg_Stress| 0       |  2018-05-05
    mfg_Prod  | 60943069|  2018-05-01
    mfg_Prod  | 53060886|  2018-05-02
    mfg_Prod  | 52098890|  2018-05-03
    mfg_Prod  | 49489239|  2018-05-04
    mfg_Prod  | 19044338|  2018-05-05
    mfg_Prod  | 20569390|  2018-05-06

To:
    MFG         |   18-05-01 |  2018-05-02  | 2018-05-02     | 2018-05-04   |  2018-05-05 | 2018-05-06  | Avg count day
    ----------------------------------------------------------------------------------------------------------------
    mfg_Dev     |       392  |      2,848   |       92,261   |     92,261   |         428 |        406  |     16,055
    mfg_QA      |   278,134  |    485,122   |      882,138   |  1,258,550   |   1,207,312 |  1,258,550  |    894,967
    mfg_Stress  |         0  |          4   |            1   |          6   |           0 |          0  |          2
    mfg_Prod    | 60,943,069 | 53,060,886   |   52,098,890   | 49,489,239   |  19,044,338 | 20,569,390  | 42,534,302
    -----------------------------------------------------------------------------------------------------------------
          TOTAL:| 61,221,595 | 53,548,860   |   53,073,290   | 50,840,056   |  20,252,078 | 21,828,346

Can anyone help with a query?
Thanks in Advance!
Please reopen, I need help disparately!
Comment: https://stackoverflow.com/questions/15931607/convert-rows-to-columns-using-pivot-in-sql-server
Comment: Seriously consider handling issues of data display in application code
Comment: I am afraid none of those links are helping me out.
Answer: Consider this crude example...
<?php

//include('path/to/connection/statme.nts');

$query = "
SELECT env
     , sum_trx
     , trx_date
  FROM my_table
 ORDER
    BY env,trx_date;
";

$result = mysqli_query($conn,$query);

$array = array();

while($row = mysqli_fetch_assoc($result)){
$array[] = $row;
}

foreach($array as $v){
$new_array[$v['env']][$v['trx_date']] = $v['sum_trx'];
}

print_r($new_array);
?>

Outputs...
Array
(
    [Dev] => Array
        (
            [2018-05-01] => 392
            [2018-05-02] => 2848
            [2018-05-03] => 4024
            [2018-05-04] => 92261
            [2018-05-05] => 428
            [2018-05-06] => 406
        )

    [Prod] => Array
        (
            [2018-05-01] => 60943069
            [2018-05-02] => 53060886
            [2018-05-03] => 52098890
            [2018-05-04] => 49489239
            [2018-05-05] => 19044338
            [2018-05-06] => 20569390
        )

    [QA] => Array
        (
            [2018-05-01] => 278134
            [2018-05-02] => 485122
            [2018-05-03] => 882138
            [2018-05-04] => 1207312
            [2018-05-05] => 1258550
            [2018-05-06] => 981031
        )

    [Stress] => Array
        (
            [2018-05-01] => 0
            [2018-05-02] => 4
            [2018-05-03] => 1
            [2018-05-04] => 6
            [2018-05-05] => 0
            [2018-05-06] => 0
        )

)

Comment: Thank you @Strawberry. That helps!


Best edge finish for spill resistance?

Question: I've seen two common types of edge finishes for laminate flooring. Since I'm not familiar with the actual trade terms (feel free to point these out), I'm going to dub them: flush fit and V-fit. I call flush fit is the planar one, where the edges attempt to form a continuous & seamless surface between planks. The V-fit is the one where the planks are slightly grooved on the edges so that adjacent planks form a V-shaped notch. As far as I can tell from the advertising material, the main purpose of this notch is to give a 3D impression of actual wood planks.
I'm wondering what's the best edge shape for maximum spill resistance. The manufacturers are rather mute on this. The V-shaped notches look like an obvious place where liquid would gather. On the other hand, the notches could be well sealed... and I've seen "aqua safe" boards from Pergo that use V-edges. The flush edges could actually draw in more liquids through capillary effect if the fitting isn't tight. Is there any comparative experience or data on this edge shape issue as it relates to spill resistance? (As an aside: I'm well aware that some manufacturers like Egger advise to use (and even sell their own brand [STRIP-EX] of) glue for increased spill resistance between boards.)
Comment: The real bottom line is that wood and wood derivative products used for floors are not very friendly water and liquid spills. If you have as big of concern regarding this as your question seems to imply you may want to consider an alternate flooring type.
Answer: Standing water is a problem for any wood-based product, as the water will eventually find its way to the unfinished sides of the planks and be absorbed, causing swelling, heaving, mold, and all sorts of unpleasantness.  At that point, the affected flooring will have to be removed and replaced, which isn't quick or easy.
Accidental spills of water or beverages, if cleaned up quickly, are much less of a concern.  A flooring that cannot withstand the wear and tear of everyday life wouldn't be very popular or last very long.
If you're concerned about long-term standing water (an appliance or fixture prone to leaking or dumping water, or a basement that regularly floods), consider a vinyl or tile flooring, which are much less susceptible to moisture.  If you're only concerned about the occasional spill, a wood-based flooring product is fine as long as you attend to the spill quickly.
Just as an aside, what you call "V-fit" is commonly referred to as "beveled" or "beveled-edge", and is generally aesthetic.  The beveled edges are still covered by the laminate surface (commonly mylar), rather than being "raw".
Comment: Actually whether the groover is covered by the same material as the rest of the laminate depends on how much money you spend. I've seen several sources say that: ["The groove usually isn't coated with the same protective layer as the top is making it more vulnerable"](https://flooring-laminate.com/v-groove-laminate-flooring) ["on very high end laminates is formed from the same surface as the face of the laminate"](https://www.quora.com/What-are-the-pros-and-cons-of-going-with-a-V-groove-laminate-flooring-vs-flat-joints). It seems that only top-of-the line V-grooves are laminated on the grooves

Best edge finish for spill resistance?


What does it mean to "fight through the pain"?

Question: The Burning Axe of Sankis says:

Chance to fight through the pain when enemies hit you.

What does this do?
Comment: I'm fairly certain it casts Ignore Pain, which is a barb ability for damage reduction, but I could be wrong...
Answer: It casts "Ignore Pain" on you, causing you to take 50 percent damage for 5 seconds.
Source
According to a great post by muir who analyzed the effects of the weapon, it essentially prevents 28.2 percent of all damage taken (at least while in the thick of it), once you account for procs.
Comment: So, it would stack with [Pride of Cassius](http://us.battle.net/d3/en/item/pride-of-cassius)?
Comment: It seems like that would be the case.
Comment: do you know what the proc chance is?


Extract value from a particular xml node

Question: How am I able to extract the source IP relevant for "main.mp3" mount point from the below xml source
My current code gets the first on the list which happens to be for the listen.mp3 mount point, however I would like the extraction to be bound to a particular mount point
Code that extracts the source IP:
SERVER = 'http://localhost:8382/admin/stats.xml'
authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm()
authinfo.add_password(None, SERVER, 'xxxxxx', 'xxxxxxx')
page = 'http://localhost:8382/admin/stats.xml'
handler = urllib2.HTTPBasicAuthHandler(authinfo)
myopener = urllib2.build_opener(handler)
opened = urllib2.install_opener(myopener)
output = urllib2.urlopen(page)
soup = BeautifulSoup(output.read(), "lxml")
print "source ip: ",soup.select('source_ip')[0].text

xml source of the link:

<icestats>
<admin>email@example.com</admin>
<client_connections>580473</client_connections>
<clients>32</clients>
<connections>1217611</connections>
<file_connections>220</file_connections>
<host>localhost</host>
<listener_connections>374451</listener_connections>
<listeners>29</listeners>
<location>Australia</location>
<server_id>Icecast 2.4.2</server_id>
<server_start>Thu, 15 Feb 2018 21:17:23 +1100</server_start>
<server_start_iso8601>2018-02-15T21:17:23+1100</server_start_iso8601>
<source_client_connections>99</source_client_connections>
<source_relay_connections>0</source_relay_connections>
<source_total_connections>99</source_total_connections>
<sources>2</sources>
<stats>0</stats>
<stats_connections>0</stats_connections>
<source mount="/listen.mp3">
<audio_info>channels=2;samplerate=44100;bitrate=64</audio_info>
<channels>2</channels>
<genre>Islamic Talk</genre>
<listener_peak>52</listener_peak>
<listeners>29</listeners>
<listenurl>http://localhost:8382/listen.mp3</listenurl>
<max_listeners>unlimited</max_listeners>
<public>1</public>
<samplerate>44100</samplerate>
<server_description>Qkradio Station Australia</server_description>
<server_name>listen.mp3</server_name>
<server_type>audio/mpeg</server_type>
<slow_listeners>220</slow_listeners>
<source_ip>127.0.0.1</source_ip>
<stream_start>Mon, 19 Feb 2018 23:08:01 +1100</stream_start>
<stream_start_iso8601>2018-02-19T23:08:01+1100</stream_start_iso8601>
<title>ibtihal.mp3 - 1</title>
<total_bytes_read>634036021</total_bytes_read>
<total_bytes_sent>13637049457</total_bytes_sent>
<user_agent>Liquidsoap/1.3.3 (Unix; OCaml 4.02.3)</user_agent>
</source>
<source mount="/main.mp3">
<audio_info>bitrate=170</audio_info>
<bitrate>170</bitrate>
<genre>Islam</genre>
<listener_peak>2</listener_peak>
<listeners>1</listeners>
<listenurl>http://localhost:8382/main.mp3</listenurl>
<max_listeners>unlimited</max_listeners>
<public>1</public>
<server_description>Quran Kareem Radio</server_description>
<server_name>Quran Kareem Radio</server_name>
<server_type>audio/mpeg</server_type>
<server_url>http://qkradio.com.au</server_url>
<slow_listeners>1</slow_listeners>
<source_ip>126.96.36.199</source_ip>
<stream_start>Tue, 20 Feb 2018 00:56:23 +1100</stream_start>
<stream_start_iso8601>2018-02-20T00:56:23+1100</stream_start_iso8601>
<total_bytes_read>582030204</total_bytes_read>
<total_bytes_sent>588819584</total_bytes_sent>
<user_agent>instreamer</user_agent>
</source>
</icestats>

Comment: https://www.w3schools.com/xml/xml_xpath.asp
Comment: did you try xpath?
Comment: not familiar...
Answer: I have pasted your XML data into excercise.xml file, and it should work fine with python 3.x
import os
import xml.etree.ElementTree as ET
filename = 'excercise.xml'
cwd = os.getcwd()
fullFile = os.path.abspath(os.path.join(cwd,filename))
tree = ET.parse(fullFile)
root = tree.getroot()

#Below code will get Child tag and Child attributes
for child in root:
    if (child.tag) == "source" and (child.attrib['mount'] == "/main.mp3") :
        for element in child:
            if element.tag == "source_ip":
                print(element.text)

Answer: Use ElementTree, ships with Python.
import xml.etree.ElementTree as ET
tree = ET.fromstring(xml)

for s in tree.iter('source'):
    print(s.attrib) # dictionary with all attributes
    print(s.text) # there might also be text
    print(s.get('mount')) # this is the info you want
    print(s.attrib['mount']) # or like this

Answer: You could select the container 'source' tags and collect 'source_ip' tags on each of them, so each IP will be relevant to a mount poin.
soup = BeautifulSoup(xml, "lxml")
for mount in soup.select('source[mount]'):
    print "mount point: ", mount['mount']
    print "source ip: ", mount.select_one('source_ip').text

Or you could create a dictionary and select IP by mount point, eg,
data = {
    mount['mount']: mount.select_one('source_ip').text
    for mount in soup.select('source[mount]')
}
print data['/listen.mp3']

If you want to select the IP from a specific point only, just select the 'source_ip' tag on that node.
ip = soup.select_one('source[mount=/main.mp3] source_ip').text
print "source ip:", ip