Testing wire with low voltage current

Question: What is a convenient and safe way to send some low voltage current through wire for testing and identifying purposes?  E.g. awhile ago, I wired a two speaker setup behind drywall with one input box from which two sound cables go on either side of the room, each terminating in its own box.  Assuming I didn't label wires with electrical tape, what would be an easy way for me to send some current to see on which side it ends up.  This is just hypothetical and could be any other similar tests, e.g. if current goes from one side to the other suspecting wire breakage or impedance in between etc.  I'm guessing some low voltage device would be safer and easier to hook up than real current.
Answer: Yes!  For goodness sake, do NOT put any commonly available potential (ie 120V) on the lines, they make very easy to use tools for this.  Most sources in your house will be voltage sources, vice current sources, so how much current results is a factor of the resistance in the line.  Because these speaker wires will have low resistance when you find both ends, you will get a LARGE current in the lines which could destroy your fuse/breaker or even cause a fire.
What you are describing/seeking, though, is essentially a resistance measurement (ohm reading).  Get a multi-meter, the "ohm"/resistance measurement ("upper-case" omega) sends a small current down the wire and measures the voltage, to determine the resistance (using the equation v=ir).  In your case, you know you will have found the other end when the measurement of resistance goes to near zero (after starting at off scale, or pegged).  I would wrap one of the speaker ends around the black lead (color chosen for no particular reason) then go to each wire on the other end until you get the near 0 reading of resistance.
If the wires are too far apart, make an extender out of an available piece of speaker wire. Simply twist the free piece of wire to one end of the speaker wire on the wall to extend it far enough that your red and black meter leads are long enough to reach both ends. Then continue with the resistance measuring technique described above.  Now, use the red lead of the multi-meter to go through each wire until you find the right one.  Mark those wires and move on to the next.
Answer: A wire tracker is a useful tool for this.

They usually have a few different types of connectors, so they can trace phone, and CATV lines, as well as single wires.
Alternatively, if you're cheap, and you're working on wires where speakers are hooked up. Connecting a 9V battery to the wires, will make the speaker at the other end click. Can't guarantee this won't damage the speaker, and it probably won't work if the speakers have a built in amp.

Testing wire with low voltage current


Where do I change mod settings?

Question: Ive installed the Neat RGP Hub. In the description it says that it's possible to adjust the number of inventory slots, how big containers should be and so on but I can't find any settings to do this.
I tried in the mod and settings section of the main menu. and from the in game settings. Nowhere do I get any options specific to the mod. I have also checked the world options before starting the game.
Answer: Oh.. ok. So go to the Mod section in the main menu and mouse over the mod you want to configure. IF it has a congiuration then a Config button will show upp. Just dont mouse over another mod cause then the button will dissapear.

Where do I change mod settings?


How to display images from multiple folders AJAX

Question: I am trying to display images from 3 folders named FOLDER1, FOLDER2, and FOLDER3. I am trying to use a for loop to loop through each folder incrementally and display each of their contents in separate divs categorized under their corresponding folder names. But the code I have is unable to do that. For some reason, the for loop only loops through the FOLDER3 folder and completely skips FOLDER1 and FOLDER2 despite the content file names of FOLDER1 and FOLDER2 being displayed as broken images (which is so confusing)! Maybe I'm missing a line I should be adding to my AJAX code to make it work?
THIS is the result I would like to achieve:
FOLDER1
images/FOLDER1/folder1_img.jpg

FOLDER2
images/FOLDER2/folder2_img.jpg

FOLDER3
images/FOLDER3/folder3_img.jpg

BUT - THIS is the result I currently have:
FOLDER1
images/FOLDER3/folder1_img.jpg

FOLDER2
images/FOLDER3/folder2_img.jpg

FOLDER3
images/FOLDER3/folder3_img.jpg

This is my complete code:
HTML script:
<!DOCTYPE html>

        <?php $items = array("FOLDER1", "FOLDER2", "FOLDER3"); ?>
        <?php foreach ($items as $item): ?>

<?php echo "$item"; ?>

        <?php endforeach; ?>

AJAX script:

Please, if someone can help me here, I would GREATLY appreciate it. Thank you
Answer: Add async: false in ajax request.
Comment: okay but that gives me a problem - 3 images (one from each folder) are being grouped together and displayed underneath each folder. I only want images from their *own folders* to be grouped together.


Spring Cleaning 2015: Week 2 results

Question: Summary

90% Answered: Our Area51 %Answered metric should read 90% by May 31st 23:59 UTC.
Improved Voting Economy: The Electorate badge should have been awarded 15 times total by May 31st 23:59 UTC.
Badges: Every 24-hour UTC period from May 1st - May 31st with at least three active bounties counts as a success.

Results: Week 1, Week 2.
Relevant posts: Spring Cleaning 2013, advanced search filters (more), voting strategies, how to write a good answer, vote early vote often.
Spring cleaning
As I announced for the first chat event, I think our site should make a coordinated effort of cleaning up the site during the month of May. While we had some very productive discussions during the chat, we didn't actually manage to cover much ground for me to base this announcement on, which, as I said in the summary, is mostly my fault.
In any case, I want to move on this project, so I'm going to try to provide some goals and a general framework, make some suggestions, and encourage people to post their own answers. There will be a 'halfway discussion' at some point from the 14-16th of May to go over how we are doing, and to discuss any ideas that have come up during spring cleaning, as well as whatever other topics people have.
Goals
Spring cleaning has two complementary purposes:

Signaling a discrete period of high site engagement to formerly active users who have gone passive for whatever reason.
Improving CogSci's Beta metrics, user participation/retention and general site quality.

(The first goal is basically achieved with this post, success notwithstanding, but I wanted to list it explicitly.)
To make these abstract goals tangible, I am setting the following concrete objectives for Spring Cleaning 2015.
Goal 1: 90% Answered
Target: Our Area51 %Answered metric should read 90% by May 31st 23:59 UTC.
Since late March, we've gone from 77% to 82% on April 19th, and then from 82 to 84% in less than two weeks more. A lot of the early gains came from serial closing nearly everything in our 'question purgatory,' true, but recent gains have primarily come from new answers. It's not a low bar to set, to be sure, but there is every possibility that we can reach the Promised Land with only a little elbow grease here!
To raise the chances we will meet this goal, I am personally setting off time to write two answers a day on average through May. It would be nice if a few other regulars would join me in making a (smaller, I would expect) public commitment, but I will do it regardless of what happens.
This is the most important goal, but also the most labor-intensive to contribute to. We should heed Jeromy's suggestion from my original spring cleaning proposal two years ago: answers don't need to be perfect to contribute substantial value to the site, they just need to be good. Another thing to keep in mind is that pursuing negative answers (i.e., answers which affirm that no answer exists) can be a strong strategy here, because most of the work goes into the preceding literature search, which can easily be done in bits and pieces. I suspect many unanswered questions have a negative answer.
Goal 2: Improved Voting Economy
Target: The Electorate badge should have been awarded 15 times total by May 31st 23:59 UTC. We each get 30 votes every day, so this can be accomplished by any user within the month.

I've talked about our voting economy before here. Votes are as important for an SE site as high quality questions and answers are, because the vast, vast, vast majority of people who come to this site are not in a position to evaluate the merits of an answer in any way except votes.
Relative comparisons with other Stack Exchange sites notwithstanding, the SE framework imposes an objective framework on every SE site. Answers go grey when they reach an absolute score of -3, regardless of what -3 means. Questions and Answers are "good" for SE's definition of "good" at an absolute score of 10. We can't change these things, so our voting economy needs to reflect them. (I doubt we can actually reach this ideal distribution, but it's as tangible a collective voting goal as any.)
Presently, I think it's reasonable to say our voting economy does not reflect these norms. In other words, we need more upvotes and downvotes both. Downvoting answers cost rep, but it's a miniscule -1 reps, you can downvote 10 answers for every upvote your answers get. If you don't have time to write answers, try to vote early and vote often.
Goal 3: Three Bounties
Target: Every 24-hour UTC period from May 1st - May 31st with at least three active bounties counts as a success.
Bounties are not that expensive in terms of reputation, and are a great way to signal site activity. Bounties are also effective: I have set a half dozen bounties on my own questions or ones I simply found interesting in the past month, and all of them received a satisfying answer. If you're a previously active user sitting on thousands of rep, who doesn't have time to answer questions and doesn't have time to vote, finding questions that deserve a bounty is a great way to help the site.
We can do this, so let's do it!
Comment: I don't fully agree on goal 2. I don't believe you can make any generalizations across sites on what vote counts mean. The only real way to assess what a vote count means is by taking site specific details into account, as well as the amount of viewers a particular question got.
Comment: @StevenJeuris Normal users don't have access to that information, so I went with the objective features of the SE framework. In any case, goal #2 is just to get people to vote more, so you can always vote more for a different reason, if you like.
Comment: Or propose a new formulation, I'm not married to this stuff. :v
Answer: This is great! Just remember that quality still comes first.
Hats off to Christian for this very well thought out initiative. It's great to see this kind of push from within the community. Just a friendly reminder from the Stack Exchange Community Team (of which I'm a member); while you go through this (awesome) exercise, just make sure you don't sacrifice quality in pursuit of these targets.
The way we think about things on the Community Team, having well written, expert Q&A is always goal #1. Every SE site is creating an archive of top notch domain knowledge for future readers. So please, band together, have fun and take ownership of your site! Just keep the larger goal in mind too.
Comment: We don't exactly have handlers for Stack Exchange sites, I'm just one of several who floats about the network and sleeps with one eye open. ;) You're raising several potential points in your first comment and instead of assuming I'm understanding you correctly, I's rather make sure. Care to speak in chat?
Comment: Praise from Caesar is praise indeed. Maybe you could aptly throw a call to vote more in there, since we can't just reach into the Platonic realm to identify our own quality answers from not-quality a priori. I mean, I always do my best, but sometimes my best isn't good enough―hence voting.
Comment: Also, are you our handler, or just interested? :v
Comment: I'm almost always in chat (definitely during spring cleaning), so sure.
Answer: Just to throw out some numbers on goal #1:
There are currently 2,674 questions on the site. Getting to 90% would require answering 2,407 of them. There are 412 unanswered questions right now, so we would need to answer about 145 of those questions in order to reach the goal.
Of course, we get new questions at a rate of about 3/day right now. At the end of May, this will mean an addition 90 questions. So we would also need to answer about 80 additional questions to keep up with the new questions.
All in all, achieving goal #1 would mean about 225 questions without an answer get answered before the end of May.
(Closing questions can also factor into this, but I'm ignoring that to simplify).
Comment: Thanks @Josh, concrete numbers are extremely helpful.
Comment: To add to this, we answered 111 questions during the month of April so far, so we need to approximately double our answer rate for one month, and then we'll only need to maintain the old rate to make slow gains into 90%+.
Answer: WEEK 2: The Numbers
%Answered: 86% (+2% since 01/05/2015).
Unanswered questions: 369 (-43 since 01/05/2015).
New Electorate/Civic Duty badges: 1 Civic Duty.
Days with 3 or more bounties: 1/7.
Here are a couple of plots. Because I spent a lot of time yesterday making convenience plotting functions in R, so why not use them for this too? YAY, PLOTS.
Answer: WEEK 1: The Numbers
%Answered: 85% (+1%).
Unanswered questions: 392 (-20). Note that this is despite losing some ~10 when a suspended user deleted their account.
New Electorate/Civic Duty badges: 0. Some progress: a question actually managed to reach 10 score in less than a week!
Days with 3 or more bounties: 7 (100%).
Other: Questions per day is up almost a whole point.

Spring Cleaning 2015: Week 2 results


connect: Network is uinreachable

Question: I have a problem with my network connection. When I tried to ping 18.104.22.168 I get an error that  "Network is unreachable". I tried to restart dhclient for eth0 but did not help. It is weird, that it don't show any message. When I tried to restart networking (/etc/init.d/networking restart ) there is not show any message. I don't have much skill with Linux so please help me :))
this is content of /etc/network/interfaces
#interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Comment: reedit your question by posting the content of this file: `/etc/networking/interfaces`
Comment: Are your using a server or a desktop?
Answer: Try adding these lines to your /etc/network/interfaces
auto eth0
iface eth0 inet dhcp

These two lines are to set up the eth0 interface as dhcp. According to OP's question, he mentioned "dhclient" so I think this is what he want's.
After you are done with that save the files and run the following :
if you are on 13.10 or before this should restart your networking:
$ sudo service networking restart

If on 14.04 the above may not work so try this
$ sudo ifdown eth0 && sudo ifup eth0

to pull the eth0 interface down and then restart it with the changes in the above networking file.
Comment: Thanks for your input. Can you please describe what the described steps do? [Code formatting](https://askubuntu.com/editing-help#code) for shell commands would be nice as well.
Comment: Thanks @DavidFoerster. I made the changes. New here and tried answering from the stack exchange app for android. Couldn't figure out how to format the code on that.
Comment: Thanks. I didn't know there was an app, but then again I have no smartphone anyway.

connect: Network is uinreachable


Add one month to gmdate using current format

Question: Hello I have the following php code:
<code>$date = gmdate("Y-m-d\TH:i:s\Z"); /*Format: '2015-05-24T00:00:00Z'*/
</code>
How would I simply add 1 month to the above date while keeping the same format?
I tried a few things that lead to nowhere, I am sure there should be a way of doing it that I can't seem to find.
Any help is much appreciated!
Thanks,
Al
Answer: try below:
<code>$date = gmdate("Y-m-d\TH:i:s\Z", strtotime("+1 month"));
</code>
Answer: Try with -
<code>$date = gmdate("Y-m-d\TH:i:s\Z", strtotime('+ 1 MONTH'));
echo $date;
</code>
It will add one month to the date.


Sort data into column bins in excel

Question: Suppose one has data arranged vertically like this:
Name      Birthday
John      6 June
Mary      12 May
Sue       1 June
Brian     10 August
Carl      24 June
Ted       18 August
Linda     31 January

Is it possible in Excel (without VB) to sort the data into column bins thus?:
Jan    Feb    Mar    Apr    May    Jun    Jul    Aug    Sep    Oct    Nov    Dec
Linda                       Mary   John          Brian
                                   Sue           Ted
                                   Carl

(Even better would be to have them sorted within each bin by birth date.)
Answer: Without modifying the data or using VBA, the closest I think you'll get is a PivotTable:

Click in your data
Insert --> PivotTable
OK
Drag the fields like this: Name--> Row Labels. Birthday --> Column Labels. Name --> Values
Right-click on a date in the column fields --> Group...
Select Months --> OK

Tada
Comment: Thank you. I learned a lot from your response, but it doesn't quite create a list of names under each month.
Comment: @Carboxyl happy to teach :) and no, it doesn't put the names underneath. It's the closest I can get without doing too much work ;)
Answer: FYI, this is a bit complicated, so it might be hard to maintain/explain to someone else what you did.
Result:

In Cells D1 to O1, put in 1/1, 2/1, 3/1, etc
Select those cells, right-click --> Format Cells...
Choose Custom and put "mmm" (without quotes)
In D2, put this formula in there:
=IFERROR(INDEX($A$2:$A$8,SMALL(IF(MONTH($B$2:$B$8)=MONTH(D$1),MATCH("~"&$A$2:$A$8,$A$2:$A$8&"",0)),ROWS($2:2))),"")
Enter that formula with CTRL+SHIFT+ENTER (array formula)
At the bottom right of D2, there is a little black square, hover over this and your mouse will turn into a plus sign. Click this and drag down to cell D8.
Cells D2:D8 will be highlighted. Click the little square again found in D8. Drag to the right all the way till Dec

And there you have it.
I'd like to thank Aladin for the help with this formula:
http://www.mrexcel.com/forum/excel-questions/470371-unique-list-based-criteria.html#post2322387

Sort data into column bins in excel


Are there benefits to retrofitting thicker furnace filters?

Question: I just brought a new house.  In the new house, the furnace filter is 1 inches; whereas, my old house is 5 inches.  I am just wondering should I change the 1" into 5" at my new home?  All the research online said that 5" is better than 1". Is that true?
Comment: Is the furnace exactly the same?  Furnaces are made to work with certain filters.  Using the wrong filter will probably not work as well.
Comment: A big furnace filter is semi-effective way to get cleaner indoor air. a dedicated air filter unit will work better, but takes up space and makes extra noise.
Comment: Whatever you do, don't _stack_ filters. That creates too much resistance.
Answer: The bigger filter is better, but it would necessitate modifications... AND the furnace blower is designed to pull through a specific filter.
Just stick with the filter the system calls for.
Comment: Thicker filters typically have less restriction due to larger surface area.
Comment: The furnace manufacturer should have technical information indicating what amount of flow restriction/back pressure is allowable.
Comment: @JimStewart yes indeed, if system restriction is particularly bad the motor can end up with insufficient cooling which causes long term problems. It has to be really bad though, like a filter unchanged for years, evaporator freezing, or wildly insufficient return area. Or all three.
Comment: Yes, should have stopped at filter.
Comment: my 5" filter blocks a lot less flow than a ultra-fine 1" hepa filter.
Comment: I have heard that a filter with excessively high resistance can cause motor failure by creating too much suction on the air handler inlet side. My filter is on the inlet side of the air handler. I am not sure if the fan overspeeds or boggs down in that case but the result reportedly is a failure of the motor. The squirrel cage fan is supposed to have dense, flowing air to bite into.
Answer: If a five inch fits, use it. I've seen people use one inch filters in the big five inch housings before because the 1 inch filters are individually cheaper. The five inch filters are indeed better, but they don't fit in every unit.
Comment: Our Space-Gard filter unit takes Aprilaire 201 pleated paper filter media which come folded. They are expanded in installation to 6 inches thick fold-to-fold. There is a set of plastic combs which separate the pleats. It is truly a PITA to replace, but I believe it is a superior filter that allows me to change it only once a year. My HVAC service has said that they can retrofit a rack which would allow using pre-expanded filters, but which have less total area of paper filter media. I am sticking with the Aprilaire 201.
Comment: Nice! Our Honewell housing holds anything up to about 5 inches. We could do the filter once a year but the payback based on increased static pressure is about six months in, since the heat pump runs so many hours in the winter.
Answer: Is your air handler/furnace/ac evap coil oriented vertically or is it oriented horizontally? Is it in the attic or is it in a closet off a hallway?
A 5 inch thick filter is better, but usually the extra height filter unit must be installed when the air handler is installed. It would be excessively troublesome and costly to retrofit a 5" filter unit unless the the unit is on its side in the attic. If that were the case, it would still be costly but it would be doable, otherwise it does not really make sense for the benefit you'd gain.
For over 30 years we have had a Space-Gard High Efficiency Air Filter unit at the base of our air handler, oriented vertically, in a tight closet off a hallway. The outside height of the filter unit is 9.5 inches and it takes a $35 pleated paper filter which is about 6 inches in height.
I change the filter once a year and it is a PITA to change. A relative nearby has the same filter arrangement and they cannot change the filter. I do it for them.
Three years ago we replaced our entire unit and the HVAC contractor had to source a special low height evaporator coil to be able to get the new unit into the closet.


Working iron tile doesn't produce any iron output

Question: Fairly new to this game, but it's my understanding that to gain more strategic resource output, that resource must be worked. I'm working three iron mines, 1 in my capital adjacent to the city tile that yields 2, and 2 in another city that yields 6 and 2 (not adjacent to the city tile). By working them I mean I've checked them in the city view so they're green.
Still, my overall iron output is only 2, and is used up by 2 longswordmen units, so I can't produce any catapults.
Is this a bug, or am I doing something wrong?
Any help much appreciated :)
Answer: To gain strategic resources, they do not need to be worked by your city's civilians.
Rather, you need only to improve a resource tile within your borders with some tile improvement. For iron, these are mines. Make sure that your workers have built mines over all of your iron deposits. Additionally, resources are lost if the improvement tile is occupied by an unfriendly unit or if the tile improvement on it is pillaged.
Great people's improvements provide resources (but not yield bonuses) once you have researched the required technology.
It sounds like perhaps you have built a mine on a single resource providing 2 iron, and the other two resources are being worked, but are unimproved.
Comment: As stated, the mines weren't finished. They looked a awfull lot like complete mines though :)
Comment: Well no, there are mines over all three. And only two iron-requiring units. I should gain a surplus then, right? They're supposed to yield a total of 10.
Comment: Yes, if that's the case it sounds like it may be a bug.. You're not trading any away, are you?
Comment: Yeah, it's hard to tell sometimes! If this answer helped, please mark it as accepted. (And welcome to the site, btw!)
Comment: @AkselMathias Please mark the answer as accepted instead of proposing an edit. :)
Comment: @Schism Yes ofcourse. Sorry.


Cardinals as equivalence classes

Question: An excerpt from Wiki page on Cardinal numbers,
https://en.wikipedia.org/wiki/Cardinal_number#Formal_definition
"The oldest definition of the cardinality of a set X (implicit in Cantor and explicit in Frege and Principia Mathematica) is as the class [X] of all sets that are equinumerous with X. This does not work in ZFC or other related systems of axiomatic set theory because if X is non-empty, this collection is too large to be a set."
What exactly does not work? Wy should a cardinal be necessarily represented by a set? I think cardinal arithmetic works perfectly with this definition. Where do I have a problem if I define a cardinal as an equivalence class? Thank you.
Answer: The class of singletons is a proper class. So any cardinal larger than $0$ can be represented by a proper class of sets.
Why is it important? Well, for basic statements, like Cantor's theorem, it's not. You can do away with cardinals being proper classes. But being a foundational theory, it is more satisfying to know that something like a cardinality of a set can be internalized. That we can talk about cardinality of a set as part of our theory.
Comment: To some extent, yes. At least for very basic things, it's going to be doable. Your mileage may vary as far as how much the statements are more complicated. But if you already have ZFC and the cardinals, I don't see the point.
Comment: I generally agree with you, that excessive terminology can---and often does---interrupt the natural statements of things. But then you have books like Halmos' "Naive set theory" which goes to great lengths to avoid talk about ordinals and cardinals properly, and it suffers greatly as a consequence (as do many people who study from that book, although often this suffering is unbeknownst to them). But to be fair, I don't recall many functional analysis papers involving ordinals and cardinals (except those specifically linked to set theoretic constructions).
Comment: Do I understand correctly that for utilitarian purposes like infinite dimensional linear algebra introducing cardinals as equivalence classes causes no contradictions?
Comment: The point is not introducing too much terminology to a non-set-theorist who just wants to add and multiply dimensions of infinite dimensional vector spaces. This is like defining a manifold to be a locally regular embedding of a topological space into a higher dimensional Euclidean space. You can do that by Whitney's theorem, but it is not an internal definition. But still, if it helps a non-geometer to handle manifolds easier then it's justified, I think.
Comment: Sure, in naive terms, you can just always replace "cardinal" by the statement "whenever such and such set is in a bijection with this and that set, then we can do so on and so on either on both sets or on neither of them". So for example, "Given a nonzero Banach space $X$, then there is an injective function from the real numbers into $X$". The problem with that, is that when you talk like this, there is often an implicit context that the function is "in the right category", which isn't always the case.
Comment: An example of the above "in another category": If $X$ is a Hilbert space and there is a function from the natural numbers into $X$ whose range spans a dense subspace of $X$, then there is an injective function from $X$ into the real numbers. Wouldn't it be much much easier saying "If $X$ is a Hilbert space and there is a countable dense subset of $X$, then $|X|=2^{\aleph_0}$"?
Comment: The example is perhaps not too pertinent. Someone who deals with Hilbert spaces surely knows what a dense subset is: no additional terminology needs to be introduced. But when an analyst works with vector spaces he need not know at all what ordinals and cardinals are in their modern interpretations. Whereas equivalence classes of sets are as intuitive as one could wish. If one starts to refer to the state-of-the-art in the definition of every object one uses, papers will become encyclopedias.
Comment: I personally think if disjoint unions and cartesian products provide all the functionality you need in your paper, you don't need to introduce ordinals and cardinals in a proper way. But this may be a matter of taste.
Comment: I do nothing but agree. If you write about sets you'd better use proper set theory. Regarding functional analysis: yes, it is hard if not impossible to do without topology. And hence most analysts don't usually need ordinals and cardinals - vector spaces with tractable topology usually have tractable cardinalities. But harmonic analysis is a strange mix of algebra and analysis, and sometimes you do want to separate algebraic aspects from functional analytic ones. And there you meet cardinalities, but don't necessarily want to dwelve too much into them.

Cardinals as equivalence classes


Why are some snaps fast, and others so slow?

Question: Straight from cold Fossa boot, until usable user interface:
Blender 2.91.2: 4 seconds
Gimp: 11 seconds
Boxy SVG: 22 seconds
Spotify: 43 seconds
The latter two seem like electron apps and take forever. Since these electron apps seem to be increasingly common, is there a way to speed up their snap load times? Spotify in particular is egregious.
Comment: An alternative to snap that doesn't suffer from the slow startup is Flatpak. https://flathub.org/home
Comment: Spotify is not an Electron app and Boxy SVG is
Answer: This is not a direct answer as it isn't a way to speed up snaps, but it may help anyway.
Spotify is available as a .deb which you can install in Ubuntu instead of using the snap.
I tested both options on my system and got the following approximate results:
Snap -> 7.5 seconds
Apt -> 0.5 seconds
Which raises another point. You mentioned in a comment that you're running on a 2.5gb/s NVME SSD which suggests to me you have a fairly modern PC. I'm running something similar but I can load Spotify as a snap in 7.5 seconds compared to your 43 seconds. Perhaps you have some other issue on your system. 43 seconds does seem excessively slow on a modern PC, even for a snap.
Comment: I'm running ZFS on root partition which might not be in a happy marriage with Snap. Dunno.
Comment: @ThomasBrowne the first generation has a maximal boost frequency of 3.7GHz. I myself don't have such problems with snaps and my processor goes up to 4.7GHz. I think Spotify is still using the slow compressor, but it launches within 0.5 seconds on my system. I've just installed it to test.
Comment: @ThomasBrowne, is your processor slow?
Comment: @france1 8/16 Core Ryzen first gen. So not the fastest but defo not slow, also 64GB or RAM, and fast Samsung 1TB ssd with plenty of free space. So no. The hardware is fine.
Comment: @france1 I suspect that this problem has been fixed by Canonical. I started using snaps early. Question is from more than 2 years ago and lots of people were complaining. Anyway I'm all in on Nix now buh-bye Snaps, Flatpak etc and good riddance.
Comment: @ThomasBrowne, actually, all the way back then, I've had a similar problem on a very slow computer. The snap would take a long time to open, especially the first time. But since the computer was absolute trash, I guessed it's just more of a performance problem.
Answer: Snap packagers need to opt in to include lzo compression so that it's not using the slower xz compression when they're installed on your system:

https://ubuntu.com/blog/snap-speed-improvements-with-new-compression-algorithm
https://snapcraft.io/blog/why-lzo-was-chosen-as-the-new-compression-method
https://forum.snapcraft.io/t/how-to-switch-your-snap-to-use-lzo-compression/21714

Spotify is one of the worst cases of this and they probably should turn it on. In certain cases, like Chromium, the difference was significant and now it launches fast once that change was committed by the packagers.
Answer: You are correct: Some cross-platform application development toolkits --like Electron or Mono-- can offer high compatibility, but also can cost a price in performance. As a user, there is nothing you can do about it at runtime.
An application packaged using Snapd should not run noticeably faster or slower slower than the same application packaged another way. If you can reliably reproduce a significant difference, then please file a bug or issue with the snap author, AND please raise the issue in the forum at snapcraft.io.
Answer: I think the most simple answer is a bigger package will take more time to start than smaller ones, Spotify is based on electron which (I think) is essentially translating a web app into a package/app which is convenient for companies because they don't need to hire more developers to work on another version of the software but the other hand, it's taking too many resources, we can only hope that developers and companies make more effort into making their apps (especially paid ones), I'd recommend on upgrading to an SSD for better performance system-wide.
Comment: thanks yes makes sense, but this is already running of a 2.5G per second NVME SSD. Also Electron apps via apt are at least 3x faster. Still slow but _much_ faster than snap.
Comment: @JonBentley Yeah, the emphasis is somewhat off on that sentence. Electron is a platform for building applications, and developers use it for the same reason they use any other library or toolkit: to avoid having to reinvent parts they're not interested in innovating. Spotify _could_ build an entire UI library which interfaced directly to your graphics card, but nobody would really notice, so they spend their resources elsewhere.
Comment: "convenient for companies because they don't need to hire more developers to work on another version of the software" - makese sense for small to medium sized companies, but doesn't make much sense for e.g. Spotify which is currently worth $66bn. A few extra developers is pocket change. On the other hand, it's hard to think of another plausible reason.
Answer: I can confirm that Atom and Slack Snaps are slow to launch. After replacing Slack Snap with a .deb package the app launches very fast.
I suspect both are Electron packages. The reason Electron app launches take extra time has to do with its architecture. Electron uses Node.js and Chromium as backend/frontend. When you launch an app it has to build this runtime environment first which takes time.


Approximation of binomial distribution - Poisson vs Normal distribution

Question: Suppose we have a random variable $X \sim \text{Bin}(n, p)$ and we want to approximate $\mathbb{P}\left[X = k\right]$.
In my statistics course we learned two ways to do this:

By using the fact that $X \approx \text{Poi}(\lambda = n\cdot p)$
By using the DeMoivre-Laplace theorem, thus approximating $X$ by the use of the normal distribution

I understand how to apply both of them, but in the context of an exam I am unsure which one to choose for a given problem, if there is no requirement stated.
What are the requirements, disadvantages, etc.. for the two choices?
Comment: If $n$ is large but $np$ remains away from both $0$ and $\infty$, then $\operatorname{Bin}(n, p) \approx \operatorname{Poisson}(np)$. On the other hand, if $n$ is large but $p \in (0, 1)$ is fixed, then $\operatorname{Bin}(n,p) \approx \mathcal{N}(np, np(1-p))$. They describe quite different situations.
Comment: @SangchulLee The Poisson approximation works fine when $np\to 0,n \to \infty$. It is just that both distributions are concentrated near 0 in this case.
Comment: @Ian, I agree :) I was too cautious about excluding degenerate case.
Comment: I believe that you can only really use the poisson distribution for this if $n$ is very large and $p$ is very low. I do not know if this is also required for your second option.
Answer: Both describes two different limiting distribution of binomial distribution.

Poisson approximation. If $n$ is large but $np$ is not large, then $\operatorname{Bin}(n, p) \approx \operatorname{Poisson}(np)$. More precisely, if $X_n \sim \operatorname{Bin}(n, p_n)$ and $n p_n \to \lambda \in [0, \infty)$ as $n\to\infty$, then
$$ \lim_{n\to\infty} \mathbf{P}(X_n = k) = \frac{\lambda^k}{k!}e^{-\lambda} \qquad \text{for all} \quad k = 0, 1, 2, \cdots.$$

Normal approximation. If $n$ is large and $p \in (0, 1)$ is fixed, then $\operatorname{Bin}(n, p) \approx \mathcal{N}(np, np(1-p))$. More precisely, if $X_n \sim \operatorname{Bin}(n, p)$, then
$$ \lim_{n\to\infty} \mathbf{P}\left( \frac{X_n - np}{\sqrt{np(1-p)}} \leq z \right) = \int_{-\infty}^{z} \frac{1}{\sqrt{2\pi}}e^{-x^2/2} \, \mathrm{d}x \qquad \text{for all} \quad z \in \mathbb{R}.$$

As we can check from the precise statements, these approximations primarily cover the limiting cases. So they do not necessarily draws a solid line between two approximations. Perhaps it is better to see directly how both methods perform well for different values of parameters. The followings are plots for these 3 distributions for $n = 1000$ and $p$ varied.

As we see, if $p$ is small, then Poisson approximation is much better (so that even plot markers for those two distributions are rarely distinguishable), while Normal approximation is better for large $p$. Also there are some grey area where both approximates the binomial distribution moderately well.
Comment: @Katharina, That is right. :)
Comment: Thank you, this is a very nice answer. So, given a question in an exam, I should do my choice depending on $p$? For example, in an example where multiple coin tosses were observed I would choose the normal approximation, since $p=0.5$ is rather large, right?
Comment: Thank you very much!
Comment: What I don't like about your answer: 1) "Poisson when $n$ is large and $np$ is not large" ? What do you mean by "large" and "not large" exactly? 2) "Normal when $p$ is fixed" ? The question is: Given $n$ and $p$, what is a better approximation, Poisson or normal? Of course $p$ is fixed!


Benchmark postgresql cluster (postgres-xc) using Daabase Test tool-2 (DBT2)

Question: I'm trying to understand benchmark tool DBT2. I want to benchmark on postgres-xc, i could not get much information about how to set up the environment of postgres-xc for DBT2. I have got the DBT2 from the link
I have fixed some compilation issues. But i have not much idea on how to use this tool. Please provide some insights. I'm completely new o this.  thanks!!
Comment: There's not much people can do to help without more detail to what your problem is.
Comment: I just want to run DBT2 on postgres-xc, I have tried searching, but i could not get much information. All i want to know is how to setup the postgres-xc cluster. I have tried with starting GTM, 1 coordinator and 2 datanodes. But when i start 'run_workload' script, server gets stopped and never starts again. Please Help..
Comment: Assuming you've read everything linked from here: http://postgresxc.wikia.com/wiki/Postgres-XC_Wiki then I would recommend the postgres-xc mailing lists.
Answer: If you are unsure of how to use DBT-2, I would focus on just using it against PostgreSQL itself.
Once you are more familiar with it, you can try DBT-2. I have only run DBT-1 and DBT-3 against Postgres-XC and Postgres-XL.
Note that the DBT-1 version used in testing XC has the schema partitioned a certain way to reduce the amount of implicit two phase commits that you need to do.  I have not looked at DBT-2, but you should select the hash distribution column carefully (CREATE TABLE .... DISTRIBUTE BY HASH(some_column)).  Also, for tables that are fairly static, please add DISTRIBUTE BY REPLICATION to the CREATE TABLE statements.
If you do end up testing Postgres-XC or Postgres-XL, I would love to hear about your results.


Dropdown UI widget for fx/hlsl shader

Question: I've made a HLSL shader (fx format) and would like to add a enum/list paremeter to its UI - as a better alternative to the list of boolean flags.
So instead of :

[x] "Use custom map"
[x] "Use custom map alpha"
[x] "Use diffuse alpha"
[x] "Use specular alpha"
[x] "Use normal alpha"

have:

Source: [ "Use custom map" ]

with all 5 choices and the index to selected item on the code level.
"DirectX Standard Annotations and Semantics Reference" mentions about the ListPicker widget but I can't find any example or description how to use it.
The questions are:

Is it possible to have a custom dropdown-like widget in the shader's UI?
How to achieve it?
Comment: A shader doesn't have a UI ... are you sure you aren't talking about DXUT?
Comment: FX shaders do have user parameters (passed by the user not the application) and those are associated with UI controls - where user may set/adjust parameter values. It's the same for HLSL (FX) and CGFX.

float3 parameter/control definition:

float3 g_ConstantColor
<
string UIName =  "Constant color";
string UIWidget = "Color";
> = {1.0f, 1.0f, 1.0f};

flaot3 parameter/control definition:

float g_ConstantScale
<
string UIName =  "Constant scale";
string UIWidget = "slider";
float UIMin = 1.0f;
float UIMax = 10.0f;
float UIStep = 0.25f;
> = 1.0f;

etc. one of them is list/enum type.
Answer: SAS allows you to set parameters like these but it is entirely ignore by the shader itself.  It is purely meta-data for another system to use if/when it needs too ... it does NOT handle rendering of the UI.  If you want a UI then you have to read this semantic & annotation data and use it to draw a UI.  Either that or use an application that recognises the semantics/annotations structure ...
Comment: Yes, Shaders don't have a UI.

Sas compliant parameters bind the shader to the host application and the application may or may not create the UI for them. It's not the host application but SAS (the name states for itself) defines a standard for parameter annotations. Those annotation are defined according to SAS rules and are part of the shader code. It doesn't matter, if the GPU doesn't care about them.

My question was about the format or example, explaining how this annotation should look so the host application will be able to create the UI control for its parameter.
Comment: @mslaf: Fair enough. What software is supplying the UI then?  Giving you a combo box UIWidget would totally depend on whether the software supports one (It is not a standard DXSAS type).
Comment: FX Composer and XSI - and frankly, I have no idea, if they do support such combos but could not figure it out otherwise, that providing something that matches the SAS docs. The ListPicker is mentioned there without a word of explanation. I'd be happy to see something based on this explanation and works in other shader editing programs like max with mental mill's plugin.

So far I assumed, that the information I've provided as annotations are in the wrong format and thus the host app. was unable to render the controls. But It's possible that the host won't render it anyway.

Dropdown UI widget for fx/hlsl shader


How to automatically close an alert after a certain time React Native

Question: I would like to automatically close an alert after a couple of seconds without having the user do it themselves.
If possible I would like to do this using Alert (not AlertIOS), but if only AlertIOS has it then I guess I have no other choice.
Thank you very much!
Comment: Have you considered using a modal? this would let you control it using a setTimeout() call once it is displayed...
Comment: I have never used a modal, can you elaborate more please?
Comment: Also, how do I even dismiss it myself? In the documentation there is no method to dismiss the alert using code.
Answer: I suggest you use Modal component
<code><Modal
  animationType={"slide"}
  transparent={false}
  visible={this.state.modalVisible}></Modal>
</code>
So you can call setTimeout() in your function to update the state variable modalVisible to show / hide it. More examples can be found here from the official doc (https://facebook.github.io/react-native/docs/modal.html)


Java - ArrayList with multiple int per index

Question: for example I have
int a =1;
int b = 2;
How can I add both values to an index of my arraylist and the be able to read them.(I need to do this in the same class where the list is)
For example with a pseudo-code i need to be able to do
Arraylist<integer> mylist = new Arraylist<integer> ;

int c = mylist.getnode(1).a //gets the value of a in node 1
int d = mylist.getnode(1).b //gets the value of b in node 1

Comment: Seems like you want an `ArrayList` where `SomeClass` contains an int a and int b.
Comment: your question is not clear, you are still living in the cloud, can you calm down and be specific what you want and give example?
Comment: If it would be possible i want it with 1D array. I want to be able to
example pseudo-code
c = mylist.getnode(1).a (gives c the value of a in the first node)
d = mylist.getnode(1).b
Comment: can you write your example pseudo code in your question ?
Comment: What you're describing should be possible with the `get` method from `List`.  Have you made any kind of attempt at this?
Comment: @SeekAddo i did just now
Comment: @MichaelMarkidis problem is i do not want to take it from another class i want to be able to do this in the same class where the list is
Answer: Create a class that contains a and b. Now create a list containing instances of that class.
class Tuple {
public int a, b;
}
ArrayList<Tuple> mylist = new ArrayList<>();
int a = mylist.get(0).a;

Comment: `Set` is a _very_ bad name for this class. First, this is not a [set](https://en.wikipedia.org/wiki/Set_%28abstract_data_type%29). Second, there already is a [Java class](http://docs.oracle.com/javase/7/docs/api/java/util/Set.html) of that name. How about `Tuple` or `Pair`?
Comment: 1) Don't name a class Set. 2) Don't just plop code for an answer without any explanation.
Comment: and shoulld it not be ArrayList since i want to be able to contain 2 ints per node?
Comment: Also, you could make that class generic: `class Tuple { public T a, b}`
Answer: This is bit inefficient and has limitation for variable index which is bounded by the list.size() but here you go
ArrayList<HashMap> list = new ArrayList<HashMap>();
//index is where you want to place your element
if(list.size() > index){
   list.get(index).put(key, value); # in your case key = a, value = 1
}else if(list.size() == index){
   list.add(new HashMap<String,Integer>());
   list.get(index).put(key, value); # in your case key = a, value = 1
}else {
   System.out.println("Index out of bounds");
}

Now you can access your values:
list.get(<some index>).get(<some_key);
#i.e list.get(1).get("a");

Note: if you use above code, you can not access to random index that is out of list.size() - 1. index variable can be atmost list.size()
Best way to do this is to create your own class which has variables for a and b. Then create a list = ArrayList<YourClass>();. That is much more clean
Reason I said above code is inefficient because as I remember HashMap naively create 16 slots when you initialize it without set size, also if you cross that number container doesn't just increase it by one element, it double the size. If you know how many elements you need, you can initialize it to that number.


Can you open the banner or interstitial ad url in the same app using webview?

Question: I'm making an app and implementing banner ad in one of its activity. But when I click on the ad, it opens the web page of the ad in the Chrome or the default web browser that I have, But I want the URL of the ad to open in the same app that I'm making using web view. Is it possible and if it is possible, how to implement it?
Answer: That's not something AdMob supports. There are a number of reasons why, with privacy and security being the most important.
Comment: Thanks ! I thought to implement it as it could lead to a better experience.
Answer: Set a custom URL on Ad click and use deep links(Android App Links) to reach requested behavior.
Cons: On click, you will see for a second or two the browser and just then your app implementation.


EF repository created from mock db context returns the dbset only once

Question: I am writing a unit test for my controller.
The test uses an actual Repository class that uses a mock dbcontext inside. I am creating the dbset as in this helper article, and it works all fine - except that it only works one time per unit test.
http://codethug.com/2015/03/20/mocking-dbset/
This means that:
  IQueryable<User> membersQuery = this.unitOfWork.UserRepository.Get();
            List<User> members = membersQuery.ToList(); //here I get 6 members
            membersQuery = this.unitOfWork.UserRepository.Get();
             members = membersQuery.ToList(); //when its called again, I get 0 members

Why does it behave like that, I would expect that it shoud return the same collection of members both times.
Here is how I create the repository
var enumerable = new List<User>();
// ... populate the mocks list
 var mockedContext = new Mock<MyDbContext>();
 mockedContext.Setup(c => c.Users).ReturnsDbSet(enumerable);
 mockedContext.Setup(c => c.Set<User>()).ReturnsDbSet(enumerable);
 var repo = new Mock<IRepository<User>>();
 return new Repository<User>(mockedContext.Object, this.logger);

For clarity, some most important bits of the repository code:
public class Repository<TEntity> :  IRepository<TEntity> where TEntity : class
{
        protected internal MyDbContext Context;
        protected internal DbSet<TEntity> DbSet;
        public Repository(MyDbContext context)
        {
            this.Context = context;
            this.DbSet = context.Set<TEntity>();
        }

        public virtual IQueryable<TEntity> Get(Expression<Func<TEntity, bool>> filter = null)
        {
            IQueryable<TEntity> query = this.DbSet;

            if (filter != null)
            {
                query = query.Where(filter);
            }

            return query;
        }

Any idea why does it work like that?
Answer: Based on the linked example. The described problem experienced is usually because of this line.
mockSet.As<IQueryable<T>>()
    .Setup(m => m.GetEnumerator())
    .Returns(queryableData.GetEnumerator()); //<-- this here

return queryableData.GetEnumerator() here alony allows for a one time forward only enumeration.
To allow for multiple enumerations return a function.
mockSet.As<IQueryable<T>>()
    .Setup(m => m.GetEnumerator())
    .Returns(() => queryableData.GetEnumerator()); //<-- note the change () =>

the function will be called every time an enumeration is needed, allowing for multiple enumerations of the collection.


How do I polish a marble table top?

Question: I have an old 42" diameter round marble table top which I would like to restore. It is very dull and has deep scratches. On some of the edges, tiny chunks have come off.
I would like to know if this is something I can do myself with a drill and a flat backing plate for circular sanding?
Answer: Deep scratches and broken edges are a bad sign.  If you want to learn about stone polishing, this would be a good learner project.  Don't expect to be able to craft a Michelangelo.  A matte finish would be reasonable, and expect to leave the deeper scratches in place.
Matte marble finish should be polished out to 1500 grit.  Gloss finish out to 3000 and buffed
These diamond pads are meant to be used wet and no higher than 4000 RPM.  Buffers are the usual motor, but there are a few angle grinders that are variable speed and slow enough (Metabo and Makita).

A velcro back is handy to changing the pads.

How do I polish a marble table top?


How to iterate on scala class members for found null value

Question: I need to check if all value is null in a Scala class (Test.class) defined as:
class Test extends Serializable {
  a: String = _
  b: String = _
  c: String = _
}

I can't change this class (is legacy code in my project).
How can i do this without a lot of if? The real class have 22 fields.
I've tried to use java reflection to detect the defined fields, but they are all defined every and I can't access it because the fields are private for the reflectors. (criteria.getClass.getDeclaredFields)
Comment: `field.setAccessible(true)` https://stackoverflow.com/questions/32716952/set-private-field-value-with-reflection
Comment: thanks, I've changed the question with solution.
Answer: Thanks @Dmytro Mitin , it works for me. I think that I will use this approach for check the not null element:
testClass.getClass.getDeclaredFields.flatMap(f => {
        f.setAccessible(true)
        Option(f.get(criteria))
    }).length


Assigning CSS width to a position:fixed element

Question: I'd like a fixed element's width to match that of the div placed immediately below it. Imagine a header and a main content div. A problem in matching their widths occurs when the header and content divs are nested inside an outer div. In this scenario the % widths of each no longer match their parents width (e.g., tag) and the fixed element's width is based on something which is confusing me.
To better explain what I mean, contrast these two js fiddles:

http://jsfiddle.net/2dudX/4/
vs.
http://jsfiddle.net/2dudX/10/

here's the code for each:

#fixed{ position:fixed; z-index:2; width:90%;
        height:25px; background:yellow;}
#content{ width:90%; height:300px; background:red}

vs.

#main{ width:95%}
#fixed{ position:fixed; z-index:2; width:90%;
        height:25px; background:yellow;}
#content{ width:90%; height:300px; background:red}

Note only in jsfiddle #1 do the yellow and red divs widths match up regardless of how you resize the browser. Unfortunately, jsfiddle#2 is more of a real world scenario and I'm wondering how to correct the id="fixed" div such that its width also matches up with id="content" div.
Thoughts?
Comment: check edit below, only just saw the note about matching the widths.
Answer: You can to it this way FIDDLE (to set % relative to the #main)
fixed element's dimensions always is calculated relative to the root element, so you need to reset %-unit accordingly
in this particular case you need to set:
#fixed {
    width: 85.5%;
}

It is case #main is 95%, your static element is 90% relative to the main. So you need to calculate its width towards the root element (1 * .95 * .9 = .855)
Comment: And you need to make sure you set object-fit correctly. I just had an image set to object-fit: cover; Size was messed up. Setting object-fit: contain; fixed it.
Comment: -@caligula, thanks so what you are saying is multiple the two percent widths (.95*.90=.85.5)?
Answer: Easy one my friend. Fixed width elements are yanked from their parents and are now relative in width to the window, so in both situations the fixed div is always relative to the size of the window, but when in a parent container with a width other than 100% the fixed element will remain relative to the window width but the non-fixed position element is now relative to the parent width. So the non-fixed element became 90% of the 95% of the window while the fixed element remained a constant 90% of the window only.
Edit:
If you wish to match the widths you can use jquery like this:
$(function(){
    $('#fixed').width($('#content').outerWidth());
});

Comment: No way to do this using just CSS without having to get the calculator out? I hate doing JS style manipulation.
Answer: In modern CSS, the width of #fixed can be calculated using the following:
#fixed {
  width: calc(100vw * (0.95 * 0.9));  /* or just use 100vw * 0.855 */
}

You would still need to know the width to which the other element is set (i.e. it won't automatically update the width of #fixed if the matching element width CSS value is changed) but at least there's no need to get out the calculator.


How can i reach the treasure in the right door of Desert Temple?

Question: How can i reach the treasure in the right door of Desert Temple? I can't jump there.
Answer: Use the teleport spell and the enchanted spear to make a staircase with the summoned tribals


c++ Run-Time Check Failure #2 - Stack around the variable 'ToSend22' was corrupted

Question: I have no idea why is that happening - when ever I call this function I have and send TCP messages to the client, I've got this:
Run-Time Check Failure #2 - Stack around the variable 'ToSend22' was corrupted.
Whenever the client is disconnected. ToSend22 is STD string which I am doing
const char *ToSend288 = ToSend22.c_str();
Client.Send(ToSend288, ToSend22.size());

Why is that happening? Thanks.
Comment: What API is Client.Send?
Comment: SFML http://www.sfml-dev.org/
Comment: There's nothing wrong with the two lines of code you posted. The problem with your code is elsewhere. One of the most difficult things for newbies to learn about C++ programming is that just because an error shows up in one place in your code, does **NOT** mean that the error is in that place in your code. The error usually happened some time earlier on. So post a bit more code if you want us to help find the problem.
Comment: I have 5000 lines of code here, I can't post them all.. No i actually mean it, it's a game server that is done, only that's bug. What should I do?
Comment: Is the Send method your code?  If so, post that since that's probably where the error occurs.
Comment: First I'd try a debugger. If that isn't helpful or productive I would start cutting code, starting at what you think are the most likely problem areas. At some point as you cut more and more code the bug will go away. At that point there's a fair chance you've found the problem code. It may then be obvious but otherwise post the problem code here.
Answer: Most probably Client.Send is modifying the char* buffer you are passing to it.
Or other local variable in same function is being overwritten somehow, which is affecting ToSend22 variable. Array or pointer mis-use is definitely involved in this function.
Please post some more code.


Connectors on wires entering a plastic box

Question: I brought a 14/3 U/F cable into a single plastic nail-on box, through a hole that I drilled through the back of the box. Do I need a connector on that wire, and if so what would you recommend a black button Romex connector backwards?
Comment: @isherwood For some reason the industry refers to cable clamps as "connectors". That would be like referring to your car's shocks as a "carburetor" but whatever.
Comment: @D.M.Electricprotectyatech -- just tell us the size of the hole you put in the box and we'll go from there :)
Comment: What size hole did you drill?
Comment: I could easy fit a 3/4 or one inch black button romex connector on backwords but isk if thats cool
Comment: but why backwards?
Comment: By "connector" do you mean a strain relief clamp?
Comment: I got snipped once by an inspector when I drilled a hole in the side several single gang plastic boxes because of unusual mounting requirements. I ran BX cable with the proper ends and everything.   He said I "modified" the box which isn't allowed. I think he was being overly picky, but he's the one with the badge.
Comment: Thanks. I suppose that's accurate in a sense--you're connecting the cable shield to the junction box--also a shield in a sense.
Comment: OK.  I'll stop with this, bc it's getting to chitchat, but I've often wondered about the term "bonding" when it comes to connecting the grounding to the neutral. Why isn't it just "connected".   Oh well, maybe a real electrician knows the answer.
Answer: I have used listed clamps on construction boxes but black button connector is a device like an "insider" plastic clamp it is only listed for 1 direction. Mechanical 2 screw clamps can be installed with the screws on the inside or outside. On plastic boxes if you have a bushing to protect the insulation the staple needs to be within 8" not all plastic boxes have clamps but if you drill a hole it will require protection for the wire at a minimum. I would say based on that it doesn't matter but if the instructions for your clamp provide a direction the inspector can flag it.


How to batch add header/footer to pdf files in Ubuntu?

Question: Is there a command or script that would help me ease the process of adding page numbers to a PDF with hundreds of pages? Thanks.
Answer: Using LaTeX!
0) Install LaTeX if necessary
1) In the following latex document replace x.pdf by your file.pdf
\documentclass{article}
\RequirePackage[a4paper,top=3cm,left=3cm,right=3cm,bottom=3cm]{geometry}

\usepackage{pdfpages}
\usepackage{fancyhdr}
\begin{document}

\fancyfoot[RO]{Braga}
\fancyfoot[LO]{2015}
\fancyfoot[CO]{===}

\fancyhead[LO]{Lecture notes of askubuntu}
\fancyhead[RO]{\thepage}

  \includepdf[pagecommand={\thispagestyle{empty}},pages=1 ]{x.pdf}
  \includepdf[pagecommand={\thispagestyle{fancy}},pages=2-]{x.pdf}

\end{document}

3) run pdflatex addfooter.tex and a addfooter.pdf will be created.
4) adapt the headers, footer (left,center, right), tune margin's sizes, etc.
Update:
Although LaTeX version give us more control over the details,
as @steeldriver, pointed out,
in some situations a pdfjam command line is the best choice. Typical use:
pdfjam --outfile newfile.pdf --pagecommand '{}' oldfile.pdf

Comment: The `pdfjam` package provides a possibly more convenient interface to Latex's `pdfpages` functionality e.g. `pdfjam --outfile newfile.pdf --pagecommand '{}' oldfile.pdf`
Comment: @steeldriver, thank you! `pdfjam` is always a good idea, but in this case I believe we will need to tune several details, (define margins, page size, header and footer details, and probably some unnumbered pages, etc)
Comment: thx, that helped me. can someone maybe give a hint on how to move the output of ```--pagecommand``` to the top, or more in general where can i find documentation about what is possible with ```--pagecommand```? maybe bold text or colors are interesting too. thx in advance!
Comment: @divramod here is the [pdfpages manual](http://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages/pdfpages.pdf)
Answer: I actually found a much better solution myself. Rather than doing it manually as suggested above, and wasting time on figuring it out, the easiest way is to simply install jpdftweak package. It does this and more with a couple of mouse clicks. Enjoy!


Should properties or fields be used internally in classes?

Question: Typically you want to encapsulate data by providing getters and setters for your internal state. Example:
public class Person {
    private int age;
    public int Age {
        get { return age; }
        set { age = value; }
    }
}

void Main() {
    Person alice = new Person();
    alice.Age = 20;
}

But let's say we then have this happen:
public class Person {
    private int age;
    public int Age {
        get { return age; }
        set { age = value; }
    }

    public String WhatIsMyAge() {
        return "My age is: " + ???;
    }
}

void Main() {
    Person alice = new Person();
    alice.Age = 20;

    Console.WriteLine(alice.WhatIsMyAge());
}

Is it better to use the property, or the field, here? Does it matter? Since we are inside the native class, do we still care about encapsulating the internals?
Comment: Unless there is a very clear reason to use a field I always use properties. You will have a single point to look for if you need to change something (like if you want to calculate the age depending on a birthdate)
Comment: you'd simply use the property.  otherwise, why would you have one?
Comment: There are many problems with mutable fields, including persistence, equality comparisons, race conditions; but the big problem with your example is correctness. If you detect `Age == 20` you have no way to know if it is correct; it might have changed since it was set. Yes, some times mutable fields are necessary but this is not such a case; Birthdate is immutable and you can calculate Age from that.
Comment: `Age` is a poor choice for fields because it is mutable. `Birthdate` is a better choice.
Comment: @DourHighArch I guess I get what you mean by it being a poor choice of it being mutable, but is that only because someone might accidentally change it, or is it a more programmatical concern? (thread-safety, for example)
Answer: If you are using simple properties without any extra functionality, it doesn't matter.
However, in such case, why wouldn't you choose to use Auto-implemented properties ?
If your property getters or setters contain extra functionality, then it does matter offcourse whether or not you're using the property accessors or the backing fields directly.  It all depends on the required behaviour then.
Comment: I would. But I added the backing variable explicitly for the verbosity to help my question.
Answer: Always use the Property, especially in class code. I will go as far as saying: Accidentally using the backing field of a property in class code critical mistake.
A high amount of effort should be made to not accidentally using the backing field:

If you use autoimplement properties, there is no backing field name you could use accidentally. (well there is one of course, but it does not has a name; So using it accidentally is not possible).
If autoimplement Properties are not (no longer) enough, I always append a Underscore to the backing field. age and Age are much easier to mix up the _Age and Age.
Some people go beyond that. Like using a Dictionary<string, object> to be the backing field(s) for every class. Using "CallerMemberName" and simialr syntax sugar, figuring out the property name to use as Index can be trivial.
Comment: Why is it a *critical* mistake ?
Comment: A large part of the point of having propertes (rather then raw fields) is the code you (may) call when you get and set them. But once you have other code (like the constructor) ignoring the properties and going for the backing field, you can never take that back without breaking code expecting that behavior.
Answer: In your example:
private int age;
public int Age {
    get { return age; }
    set { age = value; }
}

You should use auto-implemented properties anyway.
But if you'd have a backing field to provide additional logic in a property's getters or setters, such as validation, definitely use the property instead of the backing field: this makes it impossible for the type to assign values to properties which wouldn't pass validation when assigned through the property's setter.
It should be safe to read the backing field, because getters shouldn't contain logic anyway. But for consistency, perform both read and write action through the property.


What is this white rhombus icon on the mini map in Enter the Gungeon?

Question: In Enter the Gungeon, this white distorted rectangle icon appeared after I cleared a room in floor 1:

The room looks empty and the icon on the mini map seems to correspond to the walls in the center:

So what does this icon mean?
Comment: I haven't played the game, but the white rhombus on the minimap looks like it's just the staircase-shaped wall in the middle of the room, isn't it? Otherwise, I'm not sure which rhombus you are referring to.
Answer: Indeed, it is just the walls. I got a similar room on another run and was able to verify it.


Group_Concat() is not working properly in mysql

Question: I have three tables :
em_employee :
emp_number | emp_firstname |
+------------+---------------+
|          1 | Vikram        |
|          2 | S.            |
|          3 | Gopal         |
|          4 | Vaishnavi     |
|          5 | Srinivasan    |
|          6 | Saravanan

em_project
+------------+------------------------------+
| project_id | name                         |
+------------+------------------------------+
|        339 | MoneyGram                    |
|        340 | SERVICE LINE HEAD COMPLIANCE |
|        341 | SERVICE LINE HEAD ANALYTICS  |
|        342 | GSI                          |
|        343 | Tandem                       |
|        344 | Master Card                  |
+------------+------------------------------+

em_project_employee:
+------------+------------+
| emp_number | project_id |
+------------+------------+
|          1 |        339 |
|          2 |        340 |
|          3 |        341 |
|          4 |        342 |
|          1 |        343 |
|          6 |        344 |
|          2 |        342 |
+------------+------------+

And I want Output like :
+------------+----------------------------------+
| emp_number | name                             |
+------------+----------------------------------+
|        1   | MoneyGram , Tandem               |
|        2   | SERVICE LINE HEAD COMPLIANCE,GSI |
|        3   | SERVICE LINE HEAD ANALYTICS      |
|        4   | GSI                              |
|        6   | Master Card                      |
+------------+----------------------------------+

I have tried it with GROUP_CONCAT, but something going wrong. Please help me on this.
Comment: Means? I am not getting.
Comment: That means don't include tags that are irrelevant to your question, like `sql-server`.
Comment: *but something going wrong.* Were you going to tell us what's wrong? Or were you hoping we'd guess what you tried and what the problem was.
Comment: Okay okay Got it.
Answer: Try this query, it produes that output:
SELECT emp_number, GROUP_CONCAT(name) FROM em_project p
INNER JOIN em_project_employee em ON p.project_id = em.project_id
GROUP BY emp_number;

The order of the data will e slightly different from what's in your desired output. If the ordering is important.
GROUP_CONCAT(name ORDER BY p.project_id)


To make changes in the Textarea according to the selection

Question: I need to make a program wherein , when i select whichever font-family,font-size,background-color and text-color  from the drop -down, same changes should be made to the text in the textarea. As of now, if i change the background color , only that changes, nothing else happens to the text area. Please help.

<title>Binding</title>

<select id="bgColorPicker" onchange="changeColor()">
    <option value="transparent">--Select--</option>
    <option value="#FFFF99">Yellow</option>
    <option value="#0099CC">Blue</option>
    <option value="limegreen"> Green</option>
</select>

<select id="fontPicker" onchange="changeFont()">
    <option value="transparent">--Select--</option>
    <option value="Arial">Yellow</option>
    <option value="Verdana">Blue</option>
    <option value="Georgia"> Green</option>
</select>

<select id="textColorPicker" onchange="changeTextColor()">
    <option value="transparent">--Select--</option>
    <option value="#DAA520">GoldenRod</option>
    <option value="#6B8E23">OliveDrab</option>
    <option value="#DC143C">Crimson</option>
</select>
<select id="fontSizePicker" onchange="changeFontSize()">
        <option value="transparent">--Select--</option>
        <option value="100px">Large</option>
        <option value="50px">Medium</option>
        <option value="20px">Small</option>
    </select>

    TextArea:<textarea name='textarea'  rows='15' cols='50'></textarea>

Answer:
You forgot to add id to the textarea
document.getElementById('textarea').color should be document.getElementById('textarea').style.color
document.getElementById('textarea').style.fontStyle should be document.getElementById('textarea').style.fontFamily

function changeColor() {
  var newColor = document.getElementById('bgColorPicker').value;
  document.bgColor = newColor;
}

function changeFont() {
  var newFont = document.getElementById('fontPicker').value;
  document.getElementById('textarea').style.fontFamily = newFont;
}

function changeFontSize() {
  var newFontSize = document.getElementById('fontSizePicker').value;
  document.getElementById('textarea').style.fontSize = newFontSize;
}

function changeTextColor() {
  var newTextColor = document.getElementById('textColorPicker').value;
  document.getElementById('textarea').style.color = newTextColor;
}
<select id="bgColorPicker" onchange="changeColor()">
    <option value="transparent">--Select--</option>
    <option value="#FFFF99">Yellow</option>
    <option value="#0099CC">Blue</option>
    <option value="limegreen"> Green</option>
</select>

<select id="fontPicker" onchange="changeFont()">
    <option value="transparent">--Select--</option>
    <option value="Arial">Arial</option>
    <option value="Verdana">Verdana</option>
    <option value="Georgia"> Georgia</option>
</select>

<select id="textColorPicker" onchange="changeTextColor()">
    <option value="transparent">--Select--</option>
    <option value="#DAA520">GoldenRod</option>
    <option value="#6B8E23">OliveDrab</option>
    <option value="#DC143C">Crimson</option>
</select>
<select id="fontSizePicker" onchange="changeFontSize()">
        <option value="transparent">--Select--</option>
        <option value="100px">Large</option>
        <option value="50px">Medium</option>
        <option value="20px">Small</option>
    </select> TextArea:

<textarea name='textarea' id="textarea" rows='15' cols='50'></textarea>


Where are the roasted pepitas?

Question: I needed some to make birch candies in order to get another recipe for my sauce pan but I couldn't find them anywhere. I ended up buying 50 from an auction because I couldn't find them in the game. So where do they come from? I thought I saw something that said they came from pumpkins, but I haven't seen any pumpkins either. Apparently they are seasonal as well, but I have been playing since before Halloween, so I don't know what season pumpkins come in except the fall season?
TL;DR Where in the game do roasted pepitas come from?
Comment: Add me as a friend (agent86) and I'll send you whatever I've got.  They're only available around Zilloween.  If you plan on growing pumpkins to make Birch Candies around the holiday, stock up on paper *now* - the price of paper goes through the roof when candy season comes around.
Answer: From the Glitch wiki:

Roasted Pepitas are a seasonal Food: roasted Pumpkin seeds. They are
  acquired by carving a Pumpkin, using Knife & Board and a Pick. Carving
  one Pumpkin gives 5 Roasted Pepitas (and a Carved Pumpkin).
Pumpkins are a tasty seasonal crop. They can only be grown or carved
  during Zilloween. You can grow these in a crop or a herb garden.
  Pumpkin Seed is available at Gardening vendors.
Answer: Roasted Pepitas comes from carving a Pumpkin (which gives you five) as well as smashing a carved pumpkin (which gives you an additional five).
While the Pumpkins, Pumpkin Seeds, Pepitas and the recipies stay after Zilloween, the carve verb, the Pumpkin Seeds in the Gardening Goods Vendor and the ability to plant them are only available during Zilloween. Any carved Pumpkins, unlit and lit, decompose into Pepitas and Pumpkin Pies after the event.
Zilloween is a holiday that happens every 37th of Remember every Glitch Year. Since time in Glitch passes six times as fast, and there are 308 days in every Glitch year, the event occurs every 51.3 Earth days. The period of time in which the holiday items are 'active' lasts several real world days.
As to answer the actual question, the best way to get Pepitas off season is simply to ask. Glitch is, ostensibly, a social game, and the players are generally very friendly. Asking on Global, group or even local chat will usually get you someone who is willing to trade or give you the item you need. Supply of items on auction can be finicky, and you often get overcharged for rarer items like Pepitas.
Comment: As an aside, the next Zilloween will happen on the 12/1/2012 at 10am GMT

Where are the roasted pepitas?


Meteor 1.4 - General approach to file system + /public activity

Question: I've done some digging around and a lot of the threads regarding file system and how it works with Meteor seem to be pretty outdated, not to mention packages related to file storage/serving (i.e. CollectionFS). I was wondering if anyone here has deep experience with handling files in lieu of 1.4 or even 1.3 (I am currently on 184.108.40.206).
My questions are as follows:

Did Meteor 1.3/1.4 come with any changes regarding fs?
What is the general best approach to storing and serving static assets in light of Meteor 1.4?
I've seen many threads that say dynamically storing files to /public triggers a server upload, but I've tested this on local by manually copy/pasting a .png file into /public, and it only triggers a client refresh with the console message Client modified -- refreshing. Would this hold true for files added during runtime, and would it hold true in production?

Currently I am trying to stay clear from S3 or any other third party CDN's to keep a low budget, and also trying to stay clear from storing files into Mongo.
Thanks for any and all opinions!
Answer: What about setting up a shared folder or NFS folder, have your Meteor app handle the file upload, write the file to that location, and configure Nginx or whatever you are using as the load balancer to serve those files.  If you worry about browser refreshed when the file is put into the public folder, you do not need to write files to the public folder right?


PHP Check if user is logged in with a function

Question: I'm working on a website and the index page checks if the user is logged in or not with this piece of code:
if (!$_SESSION['login'] && $_SESSION['login'] == "") {
include_once($_SERVER['DOCUMENT_ROOT'] . "/login/");
} elseif ($_SESSION['login'] == 1) {
include_once($_SERVER['DOCUMENT_ROOT'] . "/main/");
}

But I want it to look cleaner, then I started wondering if was possible to achieve something like this with a function:
checklogin($_SESSION['login']);

I don't have much experience with functions, so i'm sorry if my question looks stupid, so thanks in advance.
Comment: Don't worry, both snippets you posted are perfectly valid. It's up to you how to structure your code and where to put the logic. But it must be *somewhere*. So if you just want that function (as in the second example), the logic from the previous example will have to be *inside* that function. It can't just go away.

You should re-use an existing authentication framework whenever possible, because, really, it's complex. For example, take a look at https://github.com/delight-im/PHP-Auth which is both framework-agnostic and database-agnostic.
Answer: Try this
if(check_login()) {
  echo 'You are in!';
} else {
    header('Location: login.php');
    exit;
}

function check_login () {
    if(isset($_SESSION['login'] && $_SESSION['login'] != '') {
       return true;
    } else {
       false;
    }
}

Answer: Just use empty:
if ( empty($_SESSION['login']) ) {
    include_once($_SERVER['DOCUMENT_ROOT'] . "/login/");
} else {
    include_once($_SERVER['DOCUMENT_ROOT'] . "/main/");
}

Or condense it:
include_once $_SERVER['DOCUMENT_ROOT'].(empty($_SESSION['login']) ? "/login/" : "/main/");

Answer: There is what you need:
function userCheck()
{
    return (isSet($_SESSION['login']) && $_SESSION['login']);
}

if(userCheck())
    include_once($_SERVER['DOCUMENT_ROOT'] . "/main/");
else
    include_once($_SERVER['DOCUMENT_ROOT'] . "/login/");

Answer: Disregarding the fact of whether or not your approach makes sense, I think this would do what you expect:
function checklogin($login){
      if (!$login && $login == "") {
          include_once($_SERVER['DOCUMENT_ROOT'] . "/path/");
      }
}

// **** call to the function

       checklogin($_SESSION['login']);

// ****

Answer: You can use this function:
function checklogin() {
  return (isset($_SESSION['login'])) ? true : false;
}

then on pages you want to check whether the user is logged in or not, you can:
if(checklogin() === true){
  //here you would put what you want to do if the user is logged in
} else {
  //this would be executed if user isn't logged in
  header('Location: protected.php');
  exit();
  //the above would redirect the user
}


Class imported from two different paths is not equal?

Question: It seems that entities imported using two different PYTHONPATHs are not the same objects.
I have encouneted a little problem in my code and I want to explain it with a little testcase.
I created the source tree:
a/
  __init__.py
  b/
    __init__.py
    example.py

in example.py:
class Example:
  pass

and from the parent of folder a, I run python and this test:
>>> import sys
>>> sys.path.append("/home/marco/temp/a")
>>>
>>> import a.b.example as example1
>>> import b.example as example2
>>>
>>> example1.Example is example2.Example
False

So the question is: why the result is False? Even if imported by two different paths, the class is the same. This is a complete mess if the class is a custom exception and you try to catch it with except.
Tested with python 3.4.3
Answer: In Python the class statement is an executable statement, so each time you execute it you will create a new class.
When you import a module Python will check sys.modules to see whether a module at the specified path already exists. If it does then you will just get back the same module, if not it will try to load the module and execute the code it contains.
So two different paths to the same module will load the code twice, which executes the class statement twice and you get two independent classes defined.
This usually hits people when they have a file a.py which they run as a script and then in another module attempt to import a. The script is loaded as __main__ so has different classes and different global variables than the imported module.
The moral is, always be consistent in how you reference a module.
Comment: Not the file path, the module path, i.e. the name of the module which here is `a.b.example` or `b.example`. Two different names, two different modules.
Comment: `When you import a module Python will check sys.modules to see whether a module at the specified path already exists` The problem is the real module path is the same indeed, it's the `PYTHONPATH` that differs. Since I'm using python3 that disallows `..` imports, I think the real path could and should be checked instead.
Comment: Regarding "not the module path": It is possible (in python3.6) that str(class1) == str(class2), but class1 != class2.
str(classX) seems to show the module path, it looks like this:  ''
Answer: The is operator is used to check if two names are pointing to the same object (memory location).
example1.Example is example2.Example

are obviously not pointing at the same locations since you are importing the same object two times.
But, if you did something like:
a, b = example1.Example, example1.Example

a is b # True

Instead, you should use the == operator:
example1.Example == example2.Example
True

Note that if you don't implement __eq__or __hash__, the default behavior is the same as is
Comment: Have you tried that? Equality comparison for the two classes will return `False` even if their definitions are identical. For a class `==` is usually exactly the same as `is` (though I guess you could override the behaviour with a metaclass but that would be unusual).
Comment: @Duncan Yes, if you don't implement `__eq__`or `__hash__ `The default behavior is the same as is
Comment: @Duncan If that was always the case, since everything is an object in python, `==` would works for nothing.
Comment: No, is you define `__eq__` on a class then you have redefined comparison for the instances of that class. Lots of classes do that. To redefine comparison for the class itself you have to define `__eq__` on the metaclass. That is pretty unusual (any use of metaclasses is fairly unusual).


Key bindings disappear after changing JTable model

Question: I have a JTable which is created as below with a default empty model.
If I change that data model by the external processing of a text file (CSV), and reset it using RosterTable.setModel(...), the the standard key binding for TAB and Shift+TAB are lost.  The change of the TableModel is a pretty standard, and laid out below.
So the symptom is: A brand new RosterTable performs as expected, meaning that TAB moves one cell to the right, Shift + TAB moves one cell to the left and both wrap to the next/prev row at the ends of the table rows.  After the call to setModel(), TAB and Shift + TAB no longer function at all.
Why would the InputMap change when setting the TableModel?
NOTABLY: Other tables within the same application load their tables at instantiation by use of a serialized object.  These tables also function normally with the TAB and Shift + TAB keys.  Changing the data in the table "on the fly" by manual editing does not seem to affect the key bindings either.  It only seems to show errors when using setModel.
RosterTable = new javax.swing.JTable();

RosterTable.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {
        {null, null, null, null, null, null, null, null},
        {null, null, null, null, null, null, null, null},
        {null, null, null, null, null, null, null, null},
...
    },
    new String [] {
        "Callsign", "Close Time", "Notes", "Precedence", "Dest RI", "List Time", "Status", "Sent Time"
    }
) {
    Class[] types = new Class [] {
        java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
    };

    public Class getColumnClass(int columnIndex) {
        return types [columnIndex];
    }
});

RosterTable.setFillsViewportHeight(true);
RosterTable.setRowSelectionAllowed(false);
RosterTable.getTableHeader().setReorderingAllowed(false);
RosterScrollPane.setViewportView(RosterTable);
RosterTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
setRosterTableColumWidths(); // to resize columns to preferred widths
RosterTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
RosterTable.setGridColor(java.awt.Color.DARK_GRAY);
RosterTable.setShowGrid (true);

Then when the table data needs to be changed in a wholesale manner, the code to accomplish this looks like the following.  The first statement is the recipient of the output of a FileChooser open action.  EMPTY is a static empty String in case that is not abundantly obvious.
        File f = fc.getSelectedFile();
        String lineIn = null;
        int count = -1;
        Vector<Vector> data = new Vector<>();
        Vector<String> row = null;
        String[] tokens = null;
        String delim = ",";
        try {
            BufferedReader br = new BufferedReader(new FileReader(f));
            // skip all data before the roster itself
            while ((lineIn = br.readLine()) != null) {
                // call is the start of the header text line
                if (lineIn.startsWith("NCS:")) {
                    break;
                }
            }

            // now process all roster lines until we get to BT
            while ((lineIn = br.readLine()) != null) {
                if (lineIn.startsWith("BT")) {
                    // we found the end of the data
                    break;
                }
                count++;
                row = new Vector<>();
                tokens = lineIn.split(delim);
                if (tokens.length > 0) {
                    for (String token : tokens) {
                        row.add(token.equals(EMPTY) ? null : token);
                    }
                } else {
                    for (int i = 0; i < 8; i++) {
                        row.add(null);
                    }
                }
                data.add(row);
            }
            br.close();
            // now fill the rest of the rows with nulls so
            // empty rows may be filled by the user in the UI
            while (count < 100) {
                row = new Vector<>();
                for (int i = 0; i < 8; i++) {
                    row.add(null);
                }
                data.add(row);
                count++;
            }
        } catch (FileNotFoundException ex) {
            Logger.getLogger(StationManager.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(StationManager.class.getName()).log(Level.SEVERE, null, ex);
        }
        // reload the column labels from existing
        Vector<String> colsV = new Vector<>();
        TableModel tcm = RosterTable.getModel();
        for (int i = 0; i < 8; i++) {
            colsV.add((String) tcm.getColumnName(i));
        }
        TableModel tm = new DefaultTableModel(data, colsV);
        RosterTable.setModel(tm);
        setRosterTableColumWidths();

Once this method is complete, the table model is correct, but TAB, Shift+TAB, and ENTER no longer work the same as when the table model was first initialized.  TAB, Shift+TAB and ENTER put the highlighted cell into edit mode only.  The arrow keys function as normal.  Text may be typed into any cell per normal also.
Does the JTable care that I build a new model with Vector instead of String[], etc.?  Doesn't sound logical to me.
Here is an SSCCE, and as noted in comments, it works as expected, so I am more confused now. ;)
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

public class TableModelChange extends JFrame {

private JTable t = null;

public TableModelChange() {
    super();
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setBounds(100, 100, 500, 200);
    JButton loadModel = new JButton("Load New Model");
    loadModel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            loadModelButtonActionPerformed(evt);
        }
    });
    t = new JTable();
    t.setModel(new javax.swing.table.DefaultTableModel(
            new Object[][]{
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null}
            },
            new String[]{
                "Col1", "Col2", "Col3", "Col4", "Col5", "Col6", "Col7", "Col8"
            }
    ) {
        Class[] types = new Class[]{
            java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
        };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }
    });
    this.getContentPane().add(t, BorderLayout.CENTER);
    this.getContentPane().add(loadModel, BorderLayout.NORTH);
    this.pack();
}

private void loadModelButtonActionPerformed(ActionEvent evt) {
    Vector<Vector> data = new Vector<>();
    Vector<String> row = new Vector<>();
    for (int j = 0; j < 6; j++) {
        for (int i = 0; i < 8; i++) {
            row.add("A");
        }
        data.add(row);
    }
    Vector<String> colsV = new Vector<>();
    TableModel tcm = t.getModel();
    for (int i = 0; i < 8; i++) {
        colsV.add((String) tcm.getColumnName(i));
    }
    t.setModel(new DefaultTableModel(data, colsV));
}

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            TableModelChange tm = new TableModelChange();
            tm.setVisible(true);
        }
    });
}

}

Comment: `Why would the InputMap change when setting the TableModel?` - It won't. Post a proper [SSCCE](http://sscce.org/) that demonstrates the problem.  And fix your variables names while creating the `SSCCE`. Variables should NOT start with an upper case character.
Comment: The likely causes are, you're creating a new instance of `JTable`; the `JTable` on the screen isn't the one which you've applied the key bindings to; some other guess I've not thought of
Comment: Why are you changing the JTable data model?  Create one table model and add and / or remove rows from that data model.
Comment: I was considering that as well.  It would involve deleting the data in the model already, which is not too bad since max it is only 100 rows and 8 columns of `String`.  That way, I won't have to reset the column widths and such also.
Comment: But I also make use of a `tableChanged` handler on `TableModelEvent`s, so that complicates things a bit.
Comment: @MadProgrammer, there is no new instance of JTable.  I create a Vector of String for the data and Vector for column names and do a setModel() on the original table object, as noted in the original text above.  I will add the actual model build and set into the question.
Comment: In the process of SSCCE now.  Interestingly, I cannot recreate the issue when simplifying the process using static data in the SSCCe.  I am beginning to suspect the TableModelListener somehow...or perhaps I didn't get this GUI on the EDT...hmmm..
Comment: SSCCE added, and it functions properly after a model change.  I have examined the content of the InputMap before and after model change as well as the ActionMap using a step debugger.  Nothing out of the ordinary, though they are layered due to ancestry so that can get interesting to trace.  Though less efficient, I may try @Gilbert Le Blanc 's suggestion at least as a sanity check and delete and add rows in the current model.
Comment: It works because you're not losing Key Bindings from a model change, since this won't cause that side effect. Something else is going on, and this means that you have to do more debugging.
Comment: I tried simply changing the rows of the existing model and I get the same result.  Interesting twist however:  I changed on the fly from Nimbus L&F to Metal L&F and the InputMap/ActionMap issues disappeared.  If I did the same data model change function in the Metal L&F the problem reappeared.  Then if I changed back to Nimbus, the problem once again went away....and so on.
Comment: ...and the SSCCE does not include L&F code, but it functions as expected.
Comment: So this makes me ponder, "I wonder if the L&F interaction is involved, so perhaps I should try to explicity re-set these KeyStroke bindings in the ActionMap just for grins??"  Details at 11.
Comment: More info:  I have two `JTable`s in the same GUI.  When I lose key bindings in the subject table, they are also lost on the other table.  This is definitely up the hierarchy somewhere.
Comment: It even happens when the GUI spawns another `JFrame` with a `JTable` in it.  This GUI is defaulted to Nimbus or Metal when created and I can change back and forth on the fly.  Doing so "fixes" the issue util the model is updated again.  I am going to turn off the plaf "feature" and use the default plaf and see what happens.
Comment: If I add a call to load the existing L&F after changing the `JTable` model,  the problem disappears.  **For now, that's the workaround**, but I would love to get to the bottom of this issue.  Suggestions on how/where to trace would be welcome.
Answer: If I add a call to load the existing L&F after changing the JTable model, the problem disappears. For now, that's the workaround, but I would love to get to the bottom of this issue. Suggestions on how/where to trace would be welcome.


What is the purpose of angular-sanitize ?

Question: I was just going through the examples for a angular and openlayers directive HERE and came across the following example:
<!DOCTYPE html>

    <link rel="stylesheet" href="../bower_components/openlayers3/build/ol.css" />

    <openlayers ol-center="center"  height="400px"></openlayers>

Center autodiscover example

    <form>
        Latitude : <input type="number" step="any" ng-model="center.lat" />
        Longitude : <input type="number" step="any" ng-model="center.lon" />
        Zoom : <input type="number" step="any" ng-model="center.zoom" />
        <button ng-click="center.autodiscover=true">Discover position</button>
    </form>

The example can be seen as a live example HERE.
My question is about the files being loaded,  I don't quite understand why the below script being loaded:

What is the purpose of the above script ?
EDIT:: : i found out the git repo and the docs here for this module in angular HERE. , but i still don't understand the purpose of this script , the documentation does't even have a single example.
I have coded in jQuery a fair bit , so can somebody explain this in jQuery terms ?
Answer: If you include the angular-sanitize script, inputs are sanitized by parsing the HTML into tokens. All safe tokens (from a whitelist) are then serialized back to properly escaped html string. This means that no unsafe input can make it into the returned string.
I have included a small example below inspired by this blog post. If you run this script with var app = angular.module("app", ["ngSanitize"]); the html links are rendered correctly. However, if you comment this statement out and uncomment var app = angular.module("app", []); the following error message is raised: Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context.

<!DOCTYPE html>

  <link rel="icon" type="image/x-icon" href="favicon.ico">

Comment: `ng-sanitize` is not needed for static html, but should be used when the html input is dynamic or comes from client input, either directly or indirectly.
Comment: Does it mean that `ng-sanitize` is only useful in cases where html input is dynamic or comes from client input? So when using only static html and template urls (from our own trusted domain (https) or from template cache) for loading html in our views/directives there is no need for `ng-sanitize`? Or are there other cases where `ng-sanitize` should be used.


Halo 3 legendary ending

Question: If I want to watch Halo 3's extended "legendary" ending, do I have to beat the entire campaign on Legendary difficulty, or could I just beat it on Easy and then beat the final mission on Legendary?
Comment: You don't have to beat the campaign at all - just YouTube it!
Answer: You only need to complete the final mission on Legendary. The difficulty setting for the rest of the campaign is irrelevant. This has been confirmed by other players as well.

Halo 3 legendary ending