How to get rid of fruit flies on front porch

Question: I think they are fruit flies since they are small. They move at regular speed like a fly but they keep hovering all day on my front porch.
I do have a waterbody (small fountain) there now, but it was dry for 4-5 months when I was fixing it, but the flies were still there.
How do I get rid of them?
Thanks
-Amit
Answer: Fruit flies by their name are attracted to fruit and rotting food. So they live and multiply around damp mulch, compost bins, rubbish bins, pastures (with cows) etc.

For inside you can spray them with flyspray or install insect screens on your doors and windows.
For the porch, you really need to remove the source.  Look for the spot where the numbers are huge and see if you can get rid of it.  We spray flyspray in our compost bins to control them.
Comment: Websearch will find many DIY fly traps that use vinegar, or occasionally diluted honey, as the attractant. Some commercially sold traps are exactly that in fancier packaging. If the infestation is particular bad, I've been known to spendd an hour cutting down the population by chasing them with a vacuum cleaner. MAKE SURE no other food source is available for them to feed/breed on.
Comment: +1: in my experience this is always the case.  My friend asked "how do I get rid of fruit flies in my kitchen", and I ironically replied "get rid of the rotting fruit!"  He got home and realized there was some very old produce on top of the fridge, hiding behind a bunch of boxes.  He tossed it out, and the fruit flies disappeared.
Answer: Is this an enclosed porch, or open to the elements?
If it's enclosed, then you need to eliminate sources of damp - they won't breed near moving water, so the fountain is unlikely to be the source, unless there's a nice green mossy bit underneath.
House plants - they love damp potting compost, so you have to under-water your plants to kill them off, garbage bins, food recycle/composting, etc. Basically anything organic & damp.
If it's an open porch, they could be coming from literally anywhere nearby. Fly spray would be a constant task; traps would catch some, but would be unlikely to reduce apparent numbers, as new ones come to fill the gap left by the caught ones in a constant cycle.
You'd need to try growing something known to put insects off. Citrus & lavender tend to be unpopular with many insects, also a lot of highly scented herbs, but figuring out the exact plant/insect match may not be easy.
You'd have a nice herb garden though ;)
Here are some suggestions -
https://www.prevention.com/life/g32982866/plants-that-repel-bugs/
https://www.thespruce.com/plants-that-repel-insects-4142012


How to successfully cross a river without using money

Question: The title sums it up. I have tried fording 4 foot deep rivers, thinking my wagon and oxen would be tall enough not to drown.
I have never forded successfully. My party members always drown or I always lose items.
Caulking seems to be more successful though. Every so often I cross the river without losing people or items.
It seems like the only way to cross a river without losing anything is to pay for a ferry or trade with an Indian to guide you, so I was wondering if there is there a way to successfully cross rivers without paying or trading?
I'm playing the 1990 version. It can be played here.
Comment: "It can be played here."   Missing a link? :)
Comment: woops haha, will fix
Answer: Fording rivers deeper than 3 feet deep is not recommended and has a high chance to go wrong.
Caulking your wagon when rivers are over 3 feet is recommended.
There is still a chance that something can go wrong when doing this, but this strategy has the highest chance of success.
Here is a guide
Comment: Thanks, but this guide is for the 1993 version of the game, but the rest of your answer seems correct so i'm accepting it.
Answer: Success Chances
Fording Rivers:
less than 3 ft; 80% chance
greater than 3 ft; 40% chance

Caulking Wagon and Floating:
less than 5 ft; 85% chance
greater than 5 ft; 25% chance

Taking A Ferry: 80% chance
Hiring an Indian (Shoshoni): 90% chance
Tip: Unless you have less than $10, DO NOT take the Columbia River route. It is nearly impossible. Take the Barlow Toll, which usually costs around $10.
Comment: @Virusbomb It was a formatting issue, which is fixed in my suggested edit.
Comment: This looks to be a well written answer but it seems to be missing the final sentence.
Comment: Unless the IBM version of the game speed is noticably different from the Apple II version, I'm inclined to disagree regarding the Columbia River route... it's another mini game and saves time IIRC, and not so nearly impossible as J. Kane implies.  It would have been nice to practice to get a slight feel for the perspecitve vs hit boxes side, but after a couple of times, I don't think I ever hit anything.


How can I get this dynamic WHERE statement in my LINQ-to-XML to work?

Question: In this question Jon Skeet offered a very interesting solution to making a LINQ-to-XML statement dynamic, but my knowledge of lambdas and delegates is not yet advanced enough to implement it:
I've got it this far, but of course I get the error "smartForm does not exist in the current context":
private void LoadWithId(int id)
{
    XDocument xmlDoc = null;
    try
    {
        xmlDoc = XDocument.Load(FullXmlDataStorePathAndFileName);
    }
    catch (Exception ex)
    {
        throw new Exception(String.Format("Cannot load XML file: {0}", ex.Message));
    }

    Func<XElement, bool> whereClause = (int)smartForm.Element("id") == id";

    var smartForms = xmlDoc.Descendants("smartForm")
        .Where(whereClause)
        .Select(smartForm => new SmartForm
                     {
                         Id = (int)smartForm.Element("id"),
                         WhenCreated = (DateTime)smartForm.Element("whenCreated"),
                         ItemOwner = smartForm.Element("itemOwner").Value,
                         PublishStatus = smartForm.Element("publishStatus").Value,
                         CorrectionOfId = (int)smartForm.Element("correctionOfId"),
                         IdCode = smartForm.Element("idCode").Value,
                         Title = smartForm.Element("title").Value,
                         Description = smartForm.Element("description").Value,
                         LabelWidth = (int)smartForm.Element("labelWidth")
                     });

    foreach (SmartForm smartForm in smartForms)
    {
        _collection.Add(smartForm);
    }
}

Ideally I want to be able to just say:
var smartForms = GetSmartForms(smartForm=> (int) smartForm.Element("DisplayOrder").Value > 50);

I've got it this far, but I'm just not grokking the lambda magic, how do I do this?
public List<SmartForm> GetSmartForms(XDocument xmlDoc, XElement whereClause)
{
    var smartForms = xmlDoc.Descendants("smartForm")
        .Where(whereClause)
        .Select(smartForm => new SmartForm
                     {
                         Id = (int)smartForm.Element("id"),
                         WhenCreated = (DateTime)smartForm.Element("whenCreated"),
                         ItemOwner = smartForm.Element("itemOwner").Value,
                         PublishStatus = smartForm.Element("publishStatus").Value,
                         CorrectionOfId = (int)smartForm.Element("correctionOfId"),
                         IdCode = smartForm.Element("idCode").Value,
                         Title = smartForm.Element("title").Value,
                         Description = smartForm.Element("description").Value,
                         LabelWidth = (int)smartForm.Element("labelWidth")
                     });
}

Answer: I expect you mean:
public List<SmartForm> GetSmartForms(
       XDocument xmlDoc, Func<XElement,bool> whereClause)

and:
Func<XElement, bool> whereClause = smartForm => (int)smartForm.Element("id") == id;

To use as a method, I would make it IEnumerable<T>:
public static IEnumerable<SmartForm> GetSmartForms(
       XDocument xmlDoc, Func<XElement,bool> predicate)
    {
        return xmlDoc.Descendants("smartForm")
            .Where(predicate)
            .Select(smartForm => new SmartForm
            {
                ... snip
            });
    }

and call as:
            foreach (SmartForm smartForm in GetSmartForms(xmlDoc,
                sf => (int)sf.Element("id") == id))
            {
                _collection.Add(smartForm);
            }

Comment: brilliant, this (1) worked, (2) was exactly what I needed, (3) taught me something about lambdas seeing them solve my own issue, thanks!
Answer:
I'm just not grokking the lambda magic,

Marc's answer addresses the scenario you have.  My answer will attempt to address the lambda magic you are missing.
lambda expressions have three parts: parameters arrow methodbody
Func<int, int, int> myFunc =  (x, i) => x * i ;

For parameters, these must be enclosed in parens except in the case of a single parameter.  This section introduces variable names into the scope.  Since you didn't supply parameters in your lambda, you didn't have any variable names.
arrow is required, since you didn't have an arrow, the compiler didn't know you were making a lambda.
For methodbody, if it's a one-liner, return is implied.  Otherwise, open a curly brace and make a method body like you normally would.


Why do auto and template type deduction differ for braced initializers?

Question: I understand that, given a braced initializer, auto will deduce a type of std::initializer_list, while template type deduction will fail:
auto var = { 1, 2, 3 };   // type deduced as std::initializer_list<int>

template<class T> void f(T parameter);

f({ 1, 2, 3 });          // doesn't compile; type deduction fails

I even know where this is specified in the C++11 standard: 126.96.36.199/5 bullet 5:

[It's a non-deduced context if the program has] A function parameter for which the associated argument is an initializer list (8.5.4) but the parameter
  does not have std::initializer_list or reference to possibly cv-qualified std::initializer_list
  type. [ Example:
template void g(T);
g({1,2,3}); // error: no argument deduced for T
—end example ]

What I don't know or understand is why this difference in type deduction behavior exists. The specification in the C++14 CD is the same as in C++11, so presumably the standardization committee doesn't view the C++11 behavior as a defect.
Does anybody know why auto deduces a type for a braced initializer, but templates are not permitted to? While speculative explanations of the form "this could be the reason" are interesting, I'm especially interested in explanations from people who know why the standard was written the way it was.
Comment: Quote from [Scott Meyers](http://scottmeyers.blogspot.cz/2013/07/when-decltype-meets-auto.html): "*I have no idea why type deduction for `auto` and for templates is not identical. If you know, please tell me!*".
Comment: Ok, found it. The only real why discussion is one comment, but you can take a look: http://stackoverflow.com/questions/17496268/type-inference-with-rvalue-initializer-list
Comment: There was another SO question asked recently on what you figured out. It might have some why in it.
Answer: There are two important reasons for templates not to do any deduction (the two that I remember in a discussion with the guy in charge)

Concerns about future language extensions (there are multiple meanings you could invent - what about if we wanted to introduce perfect forwarding for braced init list function arguments?)
The braces can sometimes validly initialize a function parameter that is dependent

template<typename T>
void assign(T &d, const T& s);

int main() {
  vector<int> v;
  assign(v, { 1, 2, 3 });
}

If T would be deduced at the right side to initializer_list<int> but at the left side to vector<int>, this would fail to work because of a contradictional argument deduction.
The deduction for auto to initializer_list<T> is controversial. There exist a proposal for C++-after-14 to remove it (and to ban initialization with { } or {a, b}, and to make {a} deduce to the type of a).
Answer: The reason is described in N2640:

A {}-list cannot deduce against a plain type parameter T. For example:
template<class T> void count(T); // (1).
struct Dimensions { Dimensions(int, int); };
size_t count(Dimensions); // (2).
size_t n = count({1, 2}); // Calls (2); deduction doesn't
                          // succeed for (1).

Another example:
template<class T>
void inc(T, int); // (1)
template<class T>
void inc(std::initializer_list<T>, long); // (2)
inc({1, 2, 3}, 3); // Calls (2). (If deduction had succeeded
                   // for (1), (1) would have been called — a
                   // surprise.)

On the other hand, being able to deduce an initializer_list<X> for T is attractive to
  allow:
auto x = { 1, 1, 2, 3, 5 };
f(x);
g(x);

which was deemed desirable behavior since the very beginning of the EWG discussions about
  initializer lists.
Rather than coming up with a clever deduction rule for a parameter type T matched with a {}-list (an option we pursued in earlier sketches and drafts of this paper), we now prefer to handle this with a special case for "auto" variable deduction when the initializer is a {}-list. I.e., for the specific case of a variable declared with an "auto" type specifier and a {}-list initializer, the "auto" is deduced as for a function f(initializer_list<T>) instead of as for a function f(T).

For conclusion, the problem is that if we allow a {}-list to deduce against a plain type parameter T, then the function with parameter T would have very high priority during overload resolution, which may cause wired behavior (like the examples above).
Answer: First of all it's "speculative explanations of the form "this could be the reason"" as you call it.
{1,2,3} is not only std::initializer_list<int> but also allow initialize types without constructor. For example:
#include <initializer_list>

struct x{
    int a,b,c;
};

void f(x){

}
int main() {
    f({1,2,3});
}

is correct code. To show that it isn't initializer_list let's see the following code:
#include <initializer_list>

struct x{int a,b,c;};

void f(x){

}
int main() {
    auto il = {1, 2, 3};
    f(il);
}

Error is:
prog.cpp: In function 'int main()':
prog.cpp:10:9: error: could not convert 'il' from 'std::initializer_list<int>' to 'x'

And now to the question "What is the difference?"
in auto x = {1, 2, 3}; code it's OK to determine type, because coder explicitly said "It's not important what's type it is" using auto
While in case of function template he may be sure that he is using different type. And it's good to prevent errors in ambiguous cases (It doesn't seem like C++ style , through).
Especially bad it will be in case when there was 1 function f(x) and then it was changed to template one. Programmer wrote to use it as x, and after adding new function for other type it slightly change to call completely different one.
Comment: I don't understand how saying `auto` means "it's not important what the type is," but saying `template` means something different. In both cases, you run the risk that the type deduced may not be what the programmer intended.
Comment: I dont understand the second code. You write "To show that it isnt initializer list" but in the example `{1,2,3}` is a initializer list, hence the error...
Comment: I mean I'm showing that in first code it's not initializer_list. Because when it's initialzer_list it doesn't work


Replacing 47-gal electric water heater with no pan and elevated drain

Question: I recently moved into a condo unit in Washington, DC (2nd floor of 2 story building) and I'm looking to replace the 47-gal lowboy electric water heater that's from 2003. The problem is that there is no pan (we do have people that live below us) and, while there is a drain pipe, it's higher than the pan (see pictures below). I believe that the copper pipe connects the heater relief valve to the drain.
Also, there's no expansion tank.
The heater is in a hard to reach location in the kitchen closet, behind the washer/dryer unit. To access it, I'd have to remove the fridge from the kitchen, take off the closet door, and pull out the washer/dryer.
The tank is 31.5-32" tall and there's 19" of space above it. I'd likely have to get the exact same size replacement because the water lines coming in from the top aren't flexible. I'd ideally like a larger capacity tank because we don't get a lot of hot water with this one.
I've had 3 plumbers come in and all want to charge me between $1800-$2500 with a "play it by ear" mentality regarding the pan. Needless to say, that doesn't give me a warm and fuzzy feeling. I'd like to know exactly what is going to be done to address the pan issue because come time to sell down the road, it's important to me that the new heater will pass inspection.
Given the estimates, I'm tempted to try and do the job myself. But I need some guidance on how to address the drain being higher than the pan. One of the plumbers suggested trying to build up the floor underneath the water heater, but I don't know how feasible that is. Also, is an expansion tank necessary?
I'd really appreciate any advice on this matter.

Adding pictures of HVAC as it relates to the discussion in the comments:

And finally, a picture of my electric panel
Comment: How big is your condo? A 47 gallon tank should provide plenty of water for  even a 3-4 BR, 2-2.5 BA house (I have a 50 gallon tank in a 4BR, 2.5BA). I suspect your current tank may be full of sediment, severely restricting its capacity. Replace it with a like sized one (or even a smaller one, depending on condo size, maybe a 40 gallon) and you probably won't have hot water issues anymore.
Comment: Are you sure you need a *bigger* tank? I'd be grading tanks based on first hour recovery, not size...
Comment: The exact same size replacement might not be feasible due to efficiency regulations requiring thicker insulation. One the exact same size externally will necessarily have a smaller tank. The copper tubing isn't flexible of course, but would be cut and fit for a new tank anyway, so you'll end up using that height if you want the same capacity.
Comment: Do you have any gas appliances?
Comment: No gas, everything is electric. The condo is 1100 sq. ft. (2BR, 1BA). Any thoughts on the pan and drain situation?
Comment: How strong is your electric service? This has "tankless" written all over it.  @mmathis "absolutely no gas in the building" is very common for condos.  I am at a site which is the same, with a heat pump (on 20A breaker) interchanging with water from a service coolant loop.  In summer that coolant goes through a cooling tower, in winter it is heated with gas in the boiler room.
Comment: I would love to go tankless, but I've seen mixed reviews on electric ones. Also, the plumbers I've spoken with say they won't install due to cost of electric bill during the winter time as well as the hardness of DC water. But I'd imagine that hard water would effect tanks more? And given the mechanics of a tankless, I can't imagine it would be more energy than a tank? I have yet to test amps, but I'd have to expand the electric box. There's no more empty cartridges.
Comment: Is there any reason (code reqt or practical) for the drain to be that high off the floor? If not, you could cut it off say 4" above the floor, then put a new heater on a platform the same height as the drain so a pan could drain by gravity into the drain pipe. I assume the drain is plastic and so it could be cut off easily by a DIYer. If it is cast iron, it can still be cut off, but this would require a special cutter which one could rent.  When you install a new tank you will cut the copper lines and you should connect the new heater with flexible lines with an insulating coupling.
Comment: Not sure if there's any justification behind the drain height, but I can ask other owners in the building about their setups. It appears to be plastic, so  I think that cutting it would be a feasible option. What type of platform would you put the new heater on?
Comment: A central electrical resistance tankless heater would draw more current than you have available. Replacing the existing tank with a new one of the same type is going to be the only practical solution. The heat pump heater described by @Harper would heat water for much less electric power than resistance heat, but requires the extra water heat exchange loop to the roof. This must have been installed as new construction. I doubt you could do this as a replacement. Is this heat pump a tankless or a tank? What is the noise level when the compressor is on?
Comment: @Jim With "heat pumps" I was referring to our HVAC... but you raise an important question.  What if his old water heater *is already* the heat pump exchange type?  Probably not.
Comment: Our HVAC is a heat hump, and it is positioned directly above the water heater. Not sure how I'd determine if the water heater is tied into it.
Comment: extra unexplained pipes.   @littleK Tankless water heaters are awesome when idiots are not involved.  Speccing correctly requires skill.  It uses less electricity *overall* but **much more** in the moments of use, hence my interest in your electric service.  What matters is the ampacity of your panel, not the spaces available (there are ways around "full".)
Comment: How can I determine the ampacity of the panel?
Comment: @Harper, from my experience the existing heater here is a simple electric resistance heater. I don't think a heat pump water heater tank would work in this application: (1) insufficient vertical clearance (2) insufficient space for heat extraction (3) possibly noise generation unacceptable
Comment: I've added two pictures of the HVAC that sits above the heater in case it helps with this discussion. It's at least 15 years old.
Comment: @littleK there will be a breaker larger than the others, or, in the upper left corner.  It will have a number on it, probably 100, 150, 225, something in that range.
Comment: Added a pic of my electric panel as well. #1 & #3 is heat pump, and #2 & #4 is AC, and #6 is water heater.
Comment: A suitable platform could be built with a 2x4 frame with 3/4" plywood on top, which you can make (and should) even if you have a plumber install the heater. Plumbers as a group are not especially good carpenters and with a little planning you can make a really good platform. Find out if there are any code or other requirements on the height of the drain. It could be that the height must be above certain other drains in the house. If you can't cut it off or don't want to, just make the platform the height of the drain as it is, and get a water heater which will fit on it.
Comment: There are commercially available stands required in most jurisdictions for water heaters in basements and garages. Usually they elevate the heater 18" which is more than you need and could possibly be too high for the heater you would want. See http://www.homedepot.com/p/Eastman-21-in-D-x-21-25-in-W-x-18-in-H-Water-Heater-Stand-86278/205365245?cm_mmc=Shopping%7cTHD%7cG%7c0%7cG-VF-PLA-D26P-WaterHeaters%7c&gclid=Cj0KEQjwmcTJBRCYirao6oWPyMsBEiQA9hQPbiDWsmb9T-MBOR2J0DD-ydbBpLtM2W4MN-ZtzzQWHFwaAnls8P8HAQ&gclsrc=aw.ds
Comment: Hmmm. 1-3 is a double-stuffed 2-pole, 100?/30.  The 100 can't possibly be the main breaker since it's too little to serve the two 2-pole 60s and two 2-pole 30s. Oversubscription is normal but not *this* much on the *big stuff*.  5-7 is baseboard heat?   The main breaker is not there.  This may be the time to consult with the building's superintendent
Comment: Thanks @JimStewart. I'll look into building or purchasing a stand, as well as what is up to code.
Comment: @Harper, #5 is electric oven range and #7 is dishwasher. The master circuit breaker for each individual unit is in a separate utility closet located in the front of the building. Same goes for master water shut-off. This place used to be an old car garage, renovated in the 1970's.
Comment: Yea, 10&12 is Dryer & Washer. I'll see if I can get into the main utility closet to examine the main.
Comment: 5-7 are a 2-pole, can only be one thing, range then.   60A is generous.  I see now, 1-3 is both your heat pump (30A) and auxiliary heat (100A). The upshot of all this is your service is quite impressive and could likely support on demand heater(s) even right at point of use (i.e. Near instant). Next question is if on demand can play well with the hard water.  Relevant advantage here is an on-demand takes much less space.
Comment: Home Depot has a 24" square stand which you would probably need for a squat form electric tank, but it is 18" high which might be too high for your application, but maybe not. You should not cut off the drain until you find out for sure that it does not have to be say taller than the toilet bowl or the tub wall. This drain is in a not readily accessible space and in case of a sewer blockage you don't ever want it to overflow before other places do.
Comment: I'm going to follow the advice @JimStewart and just replace with another tank. I'll build a platform out of wood to match the height of the drain so that I don't have to cut it. Then, I'll just get the largest tank that will fit in the space. I'll cut the copper water lines and replace with flexible hosing to allow for additional space. The only question I have now is do I also need to install an expansion tank? Thanks for all of your help.
Comment: Noted, @ThreePhaseEel, I'll be sure to check compare tank recovery times.
Answer: My advice is to leave the old water heater where it is and install a tankless hot water heater. I installed one at a shop for a friend in Georgia a few years ago. They had a shower in the shop and I showered there several times and never had any trouble with hot water. 4 gallons per minute was more than sufficient for a decent water flow shower and never ran out of hot water.
I think the link below is to the same unit I installed. It was quite small so it will take up very little space.
https://www.amazon.com/Rheem-RTE-13-Electric-Tankless/dp/B003UHUSGQ/ref=sr_1_5?s=kitchen-bath&ie=UTF8&qid=1496426163&sr=1-5&refinements=p_n_style_browse-bin%3A542712011
Drew k
Comment: The description for this 13 kW 240 V tankless water heater is that it would work for one shower so it would probably not by itself work for a whole apartment. It requires a 60-A 2-pole 240 V breaker and 6 AWG wire. This would probably require rewiring of the existing circuit since the breaker for the current tank is a 2-pole 30-A breaker.  The service might or might not have capacity for an additional 30 A. The real crunch would be in winter time with (depending on the climate) extremely cold inlet water. A tankless gets only one pass at the water, but a tank can still give hot water.
Comment: The current circuit is probably wired with 10 AWG wire, but that would have to be determined. How many hot water use points would be used simultaneously? How many bathrooms? The only place one really needs very hot water out the tap is the kitchen sink supply. So one could use this 13 kW electric tankless as the central heater and put a 2 kW point of use 120 V heater under the kitchen sink. If you have a dedicated 20-A circuit for a disposer, you would plug this into the receptacle for the disposer, if you can do without a disposer.  (I pitched our disposer 25 years ago, but we've a house.)
Comment: See, once you realize all you'd have to do to put in an electric tankless water heater, you realize why the ~50 gal electric tank is such a good idea.
Comment: I don't recall the flow rate of the shower at the shop, but it wasn't a low flow. I selected the 4gpm for the shop but think they make higher power ones. The big thing for me was it seems silly to store a tank full of hot water when you can just make it as needed. I used electric showers for years while stationed in England in a house without any hot water tanks.
Comment: All shower heads sold in the US now are max 2.5 gpm. This however is achieved with an engineered flow restrictor which can be removed and many people do remove them. I too have used electric point of use shower water heaters in Britain (in my case in the 1970s) and according to my recollection by US standards they were low flow.
Comment: Many are low pathetically low flowing. You really need a power shower there because the water pressure comes from the cistern in the attic. I had one in '04. A tankless water heater is a good reason to keep the restrictor in the shower and conserve water. I will install one when i buy a house...eventualy.
Comment: I remember an episode of "This Old House" in which Rich Trethewey (the plumber) was in London UK. The local expert explained that water pressures in London were very low because much of the municipal water distribution network was very old and simply could not stand the pressures used in the US.  I had not realized that pumps were used to boost pressure and flow at the point of use.  Because of lower pressures do UK houses use larger diameter pipes in the houses?
Comment: I put a natural gas fired tankless water heater in our house in 2005. It is a basic Bosch rated at ~120 kBTU/h, a discontinued model, very simple with a standing pilot light so no electrical connection. It replace a 40-gal ng fired tank with a burner of about 40 kBTU/h. A couple of years ago I changed shower heads from standard 2.5 gpm to  low flow 1.4 gpm and we started having problems with the water heater shutting off in mid shower. I had to remove the flow restrictors in the new shower heads to keep the flow rate through the heater above the cut-off.
Comment: I have not been in England since '05, and that was at RAF Mildenhall near Cambridge. My brother in Virginia used to use a gas tankless I  the meat plant for water over 150 (or 175?). Had good flow and kept it hot.
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/59815/discussion-between-jim-stewart-and-gwydionforge).
Answer: Performance of the Rheem RTEX-13 240V tankless heater from a seller Q&A is below. Do you see the problem? It only supplies 4 gal/min for a 20 deg F temperature rise. What is the temperature of the inlet cold water in the winter? You would probably want 105 F water for a shower. If your inlet water is 70 F then you'd want a 35 F temperature rise which means you would get a flow rate of 2.6 gal/min. This is great for one shower. If you installed a low flow shower head with a max of 1.3 gal/min, you could take a shower and simultaneously operate one other moderate use (which only needs 105 F water).
Georgetown SupplyMinimum activation flow rate is 0.4 gpm and the maximum flow rate is 4 gpm (RTEX-13 13kW/240V).
** Temp Rise Listing (F) and Flow Rates **
20 deg F temp rise = 4.00 gpm
30 deg F temp rise = 2.96 gpm
40 deg F temp rise = 2.22 gpm
50 deg F temp rise = 1.78 gpm
60 deg F temp rise = 1.48 gpm
70 deg F temp rise = 1.27 gpm
80 deg F temp rise = 1.11 gpm
90 deg F temp rise = 0.99 gpm
100 deg F temp rise = 0.89 gpm


XSLT: Passing URL querystring as a parameter

Question: I know this is an old question that has been passed around SO several times but I was wondering whether anyone can expand on whether a URL that has a querystring attached to it can be stripped out via XSLT 1.0 and can be used as a parameter for later use of the XSLT transformation.
For example, I have a URL of http://www.mydomain.com/mypage.htm?param1=a&param2=b
via XSLT, I am looking for a result of something along the lines of:
<xsl:param name="param1">a</xsl:param> and <xsl:param name="param2">b</xsl:param>
where both parameter name (param1, param2) and it's value (a, b) has been extracted from the quesrystring to allow me to use $param1 and $param2 later on say in an if condition
e.g. <xsl:if test="$param1 = 'a'> comes out true but if we use <xsl:if test="$param1 = 'b'> comes out false.
I have seen a similar question here: Retrieve page URL params or page URL in XSLT which uses the str-split-to-words template but I have unsuccessfully got it working (possibly due to me implementing it the wrong way) so any working examples of how it can be done in practice would be massively beneficial.
XSLT:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://exslt.org/common">
<xsl:import href="http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/strSplit-to-Words.xsl"/>
<xsl:output indent="yes" method="html"/>

<xsl:template match="/">
<xsl:variable name="vwordNodes">
  <xsl:call-template name="str-split-to-words">
    <xsl:with-param name="pStr" select="$pQString"/>
    <xsl:with-param name="pDelimiters" select="'?&'"/>
  </xsl:call-template>
</xsl:variable>
<xsl:apply-templates select="ext:node-set($vwordNodes)/*"/>
</xsl:template>

<xsl:template match="word">
  <xsl:value-of select="."/>
  <xsl:text>
</xsl:text>
</xsl:template>

</xsl:stylesheet>

Answer: There are a few problems in your code:

<xsl:import href="http://fxsl.cvs.sourceforge.net/viewvc/fxsl/fxsl-xslt2/f/strSplit-to-Words.xsl"/> I doubt that the wanted stylesheet can be imported directly from its SourceForge view page -- especially taking into account, that it itself imports other FXSL stylesheets. The correct way to use FXSL is to download it to the local computer and reference its stylesheets off the file location it resides in at the local computer.

...
.2. <xsl:with-param name="pStr" select="$pQString"/> This will produce a compilation error because you missed to define the $pQString global/external parameter. You need to define this parameter at global level. It can be given a default value (for example a particular URL) for easier testing. However, the idea of using this parameter is that the invoker of the transformation should pass this parameter to the transformation.
.3. The results of the transformation are written to the output. While this is good for demonstration purposes, you want to be able to use these results later in the transformation. The way to do this is to capture these results in a variable, make another variable from it, with a regular tree (from its RTF type) and then reference the nodes of this last variable.
Here is an example of the code you want (provided that you have downloaded FXSL, unzipped the distribution and saved this code in the same directory as the unzipped distribution of FXSL):
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:ext="http://exslt.org/common"
 >

   <xsl:import href="strSplit-to-Words.xsl"/>

   <xsl:output indent="yes" omit-xml-declaration="yes"/>

   <xsl:param name="pUrl" select=
   "'http://www.mydomain.com/mypage.htm?param1=a&param2=b'"/>

   <xsl:param name="pQString" select=
     "substring-after($pUrl, '?')"
     />

    <xsl:template match="/">
        <xsl:variable name="vwordNodes">
          <xsl:call-template name="str-split-to-words">
            <xsl:with-param name="pStr" select="$pQString"/>
            <xsl:with-param name="pDelimiters"
                      select="'?&'"/>
          </xsl:call-template>
        </xsl:variable>

       <xsl:variable name="vrtfqueryParams">
         <xsl:apply-templates select="ext:node-set($vwordNodes)/*"/>
       </xsl:variable>

       <xsl:variable name="vqueryParams" select="ext:node-set($vrtfqueryParams)/*"/>

       <xsl:value-of select="$vqueryParams/@name[. ='param1']"/>
       <xsl:text> : </xsl:text>
       <xsl:value-of select="$vqueryParams[@name = 'param1']"/>

       <xsl:text>
</xsl:text>
       <xsl:value-of select="$vqueryParams/@name[. ='param2']"/>
       <xsl:text> : </xsl:text>
       <xsl:value-of select="$vqueryParams[@name = 'param2']"/>
    </xsl:template>

    <xsl:template match="word">
      <param name="{substring-before(.,'=')}">
        <xsl:value-of select="substring-after(.,'=')"/>
      </param>
    </xsl:template>
</xsl:stylesheet>

When this transformation is applied on any XML document (not used in this demo), the wanted, correct result -- the query-string parameters referenced of a results variable by name -- is produced:
param1 : a
param2 : b


Should this severed wall stud be repaired, and if so, how?

Question: We hired a plumber to fix a corroded gas valve in the kitchen. The valve was difficult to get to, and there was an existing pipe in the way, so they had to hack a chunk out of the cabinet and neighboring beam. I'm not sure, but I believe this beam might have been a load-bearing wall stud. (Right behind the black lining is the exterior kitchen wall, though I'm not sure how much stuff there is between that and the outside. There's wall insulation next to the valve.)

How big of an issue is this?
What happens if it's not addressed promptly? (In other words, is this an emergency?)
If repairs are required, is it possible to repair the gap without taking apart the entire kitchen wall and/or floor? (Can it be "patched"?)
Comment: If you're a renter, this sounds like a problem for your landlord.  If you're concerned about a safe repair (i.e. continuing to live in the place after the repair), get the local housing/code authority in for an inspection.
Comment: In my experience, plumbers only rip out what they need to fix the issue. It will be up to you to make the other repairs. It being a corner that was cut on is a help. It is the strongest part of the wall, usually has the most studs in one spot. How much of the studs is gone, about half it its width?
Comment: Note: they're not done with the job yet, so this might not be the final state of the repair. But I don't think they're planning to reinforce the beam.
Comment: Also, this section is pretty close to the corner of the building.
Comment: The stud in question looks to predate modern dimensional lumber.  Just how thick is it?
Comment: Sorry, I'm only a renter and I have a very limited understanding of what's actually going on in a house's walls. This house is from 1907. This stud is not right on the corner, but maybe 4 feet from the corner. (But it's part of a corner wall.) As far as I can tell, an entire section of the stud has been removed — there's none left in the gap. (Unless it continues behind the black backdrop? But I don't think so.) The thickness is maybe 4 inches, but I haven't measured it.
Comment: As a renter, I presume your landlord called in the plumber, right? Make sure you get the landlord out there to look at the work, as it's her responsibility to ensure that the property is safe for you to live in.
Answer:
We hired a plumber to fix a corroded gas valve in the kitchen.

Where do you live? Per your comments, you rent. If this wasn't authorized by the landlord then you could be on the hook.

so they had to hack a chunk out of the cabinet and neighboring beam

Plumbers are notorious for this kind of behavior.

How big of an issue is this?

We can't tell, the image is zoomed in too far. Add a zoomed out image, an image from the outside of the house, and describe anything above this stud such as a second story.

What happens if it's not addressed promptly? (In other words, is this an emergency?)

If it was an emergency then you would not have had time to take the picture.

If repairs are required, is it possible to repair the gap without taking apart the entire kitchen wall and/or floor? (Can it be "patched"?)

House framing is built with redundancy in mind. It's fairly difficult to botch a single item and cause a failure. I guess sawing a 20-foot load-bearing beam in half would probably do it.
Comment: @Archagon Ah, I see. I'm glad to hear that this is all coordinated. I wish your landlord the best and a good recovery. This could be "patched" by getting that stud cut flat so that you can insert a new piece of wood to handle the vertical load. It will be impossible to strengthen it enough for shear strength unless the wall is opened up more. It is just a single stud and is unlikely to result in anything catastrophic. You should provide the picture to your landlord and ask how to proceed. If he insists that the plumber has to fix it then you will get to experience the "fun" of all that ensues.
Comment: @Archagon I see the new pictures. In the grand scheme of things there is no emergency here and the structure should remain standing for the next 100 years. Still, present the situation to your landlord and let them make the final decision.
Comment: We called the plumber ourselves since this was an urgent matter, but it was authorized in writing by our landlord. He is in chemo so we're trying to coordinate with the plumbers as much as possible and make his life a bit easier. He is footing the bill.
Comment: We're on the second floor, and there is another floor above us.
Comment: Thank you, that's very helpful. I added some more photos to the question showing the rest of the kitchen corner as well as the outside wall.


How can you index a text search that has only one wildcard at the beginning of the search term ('%TERM')?

Question: I found the following query in our MySQL slow query log:
SELECT target_status
FROM link_repository
WHERE target_url LIKE CONCAT('%', 'bundle/rpi_/activity/rpi_bridge/bridge_manual.pdf')

When I pointed this out to the developer manager in a conversation about slow page loads, he stated:

come on; concat() is a simple string concatenation and '%' is the wildcard in the search string. I know that searching strings is not the fastest of operations (that's why we have lucene-like engines, but this is trivial stuff)

There's about 18k rows in link_repository, which isn't much. The documentation I'm finding is that indexing on character strings doesn't work with wildcards. Is there an alternative strategy one can use?
Comment: Your manager is trying to sound authoritative.  Ask him what the index would look like, i.e. what entries it would have, since you don't know in advance what the value of `TERM` is.  Say `TERM` is `XYZ`, it would have to be able to find `AXYZ`, `AAAAAXYZBBBBBB` and `AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAXYZBBBBBBBBBBBBBBBBBB`.  Challenge him to come up with an indexing scheme for this without knowing in advance the string to be searched for.  That is indeed why Lucene and others exist, but they do so by building multiple indexes.
Comment: Sometimes it's best to disengage; but I will note that it doesn't have to find (.b)*, there's no index. It's a scenario that could plausibly be indexed, by a system clever enough to build an index out of the REVERSE() of the string field.
Answer: In order for LIKE to use index it has to start with something. MySQL search from left to rigt. So if the string star with anything then MySQL will do a table scan and no index will work.
However, if you are using InnoDB tables you can try to use Full-Text Index.
You can  add a Full-Text Index on the column, then you can use MATCH AGAINST function to find what you need then you can add RIGHT() clause to only give you the results that end with your string.
CREATE FULLTEXT INDEX target_url ON target_status(target_url);

Then you can query the records like so
SELECT target_status
FROM link_repository
WHERE MATCH ('bundle/rpi_/activity/rpi_bridge/bridge_manual.pdf') AGAINST(target_url) AND RIGHT(target_url, 49) = 'bundle/rpi_/activity/rpi_bridge/bridge_manual.pdf'


Defining a Function to Match document array element to document value in Meteor

Question: I have been working on a meteor web app. I inserted a document into MongoDB.
questionsList.insert({ask: "When was the War of 1812", answer: "1812", possAnsw: ["1811", "1812", "1819", "1820", "1840"]})

I am looking to have a function match when a person chooses the correct answer out of the possible answers. The problem is that I am having a hard time accessing one value and matching it to a specific
 tag.
Pseudo-code:
if (li.currentTarget == questionList.find({answer: 1}).fetch() {
       $(li.currentTarget).css("background-color", "yellow");
}

Essentially, this would highlight only if I clicked the right answer:
Template.questions.events({
      'click .answers':function(li) {

        $(li.currentTarget).css('background-color', "yellow").css("width", "fit-content");

      }

    });

Right now, it highlights each
 element regardless if it matches the correct answer (i.e. "ask"). The problem is I cannot seem to find how to get the value of the "ask" key and match it to the li.currentTarget.
I have looked at a couple of the following articles to no avail:
Get particular element from mongoDB array
Retrieve only the queried element in an object array in MongoDB collection
Answer: if I get your question correctly, basically when user click an answer of question, the server will check if it is correct answer.. so, I think you should query the question not the answer
var currentQuestionObject = questionList.find({ask: "When was the war of 1812?"}).fetch()

if (li.currentTarget == currentQuestionObject.answer) {
   $(li.currentTarget).css("background-color", "yellow");
}

Comment: I think you're right; the problem is that `currentQuestionObject.answer` isn't returning the value, only "undefined". I wasn't having much luck with this approach. I ultimately separated the answer from the array. I can end up with the right coloration in the background, but the new problem is that no randomization algorithm seems to be working to randomize the `` elements. The problem in short is that the right answer will always be first or last.
Comment: So essentially, I have `

        {{#each question}}
         {{ask}}

 {{answer}}

                {{#each wrongAns}}
            {{this}}

        {{/each}} {{/each}}

    `


How to get a repository to override all other repositories, for all software in that repository?

Question:
How do I get a specific repository to override all other repositories, for ALL software in that one repository?  (At all times, no matter what any other repository does.)
After solving question 1, what is needed to get the system back to the original state (regarding  LibreOffice, see Background).

Desires:

All solutions are from the command line.
You actually use, or have used, the solution you're giving. (see Reference Notes)

Background:
Official 14.04 recently updated LibreOffice, causing the official repositories to install over and override the  LibreOffice PPA, error message is:
<code># apt-get update
# apt-get upgrade

... snip ...

You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libreoffice-calc : Depends: libreoffice-base-core (= 1:5.4.1~rc2-0ubuntu0.14.04.1~lo0) but 1:5.4.2~rc2-0ubuntu0.14.04.1~lo1 is installed
                    Depends: libreoffice-core (= 1:5.4.1~rc2-0ubuntu0.14.04.1~lo0) but 1:5.4.2~rc2-0ubuntu0.14.04.1~lo1 is installed
 libreoffice-core : Breaks: libreoffice-calc (< 1:5.4.2~rc2-0ubuntu0.14.04.1~lo1) but 1:5.4.1~rc2-0ubuntu0.14.04.1~lo0 is installed
                    Breaks: libreoffice-draw (< 1:5.4.2~rc2-0ubuntu0.14.04.1~lo1) but 1:5.4.1~rc2-0ubuntu0.14.04.1~lo0 is installed
                    Breaks: libreoffice-impress (< 1:5.4.2~rc2-0ubuntu0.14.04.1~lo1) but 1:5.4.1~rc2-0ubuntu0.14.04.1~lo0 is installed
 libreoffice-draw : Depends: libreoffice-core (= 1:5.4.1~rc2-0ubuntu0.14.04.1~lo0) but 1:5.4.2~rc2-0ubuntu0.14.04.1~lo1 is installed
 libreoffice-impress : Depends: libreoffice-core (= 1:5.4.1~rc2-0ubuntu0.14.04.1~lo0) but 1:5.4.2~rc2-0ubuntu0.14.04.1~lo1 is installed
E: Unmet dependencies. Try using -f.
</code>
System will now not update anything until this is resolved.
Reference Notes:
Based upon How to only install updates from a specific repository?, pinning is not the answer.  APT preference may be, but I'm highly hesitant to use examples found as they contradict each other and even the Debian wiki for it:

This page has been written by ZugSchlus, who not even remotely grasps
  the concept of pinning. So, please take the words "probably", "needs
  to be verified" and similiar wordings literally, and document your
  findings (may they be "this page is right" or "this page is wrong",
  optionally "this page is wrong because") here.

Further information at: https://bugs.launchpad.net/ubuntu/+source/libreoffice/+bug/1722932
Comment: Regarding your actual problem, https://packages.ubuntu.com/search?keywords=libreoffice-core says the official 14.04 repositories are all still `1:4.x.y`. The problem is with the PPA (who seem to have made a half-update, or something else) and not with Ubuntu's repos. Prioritizing the PPA won't help since none of the package versions mentioned are from Ubuntu's repos.
Comment: Apt always assumes that the higher version is preferred. You want something different - you want apt to prioritize by source. Apt-preferences won't help you - that's not what preferences do. You are trying to use apt for a purpose it was not designed for, so you may not be satisfied with many realistic answers: Apt-pinning, Snaps, Source management, etc.
Comment: @user535733, I'm not sure why you say this isn't something Apt, or variant, should do, other dist's do this, see:
https://wiki.centos.org/PackageManagement/Yum/Priorities .  So it's not like this is a new concept, but just how is it accomplished in the Debian world?
Comment: Nobody said apt *shouldn't* do it. We said apt *doesn't* do it. It's accomplished in the Debian world by choosing your version and source wisely, and managing them. PPAs are not intended to be a reliable long-term source - some are, but that's a misuse.
Comment: @user535733 It seems like you've basically answered the question. Would you consider posting an answer along the lines of your comments? (Other users will still be able to answer, of course, and maybe a later answer will meet Michael's needs better, but I think your answer would still be valuable.)
Comment: "pinning is not the answer. APT preference may be" is contradictory since pinning is done in the preferences. Regarding the Wiki note, it's not unusual for people who *are* experts to say they are idiots who know nothing (tongue-in-cheek). ZugSchlus has been a DD since 2001 and has written a number of apt-related things. Take that note as the light-hearted word of caution it is rather than a literal "I know nothing".
Comment: Well, rpm systems do have some advantages and this looks like one scenario. The way to do what you want is via a combination of pinning and putting packages on hold. The results will be similar to the option in centos, but, be warned, doing such things can eventually result in problems with updates when there are conflicts between the repositories. IMHO, your best option with both .rpm and .deb systems is to file a bug report against the packages in question or in your case the ppa. This is because holding packages / pinning / giving repos priority eventually causes these types of problems
Comment: I want to thank all of you for your comments.  I'm doing this separately so it's actually viable, and not squished up inside another of my replies ;)  Doing my replies in order.
Comment: @user535733, I agree with Eliah Kagan, your combined comments are worthy of being an Answer.  They do a good job of explaining the issues involved, with respect to Ubuntu (Debian?) specifically.
Comment: @muru, Okay, this is completely outside scope, but damn!  I see your, and his, point for being light hearted, but a 'newbie' user is going to take his words literally, as we don't know his background to even have a chance to realize the tongue-in-cheek nature.  :(  I'll re-read that page.  Thanks for the heads up.
Comment: @muru, v2.  Ah, no it was the recent release by Ubuntu of an updated LibreOffice, which breaks the existing LibreOffice PPA.  AFAIK, Ubuntu is not following the package naming conventions that LibreOffice established, hence [valid / leftover] LibreOffice PPA packages are being broken from their -core package requirement now being the Ubuntu version.
Comment: @Michael your statement would be more credible if even a single package version listed in the output above was from Ubuntu's repositories. None of them are.
Comment: @bodhi.zazen, Would you?  Can you?  Please, write up an Answer?  Your opinion is exceedingly valid, this is NOT the way to do this for 99% of use cases out there.  Even in RH/CentOS it isn't.  But, in a specific case like this, with PPAs who implicitly know their software better than Ubuntu ever will, how to accomplish this is highly needed. [Well I think so ;) ]  Thanks!
Comment: @muru, libreoffice-core is from Ubuntu's repository.  It's what Ubuntu updated (a week ago-ish).
Comment: And you can see in https://packages.ubuntu.com/search?keywords=libreoffice-core that `libreoffice-core` in Ubuntu's repo is at 1:4.2.8-0ubuntu5.1, not 1:5.4.1~rc2-0ubuntu0.14.04.1~lo0 or 1:5.4.2~rc2-0ubuntu0.14.04.1~lo1. OTOH, you can see in https://launchpad.net/~libreoffice/+archive/ubuntu/ppa/+packages that both these versions of `libreoffice-core` are from the PPA (click on the package names to expand the full list of packages provided by each version)! Don't take my word for it, run `apt-cache policy libreoffice-core` and see for yourself.
Comment: This may not be an answer (I've insufficient reputation to merely comment), but it might help solve the problem and may in fact be the correct path to resolving this type of issue without causing subsequent dependency issues or redesigning apt. Since this is apparently not what apt is meant to do, this bug has been logged with LibreOffice. See https://bugs.documentfoundation.org/show_bug.cgi?id=113269
Comment: Thank you @Little me, I've updated the bug/request you submitted with additional reference information.
Comment: @muru, I stand corrected.  Both Ubuntu and LibreOffice updated their repositories at the same time? So I'm mistaking a LibreOffice bug for a Ubuntu one?  Maybe I should just head back to the CentOs world, at least I wouldn't make a fool of myself. Thank you for the command.
Comment: @Michael I think, as a first step, you should run `apt-get update; apt-get upgrade -f`
Answer: So, after some more experimentation and learning, I think that I have an answer; don't revert system to original state; update the broken bits instead.  Both Ubuntu and LibreOffice bugs were being 'Resolved' as 'It's their fault'!
Necessity is the mother of invention...
Solution in fellow Noobspeak:

Run Synaptic Package Manager
    If not sure how, press the Windows/Super key then type Synaptic and click the appropriate icon
Enter your password when prompted
Click On The 'Status' button.  Above that, select 'Broken Dependencies'
To the right, Select all four affected LibreOffice Packages
Right click them and choose 'Mark For Upgrade' option
Click the big Apply button, above.

Unless the tiger is hiding, waiting to bite my hubristic backside, I think that this solves it.  Tell me if I'm giving stupid advice!  Thanks.
If it hasn't worked for you, perhaps you'd deseleted the LibreOffice PPA in the Depositary List.  Reenable it and start again.


converting variable to date format in unix script

Question: <code>if [ -f $FILEPATH3 ]; then
#Will print the Header columns from properties file.
print $header >$CFILEPATH3
#To add rows in output file from input file .
awk -F\" 'BEGIN{OFS=FS;} {for(i=1;i<=NF;i=i+2){gsub(/,/,"~\t",$i);}}1' $FILEPATH3 > $TFILEPATH3

#Removes the footer,header and prints the columns as per mapping by picking column numbers from properties file
cat $TFILEPATH3| sed '1d' | awk 'BEGIN { FS = "~\t"; OFS = ",";}{ DATE = date -d "$'$ms2'" "+%Y%m%d" } { printf "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n",  $'$ms1', $DATE,$'$ms3',$'$ms4',$'$ms5',$'$ms6',$'$ms7',$'$ms8',"MS",$'$ms10',$'$ms11',$'$ms12',$'$ms13',$'$ms14',$'$ms15',$'$ms16',$'$ms17'}' >> $CFILEPATH3
</code>
In the above code, I'm trying to copy the data from the input file to output file. ms1, ms2 are the column positions of a CSV input file.
ms2 is the date with format mm/dd/yyyy and which is considered as variable. We need to convert the variable into YYYYMMDD format and write it into output file
In the script I'm trying to change the date format to YYYYMMDD.. but I'm getting an error.
I think the error is from this code
<code>{ DATE = date -d "$'$ms2'" "+%Y%m%d" }
</code>
Comment: in the properties file i have defined ms2=1 which means it has to pick the column 1 value from the input csv file. In input csv file, the column 1 will have date in the format of mm/dd/YYYY (example.. 6/03/2015).. i want to be formated to YYYYMMDD (20150603) while writing into output file..
Answer: You are trying to access the variable in single quotes and which wont happen, So try to use the following syntax.
<code> DATE=$(echo $ms2|awk -F '/' '{print $3$2$1}')
cat $TFILEPATH3| sed '1d' | awk  -v ms2="$DATE" 'BEGIN { FS = "~\t"; OFS = ",";} { printf "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n",  $'$ms1', $ms2,$'$ms3',$'$ms4',$'$ms5',$'$ms6',$'$ms7',$'$ms8',"MS",$'$ms10',$'$ms11',$'$ms12',$'$ms13',$'$ms14',$'$ms15',$'$ms16',$'$ms17'}' >> $CFILEPATH3
</code>
Comment: it did not work.. the output was   0$$ms2+%Y%m%d .. but i want the date
Comment: Can you please provide an example format and syntax of command that you are using?
Comment: ms2 is the date with format mm/dd/yyyy and which is considered as variable. We need to convert the variable into YYYYMMDD format and write it into output file
Comment: In that case you can use `awk` command to convert the variable.
`echo 'mm/dd/yyyy'|awk -F '/' '{print $3$1$2}'`

I modified the answer , You can refer that.
Comment: i tried.. it did not change the format.. it still prints the date as mm/dd/YYYY


How does knowing that $\sqrt{7}\notin\mathbb{Q}(e^{2\pi i/7})$ help construct this character table?

Question: Here's a question that has haunted me since it appeared on a problem sheet in a Representation Theory course I attended as an undergraduate. I'll reproduce it exactly:

A group of order $168$ has $6$ conjugacy classes. Three representations of this group are known and have characters $\alpha$, $\beta$ and $\gamma$ summarised in the table below. Construct the character table of the group. You may assume if required that $\sqrt 7$ is not in the field generated by $\mathbb Q$ and a primitive $7^{\text{th}}$ root of unity.

\begin{array}{c r r r r r r} |[g]|&1&21&42&56&24&24\\ \hline
 \alpha&14&2&0&-1&0&0\\ \beta&15&-1&-1&0&1&1\\ \gamma&16&0&0&-2&2&2\\
 \end{array}

I can do the question quite easily by using the various properties of character tables. But I don't need to use the fact that $\sqrt{7}\notin\mathbb{Q}(e^{2\pi i/7})$. So my question is:
What approach to the question did the writer have in mind when they allowed the student to assume that "$\sqrt 7$ is not in the field generated by $\mathbb Q$ and a primitive $7^{\text{th}}$ root of unity"?
Comment: @Somos They aren't the characters of **irreducible** representations, they're just characters. So we're not completing the table based on three existing entries, we actually have to find all six irreducible characters.
Comment: Something is not correct about the table. The sum of the squares of the character values of the identity class should be the order of the group, but the sum of $(14,15,16)$  squared is $677$ which is bigger than $120$ the size of this group.
Comment: Ah, I had implicitly assumed they **were** irreducible. That makes the task harder and more challenging.
Comment: In case it helps: the group is actually PSL(2,7) and its character table is on its [Wikipedia page](https://en.wikipedia.org/wiki/PSL(2,7)).
Comment: It does. There is **another** group of order 168 with 8 conjugacy classes.
Answer: Okay, I finally worked it out. I'll give a complete solution to the exercise:
First of all we have the trivial character, which we'll denote $\chi_1$. We have $\left<\chi_1,\alpha\right>=\left<\chi_1,\beta\right>=\left<\chi_1,\gamma\right>=0$, so it isn't present in any of the characters we've been given.
Computing the inner product of each character with itself gives $\left<\alpha,\alpha\right>=2$, $\left<\beta,\beta\right>=2$ and $\left<\gamma,\gamma\right>=4$, so $\alpha$ and $\beta$ are each the sum of two distinct irreducible characters, and $\gamma$ is either the sum of four distinct irreducible characters or two copies of the same irreducible character. In fact it must be the latter, because $\left<\beta,\gamma\right>=2$, which would mean that both the irreducible characters in $\beta$ would have to appear in $\gamma$. But then the remaining two irreducible characters in $\gamma$ would only have dimension $1$ between them, contradiction. So $\chi_2=\gamma/2$ is an irreducible character of dimension $8$.
Then it turns out that $\left<\chi_2,\alpha\right>=1$ and $\left<\chi_2,\beta\right>=1$, so we can find two more irreducible characters: $\chi_3=\alpha-\chi_2$ and $\chi_4=\beta-\chi_2$, of dimensions $6$ and $7$. Using the fact that the squares of the dimensions of the irreducible representations must sum to 168, we can see that the two remaining irreducible characters must both have dimension $3$.
So our character table so far is given by:
\begin{array}{c r r r r r r} |[g]|&1&21&42&56&24&24\\ \hline
 \chi_1&1&1&1&1&1&1\\
 \chi_2&8&0&0&-1&1&1\\
 \chi_3&6&2&0&0&-1&-1\\
 \chi_4&7&-1&-1&1&0&0\\
 \chi_5&3&x_2&x_3&x_4&x_5&x_6\\
 \chi_6&3&y_2&y_3&y_4&y_5&y_6\\
 \end{array}
To work out the $x$s and $y$s we'll use column orthonormality. Using orthonormality of the second column with the first and with itself gives
$x_2+y_2=-2$ and $|x_2|^2+|y_2|^2=2$, which imply $x_2=y_2=-1$. Likewise, $x_3+y_3=2$ and $|x_3|^2+|y_3|^2=2$ so $x_3=y_3=1$, and $x_4+y_4=0$ and $|x_4|^2+|y_4|^2=0$ so $x_4=y_4=0$.
In the fifth column we get $x_5+y_5=-1$ and $|x_5|^2+|y_5|^2=4$. These equations have multiple solutions. But since the complex conjugate of an irreducible character is an irreducible character, we know that either $x_5$ and $y_5$ are both real, or they are each other's complex conjugate. In the real case we have $x_5+y_5=-1$ and $x_5^2+y_5^2=4$, and hence $x_5=\frac{-1\pm\sqrt 7}2$ (without loss of generality we can take the "$+$" case, and then $y_5=\frac{-1-\sqrt 7}2$). In the unreal case we have $2\mathrm{Re}(x_5)=-1$ and $2|x_5|^2=4$, and hence $x_5=\frac{-1\pm\sqrt 7i}2$ (again we will take the "$+$" case, and hence $y_5=\frac{-1-\sqrt 7i}2$).
It's clear that $x_6$ and $y_6$ must take the same values as $x_5$ and $y_5$, but the other way around. So we have narrowed down the possibilities for the character table to two remaining choices, both of which fully satisfy all the orthogonality relations. The character table is either
\begin{array}{c r r r r r r} |[g]|&1&21&42&56&24&24\\ \hline
 \chi_1&1&1&1&1&1&1\\
 \chi_2&8&0&0&-1&1&1\\
 \chi_3&6&2&0&0&-1&-1\\
 \chi_4&7&-1&-1&1&0&0\\
 \chi_5&3&-1&1&0&\frac{-1+\sqrt 7}2&\frac{-1-\sqrt 7}2\\
 \chi_6&3&-1&1&0&\frac{-1-\sqrt 7}2&\frac{-1+\sqrt 7}2\\
 \end{array}
or
\begin{array}{c r r r r r r} |[g]|&1&21&42&56&24&24\\ \hline
 \chi_1&1&1&1&1&1&1\\
 \chi_2&8&0&0&-1&1&1\\
 \chi_3&6&2&0&0&-1&-1\\
 \chi_4&7&-1&-1&1&0&0\\
 \chi_5&3&-1&1&0&\frac{-1+\sqrt 7i}2&\frac{-1-\sqrt 7i}2\\
 \chi_6&3&-1&1&0&\frac{-1-\sqrt 7i}2&\frac{-1+\sqrt 7i}2\\
 \end{array}
and it remains to rule out one of these possibilities.
Here's the intended solution: By the Sylow Theorems we know that $C_7$ appears as a subgroup of our group either $1$ or $8$ times. None of these subgroups can intersect (except at the identity) since $C_7$ is generated by each of its nonidentity elements. So the number of elements of order $7$ is either $6$ or $48$. The elements in each conjugacy class must have the same order, so in fact it must be the case that the elements of order $7$ are precisely the elements of the two conjugacy classes of size $24$. The eigenvalues of a representation of an element of order $7$ must be $7$th roots of unity. So since $\boldsymbol{\sqrt{7}\notin\mathbb{Q}(e^{2\pi i/7})}$, the first character table above cannot be correct, and the answer must be the second one.
Of course I think it's actually easier to not use the extra assumption. For example you can calculate that if we take $\chi_5$ and $\chi_6$ as in the first character table we get $\left<\chi_5,\chi_5\otimes\chi_6\right>=1/2$, which is a contradiction since this value should be a natural number. This answers the question using only properties of characters, and without having to delve into the properties of the group.


Can I use bisphenol resin to bond plastic?

Question: I have a tube of bisphenol two part resin I'd like to use to repair headphones with a broken band. Problem is the band is plastic. Can I use a BPA resin to bond the earphone back to the band? I ask because both parts are plastic, and I don't know how well BPA plays with plastic. I also have JB weld which I know does NOT play well with many plastics.
I can also grab any relevant adhesive if there's something you think would work better.
Answer: Epoxy is not a bonding agent; it is a filler. Use something that is called plastic cement, or melt the pieces together. Epoxy only works well for bonding if the surfaces are rough such that the epoxy can fill the voids on each side of the bond. Epoxy's internal strength is high, but it does not attach well to anything, so it can generally be pulled right off its host surface. The only way to attach something to a smooth surface with epoxy is to drill through the surface and let the epoxy ooze through those holes and spread out on the other side; like a molly bolt.


How many Daedric artificts are in Skyrim?

Question: How many Daedric artifacts are in Skyrim, and what are their names?
Daedric artifacts are the rewards you get for completing certain Daedric quests. Some of them are the Mace of Molag Bal and Dawnbreaker. I do not know most of their names, and I am trying to get the platinum trophy for Skyrim, and one of the trophies are to get all of the Daedric artifacts. Any help is appreciated.
Comment: Literally the first result when searching for ["list of deadric artifacts in skyrim"](http://www.uesp.net/wiki/Skyrim:Daedric_Quests)
Answer: There are 16 Daedric Artifacts possible in Skyrim.
Azura's Star or The Black Star
This reusable soul gem is rewarded for completing "The Black Star" quest.
Dawnbreaker
This One-Handed sword is rewarded for completing "The Break of Dawn" quest.
Ebony Blade
This Two-Handed sword is rewarded for completing "The Whispering Door" quest.
Ebony Mail
This piece of unique armor is rewarded for completing "Boethiah's Calling" quest.
Mace of Molag Bal
This unique one-handed weapon is rewarded for completing "The House of Horrors" quest.
Masque of Clavicus Vile
This unique Heavy Armor helm is rewarded for completing "A Daedra's Best Friend" quest, but only if the Dragonborn chooses to give Vile his axe instead of using it to kill Barbas.
Mehrunes' Razor
This unique dagger is rewarded for completing the "Pieces of the Past" quest, but only if the Dragonborn kills Silus when Dagon tells him to.
Oghma Infinium
The Oghma Infinium is a powerful tome of knowledge that is rewarded for completing the "Discerning the Transmundane".
Ring of Namira
This ring is rewarded for completing "The Taste of Death" quest.
Sanguine Rose
This unique staff is rewarded for completing "A Night to Remember" quest.
Savior's Hide and/or Ring of Hircine
Either of these items is a potential reward for completing "Ill Met by Moonlight" quest", in a certain manner.
Skeleton Key
The Skeleton Key is the only Daedric Artifact known not to count for the achievement, Oblivion Walker. It is obtained during the Thieves Guild quest "Blindsighted."
Skull of Corruption
This unique staff is rewarded for completing "Waking Nightmare" quest, but only if you kill Erandur in the quest.
Spellbreaker
This unique shield is rewarded for completing "The Only Cure" quest.
Volendrung
This unique warhammer is rewarded for completing "The Cursed Tribe" quest in Largashbur.
Wabbajack
This unique staff is rewarded for completing "The Mind of Madness".
TAKE NOTE:, some of them are missable, so be careful.
Comment: Just gonna note *it is possible for you to get both the saviors hide and the ring of hircine*


Terminal block kenmore dryer all wires connect. Have one lose bare wire where does it go

Question: Kenmore dryer terminal block replacement now I connect the two hots and n but I have a naked wire from the cord going to dryer or terminal block where does it go or do I even need it
Answer: Normally there is a green screw to the frame of the dryer for that wire called the equipment ground.
Answer: The bare wire is important. It does not go to one of the 3 terminal block screws.  It goes to the ground/chassis of the machine.
However, there's another important factor.  On many dryers, there is a strap/wire/etc. from the neutral screw to the ground/chassis of the dryer. This must be removed!


I need to find my bed in Minecraft 1.8

Question: I was on my creative server and fell out of the world. I was in one of the little towns that are already spawned and I sort of built off of one of them, creating a larger "town". When I fell, I lost the place I was and I absolutely cannot find it. Is there a way to teleport back to your bed?
Comment: Have you tried a map?
Comment: did it say that your current bed is missing or obstructed?
Comment: If you died and didn't respawn at your bed, I think you're probably right out of luck.
Answer: You can forcibly kill yourself with the /kill command.  If the bed is still where it was, and you've slept in it, you should be teleported back.
Answer: You can suicide like the another person said but you could also use a compass that points in the direction of your current spawn point...
Comment: A compass points to the original spawn point (where you appeared when you first created the world), not your current spawn point.

I need to find my bed in Minecraft 1.8


Issue with image load stores and compute shaders

Question: I am trying to read an input texture, modify it and then write to an output texture from a very simple compute shader.
For some reason I am not able to write to the output image from the compute shader.
The screen is black (even though I have a red clear color).
Here is my application code:
    // Compute shader
    (...Code to setup images)
    glTextureStorage2D(m_color_texture, 1, GL_RGB32F, m_src_fbo_size, m_src_fbo_size); // <- Yikes, wrong format!
    glTextureStorage2D(m_temp_texture, 1, GL_RGB32F, m_src_fbo_size, m_src_fbo_size); // <- Yikes, wrong format!
    m_compute_shader.use();
    glBindImageTexture(0, m_color_texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F);
    glBindImageTexture(1, m_temp_texture, 0, GL_FALSE, 0, GL_WRITE_ONLY, GL_RGBA32F);

    glDispatchCompute(m_info.window_width / 32, m_info.window_height / 32, 1);

    // Full screen quad
    glBindImageTexture(0, m_temp_texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F);
    glDisable(GL_DEPTH_TEST);
    m_full_screen_quad_shader.use();
    glViewport(0, 0, m_info.window_width, m_info.window_height);
    glBindVertexArray(m_full_screen_quad_vao);
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);

And here is the compute shader:
#version 440 core

layout (local_size_x = 32, local_size_y = 32) in;

layout (binding = 0, rgba32f) readonly uniform image2D input_image;
layout (binding = 1, rgba32f) writeonly uniform image2D output_image;

void main()
{
    vec4 texel;
    ivec2 p = ivec2(gl_GlobalInvocationID.xy);

    texel = imageLoad(input_image, p);
    texel = vec4(1.0) - texel;
    imageStore(output_image, p, texel);
}

If I just swap m_temp_texture with m_color_texture (which is the input image )    in the call to glBindImageTexture(0, m_temp_texture, 0, GL_FALSE, 0, GL_READ_ONLY, GL_RGBA32F); then I see the image, so I know it is not a problem with the frag shader. (Here is is though anyway):
#version 440 core

layout (binding = 0) uniform sampler2D input_image;

layout (location = 0) out vec4 fragColor;

//uniform float focal_distance = 50.0;
//uniform float focal_depth = 30.0;

void main()
{
    vec4 color = texelFetch(input_image, ivec2(gl_FragCoord.xy), 0).rgba;
    fragColor = color;
}

Is there some reason why my compute shader is not being called? Even if I just write imageStore(output_image, p, vec4(1.0)); in the compute shader, the screen is all black.  I do not know what I am missing.
glGetError does not return anything.
EDIT:
I originally failed to include the code for the texture creation (the first two lines).  This affects the qustion. Please see the answer below.
Comment: If you found a solution, post it as an answer below.
Comment: @Nicol Bolas - Do we still need to use a memory barrier when
1) - We aren't reading/writing from/to a same image.
2) - We aren't overwriting any pixel of a image by subsequent `ImageStore`

So there wouldn't be any need for that since every invocation is writing to a separate pixel?
Comment: I think you only need the barrier on the C/C++ side, after the compute shader has run but before passing the texture to the rendering command. Something like glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
Comment: I'm not seeing the part where you use a member barrier to ensure visibility.
Answer: Originally mistmatching image formats (GL_RGB32F instead of GL_RGBA32F) were used in the creation of textures and the call to glBindImageTexture.
This error was hard to track down because the format (without alpha) only mattered (in this case) in the compute shader.
Using GL_RGBA32Feverywhere fixed the issue.


Running a python script at startup

Question: I am trying to get a simple python code that I have to run in the background at startup, and stay running.
The best option that I have found so far is to use Upstart. I wrote the following .conf file in the /etc/init/ folder and the service comes up with the initctl list command however when I start the service and then check the list again it is not running. The .conf is below.
If somebody could help me that would be much appreciated
start on runlevel [2345]
stop on runlevel [016]
respawn
script
    exec python /some/directory/python_code.py
end script

Comment: Have you checked that your python code is running correctly? It could be crashing or just exiting normally.
Comment: Does your python daemon fork to the background? If so, you will have to use either expect fork or expect daemon in the upstart config. See the Upstart cookbook: http://upstart.ubuntu.com/cookbook/#how-to-establish-fork-count
Comment: @superdesk my python code runs fine when I run it by entering 'python python_code.py'. However, the python code itself is an infinite while loop. Would that cause any issues with startup?
Comment: Do you actually need to run it on *start up*, or would on *log in* do? If so, it could be done really simply.
Comment: @Caleb When you run it from the command line, does it take control of the console so that you can not run any more commands, or does it go to the background so that the terminal is still available?
Answer: In my case I was able to do what I wanted using crontab.
I didn't necessarily need to run the code at startup. I just wanted to know that it would run while the computer is on. Using crontab allows me to run the python code every 15 minutes whenever the computer is on which works great.

Running a python script at startup


For loop does not work appropriate for the function

Question: Here is a for loop contains a function which specify whether the port is open or closed by using checkPort function.
var IPAdress = '192.168'; //Local area network to scan (this is rough)
var Portadd = 80;
var Newip;
var i=0;
var j=0;
//scan over a range of IP addresses and execute a function each time the port is shown to be open.
for(i=0; i <= 1; i++){
for(j=0; j <= 3; j++){
Newip = IPAdress+'.'+i+'.'+j;

checkPort(Portadd, Newip, function(error, status, host, port) {
// Status should be 'open' since the HTTP server is listening on that port
if(status == "open"){
        console.log("IP" , Newip, "on port" , Portadd, "is open");
    }
else if(status == "closed"){
        console.log("IP" , Newip, "on port" , Portadd, "is closed");
    }
});

console.log(Newip);
}
}

and this is the result:
192.168.0.0
192.168.0.1
192.168.0.2
192.168.0.3
192.168.1.0
192.168.1.1
192.168.1.2
192.168.1.3
IP 192.168.1.3 on port 80 is closed
IP 192.168.1.3 on port 80 is closed
IP 192.168.1.3 on port 80 is closed
IP 192.168.1.3 on port 80 is closed
IP 192.168.1.3 on port 80 is closed
IP 192.168.1.3 on port 80 is closed
IP 192.168.1.3 on port 80 is closed
IP 192.168.1.3 on port 80 is closed

since the NewIp as it is printed out works properly, I expected the result to be for example something like this:
IP 192.168.0.0 on port 80 is closed
IP 192.168.0.1 on port 80 is closed
IP 192.168.0.2 on port 80 is closed
IP 192.168.0.3 on port 80 is closed
IP 192.168.1.0 on port 80 is closed
IP 192.168.1.1 on port 80 is closed
IP 192.168.1.2 on port 80 is closed
IP 192.168.1.3 on port 80 is closed

Does anybody have an idea that why it shows the IPs like that in the actual result part?
Comment: Sometimes if you add a language tag you get more help.
Comment: Is this C#? VB.Net? VBA... what? Or javascript? Have we closed over the Newip badly?
Comment: good guidance. Done :)
Answer: Change to:
checkPort(Portadd, Newip, function(error, status, host, port) {
    // Status should be 'open' since the HTTP server is listening on that port
    if(status == "open"){
            console.log("IP" , host, "on port" , port, "is open");
    }
    else if(status == "closed"){
            console.log("IP" , host, "on port" , port, "is closed");
    }
});

You can't pass "parrent" variable into callback function, expecially You having host and port input parameter.
Full example for ip adresses in range 192.168.X.Y for X in [0,1,2] and Y in [0,1,2,3,4]:
var IPAdress = '192.168'; //Local area network to scan (this is rough)
var Portadd = 80;
var i=0;
var j=0;

//scan over a range of IP addresses and execute a function each time the port is shown to be open.
for(i=0; i <= 2; i++){
    for(j=0; j <= 4; j++){
        var Newip = IPAdress + '.' + i + '.' + j;

        checkPort(Portadd, Newip, function(error, status, host, port) {
            // Status should be 'open' since the HTTP server is listening on that port
            if(status == "open"){
                console.log("IP" , host, "on port" , port, "is open");
            }else if(status == "closed"){
                console.log("IP" , host, "on port" , port, "is closed");
            }
        });

        console.log(Newip);
    }
}

Comment: Draw attention to the difference and explain, if that's all the same and you don't mind...
Comment: I want to search through IPs 192.168.x.y which x is 0-2 for example and y is 0-4. How should I write down var host instead of that? var host = options.host || '192.168.0.1'
Comment: Thank you. In this case what should be written for var host? sorry That I am asking this question since my JS is not very good.
Comment: I have adder var NewIP inside the inner loop but the result did not change. Could you please tell me that how should I define var host based on the IP ranges which I have mentioned?
Comment: variables: `error`, `status`, `host` and `port` are input parameters. The `function(error, status,host,port){ ..... }` means: Let me define anonymous function with 4 input parameters: `error`, `status`, `host` and `port`.
Answer: checkPort is using a callback function that is executed later, and by the time it is executed all the IP addresses have been changed in the variable NewIP.
So the result is the callback function prints the last value of NewIP, because it's referencing that value.
You have two alternatives:

You can use the parameter host that is passed to the callback function instead.
Define var NewIP inside the inner for loop by changing var Newip = IPAdress+'.'+i+'.'+j;. This will create a variable that is scoped to the callback function.
Comment: Thanks a lot. That was really useful. Now I know that what is the problem. I want to search through IPs 192.168.x.y which x is 0-2 for example and y is 0-4. How should I write down var host instead of that? var host = options.host || '192.168.0.1'
Comment: I have adder var NewIP inside the inner loop but the result did not change. Could you please tell me that how should I define var host based on the IP ranges which I have mentioned?
Comment: Can you post an example to jsfiddle.net
Comment: You aren't using `host` and `port` in the callback. Remove those parameters.
Comment: Done. But still the problem exists. :( dont know what to do
Comment: @user3834704 use a debugger.


laravel - Delete comment by id and user id Not working

Question: I'm trying to delete a comment by id and by user id but it's don't deleting, just page loading and nothing changed.
But if there is one comment it's deleted successfully,
if comment between more comments nothing deleted.
Any help, please.
 public function commntdestroy($id)
    {
        Replies::where(['id' => $id, 'user_id' => Auth::id()])->delete();
        return redirect()->back();
    }

Route:
Route::delete('commentdestroy/{id}','StaffContractsController@commntdestroy');

I try:
public function commntdestroy($id)
    {
        $user_id = Auth::user();
        $replys=Replies::where('id', $id)
        ->where('user_id',$user_id);
        $replys->delete();
        return redirect()->back();
    }

Blade:
<form action="{{url('commentdestroy', $reply->id)}}" method="post">
 @csrf
  @method('DELETE')

Delete your Comment

<button class="btn btn-custon-four btn-danger" type="submit">Delete</button>
</form>

Comment: is `id` your primary key?? if so why you need to check against user id?? whats the logic??
Comment: because when I use id only it deletes the last comment, not for this user, but any user comment (the last comment was added)
Answer: first you need to take the id, not the entire user object
and second you need to fetch it by calling first() since you only want take only 1 data
public function commntdestroy($id)
{
    $user_id = Auth::user(); // wrong here
    $replys=Replies::where('id', $id)
    ->where('user_id',$user_id); // wrong here
    $replys->delete();
    return redirect()->back();
}

correct one should be
public function commntdestroy($id)
{
    $user_id = Auth::id(); //
    $replys=Replies::where('id', $id)
    ->where('user_id',$user_id)->first(); // you need to fetch the data
    //wrap if statement to check data exist or not
    if(!is_null($reply)){
        //execute if exist
        $replys->delete();
    }
    return redirect()->back();
}

and another advice you need to use better naming convention on your function or variable.
Comment: Thank you, but I try this nothing deleted.
Comment: Give me error `Call to a member function delete() on null`
Comment: check your database, and check the $id and $user_id you sent are existed on your database
Comment: to check you can do something like `dd('id =  . '$id . ' user_id =' . $user_id   );`  put it above $replys and then check both values are existed on database or not
Comment: if there's no data, then you can wrap it under if statement
Comment: Thank you very much, yes the database working very well if there is one comment it deleted, but the user's comment in the middle of comments it's not deleted
Comment: im not talking about that, just check with the dd to check $user_id and $id values are existed on your database, the problem is incorrect value being sent to the controller, thats why it gave you an error `delete() on null`
Comment: Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/198763/discussion-between-ghiffari-assamar-and-hima-hima).
Answer: There's a little bit problem with your second commentdestroy() function. It's taking hole user object but you don't need at all. You should use Auth::id() or long way, Auth::user()->id. Also I prefer to use named routes when using form actions. You can try something like this:
Route::delete('commentdestroy/{id}','StaffContractsController@commntdestroy')->name('comment.destroy');

<form action="{{ route('comment.destroy', $reply->id) }}" method="post">
 @csrf
  @method('DELETE')

Delete your Comment

<button class="btn btn-custon-four btn-danger" type="submit">Delete</button>
</form>

others are look good but first commentdestroy() function looks more clean.
Comment: Thanks for your comment, very nice about naming the routs, I'll use it but about the deleting nothing changed yet.
Comment: Can you add `$fillable = [];` line to your 'Comment' model. also can you check your `$id` parameter and `Auth::id()` values that they are working properly
Comment: Ok I'll try it now
Answer: As far as I understand, you want to delete a single comment. The person who made that comment only can delete that. In this case your approach should be like show the delete button only to those comments those are created by the currently logged in user. Well in your current approach you can do like something like below:
public function commntdestroy($id)
    {
        $reply = Replies::where([
                      ['id',$id],
                      ['user_id',Auth::id()]
                      ])->first();
        if ($reply) {
            $reply->delete();
        }
        return redirect()->back();
    }

You should use named route and Model name in singular form.
Comment: Thank you for your comment, Yes I try this solution but don't delete, it's working when there is only one comment
Comment: as you are using `id` for fetching a comment, it will obviously delete one comment. do you want to delete all the comments by a single user?? make sure what you are trying to achieve here.
Comment: No, I want to delete one comment not all the user comment
Comment: then it should work fine. how are you rendering comments in view? what `$reply->id` holds in the delete form?


error TS1046: 'declare' modifier required for top level element

Question: I'm using a .d.ts definition file I found online for interoperating with a JavaScript library.
I'm seeing the error message:

TS1046: 'declare' modifier required for top level element

What is causing this?
I'm using TypeScript 0.9.1.
Answer: This was a breaking change between 0.8.x vs 0.9.x. declare is now required for all top level non-interface elements (i.e. module, class, var) in a declaration .d.ts file:

Source: Microsoft Blog
Comment: Can you provide an example?
Answer: TypeScript 0.9 is not backwards compatible with prior versions. You must prefix the top level element (probably a module) with the declare keyword.
Answer: in your package.json-> devDependencies part insert
"fast-deep-equal": "^3.0.0",
than it should function


Concatenate 2 Columns into new Column in VBA

Question: Hi I need help with concatenating 2 Columns into a new column.
I have the following dataset

The ideal result would look like this
Answer: Heavily commented to help with understanding :)
To make it work, just change the WB and WS variables.
Sub concatCells()
    ' declare variable types - immutable                              do not modify
    Dim WB As Workbook                                                '  workbook             - full name of the file containing data.
    Dim WS As Worksheet                                               '  worksheet            - worksheet within  workbook containing data.
    Dim i As Long                                                     ' loop variables        - used to iterate through loops. not user defined.
    Dim lRow As Long                                                  ' last row              - last row with data found in the  column. not constant / user defined.

    ' variables - mutable                                             ok to modify
    Set WB = Workbooks("SO.xlsm")                                     ' set the name of the  workbook here
    Set WS = WB.Worksheets("63627727")                                ' set the name of the  worksheet here

    ' code - immutable                                                do not modify
    lRow = WS.Cells(WS.Rows.count, "A").End(xlUp).Row                 ' find the last row in Col of the WS object

    For i = 1 To lRow                                                 ' creates a For loop and declares i as each iteration (i = 1 then i = 2, etc)
        WS.Range("B" & i) = WS.Range("A" & i) & WS.Range("C" & i)    ' concats cells A and C into B

        ' uncomment below to concat data into column A and clear column C
        ' WS.Range("A" & i) = WS.Range("A" & i) & WS.Range("C" & i)   ' concats cells A and C into A
        ' WS.Range("C" & i).Clear                                     ' clears contents of C

    Next                                                              ' iterate to next cell within defined range for primary loop
End Sub

Comment: Hi Sorry for the late reply. Yes, both of the lines work. Thanks for you help!
Comment: Glad I could help :)
Answer: Very basic thing. Simply use below formula
=A1 & C1

Comment: But why need `VBA` for this simple issue? Should encourage to use excel formula only.
Comment: OP has VBA tagged.
Comment: I absolutely don't disagree lol. Overkill if it's simple. OP might have something else going on.
Comment: This is just a sample dataset I created. I have a larger dataset which I have to use the same function. Appreciate your reply !


Aws EventBridge Rule pattern not forming correctly with AWS SAM

Question: I was trying to create an AWS state machine(step functions) using AWS SAM which is triggered by S3 event. Following is my AWS SAM yml snippet.
<code> SampleStateMachine:
    Type: AWS::Serverless::StateMachine
    Properties:
      Name: sample-state-machine
      DefinitionUri: state-machines/my-definition.asl.json
      Events:
        S3PutEvent:
          Type: EventBridgeRule
          Properties:
            Pattern:
              source:
                - "aws.s3"
              detail:
                eventSource:
                  - s3.amazonaws.com
                eventName:
                  - PutObject
                requestParameters:
                  bucketName:
                    - !Ref MyBucketName
</code>
On deploying this application, it's successfully creating the rule with the pattern that I've specified in the sam yml template. (but with a slight change in the order of JSON key-value pairs)
<code>{
    "source": [
      "aws.s3"
    ],
    "detail": {
      "eventSource": [
        "s3.amazonaws.com"
      ],
      "requestParameters": {
        "bucketName": [
          "my-bucket"
        ]
      },
      "eventName": [
        "PutObject"
      ]
    }
  }
</code>
Unfortunately, this rule is not capturing any event from the event bus. so I've tried like changing the JSON Key-Value pair in the following order,
<code>{
  "source": [ "aws.s3"
        ],
        "detail": {
          "eventSource": [
            "s3.amazonaws.com"
          ],
          "eventName": [
            "PutObject"
          ],
          "requestParameters": {
            "bucketName": [
              "my-bucket"
            ]
          }
        }
      }
</code>
and it started receiving events and working fine.
So my question is,

Is this order really matters for AWS eventbridge rule pattern?
If so, how we can preserve this order while AWS sam execution(YML to JSON)?

Thanks
Comment: If you can definitely verify that the order affects it then you should log it to aws as a bug.
Comment: I seem to hit same problem when I am creating rule via Terraform. JSON order is changed during rule creation + ordered version doesn't work. Did you have any luck solving this?
Answer: Order should not matter. If you can reproduce the issue, you should file a bug report with AWS support to get the service to fix it.


IE7 Z-Index Issue (CSS DropDown)

Question: I have tried a few different fixes using JQuery and CSS Tricks, but I can't seem to get my drop down menu to lay over top of my accordion slider in IE7. It seems to work fine in any other web browser. Any help would be greatly appreciated.
Code snippets::
HTML

Home

Applications

Sub1

Sub2

Sub3

Products

Sub1

Sub2

Sub3

Sub4

News/Media

About Us

Contact

Slide 1

Slide 1

Slide 1

Slide 2

Slide 2

Slide2

Slide 3

Slide 3

Slide 3

CSS
/* --------- */
/* -- Nav -- */
/* --------- */
#nav { height:43px; border-top:1px solid #dbdbdb; border-bottom:1px solid #dbdbdb;  }
.menu { padding: 7px 6px 0 0; }
.menu li { margin: 0 5px; float: left; list-style:none; position:relative; border-right: 1px solid #DBDBDB; }
.menu a { display: block; padding:  8px 15px; margin: 0; color: #555; text-decoration: none; font-size: 15px; }
.menu .current a, .menu li:hover > a { color: #CA9800; }
.menu ul li:hover a, .menu li:hover li a { color: #555; }
.menu ul a:hover { background: #CA9800 !important; color: #fff !important; }
.menu ul { background: #eee; display: none; margin: 0; padding: 0; width: 250px; position: absolute; top: 35px; border: solid 1px #ddd; z-index:9000 !important; }
.menu li:hover > ul { display: block; }
.menu ul li { float: none; margin: 0; padding: 0; }
.menu ul a { font-size: 14px; }
.menu ul ul { left: 250px; top: -3px; }
.menu li.current_page_item a { color: #CA9800; }
.menu .sub-menu li.current_page_item a { color: #CA9800; }

/* --------------- */
/* -- ACCORDIAN -- */
/* --------------- */

/* UNLESS YOU KNOW WHAT YOU'RE DOING, DO NOT CHANGE THE FOLLOWING RULES */

.easy-accordion{display:block;position:relative;overflow:hidden;padding:0;margin:0}
.easy-accordion dt,.easy-accordion dd{margin:0;padding:0}
.easy-accordion dt,.easy-accordion dd{position:absolute}
.easy-accordion dt{margin-bottom:0;margin-left:0;z-index:5;/* Safari */ -webkit-transform: rotate(-90deg); /* Firefox */ -moz-transform: rotate(-90deg);-moz-transform-origin: 20px 0px;  /* Internet Explorer */ filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);cursor:pointer;}
.easy-accordion dd{z-index:1;opacity:0;overflow:hidden}
.easy-accordion dd.active{opacity:1;}
.easy-accordion dd.no-more-active{z-index:2;opacity:1}
.easy-accordion dd.active{z-index:3}
.easy-accordion dd.plus{z-index:4}
.easy-accordion .slide-number{position:absolute;bottom:0;left:10px;font-weight:normal;font-size:1.1em;/* Safari */ -webkit-transform: rotate(90deg); /* Firefox */ -moz-transform: rotate(90deg);  /* Internet Explorer */ filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1);}

/* FEEL FREE TO CUSTOMIZE THE FOLLOWING RULES */

dd p{line-height:120%}

#accordion-1{width:800px;height:245px;padding:20px;background:#fff;margin:0 0 0 60px; z-index:1;}
#accordion-1 dl{width:800px;height:245px}
#accordion-1 dt{height:46px;line-height:44px;text-align:right;padding:0 15px 0 0;font-size:1.1em;font-weight:bold;font-family: arial, sans-serif; text-transform:uppercase;letter-spacing:1px;background:#fff url(../images/slide-title-inactive-1.jpg) 0 0 no-repeat;color:#BF8530}
#accordion-1 dt.active{cursor:pointer;color:#fff;background:#fff url(../images/slide-active.jpg) 0 0 no-repeat}
#accordion-1 dt.hover{color:#BF8530;}
#accordion-1 dt.active.hover{color:#fff}
#accordion-1 dd{padding:25px;background:url(../images/slide.jpg) bottom left repeat-x;border:1px solid #dbe9ea;border-left:0;margin-right:3px}
#accordion-1 .slide-number{color:#68889b;left:10px;font-weight:bold}
#accordion-1 .active .slide-number{color:#fff;}
#accordion-1 a{color:#BF8530}
#accordion-1 dd img{float:right;margin:0 0 0 30px;}
#accordion-1 h2{font-size:2.5em;margin-top:10px}
#accordion-1 .more{padding-top:10px;display:block}

Comment: Perhaps you can post the relevant portions of your CSS and HTML within the question.
Answer: There is a known issue with z-index in IE 7.  It treats z-index differently for absolute positioned elements than it does for relative positioned elements.  It's like you have two sets of z-indexes.  You might be able to fix it by using wrappers with the same positioning, if you cannot get all your elements to use the same positioning.
z-index bug threads
Z-Index IE bug fix?
Internet Explorer z-index bug?
jQuery Solutions:
http://www.vancelucas.com/blog/fixing-ie7-z-index-issues-with-jquery/
http://webdeveloper2.com/2010/01/how-to-fix-the-ie-z-index-bug-with-jquery/
Comment: Tried a few of those, perhaps I'm just not implementing it correctly. I'll take a look at a few of those other links. Thanks.
Answer: You may want to add position:relative; to the part that's dropping down. According to this it'll usually solve your problem.
Comment: adding position: relative to the accordian div seemed to resolve the issue.
Comment: You may also want to see this: http://stackoverflow.com/questions/1287439/ie7-z-index-problem

IE7 Z-Index Issue (CSS DropDown)


What has changed between Pokemon Black and Black2?

Question: I've got all the games from Diamond on and really enjoyed Black, but it seems too similar. What are the differences?
Comment: So, we won't really be able to answer the "should I get it question" as those types of questions are off-topic here. But if you're just looking for the differences, we should be able to answer that.
Answer: You can find them on Bulbapedia. Here are the most important:
Aesthetic changes

New locations such as Aspertia City, Virbank City, Floccesy Town, Lentimas Town and Humilau City have been added to the game.
New characters are introduced.
All Unova Gyms receive redesigns, including newly remixed music.
There have been several changes made to existing locations, such as Driftveil City and Nimbasa City.
Several attacks have received new battle animations.
The battle menu and the C-Gear have been redesigned.
The Unova Pokédex has been expanded tremendously to accommodate older Pokémon.
In place of Cold Storage, there is now the Pokémon World Tournament.

Storyline changes

The player no longer starts in Nuvema Town, instead starting in Aspertia City.
Chili, Cress, Cilan, Lenora and Brycen are replaced by Cheren, Roxie and Marlon as Gym Leaders.
Bianca gives the player a Starter Pokémon.
A new Team Plasma has formed, and is run by Ghetsis.
Iris is the new Champion of Unova.
Ghetsis returns and plans to freeze Unova with Kyurem.
Neither the version mascots Black Kyurem or White Kyurem can be caught within the story, but can be obtained post-game by following certain requirements.
Another new attraction introduced is the Pokéstar Studios, located in Virbank City, where the player takes part in many different movies.
Several areas that were previously limited to the post-game of Black and White are now part of the main story. In contrast, some of the areas that were formerly part of the main story are now limited to the post-game.

Gameplay changes

A new feature called the Memory Link is introduced, which reveals flashbacks from the NPCs that shed light on events that happened between Black and White and Black 2 and White 2.
Many TMs and all but one HM are received in different locations.
The Move Tutors are back, and as with Pokémon Platinum, they teach most of the moves that were in that game for Shards, but here they all ask for shards of a specific color. They also teach many moves that lost their TM status.
A number of legendaries from Hoenn and Sinnoh (excluding the Weather trio and Creation trio) can be found in the post-game.
Zorua and Zoroark, which were previously accessible through Nintendo events only, can now be found within the game without any special requirements.
Hidden Grottoes are introduced and scattered all over Unova, giving access to many items and Pokémon with their Hidden Abilities, many of which were previously unobtainable.
Comment: There's also a completely new story. Black 2 and White 2 are set three years after the events in Black 1 and White 1.