What's the best way to connect my 3/4" gas line to my 3/8" grill hose?

Question: I just had a natural gas line installed in the outside wall of my house.   It has a valve and a female 3/4" connector.   My natural gas grill has a hose with a 3/8" connector.   How can I best connect these?
I saw silver male-to-male fittings going from 3/4" to 1/2".  Big box stores didn't have 3/4 to 3/8.  Is there such a thing?   An old guy at the store told me a need a bunch of black iron pipes strung together to achieve the reduction but couldn't explain why.  He seemed dubious about a simple double threaded connector.   I'd rather not have 7" of lead pipe sticking straight out of the wall if I can avoid it.
My intent is to only have the gas on when using the grill and turn off the supply valve when the grill is not in use (ie most of the time)
Thoughts?
Here's the 3/4" connector (gas line) from the house w/valve:

Here's the threaded 3/8" connector for the hose on the grill:

Just found this from a company selling brewer's supplies:

The thread sizes match what I need but...  Does that mean it's OK to use for natural gas???  Doesn't mention what it's made from.  My existing connectors both seem to be brass.
Comment: BTW, there is a special type of gas rated teflon thread tape for natgas/propane line fittings that is yellow in colour. Do **not** use the regular stuff.
Comment: what kind of connectors are on the two ends?
Comment: There are several types of fittings/threads that could be in play here (e.g. NPT, flare). We **must** see pictures of the connectors, pipes, and fittings to be able to help you.
Answer: I had the exact same size gas pipe connector and hose connector.
I ended up using one adapter.
I located it on Amazon, https://www.amazon.com/dp/B008E5CIMQ
Comment: Hello, and welcome to Home Improvement. Thanks for the answer; keep 'em coming. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know the details of contributing here.
Comment: Did this actually work? My grill expects 3/8" male **pipe** thread, not **flare** thread as you linked here. 3/8" flare adapters seem to be much more common than pipe thread adapters.
Answer: This is where big box stores don't help but plumbing and electrical specialty stores May have the correct fitting and the gas rated tape or dope.  My specialty store carry's both the hard line adapters for pipe  1-1/4" down to 1/2"  for the flex lines, I was picking up a fitting just a few weeks ago for my son in law he said they did not have them but he went to the big box store and was ready to use several nipples and reducing adapters, I picked up the correct one for less than he paid for the mess he had cobbled together. You may be able to find it on line also. I think it was a 3/4" female pipe to male 3/8" flare fitting.  Note you should have a gas rated shutoff valve at this connection and there are 3/4 to 1/2" ball valves out there
Answer: What brand is the grill? Weber, for example, manufactures (or has someone else manufacture) a kit that includes all the necessary connectors for hooking the gas grill to a domestic line.
Your first stop should be to contact the grill manufacturer, explain what you want to do, and see if they can provide such a kit. (And if the grill's manufactured by Weber, my first-hand experience is that they do, since I've already had that conversation with them.)
Surely you can find the appropriately-sized fittings at a specialty store and cobble together your own connection. And assuming you use the right tools and materials (e.g. gas-rated thread tape, etc.) there's probably nothing wrong with that. But IMHO it'd be better to just get whatever the grill manufacturer provides, assuming they do.
Answer: If your gas grill connection is really a 3/8 female NPT sized... Then what you need are two pieces. A 3/4" x 3/8" NPT black steel bushing, and a short 3/8" black steel nipple. ( short pipe with male threads on both ends. ) You can get a really short nipple and barely add any length to the output. However, that complicates the install since you won't be able to get a wrench directly on the nipple. I suggest a 3" nipple. It will add about 1.5 inches to the overall length with the bushing.
For something this close to valves, I wouldn't bother with tape, just use the correct pipe dope (sealant) for gas pipes. I recently fell in love with sealant in small tubes! No brush, no mess.
Leak test with soap once you are done.

What’s the best way to connect my 3/4” gas line to my 3/8” grill hose?


is it not a good practice to have a class without final fields in Dart?

Question: I have this situation where I want to make classes reactive, I will use GetX lib for the example.
I have this User class.
class User {
    User({
        required this.id,
        required this.name,
    });

    int id;
    String name;

    factory User.fromJson(Map<String, dynamic> json) => User(
        id: json["id"],
        name: json["name"],
    );

    Map<String, dynamic> toJson() => {
        "id": id,
        "name": name,
    };
}

I will make that class reactive.
final Rx<User> user = User(1, "Test");

Fields cannot be final because I might need to reassign them and rebuild certain widget, for example.
user.value.name = "Test2";
user.refresh(); // This will trigger rebuild widget.

If I had final fields in the class I would need to have separate reactive fields to each field I need to update and rebuild widgets:
final RxInt id = 0.obs;
final RxString name = "Test".obs

id.value = 1; // This would trigger rebuild widget.
name.value = "Test2"; // This would trigger rebuild widget.

Let's say I have like 20 fields or more would be easier to not have final fields, is it not a good practice creating classes like this?
Answer: It's easier, but you should understand that all of your .obs like vars are stream-like, which isn't optimized, but very easy to use and understand.
I use in project immutable-like objects because it's more obvious than variable mutations, and as a plus, I can save all of the class states because all changes its other class instance.
The immutable and mutable ways are different, so one is better then other in some cases or for some architecture, as well as the second.
You can read about https://bloclibrary.dev/ and https://github.com/jonataslaw/getx/blob/master/documentation/en_US/state_management.md. Its two different ways to build arch and you can create own conclusions for you question


Who is Mark Shuttleworth, and how is he related to Ubuntu?

Question: I am going to introduce Ubuntu to some new users (students in this case). Usually, I talk about the history of Ubuntu, how Ubuntu started, who has built Ubuntu in the past, and who decides the road Ubuntu takes.
Of course, you can't talk about the history of Ubuntu without mentioning Mark Shuttleworth. I would quite like to have a question on Ask Ubuntu to point new users to, so this is it!
Who is Mark Shuttleworth, and how is he related to Ubuntu?
Comment: [Wikipedia: Mark Shuttleworth](http://en.wikipedia.org/wiki/Mark_Shuttleworth) (Ctrl+F "Ubuntu") and [Wikipedia: Ubuntu](http://en.wikipedia.org/wiki/Ubuntu_(operating_system)) (Ctrl+F "Shuttleworth")
Answer: Mark Shuttleworth is an entrepreneur from South Africa who founded the Ubuntu operating system through his company, Canonical.

Before founding Canonical, he was the founder of Thawte, a company he founded in 1995 to provide digital certificates and internet security.  Thawte has since been sold to Verisign.
Shuttleworth was a Debian Developer in the 1990s.
Shuttleworth founded his company Canonical LTD in 2004, a company dedicated to supporting free software.
Through his company Canonical LTD, he founded the Ubuntu operating system in 2004.  Ubuntu is a derivative software product of Debian.  Canonical still governs and supports the Ubuntu operating system to this day and Ubuntu continues to be a product based on Debian.
He set up the Ubuntu Foundation in 2005 with an initial donation of $10 million USD of his own funds.
He remained the CEO of Canonical LTD until 2010, when he stepped down to focus on other responsibilities within Canonical and Ubuntu.
Shuttleworth is also famous for being the second ever self-funded space tourist (funded a trip to space with his own money) and the first ever South African in space.
Comment: No but interestingly, 10.04 marked the first release where Shuttleworth *wasn't* CEO anymore and instead was focusing more on, among other things, product design.
Comment: Whao, interesting, I never knew Ubuntu was Canonical's child from the beginning. I always assumed Canonical stepped in right around 10.04 and that's when UI changes began.
Comment: @Flabricorn: the thought that some people think this never even occurred to me! Have an upvote.


How do return all columns in Table A where an ID column is present in Table B which contains hundreds of ID columns

Question: I understand how to check if Column ID in Table A is present in Table B Column X.
But is there a way to return all rows in Table A in which it does NOT match a single Identifier in Table B?
In reality, Table B contains hundreds of columns.
Table A:
+------------+------+--------+----------------+
| Title Name |  ID  | Region | Numeric Column |
+------------+------+--------+----------------+
| Sam        | B021 | NA     |           5.99 |
| Brook      | B026 | EU     |           5.99 |
| Harry      | B032 | KOR    |          10.99 |
+------------+------+--------+----------------+

Table B:
+------+-------+-------+
| SAM  | BROOK | HARRY |
+------+-------+-------+
| B021 | B024  | B030  |
| 1    | B025  | B031  |
| 2    | 4     |       |
| 3    |       |       |
+------+-------+-------+

So in this instance, I would like my query to SELECT Rows 2 & 3 in Table A.
Comment: `SELECT` selects *rows*, not *columns*.  Of course, you can specify the columns (or expressions) that you want, but what is returned are rows.
Answer: I would use the NOT IN function to where,
SELECT * FROM TABLE A
WHERE col_A NOT IN (SELECT col_A
                    FROM TABLE B)

This will return all the rows from TABLE A where the val of col_A is not in TABLE B col_A
Hope this is helpful!
Answer: I think that one way or another, you will need to enumerate the columns that you want to search.
I would go for the left join antipattern, that, allows you to (safely) use the in operator:
select ta.*
from tableA ta
left join tableB tb on ta.id in (tb.sam, tb.brook, tb.harry)
where coalesce(tb.sam, tb.brook, tb.harry) is null

If you have a column in tableB that is not null (say, column never_null), the where clause can be simplfied:
select ta.*
from tableA ta
left join tableB tb on ta.id in (tb.sam, tb.brook, tb.harry)
where tb.never_null is null

Answer: Using a NOT EXISTS could work.
SELECT *
FROM TableA a
WHERE NOT EXISTS
(
    SELECT 1
    FROM TableB b
    WHERE a.ID IN (b.SAM, b.BROOK, b.HARRY)
);

Answer: I think you are looking for.
UNION doesn't work
SO
SELECT *
FROM tablea
Where `ID` NOT IN (SELECT HARRY FROM tableb)
OR `ID` NOT IN ( SELECT SAM FROM tableb )
OR `ID` NOT IN (SELECT HARRY FROM tableb)

DBfiddle
https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=333a6d2605f881299d888e774fd41c44


With which command in "Terminal" can I connect to internet?

Question: I errased some Ubuntu programs in Ubuntu 10.4 and now I just can work with "Terminal".
All my directories are still there but I wish to recover the graphical presentation.
But because I need the internet to download some programs, a terminal-command is asked.
Thanks.
Comment: I'd suggest you upgrade 10.04 is not supported any more except the server which does not have a GUI. Backup all your personal data then install either [Xubuntu 12.04 LTS](http://xubuntu.org/getxubuntu/) or [Ubuntu 12.04 LTS](http://www.ubuntu.com/download/desktop) depending on your hardware: Xubuntu is more like Ubuntu used to be and runs on older hardware.  You can try them both from a live USB and install the one you prefer.
Comment: You should be already connected to the internet. Try `sudo apt-get install ubuntu-desktop`.
Comment: `sakis3g` will help you to connect to the internet.
Comment: @searchfgold6789 Impressive if you can do that without an internet connection.
Comment: Maybe is time to download an the ISO and reinstall (**after doing backups**). It will be faster and bandwidth cheaper (you don't have to install all your packages to then upgrade Ubuntu)
Answer: Hit alt+ctrl+f1 and login to your system with your existing account.
All terminals are by default can access to the internet if your pc is connected. for your confirmation you can ping any server like
ping google.com

if  you get some response then you are connected to the internet. now you can download and install your required software.
Comment: +1 - internet connection is configured during boot.
Answer: You can use a text-only browser like elinks to browse in text mode via the command line.
sudo apt-get install elinks


Getting "unknown ReadRequestTimeout parameter"

Question: I've configured an apache 2.4.6 webserver, and am hardening it with the RequestReadTimeout directive. All the parameters such as header, MinRate, and body are accepted, but when I add handshake=20, then apachectl throws me an error handshake=20: Unknown RequestReadTimeout paramater. According to the apache.org doc, the handshake parameter is available in versions 2.2 and later. Any idea what I'm missing?
Comment: Why 2.4.6? You can use 2.4.46. It has more security fixes. What OS are you using?
Answer: The handshake stage is not available until 2.4.39. If you omit setting that variable, the httpd service will run as expected. Please see https://httpd.apache.org/docs/2.4/mod/mod_reqtimeout.html.


Working example of mediaelement.js flash fallback working on IE9

Question: I basically can't get mediaelement.js working on IE9 (and, apparently, even mediaelement.js' home page can't seem to do it). A friend told me to look into forcing IE9 to fall back to flash, so I was hoping to find examples. That effort was both fruitless and futile. So any example site/page that shows that is appreciated.
Answer: A little hacky, and won't work depending on what is on your page but you could do something like adding the following meta tag:
<code><meta http-equiv="X-UA-Compatible" content="IE=8" />
</code>
Which will force IE to render using IE8 standards, and hence, use flash. I know there's a better way, but if your in a jam, it's better than nothing and won't affect other browsers.
You may also check the compression of you videos/audio, as not all .mp4/.mp3 are created equal. I once had an issue where it wasn't playing in IE9, and a re-encoded video did the trick.


WMI Query returning null collection when querying Win32_Directory

Question: I'm trying to use VBScript to select all csv's in a specific folder and then concatenate them into one. I am adding all of the csv's to a collection using ExecQuery on Win32_Directory, specifying the path and the extension properties. I have five csv's in the folder to test. But the collection returned is always null.
Here's my code:
strComputer = "."
Set wshShell = WScript.CreateObject( "WScript.Shell" )
Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Options for CreateTextFile
boolOverwrite = True
boolUnicode = True

'Options for OpenTextFile
constForReading = 1
constForWriting = 2
constForAppending = 8
boolCreate = False
constTristate = -1

strPath = "C:\Users\adam\Documents\Test\Temp.csv"
strDrivePath = "C:\Users\adam\Documents\Test"

'Creates object reference to files in relevant folder.
Set objFSO = CreateObject ("Scripting.FileSystemObject")

'Creates new CSV to write others' contents to.
Set objNew = objFSO.CreateTextFile(strPath,boolOverwrite,boolUnicode)

Set colCSV = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_Directory WHERE Path = strDrivePath AND Extension = 'csv'")

'Concatenates contents of CSVs
For Each objCSV in colCSV
 Set objTemp = objFSO.OpenTextFile(objCSV.Path & objCSV.FileName & objCSV.Extension,constForReading,boolCreate,constTristate)
 Set strLine = objTemp.ReadLine
 objNew.Write strLine

Next

I am also unsure of whether the way I've specified the path for OpenTextFile is going to work or not. But my main concern right now is getting the query to return the files I want.
Thanks for any help!
Answer: You've got a few issues here.

If you want to select files, use the CIM_DataFile class. Win32_Directory is for, you guessed it, directories.
Backslashes in the Path property must be escaped (\\).
strDrivePath is a variable but you're using it literally in your WMI query.
Is your intention to run this script on a remote machine? If not, why not use the FileSystemObject methods? You already have an FSO object created.

Here is a similar question I answered in the past showing how you can use a FileSystemObject or a WMI query to find files matching a specification.
In this situation, your query might look something like this:
strFileSpec = "C:\\Users\\Adam\\Documents\\Test\\%.csv"

Set colCSV = objWMIService.ExecQuery _
 ("select * from CIM_DataFile where Name like '" & strFileSpec & "'")

But your query will run faster (often noticeably) if you specify values for Drive and Path in your statement. See my linked post for an example.
Edit: I just realized that you were the OP of the question I linked to as well!
Comment: Thanks for the help!

Yeah, I thought it was weird for Win32_Directory to be used for files. But the MSDN entry made it sound like it would work. I don't know, I'm still not too great at reading the MSDN.

I'm using WMI instead of FSO because I read a little on it, and it looks like it should be quicker for my purposes to use WMI. I'm querying in a folder that has more than just CSV's. And, from what I've read, FSO only works faster if you are selecting everything in a folder.

Either way, my code still isn't working. It isn't entering the For Each statement. But at least this gave me a start.
Comment: Actually, if you've got any idea on why it won't enter the For Each statement, that would be really nice. I've been trying to figure it out. But I can't seem to get anywhere. I've put an echo statement on either side of the For Each to make sure the query is working. I've also tried using this For Each to make sure the collection isn't the issue:

    For Each objCSV in colCSV
     wscript "A"
    Next

But it won't enter that statement either.
Comment: Try the FSO route. Really. It's _much_ easier and I can't imagine WMI would be any faster than using the FSO. `For Each objFile In objFSO.GetFolder("C:\Users\Adam\Documents\Test").Files`. That's all it takes to iterate every file in a folder. `If UCase(Right(objFile.Name, 4)) = ".CSV" Then`. One more line to test if it's a CSV.
Comment: Okay, so I changed all of the WMI stuff to this:
For Each objFile In objFSO.GetFolder("C:\Users\Adam\Documents\Test").Files
 If UCase(Right(objFile.Name, 4)) = ".CSV" Then
  Set objTemp = objFSO.OpenTextFile(objFile.Name,constForReading,boolCreate,constTristate)
  Set strLine = objTemp.ReadLine
  objNew.Write strLine

 End If

Next

But CMD returns "Runtime Error: File Not Found"
Comment: Which line is causing the error? Try using `objFile.Path` instead of `objFile.Name` in `OpenTextFile`.
Comment: Also, `Set` is only used on objects. `ReadLine` returns a string, not an object, so don't "set" `strLine`, just assign it normally.
Comment: Okay, I've taken out Set where I should. It turns out my file not found error was due to me, once again, either misreading the MSDN documentation or the documentation being wrong (which it has been on several other occasions). I did need to use Path instead of Name. So my script is nearly working now. The only issue it is having is that it doesn't write the correct text to the new CSV. It might be an encoding issue. I'll have to check that. But, thanks for all of your help! I really appreciate it!


Is there a name for the inverses of the functions (i.e for the left-unique, right-total binary relations)?

Question: The right-unique, left-total binary relations are the functions, while the  left-unique, right-total ones are their inverses. So, they are the morphisms of $\mathsf{Set}^\mathrm{op}$. Do they have a name too?
Answer: I know of no name for these more fundamental than the two you already gave, unless you view $\mathbf{Set}^\mathrm{op}$ as the category of powersets and call them homomorphisms!


Can you control what ore a drill harvests when it's placed over multiple ores?

Question: I'm trying to harvest the maximum amount of uranium possible from a small patch.  Unfortunately, there is a bordering coal patch nearby as well, and two of my electric mining drills are within range of this coal, and as such, mine some of it:

I put a chest in front of each of their outputs with a filter inserter to take only the uranium out.  But when I first fired up these drills, they mined coal, which is now sitting in their chests.  After a while, they switched to uranium.  Is it possible to control what ore it harvests? I want it to focus only on uranium.
Comment: Not to my knowledge, other than shifting them down a space so they're not in range of the coal...
Comment: I've just quickly googled to see if any mods provide this functionality, but didn't find anything. Maybe I missed something, maybe there's a mod that'll do this.
Comment: @Timmy Jim Google "splitter sorting" or ask me if you need the resources:  http://i.imgur.com/pbXyRuR.gifv (with back-up protection) Eight-lane variant: http://i.imgur.com/8sBmW0S.gifv **Note:*** You *have* to prime each of the key splitters (explained in the designers' threads) with item type for it to memorize. Just drop an item on the half you want with Z.
Comment: Why Marc, do you suggest this big crazy opposite K.I.S.S. solution? Fast filter inserters exists early on anyway.
I'm pretty sure you could easily avoid this problem in the early stages, if its a missing tech thing.
Answer: No, you cannot.
Two ways of dealing with the fact that some coal will be included with the uranium are:

Placing the uranium drill in such a manner that it does not touch coal. Note that, when you place down the miner, it shows a square around it, indicating what area will be mined.  Hovering over the miner shows what resources it covers.
Feeding the output to a belt and having a filter inserter on it, or somesuch (feeding it into a provider chest and make the robots deal with it, feed it into a chest and have a filter inserter extract only the uranium ...)

Alternatively, you could fix this problem not at the start, but at the end: feed the entire belt into your centrifuges, and have a filter inserter pick out all the coal at the end. The centrifuges will only pick out the uranium.
Comment: It is mentioned in the official forums over and over again that they will not change this behavior. The above solution with FIlter Inserters is the way to go.
Comment: @SimonForsberg Each splitter prefers to sort A and ~A (or !A). If you want to sort multiple, you need a splitter for each. You must prime them (drop the item onto the half-splitter with Z). Details here (note backlog prevention--backlog causes it to stop sorting): https://www.reddit.com/r/factorio/comments/6hm9mh/black_magic_explained_how_do_beltbased_sorters/ (see link inside). Example: https://www.reddit.com/r/factorio/comments/6hz0gw/one_belt_5_items_sorter/
Comment: There is also a third solution: https://i.imgur.com/5U9jeYF.gifv
Comment: http://i.imgur.com/8sBmW0S.gifv
Comment: @MarkC Can you please explain how on earth that works?
Comment: @SimonForsberg Here is a picture of the backup protection: Note it needs only a wire! No power required. http://i.imgur.com/pbXyRuR.gifv The two "controlled" belts per splitter on the left are the inputs. The two on the bottom (per splitter/item) are for output--presumably they disable (the upper ones) when Read:Items is larger than 6 or 7.
Comment: Using a filter inserter at the end to pick out the unwanted product is usually a bad idea. If the wanted product backs up then you can end up with unwanted product backed up behind wanted product starving the consumers.
Answer: It is now (0.16.17) also possible to set an output filter for one output lane of a splitter. This will put only items of that type on that belt, everything else on the other. Left click on the splitter to control its settings.
This is similar to the filter insert approach except that it achieves maximum throughput with a single splitter. With a filter inserter you might need multiple inserts to get the same throughput.
Answer: An alternative solution: use mining drills (electric and/or burners) to mine the coal first, then place the drills on the uranium once the offending coal has been removed. This may or may not be feasible, depending on the richness of the patch.
Comment: I think it's very rich - it would take a while to do that, but it would work. I think the best solution atm is the filter inserter method


Where do I find the settings and administration menu?

Question: In Ubuntu Unity, I can't seem to find the settings and administration menus, are they anywhere to be found?
Answer: Well, you have all your System and Administration applications on "Applications" icon on the Dock. You click on it and then select "System". It will show you your most used Apps, and under them all you your System and Admin apps.
Comment: Yes, I've found that, but it seems that not all the entries I'd usually find in the settings and administration menus is there...
Comment: Well, this is because they are a bit minimized (I think, I do not use Unity). Try to execute "alacarte" on Terminal. And enable or disable the àpps you want to see in every section of applications.
Comment: Yes, there I can move elements from the System menus to the applications menu. That solves the problem.


UI page for editing and maintaining Profile settings for a User

Question: In asp.net Webforms apps, is there not any kind of maintenance UI page to edit and maintain the Profile properties of a User (I'm using VS2008 and the Web Application template), like in the WSAT Web Site Administratration Tool where you already can edit the basic Membership and Role properties for a User? I'm using the basic SQL Express data tables and the basic Membership and Role providers, and now I want to begin using the Profile provider to store and access additional properties for each User I create an account for. For instance, when I create a new User and assign them to a Role(s) on my web app, I use the WSAT tool, and now I also need to set certain Profile properties for them too. Is the only way to set these properties is programmatically? Surely there is an Admininstrative type of UI page for this so you can quickly view and edit Profile properties for a User.
Answer: Roles and Membership conform to a standard schema that you can easily create a static form for editing. Profile details are dynamic based on your configuration settings - and building dynamic forms can be a bit tricky.
On top of that, the default Profile provider stores all the profile information in one concatenated field, so you'd end up with a list of comma-separated values if they went for a really basic form.


Client-side http connections in webpage without domain restriction

Question: I would like to make a webpage where the user browser would have to download data like with Ajax but without domain restrictions. I don't care about the technology. Flash, Java, whatever. Is it possible?
Comment: Domain restrictions are there for a purpose. What do you think would happen if browsers would allow loading data from everywhere?
Comment: So, it's impossible in every technology?
Answer: Assuming you don't have control of the other servers and access control is not an option, one common way is to have a proxy on your own server. Can be as simple as a PHP script
$handle = fopen($_GET['url'], "rb");
while ( !feof($handle) ) {
    echo fread($handle, 8192);
}
fclose($handle);

that is used in proxy.php?url=http://example.com/data/ fashion.
Comment: No, I want the clients to download it so the server doesn't have to.
Comment: As halfdan noted, the restrictions are there for a reason. By using a proxy, the requests to the external server will be coming from your server, making it easy to block.
Answer: Yes it's possible.
When fetching data with ajax, the domain doesn't matter because it's simply an independent http-request. It's as if you would be typing the url in a new browser tab, but in the case of ajax, your browser handles these requests automatically.
This is similar to what happens to images, scripts, css files, ...
(I use php5 and jquery for my apps)
Comment: I believe you are wrong since cross domain policy applies to http requests


Software updater not working

Question: The following error occurred while opening software updater/Ubuntu software center/sypnatic package manager/software sources.
E:Encountered a section with no Package: header,
E:Problem with MergeList /var/lib/apt/lists /ppa.launchpad.net_atareao_atareao_ubuntu_dists_quantal_main_i18n_Translation-en,
E:The package lists or status file could not be parsed or opened.

How to solve this problem?. Any help please.
Answer: After digging many sites now I have solved the problem with the following commands in terminal. Hope this may help someone who is having the same error message.
1. sudo rm /var/lib/apt/lists/* -vf
2. sudo apt-get update
3. sudo apt-get upgrade

Software updater not working


What are Visual Studio project references?

Question: I came across the Framework and References tab of my project and noticed that I can "Add New Reference..." to my project, what is this functionality?
Comment: It is important when you write code in the C++/CLI language.  Not to be confused with the C++ language.
Answer: For C/C++ in Visual Studio 2010 Express, adding a project reference (see first image, text in German, but you get the idea) adds a node as follows to the .vcxproj file:
<ItemGroup>
  <ProjectReference Include="..\Ws1Lib\Ws1Lib.vcxproj">
    <Project>{22c9de39-f327-408b-9918-187c0ee63a86}</Project>
  </ProjectReference>
</ItemGroup>

This will make the static library produced by the referenced project available to the referencing project and also add a non-removable project dependency (right-click the project and select project dependencies, see second image) to the referencing project.
(The effect of such click actions on project configuration files become apparent when you put the project configuration files under version control and then look at the diff.)
To create setup where one or more projects reference a static library project, see this MSDN guide:
Walkthrough: Creating and Using a Static Library (C++)
Answer: References are used to pull additional libraries into your project. For example, when you're creating a Windows project, you'll be using Windows forms, XML parsers, socket libraries, and lots of other useful stuff. Now, you could create all these from scratch, but that would be an insane undertaking. Instead, you can use libraries which have been pre-built, such as System.Windows.Forms (all the form stuff), System.Xml (XML parser stuff) and others.
Down at the low level, these are all DLL files precompiled by Microsoft and distributed along with Visual Studio. Add Reference allows you to add new ones of these to your project, for example, Managed DirectX for 3D isn't something which is commonly used, so must be manually added to a project.
I've also just noticed the C++ tag on this, so this may actually sound very patronising (as I may have gotten the scope of the question wrong), in which case, I didn't mean it. For C++, it will be used for C++/CLI, which is Microsoft's attempt to allow C++ to use the .NET framework.
Comment: So if I am understanding you correctly: it just links static libraries (which have already been built) to my current project during linking?

How does this differ from adding the .lib for the linker input settings of the project.
Comment: Aha, so you're linking native libraries. In which case, my post probably does seem very patronising, so sorry about that. References are basically just the .NET way of doing what you asked, and is used for C++/CLI. It has nothing to do with static libraries (and references are still used as dynamic libraries).
Comment: See Lumi's answer; the references are used by the project system for native C++ projects.


C# static vs instance methods

Question: I'm risking it this might be a newb question but here goes. I'm tempted to add a method to a class that could possible have thousands and thousands of instances in memory at a given time. Now, the other option is creating a static class with a static method, and just create the [static] method there, instead of an instance method in the class. Something like so:
This:
public static class PetOwner
{
    public static void RenamePet(Pet pet, string newName)
    {
        pet.Name = newName;
    }
}

Instead of this:
public class Pet
{
    public string Name { get; set; }

    public void Rename(string newName)
    {
        this.Name = newName;
    }
}

I'm just wondering if the static class alternative would take considerably less memory.
Thanks!
Comment: Take a look at some of the answers to [this question](http://stackoverflow.com/questions/169378/c-method-can-be-made-static-but-should-it).
Answer: Only data fields require storage per instance, subject to certain conditions and optimisations. For instance, 10,000 instances of a class that define an Int32 member will consume ~40,000 bytes of memory.
Strings, on the other hand, are not so simple due to interning. You can try this as an example:
object.ReferenceEquals("", string.Empty) // returns true!

If the same 10,000 instances also define a string, and that string is the same for each instance, then you're going to have 10,000 references pointing at the same data, reducing overhead considerably (but in a 32-bit environment, there's another 40,000 bytes taken up by the references).
Methods, as pointed out by others, whether static or instance, are only loaded once.
The decision to use either instance or static methods is not influenced by performance reasons, but by how the method is intended to be used. In your case, the method requires an instance of the type as its first parameter so it may as well be an instance method.
Static methods, in my experience, are most useful as an alternative to a type's constructor for returning a new instance. Constructors, once invoked, have to either return a new instance or throw an exception, which may not be desirable. Static methods can return null if something fails, or return a cached instance (the latter of which is useful if the constructor is an expensive operation).
Comment: Joe: not all string get interned, that particular example is bad imo
Comment: Note that it's only in the recent versions of the compiler that `""` and `String.Empty` is the same instance. In earlier versions they were separate.
Comment: I didn't say all strings were interned, and I thought it was a good example of the point I was trying to make.
Answer: Methods only exist once in memory, regardless if they are static or not, so there is no difference at all in memory usage.
Comment: In fact all method calls effectively behave like your static call. The details are just hid behind the scenes.
Comment: Extension methods are a pretty good example of this. The only difference being that they are defined against another class and don't have access to protected/private members of the instance.
Comment: Generic methods are jitted once per generic signature, so those will exist more than once though...
Comment: @RogerAlsing: Yes, but there is no difference between instance methods and static methods there either.
Answer: In addition to Guffa's answer:

Methods only exist once in memory,
  regardless if they are static or not,
  so there is no difference at all in
  memory usage.

The instance method has a class instance passed to it as an invisible(which can be explicitly accessed through this) parameter, essentially making the newName of void Rename(string newName) a second parameter passed to your instance method; thus the resulting burned instructions for static void RenamePet(Pet pet, string newName) and void Rename(string newName) look essentially the same, so they has no differences on performance or whatsoever
Answer: It doesn't make a difference, methods (static or instance) are only loaded once into memory and JIted, they don't consume more memory just because they are instance methods.
Answer: The amount of instances of a class, does not effect how much memory the method uses.
Answer: With respect to memory static and instance methods are same except the fact that instance methods can contain data members where as static methods can have only static data members.
Answer: In case of memory it doesn't make any difference,Methods exist only once in the memory regardless of being static or instance but static methods are minutely faster to invoke than instance methods because Instance methods actually use the 'this' instance pointer as the first parameter, so an instance method will always have that overhead
So static methods have little advantage over instance methods in case of performance but for memory usage they both use same amount.
Comment: I read this so often and it doesn't make sense to me. If an instance method does access the instance then an equivalent static method will have the same number of parameters
Answer: You don't need a method "Rename" at all; you already have one, it's the setter of the Name property.  Instance methods do not require more and more memory on a per instance basis, that would be silly.
Don't make design decisions like this before profiling your code.  Adding an instance method to a class is not going to cause a performance bottleneck, and even if it did, you shouldn't start out with a bad design based on a guess; prove it is a bottleneck and make adjustments as necessary.
Comment: This should be a comment, not an answer.
Comment: @Shimmy: No, it *is* the answer, it's just not what the OP expected.  Just because you can only think of one solution doesn't mean better options don't exist.  Methods don't require per instance memory, so the entire basis of the question is faulty.

C# static vs instance methods


Java - Applet - Reading the file hosted in the same directory as applet class

Question: My applet has this code snippet (basically reading from the file in the same directory).
Scanner input = new Scanner(getClass().getResourceAsStream(a_file_name));

I am playing with Applets to see how to read file that is hosted on the server (or kept in the same directory as *.class file locally).

I chose the java class in Eclipse and selected "Run As Applet". I am able to read the file  (which is kept in the workspace/bin directory). So, it worked fine.
I hosted the (*.class file; *.txt file and the *.html) file on a remoter server. Gave complete permission to the URL by adding it to the safe list in "Configure Java". I am able to read the file. So, it worked fine.
Then I launched the *.html file locally on my machine (Again, I gave the complete permission to the URL by adding it to the safe list in "Configure Java").And *.html, *.txt file and *.class file are in eclipse workspace project bin directory. However, it is not working. The code below is throwing an exception.
Scanner input = new Scanner(getClass().getResourceAsStream(a_file_name));
Case [1]: There is no such thing as safe URL because I am launching from Eclipse (Run as Applet)
Case [2]: The safe URL starts with http://
Case [3]: The safe URL starts with file:///D:/apps/eclipse/workspace/AppletSnippet/bin/index.html

Can you throw some light on why it is not working in Case [3]?
By the way, here is the exception I am getting in case of [3]
java.lang.NullPointerException
    at java.io.Reader.<init>(Unknown Source)
    at java.io.InputStreamReader.<init>(Unknown Source)
    at java.util.Scanner.<init>(Unknown Source)
    at AppletSnippet.readFromTextFile(AppletSnippet.java:46)
    at AppletSnippet.init(AppletSnippet.java:100)
    at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

Comment: *"Can you throw some light on why it is not working in Case [3]?"* Because it is throwing an exception.  Speaking of which, ***always copy/paste error or exception output.***
Comment: Don't put a stack trace in comments where it is unreadable, edit it into the question (and use code formatting).
Answer: OK. The problem is solved.
I just have one single *.class and a text file it is reading *.txt.
Case 1 (Running from Eclipse as an Applet) and Case 2 (Running from Remote Server) -- these options do NOT have any issue with it.
However, in Case 3, if I were running it locally by opening the HTML file,  getClass().getResourceAsStream(a_file_name) is returning NULL.
So, I created a *.jar file with that *.class and *.txt file; And specified the ARCHIVE attribute in my HTML.
Then Case 3 is also working.
Thanks


How to find browser app settings using AngularJs or Other JavaScripts?

Question: I am trying to create a form which should work in the browsers on mobile devices (e.g. Safari on iOS, Chrome on Android, IE on Windows Mobile).
I've heard that starting from iOS8 it should be possible to upload from the image gallery on the phone/ipad or use the camera to take a photo, however the user needs to give permission for this and when he has refused this before (on a different site) it won't work until he changes his settings.
Is there any way to detect that the user has disabled this setting.
Tried Several things with the help of below JavaScript plugins:
https://github.com/muaz-khan/DetectRTC
The below link shows how to detect OS, browser & device :
https://github.com/srfrnk/ng-device-detector/blob/master/ng-device-detector.js
But no luck :(. How can I detect the settings of browser/ native app, if user didn't allow to access the storage/file media ?
I don't want to use any framework, like Ionic or Cordova ?
Just want to implement in simple Javascript.
Comment: Please read [How do I ask a good question](http://stackoverflow.com/help/how-to-ask) and [What topics can I ask about here](http://stackoverflow.com/help/on-topic).
Comment: @KhalidHussain Thanks for your suggestion. Any help on the scenario ?
Comment: Since you are using Angular already, [take a look at this one](https://angular-file-upload.appspot.com/)... It does have capture functionality for mobile.
Answer: I tried using the input file to upload via iOS 9, and it worked fine without giving me the option to prevent this from happening again. I can't find a way to replicate your concern.
Why do you want to detect the settings? What is it you're trying to do? Provide a helpful message or something? I can't imagine it being possible to access a user's private settings just via JavaScript. That doesn't sound secure at all.
You can try testing if the file input is even supported, e.g.
File Upload Support On Mobile
 (same code on Modernizr)


Boot failure after upgrading to Ubuntu 15.04

Question: I have Sony Vaio Fit computer with a dual boot setup of Windows 8 and Ubuntu 14.10.
After upgrading to 15.04, booting into Linux fails with a number of 'builtin file not found' errors.
I tried toggling Secure Boot but that doesn't help.
The boot-repair info is at http://paste.ubuntu.com/12101145. If anybody has a suggestions, I would appreciate.
TIA
Comment: Can you get to grub ( OS selection screen ) ?
Answer: Maybe grub is configured badly:
Create a super grub2 disk (http://www.supergrubdisk.org/super-grub2-disk/) usb drive.
Boot from the usb drive and try to start ubuntu.
If it works, run   update-grub and try booting without the usb drive.


Basic truss design for outbuilding

Question: I am building a small outbuilding (wood-fired sauna) that is 8 feet by 16 feet.  The design is based off a friend who made a similar structure, just four feet shorter.
For the roof trusses, he used 2x6s for the top chords cut at 45 degrees (12:12 slope) and then a 2x4 braced to one side.  This 2x4 sits on top of the walls' top plates.  The nine total trusses will be at 24 inches OC.  We live in southern Wisconsin in the US, so we see a fair share of snow but nothing like what they see even an hour north.

This avoids the birds mouth cuts, which is great, but I haven't seen anything like this in the internet research I've done -- most of what I've found uses birds mouths or something similar to the below picture (minus the king post), and always 2x4s for the top chords.  Is my friend's design good enough to roll with or should I reconsider?
Comment: Technically speaking, a king post does more-or-less nothing, from what I recall of truss theory. For a sauna, I'd suggest doing a "high-heel" or "raised heel" truss that adds depth at the wall so you can put lots of insulation in - or else build the walls a foot higher and drop the ceiling joists down in the walls for the same purpose. You don't want that thin spot in the insulation.
Comment: The point wasn't about access--you can insulate from above before you close the sheathing--but about heel height. if you want R38 you won't fit it with a basic rafter situation.
Comment: Good point, but I'm not sure I'd want a ton of insulation in a wood-fired building of that size. You'll have an oven.
Comment: @Ecnerwal my friend said that the steep roof gave him enough room to crawl in and lay insulation.  He made a small hatch that he could crawl into on one of the outer trusses.  Says he needs to watch his beer intake or else one day he won't be able to fit :)
Comment: @isherwood gotcha.  I'll probably just put up 3.5" of mineral wool (R-15) and however much else I can fit on top of that without sacrificing airflow.  And a big oven is basically when I'm striving for :)
Comment: Yeah, "crawl in" to insulate is _nuts_! Insulate before you put the finished ceiling on
Comment: If the king post is not used, you might consider adding a collar tie near the top.
Comment: No collar tie is needed for such a tiny building. The rafter tie is more than adequate.
Comment: @isherwood: _"I'm not sure I'd want a ton of insulation in a wood-fired building of that size"_ -- sure you would. More insulation is always better. No reason to let the building get too hot (though, for a sauna you're going to want it pretty warm). Just means you get to burn less wood for the same temperature.
Answer: For small buildings like this I'm not a load calculations guy. I'm a seat-of-the-pants experience guy. This is because lumber is usually grossly oversized for such short spans anyway, so it comes down to your carpentry techniques.
Yes, that design is plenty stout from a lumber standpoint (even 2x4 rafters are plenty), but you must fasten the joints together very well. Due to the steep nature of your roof and the lack of direct rafter bearing (without a bird's mouth cut) there's a lot of shear force on that connection. Nearly all the roof load gets carried by the fastening.
I might use three 2-1/2" construction screws from each side of each joint. For a lesser sloped roof with 2x4 rafters I've even used timber screws through from the top into the wall plate (with countersunk heads). Ecnerwal rightly points out that construction adhesive is a good idea here. I've used it for OSB gussets. It'll add a lot of rigidity to the connection.
Whatever you decide, it needs to be stout. If you bounce your weight on the peak and there's any flex at all in the joints it's not good enough. Do that right and you'll be golden.
One other tip: Build all trusses from the same prototype (jig) and mark the ends so they stay oriented. Trusses are rarely perfect and if you swap ends with any you'll have a wavy roof and fascia.

Basic truss design for outbuilding


What do I miss if I buy Monster Hunter: World late?

Question: Recently I have tried Monster Hunter: World on my friend's PS4 and am really hooked on it. I am planning to buy the PC version yet I noticed (at least in the PS4 version) that there are many time limited events ending in the past e.g. the recent Witcher collaboration.
Am I missing out something important if I start playing the MH:W PC version now or later? If so, what would I miss? Ultimately, would this impact my game experience?
Answer: You won't miss anything whatsoever, if you're willing to play long enough.
The time limited events you mention are a set of quests that periodically rotate in and out of availability, according to this schedule. New event quests are still being added to the PC version, while older event quests are made playable after their original release.
In addition, every event quest is made available during time-limited festivals, lasting 3 or 4 weeks during certain parts of the year. The next such festival is the Spring Blossom Fest, which is coming on April 26.
Comment: @Nzall Yes and no. On PC, the Witcher collaboration event hasn't happened yet. On consoles, there are two parts two the Witcher collaboration: a single-player quest permanently added to the base game, and a rotating, multiplayer event quest that will come back in the future. Nothing is missed by starting to play now in either case.
Comment: As of May/2020, PC and console versions are on par, and nothing is missed. Limited events, as previously answered, keep coming back during holidays and the likes.
Comment: So the Witcher event will also return?


200A 240V Electric Panel Clearance

Question: I am installing an electric panel. NEC 110.26A providing for 30" x 36" x 6'6" is met EXCEPT for the main water supply line which will runs against the wall and underneath it at floor level. There is no other equipment. Is there no way around this problem?
@ThreePhaseEel Surface mount. I thought about rerunning the pipe over the panel to clear the 6'6". But the idea of putting a water line above the panel is just wrong!
Comment: Going directly under or over is going to  give problems with 110.26(E)(1)(a), depth and width of panel from floor to 6 ft. above panel or structural ceiling.
Comment: Is this a surface-mounted or a flush-mounted panel?
Comment: Surface mount panel
Comment: What sort of wall construction is the panel mounted to?
Comment: @ThreePhaseEel Brick
Answer: This requirement is to provide a good clean standing area when accessing it.
If the inspector would give you flack for it (call them in advance whether they would) you can build out the bit of wall the electric panel is mounted to such that the water line is actually under the panel inside the wall instead of in front.
Comment: I may mount a backing plate first so that the panel is never actually "over" water line!

200A 240V Electric Panel Clearance


Architectural issue with Tomcat cluster environment

Question: I am working on project in which we have an authentication mechanism. We are following the below steps in the authentication mechanism.

The user opens a browser and enter his/her email in a text box and click the login button.
The request goes to a server. We generate a random string (for example, 123456) and send a notification to the user's Android/iPhone and makes the the current thread wait with the help of the wait() method.
The user enters a password on his/her phone and clicks the submit button on his/her phone.
Once the user clicks the submit button, we are making a webservice hit the server and passing the previously generated string (for example, 123456) and password.
If the password is correct against the previously entered email, we call the notify() method to the previously waiting thread and send success as the response and the user gets entered into our system.
If the password is incorrect against the previously entered email, we call the notify() method to the previously waiting thread and send failed as the response and display an invalid credential message to the user.

Everything is working fine, but recently we moved to a clustered environment. We found that some threads are not notified even after replied by the user and for an unlimited waiting time.
For the server, we are using Tomcat 5.5, and we are following The Apache Tomcat 5.5 Servlet/JSP Container for making tomcat cluster environment.
Answer :: Possible problem and solution
The possible problem is the multiple JVMs in a clustered environment. Now we are also sending the clustered Tomcat URL to the user Android application along with generated string.
And when the user clicks on the reply button, we are sending the generated string along with the clustered Tomcat URL so in this case both requests are going to the same JVM, and it works fine.
But I am wondering if there is a single solution for the above issue.
There is a problem in this solution. What happens if the clustered Tomcat crashes?  The load balancer will send a request to the second clustered Tomcat and again the same problem will arise.
Comment: This seem to me like a netbanking solution when the user receives an additional password (OTP) and using his regular password and the OTP can log in. Why is it necessary to login via the phone?
The click in the email can redirect him to a login page where he can type in his regular password and the OTP which will arrive meantime to his phone. This way no need for wait/notify.
Comment: @Andras Kerekes: It was presumptions that login can be done by password, by face authentication, by voice authentication, by fingerprint authentication that can be done on phone and not on web-app. so in this way our authentication system will be more mature and there is no password kind of thing over the net so we are more safe. and in future we plan to make authentication system for third parties as a plugin.
Comment: In this case the login page where he entered his email address could periodically query the server if the login was successful/failed via the phone.
I don't think it is a good idea to keep the app server worker threads in wait state. In case of many users the application can  become unresponsive due to lack of worker threads.
Answer: The underlying reason for your problems is that Java EE was designed to work in a different way - attempting to block/wait on a service thread is one of the important no-no's. I'll give the reason for this first, and how to solve the issue after that.
Java EE (both the web and EJB tier) is designed to be able to scale to very large size (hundreds of computers in a cluster). However, in order to do that, the designers had to make the following assumptions, which are specific limitations on how to code:

Transactions are:

Short lived (eg don't block or wait for periods greater than a second or so)
Independent of each other (eg no communication between threads)
For EJBs, managed by the container

All user state is maintained in specific data storage containers, including:

A data store accessed through, eg, JDBC. You can use a traditional SQL database or a NoSQL backend
Stateful session beans, if you use EJBs. Think of these as Java Bean that persists its fields to a database. Stateful session beans are managed by the container
Web session This is a key-value store (kinda like a NoSQL database but without the scale or search capabilities) that persists data for a specific user over their session. It's managed by the Java EE container and has the following properties:

It will automatically relocate if the node crashes in a cluster
Users can have more than one current web session (i.e. on two different browsers)
Web sessions end when the user ends their session by logging out, or when the session is inactive for longer than the configurable timeout.
All values that are stored must be serializable for them to be persisted or transfered between nodes in a cluster.

If we follow those rules, the Java EE container can successfully manage a cluster, including shutting down nodes, starting new ones and migrating user sessions, without any specific developer code. Developers write the graphical interface and the business logic - all the 'plumbing' is managed by configurable container features.
Also, at run time, the Java EE container can be monitored and managed by some pretty sophisticated software that can trace application performance and behavioural issues on a live system.
< snark >Well, that was the theory. Practice suggests there are pretty important limitations that were missed, which lead to AOSP and code injection techniques, but that's another story < /snark >
[There are many discussions around the 'net on this. One which focuses on EJBs is here: Why is spawning threads in Java EE container discouraged? Exactly the same is true for web containers such as Tomcat]
Sorry for the essay - but this is important to your problem. Because of the limitations on threads, you should not block on the web request waiting for another, later request.
Another problem with the current design is what should happen if the user becomes disconnected from the network, runs out of power, or simply decides to give up? Presumably you will time out, but after how long? Just too soon for some customers, perhaps, which will cause satisfaction problems. If the timeout is too long, you could end up blocking all worker threads in Tomcat and the server will freeze. This opens your organisation up for a denial of service attack.
EDIT : Improved suggestions after a more detailed description of the algorithm was published.
Notwithstanding the discussion above on the bad practice of blocking a web worker thread and also the possible denial of service, it's clear that the user is presented with a small time window in which to react to the the notification on the Android phone, and this can be kept reasonably small to enhance security. This time window can also be kept below Tomcat's timeout for responses as well. So the thread blocking approach could be used.
There are two ways this problem can be resolved:

Change the focus of the solution to the client end - polling the server using Javascript on the browser
Communication between nodes in the cluster allowing the node receiving the authorization response from the Android App to unblock the node blocking the servlet's response.

For approach 1, the browser polls the server via Javascript with an AJAX call to a web service on Tomcat; the AJAX call returns True if the Android app authenticated. Advantage: client side, minimal implementation on the server, no thread blocking on the server. Disadvantages: During the waiting period, you have to make frequent calls (maybe one a second - the user will not notice this latency) which amounts to a lot of calls and some additional load on the server.
For approach 2, there is again choice:

Block the thread with an Object.wait() optionally storing the node ID, IP or other identifier in a shared data store: If so, the node receiving the Android app authorization needs to:

Either find the node that is currently blocking or broadcast to all nodes in the cluster
For each node in 1. above, send a message that identifies the user session to unblock. The message could be sent via:

Have an internal-only servlet on each node - this is called by the servlet performing the Android app authorization. The internal servlet will call Object.notify on the correct thread
Use a JMS pub-sub message queue to broadcast to all members of the cluster. Each node is a subscriber that, on receipt of a notification will call Object.notify() on the correct thread.

Poll a data store until the thread is authorized to continue: In this case, all the Android app needs to do is save the state in a SQL DB
Comment: Added the concept of an in-memory cross-jvm cache such as Terracotta - thanks Luigi R. Viggiano
Comment: Really helpful, I have suggested both the approach to my senior manager let see what the decision comes from senior manager or architecture. We are very thankful to you and the stackoverflow community.
Comment: I really appreciate your efforts. After reading the answer one thing is clear the design is not correct and my server will freeze. Please write me some solution to above question. I am going to modify my question and writing the steps we are following in our application. Probably you can get more information about exact use-case.
Comment: Great -  got the feedback.It's midnight here now so I'm not in the best state to answer. I'll do so hopefully in the next 12 hours.
Comment: Improved details on the implementation of a solution
Comment: And yes a +100 to you, Thanks @Andrew Alcock again, Happy new year in advance.
Comment: Cheers and a Happy New Year to you and your team.
Answer: Using wait/notify can be tricky.  Remember that any thread can be suspended at any time.  So it's possible for notify to be called before wait, in which case wait will then block for ever.
I wouldn't expect this in your case, as you have user interaction involved.  But for the type of synchronisation you are doing, try using a Semaphore. Create a Semaphore with 0 (zero) quantity. The waiting thread calls acquire() and it will block until another thread calls release().
Using Semaphore in this way is much more robust that wait/notify for the task you described.
Answer: After analysing your question, I came to the conclusion that the exact problem is of multiple JVMs in a clustered environment.
Answer: The exact problem is because of the cluster environment. Both requests are not going to the same JVM. But we know that a normal/simple notify works on the same JVM when the previous thread is waiting.
You should try to execute both requests (first request, second request when the user replies from an Android application).
Answer: Your clustered deployment means that any node in the cluster could receive any response.
Using wait/notify using threads for a web app risks accumulating a lot of threads that may not be notified which could leak memory or create a lot of blocked threads. This could eventually affect the reliability of your server.
A more robust solution would be to send the request to the android app and store the current state of the users request for later processing and complete the HTTP request. To store the state you could consider:

A database that all tomcat nodes connect to
A java cache solution that will work across tomcat nodes like hazelcast

This state would be visible to all nodes in your tomcat cluster.
When the reply from the android app arrives on a different node, restore the state of what your thread was doing and continue processing on that node.
If the UI of the application is waiting on a response from the server, you might consider using an ajax request to poll for the response state from the server. The node processing the android app response does not need to be the same one handling UI requests.
Comment: Thanks @pd40 for reply. We designed application using ajax and database approach but this was rejected by client. Saying "lots of unnecessary hit to database as well as server and the response will not be real time". Then we come to wait and notify solution, this approach is real time and no unnecessary hit to server as well as database. But problem is load on server increases as we are waiting threads on server for 40 seconds and secondly multiple JVM issue.
Comment: I don't clearly understand your explanation. With threads waiting the client still need to hit server, doesn't it? So how else does your customer imagine it working without touching the servers?
Comment: The threads are not waiting in this solution. The state is persisted until the android app responds. Any UI waiting on the android app would poll for a response.
Comment: @pd40 For android app we are using google cloud messaging mechanism(GCM) similarly for iPhone also. So we have push mechanism for sending notification to user phone and not pull mechanism.
Comment: I have modified my question and added more steps and details so that the use case and requirement can be easily understand by community.
Answer: Consider using an in-memory grid so that the instances in the cluster can share state. We used Hazelcast to share data between instances so in case a response reaches a different instance it still can handle it.
E.g. you could use distributed countdown latch with value of 1 to set the thread waiting after sending the message, and when the response arrives from the client to a separate instance it can decrease, that instance can decrease the latch to 0 letting to run the first thread.
Answer: Using Thread.wait in a web service environment is a colossal mistake. Instead, maintain a database of user/token pairs and expire them at intervals.
If you want a cluster, then use a database that is clusterable. I would recommend something like memcached since it's in-memory (and fast) and low on overhead (key/value pairs are dead simple, so you don't need RDBMS, etc.). memcached handles expiration of tokens for you already, so it seems like a perfect fit.
I think the username -> token -> password strategy is unnecessary, especially because you have two different components sharing the same 2-factor authentication responsibility. I think you can further reduce your complexity, reduce confusion for your users, and save yourself some money in SMS-send fees.
The interaction with your web service is simple:

User logs into your website using username + password
If primary authentication (username/password) is successful, generate a token and insert userid=token into memcached
Send the token to the user's phone
Present "enter token" page to the user
User receives token via phone and enters it into the form
Fetch the token value from memcached based upon the user's id. If it matches, expire the token in memcached and consider the second-factor successful
Tokens will auto-expire after whatever amount of time you want to set in memcached

There are no threading problems with the above solution and it will scale across as many JVMs as you need to support your own software.
Comment: Thanks for effort. User can only enter his/her email from website there is no password on webpage. and when we send notification to user android/iPhone then we match password by many ways like face authentication, voice authentication, fingerprint authentication or simply text password. But the term password or matching is only on user's phone. This the beauty or feature of our application "password less authentication on web app."
Answer: I'm afraid, but threads cannot migrate over classic Java EE clusters.
You have to rethink your architecture to implement the wait/notify differently (connection-less).
Or, you may give it a try with terracotta.org. It looks like this allows to cluster an entire JVM process over multiple machines. Maybe it's your only solution.
Read a quick introduction in Introduction to OpenTerracotta.
Answer: I guess the problem is, your first thread sends a notification to the user's Android application in JVM 1 and when the user reply back, the control goes to JVM 2. And that's the main problem.
Somehow, both threads can access the same JVM to apply wait and notify logic.
Answer: Solution:
Create a single point of contact for all waiting threads. Hence in a clustered environment, all the threads will wait on a third JVM (single point of contact), so in this way all the requests (any clustered Tomcat) will contact the same JVM for waiting and notify logic and hence no thread will wait for an unlimited time. If there is a reply, then the thread will be notified if the same object has waited and is being notified the second time.
Comment: It is not good practice to spawn threads inside a JEE container such as Tomcat - that is what the JEE container is for. Those extra threads are not controlled by the container, can cause the container to fail to shut down, will not be restarted by the container and cannot be moved to other members of the cluster. Use other JEE mechanisms instead: session persistence or a data store.


Can I simply copy the mysql database folder in /var/lib/mysql/ to backup the database?

Question: As mentioned in the subject, my question is whether I can simply copy the mysql database folder in /var/lib/mysql/ to backup the database? Would this cause issues anyhow?
Obviously the idea is to add the backup folder back into the server in case of data loss.
Thanks in advance.
Regards.
Answer: seem you can if your purpose it's to restore quickly mysql installation but i don't know exactly how much feasible could be in terms of space compared to simples automatic procedure for backup . ( you have a lot of alternative , for example with crontab you can see this crontab )
Comment: Actually i am using crontab, the crontab copies that folder to another server

if the database on server1 would fail, i would copy that mysql folder from server2 to server1
Comment: maybe you can compare with the simple backup dump zipped solution : mysqldump -u root -p --all-databases | zip //db-$(date +\%F-\%T).zip


Select input where click event scrolls through set of defined values rather than opening up a drop down

Question: I need to create a form element that does the same as <select> however from a UX perspective I simply want to be able to click/tap (preferably cyclically) through the set values (of which there will be four). So instead of the click opening up a drop down, it simply changes to the next value. Staying away from the UI imposed by the <select> tag is also important.
Answer: If you want, use Javascript or jQuery to define an array with those values.
On click/tap, increment the index corresponding the selected value that from array. And when the index is array.length-1 (last one), reset it to 0.
Also, don't forget to assign the current array[index] value to your element. It can be a text input or a div.
Answer: you could do something like that.
you create array with your values, and on click cycle through its values
           var array = [ 'value1', 'value2', 'value3', 'value4' ];

            $('#input').click(function(e){
                        var currValue = e.currentTarget.value;
                        var valueIndex = array.indexOf(currValue);
                        var arrayLength = array.length-1;

                        if(valueIndex != arrayLength)
                        {
                           $('#input')[0].value = array[valueIndex + 1];
                        }
                        else
                        {
                            $('#input')[0].value = array[0];
                        }
             })

Comment: A bit confusing naming the variable array since it is an array, but this worked, thanks.
Comment: This works well until I try to reset the form, the values don't scroll in the correct order and occasionally a field will get stuck on one value?
Comment: please make a fiddle or at least show some code... cant tell what the problem could be without seeing code


Vue.js 2 pass data from component to root instance

Question: I have a component that makes an AJAX request. In the callback function I want to pass a value back to the parent or root instance.
So my callback function for example in the component is:
function callbackFunc(vm, response){
  vm.$emit('setValue', response.id);
}

and in my root instance I've tried using a method called setValue like this:
export default {
  name: 'app',
  data () {
    return {
      value : ''
    }
  },
  methods: {
    setValue: function(value){
      console.log(value);
    }
  }
}

This doesn't work. The documentation seems to say you need to have an event inside the template for it all to get hooked up but that's not going to work in this case.
Any ideas?
Cheers!
Comment: Can you show a bit more code? How is your callback getting called etc.
Comment: It's literarly just a function on it's own in the global scope. vm is a reference to the vue instance so that $emit can be called.
Comment: If it's in the global scope, why not just something like `const app = new Vue(...)` and in `callbackFunc` use `app.setValue(response.id)`.
Comment: Updated my question with the full root instance. How would I get it to work with that? Cheers!
Comment: Possible duplicate of [Vue.js what's the difference of $emit and $dispatch?](https://stackoverflow.com/questions/40923555/vue-js-whats-the-difference-of-emit-and-dispatch)
Comment: You need to use your component.$on("setValue") (setValue being the event you just emitted) and call your own method from this one.
Comment: Cheers, I don't follow that. Can you expand your answer a bit?
Comment: I really can't picture your structure here. You said the ajax call is made in a component, but the callback is in the global scope, and it looks like you are using single file components.
Comment: Yes the ajax call is made in a component, the ajax call's callback function is placed in the global scope. I'm using a vue-cli template so each "page" is using it's own component.
Comment: And the callback is defined in the same file as the component that is making the ajax call or in the main.js? `vm` is the component?
Comment: You may want to use Vuex to share the data with other components.
Comment: Same file as the component. To be honest I'm probably getting myself confused with the vue-cli project structure.
Comment: Is the component a direct child of the app component?
Comment: See this is where I'm confused. I'm using vue-router. So there's the root element that has an App component and then there's the component called Hello which has the ajax call.
Answer:
I'm using vue-router. So there's the root element that has an App
  component and then there'sthe component called Hello which has the
  ajax call

In the parent component's template you will have a <router-view><\router-view> which is where the vue-router will put your child. To wire everything up, you need to add the directive to the template:
<router-view v-on:setValue="parentMethod" ><\router-view>

When the child calls $emit("setValue") after the ajax call, it will triggers parentMethod() on the parent. It's not clear why you say it won't work to hook it up in the template. Without the template, there's not really a parent/child relationship.
Comment: Cheers! Trying this now. I'm getting: Property or method "parentMethod" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
Comment: Sorry I fixed that. Amazing, that works! Thank you! I understand what's going on better now. I thought I needed to have it binded to like a click event or blur or something. Thanks again!
Comment: Sorry - that wasn't clear. I meant `parentMethod` in a generic method on your parent. You need to write this method on your parent and call it something like parentMethod or even `setValue()` The template is telling your parent component to listen for the event `setValue` and then call some method on the parent.
Comment: Glad it's working. In Vue and also (Angular) getting the parent/child one-way communication took me a couple tries before it 'clicked'
Comment: Yeah that was crazy confusing for me! Thanks again!
Comment: One hopefully quick follow up question. If I want to get the value I set in the parent component in another child how would I do that?
Comment: You pass data from parent to child with props. So you would have something like `` Then in the child you would pick it up by defining props with ` props: ['data']` which you can then use like an instance variable.  Had to explain in this little space, but good examples here:  https://vuejs.org/v2/guide/components.html#Passing-Data-with-Props


Intel WiFi Adapter not recognized Bionic Beaver

Question: The Wi-Fi adapter in my ASUS Q427F is not recognized by Ubuntu 18.04.3.
I've found literally dozens of similar posts, but none of the steps work for me, hence YAWANFP (yet another wifi adapter not found post). Apologies.
The wireless chip is an Intel WiFi 6 AX201.  This did work for me when I first installed Ubuntu (I had to disable secure boot), but on the very next update, it stopped working again and is back to being unrecognized.
Secure boot is still disabled.
lshw shows that the hardware is unclaimed:
$ sudo lshw -C network
  *-network UNCLAIMED
       description: Network controller
       product: Intel Corporation
       vendor: Intel Corporation
       physical id: 14.3
       bus info: pci@0000:00:14.3
       version: 00
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress msix cap_list
       configuration: latency=0
       resources: memory:c441c000-c441ffff
  *-network
       description: Ethernet interface
       physical id: 1
       logical name: enx00b56d00e75b
       serial: 00:b5:6d:00:e7:5b
       size: 100Mbit/s
       capacity: 100Mbit/s
       capabilities: ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=asix driverversion=22-Dec-2011 duplex=full firmware=ASIX AX88772B USB 2.0 Ethernet ip=192.168.1.37 link=yes multicast=yes port=MII speed=100Mbit/s

Output of lspci:
$ lspci -nnk | grep -A2 0280
00:14.3 Network controller [0280]: Intel Corporation Device [8086:02f0]
        Subsystem: Intel Corporation Device [8086:0074]
00:15.0 Serial bus controller [0c80]: Intel Corporation Device [8086:02e8]

There are no system messages related to the iwlwifi driver:
$ dmesg | grep iwl
$

The device is not disabled in the BIOS:
$ rfkill list all
0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
1: asus-wlan: Wireless LAN
        Soft blocked: no
        Hard blocked: no
2: asus-bluetooth: Bluetooth
        Soft blocked: no
        Hard blocked: no

Uninstalling and reinstalling the driver doesn't seem to do anything:
$ sudo modprobe -r iwlwifi
$ sudo modprobe iwlwifi

Soft-rebooting nor power-off-rebooting does not fix the problem.
Other diagnostics run:
$ cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

$ cat /etc/netplan/*.yaml
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

$ iwconfig
lo        no wireless extensions.

enx00b56d00e75b  no wireless extensions.

Output from modinfo iwlwifi (truncated):
filename:       /lib/modules/5.0.0-36-generic/kernel/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko
license:        GPL
author:         Copyright(c) 2003- 2015 Intel Corporation <firstname.lastname@example.com>
description:    Intel(R) Wireless WiFi driver for Linux
firmware:       iwlwifi-100-5.ucode
firmware:       iwlwifi-1000-5.ucode
firmware:       iwlwifi-135-6.ucode
firmware:       iwlwifi-105-6.ucode
firmware:       iwlwifi-2030-6.ucode
firmware:       iwlwifi-2000-6.ucode
firmware:       iwlwifi-5150-2.ucode
firmware:       iwlwifi-5000-5.ucode
firmware:       iwlwifi-6000g2b-6.ucode
firmware:       iwlwifi-6000g2a-6.ucode
firmware:       iwlwifi-6050-5.ucode
firmware:       iwlwifi-6000-6.ucode
firmware:       iwlwifi-7265D-29.ucode
firmware:       iwlwifi-7265-17.ucode
firmware:       iwlwifi-3168-29.ucode
firmware:       iwlwifi-3160-17.ucode
firmware:       iwlwifi-7260-17.ucode
firmware:       iwlwifi-8265-36.ucode
firmware:       iwlwifi-8000C-36.ucode
firmware:       iwlwifi-9260-th-b0-jf-b0-43.ucode
firmware:       iwlwifi-9260-th-a0-jf-a0-43.ucode
firmware:       iwlwifi-9000-pu-a0-jf-b0-43.ucode
firmware:       iwlwifi-9000-pu-b0-jf-b0-43.ucode
firmware:       iwlwifi-9000-pu-a0-jf-a0-43.ucode
firmware:       iwlwifi-Qu-b0-jf-b0-43.ucode
firmware:       iwlwifi-su-z0-43.ucode
firmware:       iwlwifi-QuQnj-a0-hr-a0-43.ucode
firmware:       iwlwifi-QuQnj-a0-jf-b0-43.ucode
firmware:       iwlwifi-QuQnj-b0-hr-b0-43.ucode
firmware:       iwlwifi-Qu-b0-hr-b0-43.ucode
firmware:       iwlwifi-QuQnj-f0-hr-a0-43.ucode
firmware:       iwlwifi-Qu-a0-jf-b0-43.ucode
firmware:       iwlwifi-Qu-a0-hr-a0-43.ucode
srcversion:     73136E4A47DE531CDC14864
<<< DJM: all 'alias' lines deleted >>>
depends:        cfg80211
retpoline:      Y
intree:         Y
name:           iwlwifi
vermagic:       5.0.0-36-generic SMP mod_unload
signat:         PKCS#7
signer:
sig_key:
sig_hashalgo:   md4
parm:           swcrypto:using crypto in software (default 0 [hardware]) (int)
parm:           11n_disable:disable 11n functionality, bitmap: 1: full, 2: disable agg TX, 4: disable agg RX, 8 enable agg TX (uint)
parm:           amsdu_size:amsdu size 0: 12K for multi Rx queue devices, 2K for 22560 devices, 4K for other devices 1:4K 2:8K 3:12K 4: 2K (default 0) (int)
parm:           fw_restart:restart firmware in case of error (default true) (bool)
parm:           antenna_coupling:specify antenna coupling in dB (default: 0 dB) (int)
parm:           nvm_file:NVM file name (charp)
parm:           d0i3_disable:disable d0i3 functionality (default: Y) (bool)
parm:           lar_disable:disable LAR functionality (default: N) (bool)
parm:           uapsd_disable:disable U-APSD functionality bitmap 1: BSS 2: P2P Client (default: 3) (uint)
parm:           enable_ini:Enable debug INI TLV FW debug infrastructure (default: 0 (bool)
parm:           bt_coex_active:enable wifi/bt co-exist (default: enable) (bool)
parm:           led_mode:0=system default, 1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0) (int)
parm:           power_save:enable WiFi power management (default: disable) (bool)
parm:           power_level:default power save level (range from 1 - 5, default: 1) (int)
parm:           fw_monitor:firmware monitor - to debug FW (default: false - needs lots of memory) (bool)
parm:           d0i3_timeout:Timeout to D0i3 entry when idle (ms) (uint)
parm:           disable_11ac:Disable VHT capabilities (default: false) (bool)
parm:           remove_when_gone:Remove dev from PCIe bus if it is deemed inaccessible (default: false) (bool)
parm:           disable_11ax:Disable HE capabilities (default: false) (bool)

Output from uname -a:
Linux Bellatrix 5.0.0-36-generic #39~18.04.1-Ubuntu SMP Tue Nov 12 11:09:50 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

I'm at my wit's end, and I despair that the internet is getting tired of answering this question, but I beg your indulgence to try to answer this question at least one more time.
UPDATE: I gave up on 18.04 and installed 19.10, which worked right out of the box.  Backporting probably also would have worked.  Thanks for the help.
Comment: Did you install any drivers? It looks like you installed some kernel module without DKMS. After a kernel update it doesn't load.
Comment: Pretty sure I didn't. I don't really know what DKMS is.
Comment: It looks like you did because you had to disable Secure Boot. It is needed only if you install a 3rd party module. Maybe you ran some commands that installed it.
Comment: Please add output of `modinfo iwlwifi`
Comment: And also `uname -a`.
Comment: Appreciate the help so far.  I added the modinfo (minus all the alias lines) as well as uname -a.
Comment: When I installed Ubuntu, I did check the option for installing 3rd party software.  I do have a 3rd party NVIDIA driver that shows up under 'additional drivers'.
Comment: Alias lines were also important. Run then `modinfo iwlwifi | grep 02f0`
Comment: None of the alias lines matched "grep 02f0".
Comment: My guess is that because you've got a Intel WiFi 6 AX201, you may need a newer kernel to support it. That, or a new driver backported to 18.04.3. 19.10 might fix it also... try booting to a Ubuntu Live DVD/USB 19.10.
Comment: This means that this kernel doesn't support this adapter. You need to find and install backports, or use a newer kernel. It is unlikely it worked before ;-)
Comment: I guess I'll try a newer kernel.  Thanks.  (It certainly did work before, though.)
Comment: Is this Manjaro or stock Ubuntu?
Comment: Here are drivers (microcode) for kernel 5.2... https://www.intel.com/content/www/us/en/support/articles/000005511/network-and-io/wireless-networking.html
Answer: Once I installed 19.10 (over 18.04), it just worked out of the box, so I think the drivers didn't support this newer card.  Don't ask me why it worked briefly.  It's likely that backporting iwlwifi would have worked as well, but I didn't try it.
Thanks all.
Answer: Since it worked once, you can try
cd backport-iwlwifi
make clean
make
sudo make install
Reboot


Why hbase stop all HMaster service first when rolling restart in rolling-restart.sh

Question: I read the rolling-restart.sh in $HBASE_HOME/bin, found that the script would stop all master service (including the backup ones) at the same time, and then restart them both:
<code># The content of rolling-restart.sh
...
# stop all masters before re-start to avoid races for master znode
"$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" stop master
"$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \
  --hosts "${HBASE_BACKUP_MASTERS}" stop master-backup

# make sure the master znode has been deleted before continuing
zmaster=`$bin/hbase org.apache.hadoop.hbase.util.HBaseConfTool zookeeper.znode.master`
...

# all masters are down, now restart
"$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" ${START_CMD_DIST_MODE} master
"$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \
  --hosts "${HBASE_BACKUP_MASTERS}" ${START_CMD_DIST_MODE} master-backup
</code>
In this way the HMaster service would be unavailable during this period. Why it's not designed in a more graceful way:

Stop the backup master, and then restart it
Stop the active master, then the backup master would become active
start the original active one of master, now it's the backup one

I have tested it on my own cluster and work fine. Is this more graceful? Or I missing something?
Answer: Although I don't know the intentions of the authors of the rolling-restart.sh script, it also doesn't make much sense to me. I also perform a master-by-master stop and start and it works just fine.
When you turn one master node off at a time, the only thing you need to take care of is that the entry in the Zookeeper node '/hbase/backup-masters' is empty (hence the backup master really took over as active master) before you turn on the previously active master node again.
I observed that if you turn on the previously active master node on again before its Zookeeper session expired, the backup master will never take over and the previously active master will spent an awful lot of time in the "Initialize ServerManager" status  (see below) and every interaction with Hbase will fail with the "org.apache.hadoop.hbase.ipc.RemoteWithExtrasException: org.apache.hadoop.hbase.ipc.ServerNotRunningYetException: Server is not running yet"  Exception.

Start Time
Description
State
Status
Completion Time

Sat Apr 15 17:17:36 UTC 2023
Master startup
RUNNING (since 15mins, 47sec ago)
Initialize ServerManager and schedule SCP for crash servers (since 15mins, 47sec ago)
RUNNING


How can I multiply row under certain condition with R?

Question: I have a data frame, (aka df), and I want to multiply the Column Price when the column meets a specific condition, such as

df$US=='non US'`.

Here is my code:
df$Price <- df$Price[df$US=='non US']*0.85

Running the code above causes this error:
Error in `$<-.data.frame`(`*tip*`, CompPrice, value = c(140, 114.117647058824,  :
  replacement has 142 rows, data has 400

I understand the reason the error occurs, however, I don't know how to modify just the rows that meet the condition.
Thanks in advance.
Answer: We need to specify the logical condition on the lhs of <- as the lhs includes the full 'Price' column
df$Price[df$US=='non US'] <- df$Price[df$US=='non US']*0.85

It is usually recommended to create an object before the assignment to avoid doing the same computation repeatedly
i1 <- df$US == 'non US'
df$Price[i1] <- df$Price[i1] * 0.85

With data.table, this syntax is more compact
library(data.table)
setDT(df)[US == 'non US', Price := Price * 0.85]

Answer: You can use ifelse like so...
df$Price <- ifelse(df$US=='non US', df$Price * .85, df$Price)


Does router speed affect ping?

Question: I currently own a 150 Mbps router, and I am playing MW3 on PS3 with about <75ms – <100ms ping.
Does getting a new 300 Mbps router make a big difference? Would it reduce my lag?
Answer: Probably not.  The biggest thing you can do to improve your performance is to purchase a higher-tier internet speed with a larger bandwidth.  As you've probably figured out, the 4 mbps you're getting is nowhere near the limit of your router (150 mbps).  This implies that the router is more than capable of handling the data you're sending through it, and the likely culprit is a lower-tier internet connection.
Comment: -1 why would increasing your bandwidth affect your ping?  The only way would be if you're saturating your connection *(which you definitely won't just by playing MW3..)*
Comment: Ok thanks bit of a bugger living in the middle of no where haha :(
Answer: Getting a higher-tier internet connection will probably not improve your ping.  All networked XBox 360 games are required to keep their bandwidth below 8KBps; the requirements for PS3 are likely similar.  With a 4mbps (500KBps) connection, you will be using less than 2% of your total bandwidth.

Your ping is the time is takes a packet to make it from your computer to the server, and back again.  There are a few reasons you might have high ping, and a few things you can do about it:

Lossy wireless connection.  If you're on wireless and there's a lot of interference, you could be losing packets.  Try pinging your router a few times, and make sure you never get "request timed out."  If this happens, switch to wired.
Slow router.  Although doubtful, you could have a faulty/overheating router which is running much slower than it should.  It's easy enough to check:  ping your router again, and make sure the response-time is small.  There is really no reason the response should take more than 1 ms.  If this happens, get a new router.
Saturated bandwidth.  This could be the case if the PS3 is downloading updates in the background, or your brother is downloading torrents on his computer, or your neighbors are leeching off your wireless, etc.  Log into your router's administration page, and see if it has any statistics on previous/current bandwidth usage.
If you are saturating your bandwidth, find out who's downloading what, and stop the downloads.
Slow ISP.  ISP's usually sell much more bandwidth than they are capable of providing, on the assumption that most people will not be saturating their connections all the time.  Sometimes they are not able to meet the demands, causing everyone's internet to run slower.  If this happened, it would affect both your ping and your bandwidth, so a simple way to check would be to use a bandwidth test and make sure you are getting the full bandwidth you're paying for.  If you're not, call up and complain.
Server is too far away, or is overloaded.  This is the most common cause of lag, and there's really nothing you can do about it besides choosing a new server that resides closer to you.

It could also be that you're not actually experiencing lag; many people confuse low fps with network lag.  Low FPS could be caused by poor programming, or system overheating.  If you have one of the older, fat PS3's, you should be seriously concerned about this, as all the old fat PS3's seem to be dying from overheating lately.

Lastly, I'd like to mention that 75ms ping is really not bad at all - the average human reaction time is about 210 ms, with the best-of-the-best around 160ms.  A 75ms ping does not put you at a significant disadvantage over someone with a better ping - if you find you are dying a lot, just keep practicing :)
Comment: I don't die alot but the few times i do when i watch kill cam back on MW3 on my screen i shot them but when i see the replay i don't even fire a bullet and they kill me before i shoot
Answer: I contacted SKY about my internet connection, and they put me on a gamers package that reduced my ping. Might be worth phoning your ISP too and see if they have a similar deal!
Answer: I understand you are running a wireless connection. Check whats your ping to the router and do you have any packet loss. If possible try connecting through ethernet.
Also make sure there is no p2p software running while you testing. Not only on your computer, but on every computer connected to your network. On ADSL type of connections massive upload may increase your ping big time.
Comment: No its a wired connection wireless was just impossible to play Cod on

Does router speed affect ping?


Make a video be full screen size CSS

Question: I'm using the videojs.com video player and it works great the only problem is that I want the video player to be the full-screen size instead of using pixels like for example if you are on a smaller screen the video player looks messed up.
I tried to use 100% instead of px but it also messed up a lot.
Is there some other way I can make it fit the whole screen automatically?
<video id="player" class="video-js vjs-default-skin" controls autplay="true" preload="auto" width="1880px" height="980px"
  poster="FF7.png"
  data-setup="{}">
<source src="FF7.mp4" type='video/mp4' />
<track kind="subtitles" src="FF7.vtt" srclang="en" label="Svenska"></track>
 </video>

Comment: possible duplicate of [Is there a way to make HTML5 video fullscreen?](http://stackoverflow.com/questions/1055214/is-there-a-way-to-make-html5-video-fullscreen)
Answer: Check the Codepen here
video {
    position: fixed;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -100;
    transform: translateX(-50%) translateY(-50%);
 background: url('//demosthenes.info/assets/images/polina.jpg') no-repeat;
  background-size: cover;
  transition: 1s opacity;
}

Comment: Did not help... Looks even more messed up now :/ https://gyazo.com/678b7bd35604140b9340a8767f733207
Comment: have you had a look at codepen. Just take the code you need, not everything. remove translate if its not helping. And also position fixed
Comment: Given that the codepen works and your site doesn't, I feel there might be something particular about your site's HTML or CSS that's interfering. Above the video in the hierarchy, can you find any elements that set a `position` attribute in CSS?
Answer: You can use a parent div container for your video, so it acts like a cross browser anchor for your video. Also you can use the media query min-aspect-ratio and max-aspect-ratio.
Codepen example with editor:
http://codepen.io/jonathan/pen/bEbdmz/?editors=110
Codepen example in fullscreen mode:
http://codepen.io/jonathan/full/bEbdmz/
The HTML

    <video id="player" class="video-js vjs-default-skin" controls autplay="true" preload="auto" width="1880px" height="980px" poster="FF7.png" data-setup="{}">
        <source src="FF7.mp4" type='video/mp4' />
        <track kind="subtitles" src="FF7.vtt" srclang="en" label="Svenska"></track>
    </video>

The CSS:
html, body {
  height:100%;
}

body {
  margin:0;
  padding:0;
}

#video-wrapper {
   position: fixed;
   top: 0;
   right: 0;
   bottom: 0;
   left: 0;
   overflow: hidden;
}

#video-wrapper >  #player {
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   cursor:pointer;
}

@media (min-aspect-ratio: 16/9) {
    #video-wrapper >  #player {
       height: 300%;
       top: -100%;
    }
}

@media (max-aspect-ratio: 16/9) {
    #video-wrapper > #player {
       width: 300%;
       left: -100%;
    }
}

And if you want a JavaScript fullscreen solution you could use some of the following:
http://vodkabears.github.io/vide/
http://dfcb.github.com/BigVideo.js/
http://syddev.com/jquery.videoBG/

Make a video be full screen size CSS


Error when converting Qimage to Mat opencv

Question: When I convert a QImage to cv::Mat the Mat comes out blurred.
This is the code that converts it:
QPixmap pixmap(*ui->imgLabel->pixmap());
QImage image = pixmap.toImage();

image.convertToFormat(QImage::Format_RGB888);

Mat matImage = Mat(image.height(), image.width(), CV_8UC3, image.scanLine(0));

This is the original image zoomed:

This is the image created:

Grateful for any help.
Comment: One is colour and one is b/w is this intentional?
Comment: Did you try [this](http://stackoverflow.com/questions/5810970/get-raw-data-from-qimage)
Answer: I don't know QT, but have you tried ready solutions from WEB? For example, from this link I found another method of conversion:
Mat qimage2mat(const QImage& qimage) {
    cv::Mat mat = cv::Mat(qimage.height(), qimage.width(), CV_8UC4, (uchar*)qimage.bits(), qimage.bytesPerLine());
    cv::Mat mat2 = cv::Mat(mat.rows, mat.cols, CV_8UC3 );
    int from_to[] = { 0,0,  1,1,  2,2 };
    cv::mixChannels( &mat, 1, &mat2, 1, from_to, 3 );
    return mat2;
};