What is the correct slope for a deck, and why?

Question: I am building a deck (12' wide) and see that deck boards (at least when perpendicular to the house) should be sloped away from the house so water will run away from the house.  Seeing numbers for the slope from 1/8" to 1/4":

per foot
per three feet
per twelve feet
per (unspecified)

Is there a 'correct' value or range of values as such?  What makes it correct?
Does it vary based on (what) conditions?
Perhaps a higher slope for composite decking that tends to sag?
Note:  a one degree slope would be 0.209" per foot.
Comment: ...but a 1% slope (which is how such things are commonly specified, not in degrees) is within spitting distance of 1/8" per foot (1:96 .vs. 1:100)- and is the slope that pretty much ANY "flat" surface outdoors should have at a minimum. If that flat surface is next to your house, the slope should be away from the house. Otherwise just where you want the water to drain to.
Answer: I'd use 1/8" per foot slope because 1) it's enough to actually allow water to run off, and 2) the deck will "appear" flat

You don't want standing water on your deck. It can cause rot, etc. I live where we get a ton of rain. It's important to get rid of water on wood, etc. on the exterior of a home.

When you look at the deck, it will appear flat AND your soup bowl will not spill when you place it on a table.


Smoothness of Modulus space

Question: Let $M_g$ be the modulus space of genus $g$ Riemann surfaces.  I know that $M_g$ is of dimension $3g-3$, which is also equal to the dimension of $H^1(T_X)$ for any Riemann surface $X$ (which is supposed to be the tangent space of $M_g$ at $X$). This suggests that $M_g$ is smooth. Yet, the comments in this question suggest that $M_g$ is singular. What is going on here?
Comment: The moduli stack $\mathcal{M}_g$ of smooth proper geometrically connected curves of genus $g$ is smooth.  Its coarse space $M_g$ (which is sometimes also referred to as the moduli space of genus $g$ curves) is a variety which "approximates" the moduli stack the best way an algebraic variety could. However, this coarse space is not really what we want the moduli of genus $g$ curves to be. Certainly,  it suffices to consider the space $M_g$ to study certain problems, but the more natural object to consider is   the stack $\mathcal{M}_g$. It is the variety $M_g$ which is singular when $g>1$.
Comment: The reason the stack $\mathcal{M}_g$ is smooth is precisely by what you say (essentially). Its tangent space at an object corresponding to a curve $X$ is given by $\mathrm{H}^1(X,T_X)$ and this has the right dimension, as you note, so the stack is smooth (for this to make sense, you'd have to familiarize yourself with the language of algebraic stacks). On the other hand, the tangent space to the point $[X]$ of the coarse space corresponding to $X$ is *not* $\mathrm{H}^1(X,T_X)$ in general.
Comment: @AriyanJavanpeykar Thanks, this makes sense!
Comment: @AriyanJavanpeykar would you consider posting your comments as an answer?
Comment: @KReiser I copied my comments and gave an answer below.
Comment: Thanks! It's a nice answer and I'm glad to upvote it.
Answer: The moduli stack $\mathcal{M}_g$ of smooth proper geometrically connected curves of genus $g$ is smooth. Its coarse space $M_g$ (which is sometimes also referred to as the moduli space of genus $g$ curves) is a variety which "approximates" the moduli stack the best way an algebraic variety could; its dimension equals the dimension of $\mathcal{M}_g$ (which is $3g-3$). However, this coarse space is not really what we want the moduli of genus $g$ curves to be. Certainly, it suffices to consider the space $M_g$ to study certain problems, but the more natural object to consider is the stack $\mathcal{M}_g$. It is the variety $M_g$ which is singular when $g>1$.
The reason the stack $\mathcal{M}_g$ is smooth is precisely by what you say (essentially). Its tangent space at an object corresponding to a curve $X$ is given by $\mathrm{H}^1(X,T_X)$  and this has the right dimension, as you note, so the stack is smooth (for this to make sense, you'd have to familiarize yourself with the language of algebraic stacks). On the other hand, the tangent space to the point $[X]$ of the coarse space corresponding to $X$ is not $\mathrm{H}^1(X,T_X)$  in general.

Smoothness of Modulus space


how to understand javascript coercion?

Question: I was watching this talk, and on 16:34 there is a javascript coercion test:

5 - "4"  // 1
5 + "4"  // 54
+!{}[true]  // 1
+[1]  // 1
+[1, 2]  // NaN
7 - "a"  // NaN
7 / 0  // Infinity

What is the exact logic behind those calculations?
Comment: "What is the exact logic behind those calculations?" coercion!
Comment: https://github.com/getify/You-Dont-Know-JS/blob/master/types%20%26%20grammar/ch4.md
Comment: @T.J.Crowder Edited the question, is it now not off-topic? On which hub would that question be not off-topic? Thanks.
Comment: *"what is your resource of choice to understand type coercion in javascript?"* Off-topic for SO. Personally, my preference is the specification.
Comment: @HyphenWrex: *"Edited the question, is it now not off-topic?"* Yup!
Answer:
5 - "4"  // 1

The - operator coerces its operands to numbers. See the subtraction operator and the abstract ToNumber operation it uses.

5 + "4"  // 54

When either operand is a string, the + is string concatenation, not addition, and the other operand is coerced to string if necessary. See the addition operator and the abstract ToPrimitive and ToString operations.

+!{}[true]  // 1

Explaining this is pointless. Don't do that in your code.
Oh, okay:

{}[true] is evaluated first. The true is coerced to "true" (via ToString linked above) because it's used in a property accessor and isn't a Symbol. {} is an empty object, so {}[true] is undefined, leaving us with +!undefined.
!undefined is true, because it coerces undefined to a boolean via the abstract ToBoolean operation, and then negates that to get true.
+true is 1, because of ToNumber linked above.

+[1]  // 1

[1] is an array with a 1 in it. Applying + to it runs it through ToPrimitive, which ultimate ends up being [1].join(","), giving us..."1". +"1" is 1 thanks to ToNumber.

+[1, 2]  // NaN

Almost exactly like the above, but since the string "1,2" can't be completely parsed as a number, we get NaN.

7 - "a"  // NaN

Almost exactly like our first example. ToNumber("a") is NaN, and any calculation involving NaN (such as substraction) results in NaN.

7 / 0  // Infinity

In JavaScript, division by 0 is defined as Infinity; see the Applying the / Operator.
As you can see, these are all understandable, with effort, by referring to the specification. Some are tricky, but really the tricky ones are things you'd almost never run into in the real world.
Answer:
What is your resource of choice to understand type coercion in javascript?

The spec.
Some examples:

to understand why 5 - "4" === 1, I would look for the binary - operator in the spec and see that ToNumber is called on each argument.
to understand why +!{}[true] === 1, I would first understand that {}[true] uses the bracket notation property accessor, which uses ToPropertyKey on the value, which will use ToString on true since true is not a Symbol, so it is the same as {}["true"], and since that object has no property called "true" the result is undefined, then to understand why +!undefined === 1 I would look at the spec for the unary logical ! operator and see that it uses ToBoolean (before negating the result), and ToBoolean converts undefined to false. To understand why +true === 1, I would look at the spec for the unary + operator and see that it calls ToNumber on its operand, and ToNumber evaluates true to 1.

The rules are actually pretty straightforward and intuitive once you are accustomed to them, which happens pretty quickly. If you learn them from the spec, there are no surprises.
Answer: To understand coercion you simply need to understand what is going on. Firstly, JavaScript is a dynamically typed language. Unlike some other programming languages, JavaScript doesn't require you to define a variable's type.
Example:
var a = 1
//you are not telling JavaScript that
// 1 is an integer, you are just defining it as is

So prior to attempting to breakdown the examples you have listed, you must next understand that to apply a method to an object, both methods have to be the same type.
Example:
5 + "hello" = ?
// in math, you can't possibly add a number to a word right?
// and JavaScript realises that.
// But instead of throwing an error, it "coerces" the
// integer 5, into a string "5",
// giving you the answer "5hello"

Lastly I would use the first 2 examples as a contrast for coercion.
The first one states 5 - "4" = 1 while the second one is 5 + "4" = "54".
The main reason for difference in result is largely because of the symbol involved. While we can "add" strings together (simply joining them) but how exactly should we be "minusing" strings?
While this may be a very brief explanation of coercion in JavaScript but hopefully it gives you a clearer picture.
Answer: to understand the logic between symbold that have functions:
1.) 5 (integer type) minus 4 (string type) results 1, 4 implemented as int
2.) 5 (integer type) plus 4 (string type) results 54, 5 implemented as string
3.)+plus !is not {} brackets results true
4.)plus array one+[1], results 1
5.)plus array one and two(multiple data set), results Nan, not do-able
6.)7 (int) minus string("a"), results Nan since its not possible
7.)7 divide by 0 , results in infinity like in math functions if a number is divided by 0 is always infinite
Wiki:Coercion /koʊˈɜːrʃən/ is the practice of forcing another party to act in an involuntary manner by use of intimidation or threats or some other form of pressure or force.
like number 1 is int against string which does not fit and forcefully written
It's just to help you understand the logic behind the language.Hope this helps :)

how to understand javascript coercion?


React: Get month name instead of number

Question: Need to get the name of the month (ie. April) instead of the number that is compatible with a React app.
I've tried using a few JavaScript snippets, but I'm not getting the results I need.
Currently using {(new Date().getMonth()+1)} to pull the month number. To note, this is rendering outside of a component.
Comment: Possible duplicate of [Get month name from Date](https://stackoverflow.com/questions/1643320/get-month-name-from-date)
Comment: Is using a predefined array of months an acceptable solution?
Answer: The simplest form would be using an array:
const monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
let monthIndex = (new Date().getMonth());
let monthName = monthNames[monthIndex];

// render jsx
return (
{monthName}
)

In case you need to do more with date (compare, add, subtract, etc.) you might want to use a library, e.g. moment.js.
Comment: May I ask why so many examples include a predefined array with the month names? `date.toLocaleString('nl-NL', { month: 'long' })` does exactly that, right?
Answer: Personally, I am not sure why most examples and answers default to using a predefined array with the month names. It can be easily done using the js Date object. But there might be some pitfalls since it's not the most common way of doing it. I just don't know what they are...
Example
function getMonthName(monthNumber) {
  const date = new Date()
  date.setMonth(monthNumber) // starts with 0, so 0 is January
  return date.toLocaleString('en-EN', { month: "long" })
}

getMonthName(1) // February
getMonthName(3) // April

Answer: You can use {['January','February',...,'December'](new Date().getMonth())}. It will pick the correct index from the months array (eg index 0 = January).
Answer: It should be:
let monthName = monthNames[monthNumber - 1];

Comment: hi Dave, thank you for your answer! could you add an explanation to your code? it's not clear what you think the author of the question got wrong, or how this is a solution. if "monthNames" is a particular array for example, please describe it (even if you think it's obvious) as it isn't mentioned in the question at all
Comment: Hi Sasha, Sorry for misunderstanding! The array is zero based, so e.g. September would be at index 8! That is why I thought it might be quite clear for everyone. See also my screenshot form VS. -Sorry it looks like I can not upload images yet!

React: Get month name instead of number


not enough arguments to satisfy format string

Question: What is wrong with this, please?
awk '{printf "%10.5f  %6.4f  %6.4f  %6.4f  %6.4f R\n, $1, $4, $5, $7, $8"}' R.dat > R0

It gives the error: not enough arguments to satisfy format string
There are five % to format 5 $columns.
Comment: You have a good question and you have posted your attempt at a solution (good job!), but in the future, you need to try and describe the problem with more particularity. For example it would be nice to see several lines of `R.dat` showing the exact input you are using as well as the command output (at least the first few lines) along with your expected output. This would allow everyone to confirm the issue you are having and be confident that the answer given would address that problem. Not a criticism, just a bit of helpful advice for future questions.
Answer: You should do it like following manner. Where we need to enclose all formatting parameters inside "...." and then other section(after ,) we need to put whatever field values/variables etc are the ones which we want to print in current line.
awk '{printf "%10.5f  %6.4f  %6.4f  %6.4f  %6.4f R\n", $1, $4, $5, $7, $8}' R.dat > R0

OR to make it more clear use like:
awk '{printf("%10.5f  %6.4f  %6.4f  %6.4f  %6.4f R\n", $1, $4, $5, $7, $8)}' R.dat > R0


The client side of web development

Question: In the field of RIAs, I've read tons of comments stated that the discussion about Silverlight vs JavaFX vs Flash vs HTML5 is outdated and the winner is HTML5.
Since I am a programmer (not a designer) but never used any of the technologies above and I have no time to learn all of them to compare, I want to ask the following:
1) With HTML5 we continue to only have interpreted JavaScript, or we can use more powerful languages that generates compiled code (some kind of MSIL or bytecode inside <object> ... </object> tags)?
2) Does HTML5 hide portions of our code from unwanted viewers (like Java applets and ActiveX did in the past) or the option "View - Source Code" continues to show all of our work?
3) HTML5 need some kind of runtime or all the work is done by the browser?
Comment: HTML5 is just a set of new features in HTML, CSS, & JS.  It doesn't change anything about how they work.
Comment: You may be interested in ASM.js, which allows specially-written JS to run much faster.
Answer: There is a bit of a fundamental problem with your question in that HTML5 is not really a thing.  It's hard to compare it to Java or Flash, which are programming languages.  It is possible to create interactive applications using HTML and JavaScript without using any of the features of HTML5.  This seems to happen a lot, but for simplicity these are often referred to as HTML5 applications -- especially by non-technical people.
1) I would say that JavaScript can be as powerful as the other compiled languages you talk about even on a webpage -- especially with the power of <canvas>.  You have found that HTML5 has won for a reason.  In my opinion, it can do what the others can do and is simpler to implement.
There is nothing that forbids you from including Flash objects of Applets alongside JavaScript, though, and they can even interact.
2) There is nothing that prevents all of your HTML/JavaScript from being downloaded in the browser and viewed in plain text, although it can be obfuscated with tools such as Uglify.
It's also possible to download and decompile swfs and jars from a web interface, so compiling does not necessarily offer you a lot of protection anyway.  Your code would be protected by Copyright (at least in the US) and you could use a license the MIT license too.
3) All the work is done by the browser.  The client will only need a browser to run your code, but some browsers do not support some features you may want to use.  This especially applies to older browsers.
There are a ton of frameworks and libraries out there for creating rich HTML/JavaScript applications, but these are just are mostly just JavaScript files.
Answer: HTML5 is a brand and trend. In silverlight/flash/html battle HTML must be the winner. Because browsers can't progress fragmentary. Is it true then some part of features developing in browser plugins, some part in browsers. For strong and fast progress always, at the start, needs the vector. In redefining web in our life such vector is HTML5. HTML5 is not a language, it is the set of capabilities, such video, music, webgl, geolocation, semantic essences and more and more only from browser. And we can't speek here about HTML5 like a language.
All your questions are about javascript.

Want bytecode inside <object> ... </object>? Use Chrome Native Client.
Want to hide your code? Use any obfuscator.
Modern javascript engines has just-in-time compilation. And there is the "subset" of javascript like asm.js which is just 2x slower then C++.

The client side of web development


Command Line - how to extract a file name only when using a for command loop

Question: What I need to do is extract the filename from %%f so I can create the correct dll name.
for %%f in (*.asmx.cs) do (
    echo %%f

    cmd /c C:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:library /r:%assemblies% %compileoptions% /out:bin/%%f.dll %%f
)

Answer: Use %%~nf.
for %%f in (*.asmx.cs) do (
    echo %%~nf

    cmd /c C:\windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:library /r:%assemblies% %compileoptions% /out:bin/%%~nf.dll %%f
)

For a complete list of FOR variable modifiers like %%~nf, run for /? from the command line, or look online here.


Closure Compiler Ignores Object Mutation

Question: I put the following code into closure compiler on advanced mode:
var obj = (function() {
  /** @constructor */
  function H(a) {
    this.a = a
  }
  var h = new H(1);
  h.b=1
  return h
})();

The result I get back is:
(function() {
  var a = new function() {
  }(1);
  a.a = 1;
  return a;
})();

Why is it ignoring the change I make to the object h.b=1 ?
Comment: Try adding `this.b = null` in the constructor. Perhaps it's optimized in a way to ignore code that would result in multiple hidden classes?
Comment: @plalx I was hoping to see it add `this.b=1` to the constructor.
Comment: While the question by itself is valid, notice that [this pattern shouldn't be used](http://stackoverflow.com/q/10406552/1048572)
Answer: The advanced compilation options enable aggressive property removal, which includes some assumptions:
It makes a strong assumption that properties defined on a "prototype" or "this" will not be iterated over and thus is a candidate for removal.

/** @constructor */
function cls() {
   this.x = 1; // removal candidate due to "this" assumption;
}

So what you're seeing is actually this.a = a being removed, and then the property b is being renamed to a.


Display local time in a different timezone

Question: Update: I found a solution to this question and posted it in the comment.
I'm new to Python. I've been searching for resources to guide me how to display local time in a different timezone (in UTC), but all I found was converting based on current time.
For example, my local timezone is 'Asia_Singapore'. How to I get the my local time in UTC - 1 which is 7:00 AM?
If it helps, I'm trying to do something like this tool: https://www.timeanddate.com/worldclock/meetingtime.html?iso=20230106&p1=145&p2=108&p3=56&p4=304&p5=179&p6=220
One of the code snippet I tried was from this page:
from datetime import datetime

import pytz

fmt = '%Y-%m-%d %H:%M:%S %Z%z'

# Print current time
print(datetime.now().strftime(fmt))

# Show current time in Berlin timezone
tz_berlin = pytz.timezone('Europe/Berlin')
local = tz_berlin.localize(datetime.now())
print("Berlin Time::", local.strftime(fmt))

# Show UTC + 2 time in local timezone
tz_sin = pytz.timezone('Asia/Singapore')
dt = datetime(2023, 1, 6, 2, 0, 0)
local = tz_sin.localize(dt)
print("Singapore Time in UTC + 2::", local.strftime(fmt))

Output:
2023-01-06 10:27:44
Berlin Time:: 2023-01-06 10:27:44 CET+0100
Singapore Time in UTC + 2:: 2023-01-06 02:00:00 +08+0800

What I expected:
2023-01-06 18:27:44
Berlin Time:: 2023-01-06 11:27:44 CET+0100
Singapore Time in UTC + 2:: 2023-01-06 10:00:00 +08+0800

Thank you in advance!
Answer: I think I found a solution without using any library. I just need to calculate the time difference between the local timezone and the targeted time in UTC.
Here's how I did it:
def convert_tz(tz, target_tz):

    new_tz = int(tz) + int(target_tz)

    print("New timezone: {}".format(new_tz))

    if new_tz < 12 and new_tz >= 0:
        return str(new_tz) + "AM"
    elif new_tz >= 12:
        return str(12 - new_tz) + " PM"
    else:
        return str(24+new_tz-12) + "PM"

target_tz = "-1"
print("Target timezone: {}".format(target_tz))
tz = ["8","-5","0","-7","+7","+2"]

for item in tz:
    print("Original timezone: {}".format(item))
    print("Converted time: {}".format(convert_tz(item, target_tz)))


role attribute of h:panelGrid

Question: I'm using exaples from the official Java EE tutorial In which contains the follow:
<h:panelGrid columns="2"
    headerClass="list-header"
    styleClass="list-background"
    rowClasses="list-row-even, list-row-odd"
    summary="#{bundle.CustomerInfo}"
    title="#{bundle.Checkout}"
    role="presentation">

But compiler says that attribute role is not defined for h:panelGrid component. How to fix this?
Answer: That attribute was introduced in JSF 2.2. As evidence, the role attribute is mentioned in JSF 2.2 <h:panelGrid> documentation, but not in JSF 2.1 <h:panelGrid> documentation.
Your question history confirms that you're using JSF 2.2 on GlassFish 4.0, so this compiler warning is actually wrong. This is not exactly a JSF problem, but an IDE problem. The IDE is somehow thinking that you're not using JSF 2.2, but JSF 2.1 or older. I.e. your toolset is working against you. You didn't mention which IDE you're using, so it's not possible to post the right answer.
If the project runs fine and the JSF page produces the right HTML output (i.e. the role attribute actually ends up in generated HTML
 element as you can see by rightclick, View Source in webbrowser), then everything is well and it's just the IDE who's pretending to be smarter than it actually is.
I'd start peeking around in IDE project's properties to check if the JSF versions are all right. The JSF facet in project's properties must be set to version 2.2, not lower. The faces-config.xml must be declared conform JSF 2.2, not lower.

role attribute of h:panelGrid


In MVC3 , getHtml giviing Column doesn't exists

Question: I am trying to populate the webgrid with the list of objects.
My HomeController is
namespace WebGridExample.Controllers
{
    public class HomeController : Controller
    {
        private readonly List<Student> list;
        public HomeController() {
            list = new List<Student>()
            {
                new Student(){ID="111",Name="Tanu",Age="24"},
                new Student(){ID="122",Name="Danu",Age="20"},
                new Student(){ID="11",Name="Taniya",Age="18"},
                new Student(){ID="888",Name="Vidushi",Age="25"},
            };

        }

        public ActionResult Index()
        {
            return View(list.ToList());
        }

    }
}

My Student Model is:
namespace WebGridExample.Models
{
    public class Student
    {
        public string Name;
        public string ID;
        public string Age;

        public Student() {

        }
        public Student(string Name,string ID,string Age) {

            this.Name = Name;
            this.Age = Age;
            this.ID = ID;
        }
    }
}

and my Index View is
@model List<WebGridExample.Models.Student>
<!DOCTYPE html>

<title>Index</title>

@{

    var grid = new WebGrid(source:Model, canPage: true, rowsPerPage: 10);
    grid.Pager(WebGridPagerModes.NextPrevious);

}

Web Grid

@grid.GetHtml(tableStyle: ".webGrid", headerStyle: ".header", alternatingRowStyle: ".alt", columns: grid.Columns(grid.Column("Name"), grid.Column("ID"), grid.Column("Age")));

In this I am getting an error at this line
@grid.GetHtml(tableStyle: ".webGrid", headerStyle: ".header", alternatingRowStyle: ".alt", columns: grid.Columns(grid.Column("Name"), grid.Column("ID"), grid.Column("Age")));

saying that Name column does not exist as well as if i give only @grid.getHtml() then, it doesnt not display anything. Please someone tell me where i am going wrong.
Comment: see this http://pavanarya.wordpress.com/2012/07/04/displaying-data-in-a-grid-using-webgrid-in-cshtml/
Comment: Thanks Yasser. But unfortunately, I am getting blank screen when i run the app. Nothing is getting displayed.
Comment: update the code, if you are trying anything new, or are you still talking about the prev code ?
Answer: Update your student model to and this should work fine
namespace WebGridExample.Models
{
    public class Student
    {
        public string Name {set;get;}
        public string ID{set;get;}
        public string Age{set;get;}
    public Student() {

    }
    public Student(string Name,string ID,string Age) {

        this.Name = Name;
        this.Age = Age;
        this.ID = ID;
    }
}

}
Thanks,
pavan
pavanarya.wordpress.com
Answer: I got the same error.
I modified the Student class to remove the constructors and define getters/setters and it worked fine:
public class Student
{
    public string Name { get; set; }
    public string ID { get; set; }
    public string Age { get; set; }
}


Very Clogged Gutter Downspout

Question: After a new roof was put on my house recently, one of my downspouts ended up completely clogged.  Based on my attempts to unclog it (I have done this many times in the past at multiple paces on house when leaves, twigs, whatever occasionally block a downspout) my educated guess is that a chunk of the foam padding the roofers use for protection from the shingles as they are working ended up in it.  So typical poking, prodding, or heavy jet of water won't work; in fact I suspect I made situation worse by using these typical approaches before understanding the nature of the blockage.
The gutter is riveted on and painted tight so I cannot disassemble without destroying it.  I might/could be able to snake up from bottom, but don't really have faith that would work given the vertical rise and two ~90 angles involved.  If there was a way to work an articulating "clawing" device in from top entry hole I could start picking away at the blockage from above by pulling material back up and out, but I am not aware of any tool heavy-duty enough as well as having the 90 degree flex necessary.  I guess I could wait for it to get dry and pour some gasoline down and light it...lol.  j/k.
But seriously...any thoughts or suggestions?
Comment: Those rivets are pop rivets and a drill removes them quite easily without damage.
Comment: I find that using an air rake/leaf blower on the downspout lifts clogs up and out against the direction in which they got jammed. Once I had to duct-tape the spout and blower port together, but it made it rain down a ton of detritus. For organic clogs, try pouring a can of coke down the gutter; it will dissolve some of the non-organic solids and feed decomposers that will eat the clog, letting it pop free within a week or so.
Comment: Cheap video endoscopes are available online in lengths of at least 15 feet or so; I would get one to feed it in both ends and figure out exactly what the issue is. It's a fun tool to have afterwards, too.
Comment: @dandavis: you mean use leaf blower at bottom to push stuff out the top, right?  I'll try anyway, but as mentioned this is not your typical leaf-n-twig clog.
Comment: @crip659: Thanks, I didn't realize that so I'll keep in mind, but for a few reasons this would really be a last resort option for me.  I am really hoping for something more "plug-n-play" :--)
Comment: I think that foam would likely completely seal it, which actually makes it a good candidate for reverse pressure. Maybe try a big noisy compressor and lots of duct tape if the air rake fails. You can find the vertical position of the clog with a fishing reel/sinker (w/o bobber), and then you might be able to poke it free with a stick, tape measure, fish tape, etc.
Answer: If it is not your typical leaf-n-twig clog, as you suspect.
Stronger methods are needed to unclog it.
Depending on the length get a 10, 20, or 30 foot drain snake and clear the clog
Comment: But using a fish tape (or other flexible long item) would be good to try and narrow down where the blockage is to better know whether it's better to come at it from the top or bottom with a drain snake.  Or, if it's really blocked and holding water well, fill it with water and tap on the downspout with your knuckles to identify by sound where it's water-filled vs empty.
Comment: A nice feature of a drain snake, as opposed to something comparable like a fish tape, is that the snake has a "screw" at its tip which can be wound into the obstructing object.

Very Clogged Gutter Downspout


OpenCart SQL request and display on product template page

Question: I am trying to access an id a table to display on the product page on OpenCart 220.127.116.11.
I am trying to access an id from a table and then bring it into the product page and display it on the variant options on the drop-down.
I run the SQL for one product and get the id 21. so for debugging reasons I add the two variables (product_id and option_id) manually so those arent causing an issue. Below is a screenshot of the sql query working

So it returns with the number 21. Obviously when I change the sql to be the product_id and option_id for each product it will return the relevant id.
I have this setup:
catalog/model/catalog/product.php
public function getOtpOptionId($product_id)
{
    $otp_option_query = $this->db->query("SELECT id from oc_otp_option_value where product_id = 62 AND parent_option_value_id = 20");
    $otp_option = $otp_option_query->row;
    return $otp_option;
}

catalog/controller/product/product.php
below
foreach ($option['product_option_value'] as $option_value) {

I add
$data['otp_option_id'] = $this->model_catalog_product->getOtpOptionId($this->request->get['product_id']);

catalog/theme/*/template/product/product.tpl
I change:
<option value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?></option>

to be
<option value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?> (<?php echo $data['otp_option_id']; ?>)</option>

I would expect it to show all the options in the drop-down with (21)
for example:
red (21)
blue (21)
Green (21)
It just shows each option with no number and only the ().
What am I doing wrong?
Thanks in advance
/******* UPDATE *******/
So I have changed the code in the model to pick up the id of each option rather than using numbers
    public function getOtpOptionId($product_id, $option_value_id)
{
    $otp_option_query = $this->db->query("SELECT id from oc_otp_option_value where product_id = '" . (int)$product_id . "' AND parent_option_value_id = '" . (int)$option_value_id . "'");
    $otp_option = $otp_option_query->row;
    return $otp_option;
}

Answer: If you do not want to use this code inside foreach loop later:
$data['otp_option_id'] = $this->model_catalog_product->getOtpOptionId($this->request->get['product_id']);

you should not put it inside the loop, you can place it after this code, that is outside the loop:
$data['options'] = array();

And in your view file, instead of:
<option value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?> (<?php echo $data['otp_option_id']; ?>)</option>

Use:
<option value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?> (<?php echo $otp_option_id; ?>)</option>

Comment: Thanks for this.It works! @DigitCart. however I need it in the loop as it will have a different product_id for each product. Can I do this?
Comment: You can see the code that I have changed above under /* UPDATE */ thanks
Comment: You're welcome. So you can use it inside loop. If my post solved your issue please mark it as accepted. Thanks
Comment: When I put it inside the loop it stops working. Any ideas?
Comment: do you know why it doesn't work when I have a variable in the loop. for example if I even put $data['otp_option_id'] = "yes"; it doesn't show the word yes?
Comment: Do you know how I can make it work in the foreach loop?


When cutting nails with dremel, can sparks be dangerous?

Question: I'm preparing the ceiling in my basement for painting, which means cutting off a ton of nails from the flooring above. I started cutting using my Dremel with the reinforced cutting wheel, but it would shower sparks against the floor joists and ceiling. Are these sparks hot enough to be a fire danger? What are some alternatives?
Comment: "When cutting nails with dremel, can sparks be dangerous?" **Yes. They can get in your eyes**.  Alternative: A false ceiling.
Answer: Cutting metal with an abrasive disk will always cause sparks, but they are so small that each spark (which is actually a very hot piece of abrasive or metal) doesn't contain much energy.  They typically can't burn your skin unless you concentrate them in one spot, and will not burn wood or other materials.
If you happen to have a gas can or oily rags or other highly flammable material, you should be careful but typical building materials shouldn't cause a concern.  Wear a hat to protect your hair (it can singe) and a face mask or good fitting safety glasses to protect your eyes.
The alternative would be to use something like a reciprocating saw with a metal cutting blade (basically a powered hack-saw).  This would probably put too much force on the nails and might cause them to loosen or even rise slightly.  It's also a heavier tool and would be harder to use.
Comment: It's got a bad word in it, but the point is the same: [Just be careful where those sparks land](https://external-preview.redd.it/e2EfvdaIw17H2fkzZMNuUjjHO9eR3AmT8SiPP_MdFys.jpg?auto=webp&s=b97fa76d4a1efa982b621172432c13a109a04d57)
Answer: The experience doing restoration work is hang around for a few hours after you are done to see if anything starts to catch.
The usual fail is this: people are grinding til 30 minutes before quitting time, clean up, walk the shop one last time, all good... go to dinner, and on the way back from dinner they see the shop in flames.  Fire Dept. confirms it started in the grinding/cutting area. That's because it smoldered for an hour or two before it caught in earnest.  The cure is having a 1:30pm cutoff for grinding and hot work.
Just pointing out, this strategy will let you use a bigger cutoff wheel than a Dremel. That way you're going through them in 2 seconds instead of 2 discs :)
Comment: @RobertMoody sounds like that comment applies to the question moreso than my answer..


PureBasic - how can i simulate pressing F1 or F2 keyboard button?

Question: From Linux i am trying to make a small executable file for Windows 7/8 and Mac.
with PureBasic language.
How can i press F1 or F2 keyboard button using PureBasic?
I tried following but getting a linker error.

<code>If OpenWindow(0, #PB_Ignore, #PB_Ignore, 200, 200, "Shortcut test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

   AddKeyboardShortcut(0, #PB_Shortcut_Apps,101);      (=) - somewhere near the Space key
   AddKeyboardShortcut(0, #PB_Shortcut_Clear,102)
   AddKeyboardShortcut(0, #PB_Shortcut_Command,103)
   AddKeyboardShortcut(0, #PB_Shortcut_Execute,104)
   AddKeyboardShortcut(0, #PB_Shortcut_Help,105)
   AddKeyboardShortcut(0, #PB_Shortcut_Menu,106)
   ;AddKeyboardShortcut(0, #PB_Shortcut_Next,107)
   AddKeyboardShortcut(0, #PB_Shortcut_Pause,108);      Pause - should be beside F12 or so
   AddKeyboardShortcut(0, #PB_Shortcut_Print,109)
   ;AddKeyboardShortcut(0, #PB_Shortcut_Prior,110)
   AddKeyboardShortcut(0, #PB_Shortcut_Scroll,111);      ScrollLock
   AddKeyboardShortcut(0, #PB_Shortcut_Select,112)
   AddKeyboardShortcut(0, #PB_Shortcut_Separator,113)
   AddKeyboardShortcut(0, #PB_Shortcut_Snapshot,114)

   Repeat
      Select WaitWindowEvent()
      Case #PB_Event_Menu
         z=EventMenu()
         If z>99 And z<115
            Debug "Found key for the event #"+Str(z)
         EndIf
      Case #PB_Event_CloseWindow
         Break
      EndSelect
   ForEver

EndIf
</code>
Answer: Under Windows you can post following messages:
<code>    PostMessage(hWnd, WM_KEYDOWN, VK_F1, 0);
    PostMessage(hWnd, WM_KEYUP, VK_F1, 0);
</code>
So you should find in your language, a way to PostMessage to your window. There are other Win API functions like: keybd_event, SendInput look here for more info:
http://www.codeproject.com/Articles/2334/Toggling-the-Num-Lock-Caps-Lock-an-Scroll-Lock-ke
I know nothing about PureBasic but after quick googling I was able to find forum where something similar is being done:
http://www.purebasic.fr/english/viewtopic.php?f=13&t=47321


Unable to import a package that seems to have been installed

Question: I am trying to work with the TimeSynth Python package in my Conda environment. It is not available on the pkgs list or conda-forge list of Conda-supported packages, so I found this post that seems to get around the issue by installing the package in the Conda environment using pip.
I followed the instructions in the accepted answer, however when I do the last step:
.conda/envs/tcl/bin/pip install timesynth

(tcl is the name of my environment)
It says the requirement is already satisfied:

Requirement already satisfied: timesynth in
./.conda/envs/tcl/lib/python3.6/site-packages (0.2.4)
Requirement already satisfied: scipy in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (1.4.1)
Requirement already satisfied: jitcxde-common==1.4.1 in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (1.4.1)
Requirement already satisfied: numpy in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth)
(1.18.1)
Requirement already satisfied: sympy in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (1.8)
Requirement already satisfied: symengine==0.4 in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (0.4.0)
Requirement already satisfied: jitcdde==1.4 in
./.conda/envs/tcl/lib/python3.6/site-packages (from timesynth) (1.4.0)
Requirement already satisfied: jinja2 in
./.conda/envs/tcl/lib/python3.6/site-packages (from
jitcxde-common==1.4.1->timesynth) (3.0.0a1)
Requirement already satisfied: setuptools in
./.local/lib/python3.6/site-packages (from
jitcxde-common==1.4.1->timesynth) (56.2.0)
Requirement already satisfied: MarkupSafe>=1.1 in
./.conda/envs/tcl/lib/python3.6/site-packages (from
jinja2->jitcxde-common==1.4.1->timesynth) (2.0.0)
Requirement already satisfied: mpmath>=0.19 in
./.conda/envs/tcl/lib/python3.6/site-packages (from sympy->timesynth)
(1.2.1)

However when I run a Python script that imports timesynth, it doesn't recognize the module. Any advice?
EDIT:
Per request, here is the start of the file I'm trying to use timesynth in:
import numpy as np
import TimeSynth.timesynth as ts
import matplotlib.pyplot as plt
import seaborn as sns; sns.set()

And the error cites line 2 and states:

ModuleNotFoundError: No module named 'TimeSynth'
Comment: Please add commands and output to your question. Though it seems trivial, we don't know for sure your import statement is correct or whether you properly activated the environment.
Comment: Seeing the import, looks like a typo. Should be `import timesynth as ts`, at least that's how [the library's example imports](https://github.com/TimeSynth/TimeSynth/blob/master/TimeSynthExamples.ipynb).
Comment: have you tried to run a pip3 install of the module?
Comment: @smitty_werbenjagermanjensen I just tried that, and it said the requirements were already satisfied.
Comment: Maybe you are not running the "good" python... Try to run with .conda/envs/tcl/bin/python
Comment: @Addison i think you should look at merv's answer
Comment: Sorry for the delay, yes @merv was correct!
Answer: Following the TimeSynth library's example, the import statement of OP
import TimeSynth.timesynth as ts

should instead be
import timesynth as ts


CSS floating issue being pushed to new line

Question: Please see my jsfiddle example below.
Can anyone figure out what I am doing wrong here?
I am attempting to use a third party plugin called Smart Wizard it all works except for this one aspect as shown in the jsfiddle.
The [X] is on a new line, it should be directly to the right of the error message.
http://jsfiddle.net/jamesjw007/4wJv4/1/
Answer: just add
<code>.content { width: 90%; float: left; }
</code>
example fiddle: http://jsfiddle.net/4wJv4/9/ - Adjust the width of content element as you prefer
Answer: Try adding this to the Stylesheet..
It worked..
<code>.swMain .msgBox .close {
    float: left;
}
</code>
You have to float all the elements to
the Left in the same  tag to get the
elements to be in One line.
Just the "float" will do..
Answer: You need to float the content div as well as the close icon. In addition to this, you might want to float the close button to the right of the message box as opposed to immediately after  the text.
<code>.swMain .msgBox .content { float:left; width:auto; }
.swMain .msgBox .close { float: right; }
</code>
I've updated your fiddle with these changes - http://jsfiddle.net/4wJv4/19/


Why $z=0$ is a removable singularity of $\frac{iz-e^{iz}+1-\frac{z^2}{2}}{z^3}$?

Question: Why $z=0$ is a removable singularity of $$\frac{iz-e^{iz}+1-\frac{z^2}{2}}{z^3}$$
I tried to show $\lim_{z\to 0}z\frac{iz-e^{iz}+1-\frac{z^2}{2}}{z^3}=\lim_{z\to 0}\frac{iz-e^{iz}+1-\frac{z^2}{2}}{z^2}=0$, however, I cannot see why this limit is $0$?
Could anyone kindly help? Thank you!
Answer: Series solution ...
$$
e^{iz} = 1 + iz +\frac{(iz)^2}{2}+\frac{(iz)^3}{6}+o(z^3)
$$
Can you go from here?
Answer: $e^{iz} = 1+iz-{1 \over 2!} z^2 - i {1 \over 3!} z^3 + \sum_{k=4}^\infty {1 \over k!} (iz)^k$.
Let $g(z) = - i {1 \over 3!} + \sum_{k=4}^\infty {1 \over k!} (iz)^{k-3}$
and note that $g$ is entire.
Note that ${e^{iz} - 1-iz+{1 \over 2!} z^2 \over z^3} = g(z) $ for $z \neq 0$.


How to change formatting of timestamp using ctime?

Question: I am new to C, and trying to figure out how to generate timestamps from the system time and use that timestamp to name a file. So far, I've had success with this:
#include <stdio.h>
#include <time.h>

int main(void)
{
    time_t rawtime;
    time(&rawtime);

    printf("%s",ctime(&rawtime));

    return 0;
}

And the output is correct.
Wed Apr 12 14:51:03 2023

Now, my question is how can I change the formatting of this timestamp to something more file-name friendly such as
MM_DD_YY_HH_M_S

Comment: Behold: [`strftime`](https://en.cppreference.com/w/c/chrono/strftime).
Comment: It's daunting for a reason, as there are many subtle differences between the various formatting choices, like 12h or 24h, but there are *innumerable* examples out there as this tool has been around for a long, long time. It's worth noting there are examples even on the `man strftime` documentation.
Comment: You want [`strftime`](https://linux.die.net/man/3/strftime)
Comment: @tadman thank you for this! could you give an example on using this? the example in the link is...daunting.
Answer:
How to change formatting of timestamp using ctime?

Standard library function ctime() does not provide for format changes.

Instead, use gmtime() (or localtime()) and strftime().
struct tm *tm = localtime(&rawtime);
if (tm) {
  #define TIME_STRING_SIZE 100
  // MM_DD_YY_HH_MM_SS
  #define TM_FMT "%m_%d_%y_%H_%M_%S"
  char time_string[TIME_STRING_SIZE];
  size_t size = strftime(time_string, sizeof time_string, TM_FMT, tm);
  if (size > 0) {
    printf("%s\n", time_string);
  }
}

Using local time risks generating the same MM_DD_YY_HH_MM_SS for 2 differed times on the 25-hour day the local time zone goes from daylight savings time to standard time.

I'd recommend using universal time, not local time, and follow ISO8601 like format: year-month-day
struct tm *tm = gmtime(&rawtime);
if (tm) {
  #define TIME_STRING_SIZE 100
  // YYYY_MM_DD_HH_MM_SS
  #define TM_FMT "%Y_%m_%d_%H_%M_%S"
  char time_string[TIME_STRING_SIZE];
  size_t size = strftime(time_string, sizeof time_string, TM_FMT, tm);
  if (size > 0) {
    printf("%s\n", time_string);
  }
}


convert to string to json

Question: I have a hash map and i was added 2 values into that map. After that i want to convert to json, but it is showing as string after converting json using jackson.
below is my code :
Map<String, Map<String, String>> attributes = new HashMap<String, Map<String, String>>();
Map<String, String> values = new HashMap<String, String>();
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("type", test.getType().toString());
metadata.put("id", test.getId());
String metadataStr = metadata.toString();
String replaceStr = metadataStr.replace("=", ":");
values.put("metadata", replaceStr);
attributes.put("caption", values);

Here I am converting attributes to json like below :
String json = this.getObjectMapper().writeValueAsString(attributes);

{
  "Test": {
    "metadata": "{id:f600b8fa-77cf-4225-ba42-39135909c7ce, type:test}",
   }
}

But i need like below :
{
  "Test": {
    "metadata": {
               "id":"f600b8fa-77cf-4225-ba42-39135909c7ce",
                "type":"test" }
   }
}

Can any one help me out this.
Thanks in Advance.
Comment: I would strongly recommend creating objects instead of placing strings in a hashmap, this way you have more (and easier) control over how you want your json to look
Comment: I totally agree with Laurens on this. You have an object, create a string from it, `"{id:f600b8fa-77cf-4225-ba42-39135909c7ce, type:test}"` since you need to replace a character, then put the string back into an object and JSON the object with the string still included. No where is the string taken back to an object. It would be better to do the "=" to ":" conversion before assigning them to objects.
Comment: can you please share any sample code?
Answer: The root of cause is in type of values and this line:
values.put("metadata", replaceStr);

Need to have:
Map<String, Map<String, Map<String, String>>> attributes = new HashMap<String, Map<String, Map<String, String>>>();
Map<String, Map<String, String>> values = new HashMap<String, Map<String, String>>();
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("type", test.getType().toString());
metadata.put("id", test.getId());
values.put("metadata", metadata);
attributes.put("caption", values);

convert to string to json


Mount Heavy TV onto re-patched drywall

Question: My contractor just installed our new 65 inch TV into our wall. The problem is it's about one inch too high. There are now 9 holes drilled into the wall, and only 2 holes is into wood. The rest is with plastic anchors into drywall. Would it be safe to remove these screws, patch the holes with wood filler, and remount the TV one inch below? The TV weighs 65 pounds and uses Samsung's no gap wall mount.
Comment: Why is the 3/4"  so important that you need to re-position it?
Comment: most wall mounts provide several holes to allow for finer adjustment than just keep drilling holes in the wall. Well, for the ones I bought anyway.
Comment: @user4202 It still might be worth reconsidering your expectations. If you are sitting a reasonable distance away from a 65" tv, even a few inches shouldn't matter. The general recommendation I have seen and used is to have the center of the tv at roughly 5 ft off the ground. This is above eye level for most people while seated and your eyes look up without having to crane your neck. No one in my family has ever complained of neck pain to date.
Comment: If the contractor didn't put the mount where it was specified to go, can you get the contractor back to do the job correctly? Have him repair the drywall and remount - get what you paid for.
Comment: 9 holes seem...excessive. Especially with there only being 2 into studs on a 65 inch TV. Are your studs spaced 16" oc?
Comment: @SolarMike all mounts I've seen allow slight lateral adjustment, but not vertical adjustment
Comment: @mmathis the mount I have on the back of my tv has 3 vertical positions for the tv on it, so I planned to use the middle set and if my measurements were adrift or I wanted change I can move up or down by about an inch either way. Perhaps my mount was cheaper, or more expensive, who knows... And as for lateral adjustment it has a swivel arm so quite a bit there.
Comment: With a 65" only 2 lags hit studs , ? , wow   I would be making contact with more studs if your contact is only 2 screws at 1 end I would expect that to be sketchy when you have to tilt it to plug in new; Disk player,  cable  box ,video game console, or whatever.  If the contact is in the center it will probably be ok  but 9 and only 2 hit?
Comment: @FreeMan The contractor said it would be a lot of work to reposition it. I think he is referring to the work required to patch up the existing holes in a way that maintains the strength of the wall.
Comment: @mmathis The 2 studs are near the center and are vertically aligned.
Comment: @AlaskaMan I've edited the original post to one inch. The TV is positioned higher than eye level (due to furniture) and an additional inch would cause additional neck strain when watching.
Comment: The contractor's job is to do what he was contracted to do. If he did it wrong the first time round, then he should be on the hook to do however much work is necessary to make it right, whether it's "a quick fix" or "a whole lot of work".
Comment: Would you come on back to give a check-mark to the answer that helped you the most, or to write up (and check-mark) what you ended up doing to fix this? We'd all like to know...
Answer: If there are two lag screws into studs near the top and these are far apart and other screws (7?) into drywall, then the TV sould be safely supported. I have not installed one of these. Does the mount extend from the wall and so exert pullout force on the fasteners?
Comment: The 2 studs are near the center and are vertically aligned. The TV uses the Samsung no gap wall mount. It does not extend from the wall and is nearly flush against it.
Comment: From your description this TV bracket is very well supported. I really don't  think it needs to be repositioned.
Answer: Yes you should be able to move it. If the screw pattern is regular you may be able to get away with a few extra holes and be able to reuse some of the original holes.
One warning - Do not use wood filler to patch holes. It will not adhere correctly to drywall and not look good. Use a premixed joint compound if you want ease of use. For example: this one
Use a suitable drywall anchor for the screws. Here is one that can hang 75lb each. Home Depot
Comment: @user4202 I think you're correct to worry about new holes that close to existing holes in the drywall even with the proper wall anchors - it's a matter of the drywall giving way, not the anchor giving up. Are there more spots in the the mount that you can use to get lag bolts into studs instead of just drywall? Did you see the comment on the OP - are there adjustments available on the mount to move the TV without remounting it? Some come with slots so you can move the mount without making new holes.
Comment: I love those drywall anchors and use them quite often but they need good unbroken drywall to provide full strength with damaged material I would not trust them even at 1/2 the load and remember this will not be tight to the wall so there are lateral forces not just weight to think about.
Comment: I heard that wood filler was stronger to patch drywall screw holes. My main concern is the drywall would be weakened from the 9 previous holes 3/4 of an inch away from the new ones. The TV is heavy at 65 pounds and only has wood on 2 holes.
Comment: The drywall will likely be ok. If you use the right type of anchor and screw each screw should be able to hold up to 75lb. I will add a link to my answer. And use larger screws for two going into wood. If for some reason the drywall will give in you can replace a section of drywall going from stud to stud relatively easily. That would also allow you to install blocking (a cross beam of wood between the studs) where you need to hang the tv.
Comment: @FreeMan Samsung's no gap wall mount is pretty limited in adjustments. I added the link to the original post. What is the best way to patch the drywall to mount the TV one inch below the current holes?
Comment: Why do you want to mount it one inch lower?

Mount Heavy TV onto re-patched drywall


Why isn't overload resolution picking the std::vector overload of my template function?

Question: In the following code, I want it to use the std::vector version of f() if I call it with a std::vector argument, but it's using the first one and complaining that std::to_string(const std::vector<T>&) doesn't exist. My understanding of template overload resolution is that it should use the "more specialized" version. Somehow I think that doesn't apply here, because this is a function overload rather than a template overload. But it's not even using the normal function overload resultion rules, or else it would complain about an ambiguous call to f().
#include <vector>
#include <string>

template<typename T>
std::string f(T&& member) {
    return std::to_string(member);
}

template<typename T>
std::string f(const std::vector<T>& member) {
    return std::to_string(member[0]);
}

int main() {
    int a = 42;
    printf("%s\n", f(a).c_str()); // OK

    std::vector<int> b = { 42 };
    printf("%s\n", f(b).c_str()); // ERROR: to_string doesn't have a std::vector overload

    return 0;
}

What am I doing wrong?
Comment: Overload resolution would prefer to not add cv-qualification if it doesn't have to.
Answer: The type deduced by the forwarding reference is std::vector<int>&, as opposed to the const std::vector<int>& of the other overload. So when comparing the overloads, your non-const argument is a better match for the non-const qualified reference parameter, and so that one is chosen.
One way to address it is to account for both const qualifications with the help of another overload.
template<typename T>
std::string f(std::vector<T>& member) {
    return f(std::as_const(member));
}

Here we obtain a const reference to member with the help of std::as_const and delegate to your original overload. You may want to provide an rvalue specific overload too, since the forwarding reference will deduce a better match for those as well when compared to your vector overloads.


VB.NET - Downloading File From Webpage

Question: I am trying to download the latest Kodi ARM build for Android from http://Kodi.tv/download and save it to a pre-existing folder on my computer. I just want to click a button and it will download that file to where it needs to be. The current code that I am using is opening up an IE browser and giving the dialogue;

Open, Save, Save As..

Here is the current code that I am using:
For Each Element As HtmlElement In WebBrowser1.document.GetElementsByTagName("a")
        If Element.OuterHtml.Contains("ARM") Then
            Element.InvokeMember("click")
           End If
    Next

This is grabbing the button off of the Webbrowser that I have on the form and clicking it. I also can not use a static link as I want to get the latest updates [link changes].
How can I download the item I need from the web page to a predesignated folder with no dialogues?
Comment: What is your question?
Comment: How can i download the item i need from the webpage to a predesignated folder with no dialogues.
Answer: I found this code online and it works great so i thought i would share it!
 Dim Address As String = String.Empty
    Dim filename As String = String.Empty
    Try
        Dim fileReader As New WebClient()
        Address = " *Link* "
        filename = " *Filename of what you want to save as* "
        If Not (System.IO.File.Exists(" *Download Location* " + filename)) Then
            fileReader.DownloadFile(Address, " *Download Location* " + filename)
        End If
    Catch ex As HttpListenerException
        Console.WriteLine("Error accessing " + Address + " - " + ex.Message)
    Catch ex As Exception
        Console.WriteLine("Error accessing " + Address + " - " + ex.Message)
    End Try
    MsgBox("Done")
End Sub

Found here: Here
Answer: Try looking at the .NET WebClient class.  It has very convenient methods like DownloadFile, which take a URL to download, and a location to save.
Because the URL is constantly changing, you will likely need to still use the web browser to determine what the current URL is.  Once you have this, you can dispose of your web browser and pass the URL to DownloadFile.  There's even events to monitor download progress and completion, DownloadProgressChanged and DownloadFileCompleted. If you intend on using these, ensure that you use the async version, DownloadFileAsync.
Comment: Thanks for the quick reply! I have looked into the web client and this does make everything a lot easier! Thanks! But where i am stuck is getting the URL address from the webpages button.
Comment: You could use a regular expression to find just that URL, but there is likely a way to do it using the WebBrowser class alone.

VB.NET - Downloading File From Webpage


Java Input mismatch exception basic

Question: This is the program that I ran. After running this I came across the error message that I also posted but I don't know what I did wrong! Please help!
This is the error message that came up
Comment: Please always include your code, comments, and pictures within your post so that users aren't forced to leave the site to answer your question.
Comment: It restricted me from doing so b/c I'm a new member
Comment: You can put in code.
Answer: This is because you are likely entering in "JPY 10000", and since the "JPY" part is a String rather than a double, if you try to store it in your double JPY it will result in a type mismatch error.
Please double check if the requirement is only to enter "10000", or the whole "JPY 100000" thing. If it is to enter the whole thing, try the code below:
String[] jpy = stdin.nextLine().split(" "); // split the input with a space
double JPY = Double.parseDouble(jpy[1]); // parse the second part of input as double

String[] eur = stdin.nextLine().split(" ");
double EUR= Double.parseDouble(eur[1]);
// and so on...

double USD = JPY/100) + EUR/0.9 + ...;

This code is vulnerable and you should really check for malformed inputs. But it is the general idea of how you should approach this.
Comment: I am just supposed to make the program so that any input value can be placed in the "10000" thing is just an example of what the computer can enter
Comment: yes it says its missing a symbol in the .split(" "); part
Comment: Problem.java:17: error: cannot find symbol
    String[] jpy = stdin.nextLine().split();
                   ^
  symbol:   variable stdin
  location: class Problem
Problem.java:20: error: cannot find symbol
String[] eur = stdin.nextLine().split();
               ^
  symbol:   variable stdin
  location: class Problem
Problem.java:22: error: cannot find symbol
String[] cad = stdin.nextLine().split();
               ^
  symbol:   variable stdin
  location: class Problem
Problem.java:24: error: cannot find symbol
Comment: You need to include `" "` in `split()`, it should be `split(" ");` not `split();`
Comment: It's complaining about `stdin` missing. Where did you declare `stdin`? Can you post the entire code?

Java Input mismatch exception basic


Problems with crossed hot & cold water lines on shower

Question: My contractor installed a brand new Grohe universal rough-in box, and a Grohe universal pressure balance rough-in valve with diverter. Right after the rough-in box was installed, and before everything else was done, we started experiencing low temperature of the water in the entire house. In addition, cold water will sometimes flow from the hot taps.
We first thought that it was a problem with the water heater and had it inspected. The water heater guy wrote that there is no problem with the water heater, but that hot and cold pipes were crossed somehow and that that needs to be fixed.
My contractor then went and closed the pass thru valve in the rough-in box and explained that the pressure of the cold water was so strong that the cold water was passing though this valve and making its way back into our hot water supply. Closing the valve seems to have resolved the problem with cold water coming out of the hot taps in the rest of the house.
However, when the shower installation was complete with pbv, diverter and the trim, I notice that the trim dial is switched: that cold water is coming from the hot water indicator, and vise versa. I also noticed a significant reduction in pressure of the main shower head in comparison to my original 20 year old shower head that was replaced. Furthermore, I see that if the trim handle is set to the limit of 'Cold', which displays as 'Hot', the water barely drips. On the other hand, if it is set all the way to 'Hot', which displays as 'Cold', there is strong pressure. This does not make sense to me, as I believe the cold water should have the strongest pressure.
So my questions are:

Does this mean that there is a cross connection between the hot and cold pipes?
If that is the case, what kind of problems will it cause?
Is my low pressure related to this crossover?
Should I make the contractor to open the walls and re-connect the pipes to the correct hot and cold connections, or it is ok to leave it as is and go with his suggestion of adjusting the cartridge and just changing the trim to point to the right way?
Comment: Remove the flow restrictor in your new shower head to get some pressure back. I do that for every shower head I install.
Comment: Some showerheads have thermal limiters for anti-scald   If hot and cold are reversed, thet feature and possibly more won't work.  I'd get a manual off the web. Oh, and a common feature of Victorians is a discreet door that lets you access the shower valve from the back, bookcase with false back, etc., highly recommended.
Comment: ... Yeah, the place I grew up in had those access panels. If my place ever needs work I'll have to add them.
Comment: Concerning the pressure, with the taps closed (no water flow) the hot water will have a higher pressure because the boiler heats up the water causing it to expand. The boiler will have a check valve that prevents the water from flowing back into the cold supply, and a pressure relief valve to prevent disaster. However, when the tap is open and water is flowing, the hot water pressure will usually drop lower than the cold water pressure due to the longer path and extra resistance (through the heat exchange, etc..)
Answer: Demand the manufacturer's instructions so you can review them. Then respectfully insist that the plumber (who you paid to install it correctly) return and make all needed corrections. It's not right for the plumber to expect you to do anything unless you agreed to up front.
He should be correcting the piping if necessary, he should be adjusting the temperature stops, he should be adjusting the cartridge, he should be ensuring the trim is oriented correctly.
Comment: You should not expect the same type of water flow from a modern shower head compared to one from 20 years ago. Most modern heads have "water saving" restrictions, causing you to spend twice as long in the shower and actually using *more* water.
Answer: to your points:
1)  no - it doesn't mean they are crossed.  it is almost impossible to make a cross connection unintentionally.  this is so unlikely its almost a guaranteed impossibility.
2)  wont harm anything
3)  low pressure is probably unrelated, but could be a result of contamination introduced into the pipes when the work was done (solder debris probably gunking something up in the system)
4)  without knowing the specific valves, i can say that almost every shower mixing valve can be simply flipped.  you just remove the locking collar, remove the valve core, rotate 180 degrees and then reinsert it and then the locking collar.  its usually a pretty simple fix so if you want it done, just get him to correct it.  if it means tearing everything out, i wouldnt bother.
you could have a faulty valve.  if the above doesnt help or solve the problem.  just turn off the shutoffs to the shower, have him remvove the valve core and return it for inspection and/or replacement.


ASP.NET MVC3/Razor C# two sides/interfaces web application

Question: I am building ASP.NET MVC3/Razor C# and I need two sides/interface base web aplication, that means I need this:
Admin side, where I will add Clients, and Client side, when client can log in and manage something too. Urls should look like these:
www/Client/ClientId/Controller/Action/Id
www/Admin/Controller/Action/Id
And I want something like this: controllers which belongs to Admin have in direcotry Controllers/Admin, and controllers which belongs to client have in directory Controllers/Client. The same with Views: Views/Admin, Views/Client. Problem is when I have url www/Client/Project and www/Admin/Project, and both are taking the same controller, which is not what I want.
So please help me to solve this, design best structure. Thank you
Answer: You should probably just create a separate website for each of the Admin and Client sites.  It's much cleaner that way.  If you have any code you want to share between the projects just make a business layer dll that has the shared code you need.
Answer: You can organise your site into separate sections using areas:
http://msdn.microsoft.com/en-us/library/ee671793.aspx
If they are completely separate then it's probably cleaner just to create them as separate MVC applications, with common code in a business layer. However using areas will let you link between the two sections easier (for example, if you wanted to display "edit" links next to data in the client section).
Comment: Another question. Where is the best place to test, if Client exists in my db? I mean if the given clientId in urls: Client/{ClientId} exists?


How many participants for a survey when you don't know the total population?

Question: I have been using a sample size calculator to know how many participants I should have to have a sample and results that are representative for my total population. But what if we don't know the total population? how do you calculate your sample?
Thanks in advance,
Answer: About 400 people. Sample size is more influenced by your confidence level and margin of error than the population size.
If your confidence level is 95% and your margin for error ±5% your sample size is 370 for a population of 10,000 or 384 for a population of 1,000,000. But from 1 million on up to 10 billion, the sample size only increases by 1.
But for a population of a reasonably large size (say 1 million), your sample size needs to be between 68 (90% confidence, 10% margin) and 16,307 (99% confidence, 1% margin).
Some calculators (like this one) will let you omit the population size.
You can also go for the largest sample size you can get, and then work backwards to see how confident you can be in the results. Maybe you can only get 100 responses, but if they all agree, that might be enough.
Answer: Good answer by Nathan and 400 is a safe sample size in survey-based social science studies. Another aspect to consider is the type of analysis and tools used for those analyses. For example, if the analysis involves exploratory factor analysis (EFA) using SPSS and confirmatory factor analysis (CFA) using AMOS, a minimum sample size of around 300 is the minimum, and a larger sample size would result in better estimates/loadings (Netemeyer et al. 2003, p.116).
If the estimates involve partial lease square (PLS) based analysis, such as using SmartPLS, a much lower sample size would work; see this forum post about '10 times rule'. For example, if a study involves survey data from marketing professors at top universities in Australia, the sample size would be very small for practical reasons. In that case, a method/tool that produces reliable estimates with lower sample size, such as SmartPLS, needs to be considered.
A study can involve different types of analysis using multiple data sets, and the sample size would vary. For example, if the study involves multi-group analysis, each group needs to have a sufficient sample size. A good example of different sample sizes for different studies in the same research project is available in this article.
Overall, the types of analysis necessary for a study, the nature/availability of the respondents, and the expected/required confidence level should be considered when setting the sample size.
Answer: There are two sides to this discussion -

sample size. This is something that Nathan and Syed have covered adequately.

sample selection. This is something that's actually more important.

Suppose you are doing this for a consumer product. Different possible user groups might be college kids, employed people, men with kids, women with kids,  retirees, etc., etc. You need to work this out based on the product in question.
These groups vary wildly in their purchasing power, interest level in different types of products/services, etc.
If you talk to 400 college kids only (low purchasing power, enough spare time, highly sociable, interested in fads and novelties), you might get a very very skewed perspective. And if this research were for a home mortgage product, your results would be summarily meaningless.
It is more beneficial to talk to 10 highly targeted/relevant users than to talk to 1000 random people - unless your subject of research is something extremely generic.
For many highly targeted groups, you probably will find it extremely hard to get to 400 users to talk to you. Sometimes these many users might not even exist. E.g. investment bank directors, governors of provinces, etc. If you are talking about a software product that solves a specific problem a group like this has, it might suffice to have meaningful conversations with 10-20 people in this group.


GFCI outlet keeps tripping

Question: We have a GFCI outlet in our kitchen that has been tripping pretty regularly (4+ times a day). We first noticed it when our fridge would go out.  (Breaker Box Circuit "A") We assumed the problem was the fridge. I unplugged it, dusted it and plugged it back it.  That did not solve the problem.  So we plugged it into another outlet in the kitchen using an extension cord. The GFCI continued to trip.
Also on the GFCI circuit is the computer in another room. (Breaker Box Circuit "B").  We took the computer off the outlet and plugged it into another.  Since then we haven't have any tripping issues.
We have had this setup for 4+ years and never had issues until about a month ago. I initially plan to replaced the GFCI outlet.
Unfortunately, I do not have  schematic diagram of the wiring.
My questions are as follows:

Why / How do the GFCI's cross breaker circuits?
Does the problem seem worse than a bad outlet?
Comment: There seem to be a few holes in your logic. How does "dusting" an appliance eliminate it as a fault suspect? Was the alternative outlet also protected by the GFCI? How can the same GFCI be on two separate breaker circuits? If eliminating the computer resolved the issue, why isn't it the suspect device?
Comment: Yeah, this sounds like denial of the form  "the X protective device tripped, surely my appliance can't have X problem, it must be the detector right?" We need to help test that definitively, by understanding which receptacles are protected by the tripping GFCI device (i.e. go out when it trips) and which are not, or which other circuits have GFCI devices and which *those* trip. And move this PC around to other GFCI circuits and see if it trips any other.
Comment: @isherwood - Thanks for pointing out that whole in my logic. It could very well be the computer.
Answer: Computers use a switching power supply so it is possible the GFCI has grown weak or sensitive with age and now sees the computer as a ground fault problem.
It is also possible the computer power supply is failing and is causing the tripping.
Try running everything but the computer on the circuit for a while and see what happens. If it trips again try replacing the receptacle with a new GFCI.
Good luck!

GFCI outlet keeps tripping


How to secure bonding lug to inside of 4x4 steel junction box?

Question: I'm running some 6 ga armored bare copper wire through the attic spaces as a "grounding bus" for retrofitting grounds to various 1960s-era 2-prong receptacles.  This will involve wire connections made with the 6 ga in a number of 4x4 steel junction boxes along the way in the attic, but I also want to properly bond the 6 ga to each metal junction box.
To do that, I plan to secure the 6 ga incoming wire end to a tinned lug as seen in the photo, and secure the lug to the junction box with a standard green 10-32 grounding screw and the box's pre-threaded hole for the same. The mounting hole in the lug is however 1/4 inch, so bonding connection will rely on the contact of the lug surfaces with box underneath and screw clamping from above. Is this sufficient? Kopr-shield will be used on the lug set screw and wire, and on the underneath of the lug where it contacts the box.
EDIT: @HABO The plan is to connect the end of the incoming ground wire to a lug attached to the box. Slightly upstream of that connection in the box, a split bolt would be used to connect the outgoing ground wire to the incoming wire. Any 10/12 ga EGC wire coming into the box would also be connected to the incoming ground wire via split bolt. I expect that a number of the boxes will have no EGC coming in at this point, being present for possible future use with other 2-prong outlet upgrades.
@blarg I did not find manufacturer (Southwire) provided instructions for lug mounting, but I have not made an exhaustive search. I have #6 bare armored ground wire and clamps/fittings on hand (100') and may need to add stove and/or dryer EGCs in the future, so this seemed straightforward to use.
Comment: Are there manufacturer provided instructions? The code requirement is to follow those. Is there a reason you are going with #6?
Comment: Will the armored bare cable terminate at each box or continue ("along the way") to subsequent boxes? If it will continue then you need to determine how you will connect the incoming, outgoing and pigtail wires in each (non-terminal) box. That also requires more space, in the  NEC  sense, since a connection is "larger" than a wire just passing through. The pigtail doesn't need to be 6ga.
Comment: @HABO Updated question with further explanation
Answer: Use a lug that's intended to accept the correct size screw
Instead of trying to hack things with a lug whose mounting hole is too big, I'd simply use a lug that has the correct size mounting hole in it.  The IHI S6-203 provides sufficient wire range for your application in the same style as the lugs you're already looking at, while the Burndy CL501TN is a copper-only lug but in a lay-in style that can speed installation.  If you want a dual-rated lay-in lug, your best option is the Ilsco GBL-4 but its hole is slightly fatter than necessary (more sized for a #12 than a #10 although Ilsco specifies it ofr the latter).
Comment: @Armand also, with the layin lugs, you can eliminate a lot of hassle by using a Garvin/Southwire GSST to screw them to the *outside* of the metal box then looping the wire through them.  of course, you can do things with a split bolt or T-tap connector and drop wire for boxes in walls and stuff, too
Comment: Thanks! I have found a cheap source of the Ilsco GBL-4DBT version, so I will use those for this. I assume the lugs with 1/4 inch hole can be used in the future with a 1/4 bolt, lock washer and nut, so I'll hold on to them for now.
Comment: @Armand yeah, one could do that provided the paint's scraped clean, I reckon


What is the best SQL field type to use for a Sqlite numeric

Question: I am loading data from a sqlite database into a ms SQL database.
The field type in the Sqlite is Numeric.
What is the best field type to use so that I don't loose any detail?
Answer: What is the underlying data representing?  Numeric in SQLite is a technically a column affinity and not a storage type.  Other databases do not have the concept of "column affinity", which is explained here.  In SQL Server, the types describe how the data is being stored.
The intention of a numeric column affinity is probably a fixed point numeric value.  In that case, decimal/numeric would be the right type in SQL Server.
Note that numeric can also apply to dates, datetime, and boolean values.  You would want to store these with the corresponding data types in SQL Server (probably date, datetime, or bit).
Answer: My understanding of SQLite is limited, but from what I'm reading here:  Datatypes in SQLite, the numeric affinity does not seem to actually tell you much about the data contained therein.
If that's the case, the best thing to do is to query the values to see what you're dealing with, then decide.  Odds are it will be a FLOAT or DECIMAL.
Answer: The best type to convert a NUMERIC column from SQLite to SQL Server is DECIMAL.
http://msdn.microsoft.com/en-us/library/ms187746.aspx


How far can I jump?

Question: Fairly frequently, I see a gap in Minecraft that I think I can make, so I go for it...and lose a couple hearts because I didn't.  How far can you jump horizontally (or horizontally + 1-3 blocks down), so I know if I'm bad or just ill-equipped (in game).
Comment: @Sadly Not - Falling damage was answered / discussed here: http://gaming.stackexchange.com/questions/10218/how-is-fall-damage-calculated-in-minecraft
Comment: If Minecraft uses the real gravity parabola then you can probably make it at most 7 blocks horizontally at a height difference that would almost kill you from falling damage.
Comment: Then you can put this into a nice 'will-I-die?' equation :)
Comment: We have a resident Minecraft code-diver (can't remember their name) that will probably sweep the floor once they find this question.
Answer: Read the long explanation of my answer below, but here is a chart that summarizes how big of a gap you can jump along with how far you must fall to make the jump and the damage you will take (without mitigation). You must make a full running jump for this chart to apply:
Gap Width (Blocks)  Blocks fallen below jump level  Damage taken from fall
2                   none                            none
3                   2½                              1
4                   7½                              3½
5                   14½                             7
6                   23½                             11½ (death)

So without falling damage mitigation you can make a jump over a gap that is at most 5 blocks wide, after falling about 14 blocks down from the point where you make a running jump.
I will test this in-game at a later time to make sure this is realistic.

So this answer only works given a number of assumptions hold.
First assumption, Minecraft models gravity using a parabolic equation of the form y = a(x - h)^2 + k, where x is the size of the gap you want to jump and y is the height difference you will be after clearing the gap (negative indicates you are below the point you jumped). a is a tunable parameter that describes the rate at which you will fall (related to the constant of gravity). k is the highest you can jump from the ground in Minecraft and h is the horizontal distance you will have cleared while jumping that high after running forward.
Second assumption, that k (the height you can jump from the ground) is 1½ blocks and h (the horizontal distance you will have cleared at that height) is 1 block.
Third assumption, that horizontal momentum is preserved. Basically this means that you will travel at the same speed horizontally throughout the jump.
These three assumptions give the equation y = -(x - 1)^2 + 1½.
So let's say you want to jump a gap that is 2 blocks wide. To see how far down you must fall before making that jump, plug x = 2 into the equation and you get y = ½. This corresponds with being able to safely jump a gap that is 2 blocks wide with a running jump, and you will reach a block on the other side of the gap while being a little higher than ground level.
Falling damage is calculated as (number of blocks fallen x ½) - 1½. So, let's say you want to jump a gap that is 5 blocks wide. Plug x = 5 into the equation and you get y = -14½. This means you will reach jump a gap that is 5 blocks wide after falling 14½ blocks and taking about 7 hearts of damage.
Sprinting Added
You can jump significantly further with sprinting; at least three blocks horizontally. This answer assumes no sprinting but I will try to update it ASAP.
Comment: Any information on sprinting available?
Comment: @Ids With sprinting you can make a 4 block jump.
Comment: So if this is framed in terms of how long a gap you can jump, the horizontal distance would be `gap (blocks) - player hitbox`?
Comment: I edited the equations and variables in your answer to make them a little easier to read; hope you don't mind @Sadly Not.
Comment: @Kevin Y: Not at all, I didn't know how to do in-line code blocks.
Comment: @Nick T: This is framed in terms of how wide of a gap you can jump in blocks. This considers the fact that you can jump from the back of your player hitbox and land on the front of your player hitbox. The distances are all 'safe', as in if you don't make the jump then probably no one could. I changed the answer to clarify it for you.
Comment: @Ids Not yet at higher heights but the one additional block rule seems pretty consistent regardless of height.
Comment: @Timtech AFAIK, sprinting in one direction actually gives you a cumulative speed boost, allowing you to clear a 5 block gap with enough run up. [See this video](https://www.youtube.com/watch?v=Qw5dyML-KJE)
Comment: @kkeey I don't think that video can be reproduced without creative because he used a command block to position himself exactly at the right coords to line up for that jump. But it's certainly possible to build enough momentum with headhitting (sprint-jumping with blocks above you) to do a 5-block jump. Check out youtube.com/watch?v=mkmSks-M3tc around 6:15 timestamp to see the explanation for your vid or a little earlier to see him do it legit but with headhitting.
Answer: I have done an experiment and these are my results:
Without sprinting, the farthest you can get is 3 blocks if the entire surface is flat. Or if you are jumping up, the max is 2 blocks in length, 1 block in height.
If you are sprinting, the farthest you can reach on a flat platform is 5 blocks in length, but if you are jumping up 1 block in height, the max length is 4 blocks.
Hope you enjoy this!
Comment: This is incorrect - for flat surfaces, sprinting = 4 and walking = 2.
Comment: It is possible to jump up to 8 blocks if you use ice, trapdoors and headhitting.
Comment: If you use more advanced techniques, you can jump up to 14 blocks. https://youtu.be/8MhJNEX-8hc
Answer: This hasn't been posted on in awhile, but here is my answer, coming from a person who pretty much only plays Minecraft Parkour:
3 block is not possible without sprinting, however 2 and up 1 is possible with no sprinting.
As for with sprinting, a 3 block onto a trapdoor 2 blocks higher (A 3 up 1.18750) is possible. And a 4 block with 8 layers of snow (4 up 0.8750) is said to be possible, however I can only do 7 (4 up 0.750). If you have HH (Headhitter, or 2 block ceiling) and 2 blocks of momentum, you can make a 5 block or 4 up 1.
Lastly, with speed II, it is possible to do a 5 block and a 4 up 1 if you have momentum.
And just one more thing, you jump 1.20 blocks high without jump boost.
Answer: I believe if you sprint then you can jump 5 bocks (On a flat surface)
and without sprinting, you can barely get 3
Comment: Welcome to the site! Normally we try to add these kinds of answers as comments to other answers. You will be able to do that if you have enough reputation. Next time try suggesting an edit not an answer. It is an easier way of getting reputation.
Comment: @lds: You make it sound like comments should be suggested as edits instead...
Comment: If you do not have enough rep to add comments, I think it should.
Comment: No, +4x and +1z (4 blocks forward and 1 over) is the max for a flat surface. +2x+1z without sprinting.
Answer: Something odd I have found is that you can jump a 3 block diagonal which should be equal to about 4.2 blocks. These seems to bring up the only viable reason being that the game registers the diagonal in Minecraft with a different formula then that of a non diagonal jump, or that the 4 blocks jumping forward is incorrect. I have not yet tested this with partially eaten sides of a cake however which is the easiest way to test the inbetween .5 jumps, or using cords. Lastly I would like to ask if this is a mechanic in the game intentionally designed where it will sort of give you the extra .2 blocks (app).
Answer: Almost infinite. Reason?  Give yourself speed 99999999. Using the /effect command.
In actual logic, You can jump 7 blocks without any use of effects, using packed ice, trapdoors, and head hits, to gain enough momentum.
Answer: You can make a flat 5 block jump.
I have made a 4x3 jump before in game with no ice/slime/HH/potions/vertical momentum ie a flat 4x3 jump. 4x3 means I am jumping diagonally from the corner of one block to the corner of another block which are 4 blocks of air apart in one direction and 3 blocks of air apart in the other. The gap between these corners is exactly 5 blocks.
I believe the explanation is that since the player has a 0.6x0.6 hit box, you can jump off a block with some of your hit box hanging over the edge of the take-off block and land with only part of your hit box on the landing block. So, the actual distance the player moves is less than 5 blocks.
Despite this, since the distance between the corners of a 4x3 jump is exactly the same as the distance between the edges of a straight 5 block gap, in my opinion, this counts as a 5 block jump.
As a side note, I have not seen anyone make a flat, straight 5 block jump. I don't know why this is. If I had to guess I would say it is because you can overhang your hit box more on the corner of a block than the edge.
Answer: You can accually jump 5 blocks. Heres proof :

How far can I jump?


How do I pass in parameters to the express.js server side routing for a MEAN.js package.

Question: I am a beginner working on a project structured by mean.js. I am still trying to figure out how the whole project struct works and I am a little stuck.
Currently, I have two crud modules. A project module and an application module. Users should be able to apply to projects. Under a certain project, I should be able to view all the applications and then accept/reject them.
I added a custom method onto the angular $resource
function ProjectApplicationsService($resource) {
    return $resource('api/projects/:projectId/applications', { projectId: '@_id' }, {
      accept: {
        method: 'PUT'
      },
      reject: {
        method: 'PUT'
      }
    });

  }

Once I click a button corresponding to a certain application, it will trigger this function and pass in the application ID as a parameter.
function acceptApp(applicationID){
      vm.application._id = vm.project._id;
      vm.application.app_id = applicationID;
      vm.application.$accept(successCallback, errorCallback);
      function successCallback(res) {
          console.log("success");
      }

      function errorCallback(res) {
        vm.error = res.data.message;
        console.log(vm.error);
      }
    }

This should make an API call to express and here is the routing for that
  app.route('/api/projects/:projectId/applications')
    .get(users.requiresLogin, projects.hasAuthorization, projects.getApplications)
    .put(users.requiresLogin, projects.hasAuthorization, projects.updateApplication)
    .delete(users.requiresLogin, projects.hasAuthorization, projects.deleteApplication);

Essentially, I want to end up calling updateApplication but how do I get the application ID within this method?
Answer: Assuming you're going to upload something to the server which will trigger your put route - which contains the function you want to call.
You need to structure your handles like so:
function(request,response,next){ // usually abbreviated to `req,res`
    handleData();
    next(); // move onto the next function;
}

The parameters are easy to remember by, request comes before response, and then next - You only need next when you want to move onto another handler.
If you don't call next() the route will stop - you'll probably want to call next once authorization succeeds.
data is held in the requests body, so you can access it using request.body
Note: remember to respond to your user - with something like res.send("success"), or they'll time out
Comment: Man I literally just figured this out. Request.body was the key. Thanks!!


MarkLogic : DHF 4.0.0 Load Custom REST modules

Question: We are using version 9.0.6 and DHF 4.0.0
I have a custom REST module in my data hub repository at ..\src\main\ml-modules\services\customModule.sjs
When I run 'gradle mlLoadmodules' the build is successful but the module (/marklogic.rest.resource/RegsiteredCustomer-Preferences/assets/resource.xqy) is not loaded to data-hub-MODULES or data-hub-final-MODULES DBs. I removed timestamp property (rm .tmp/user-modules-deploy-timestamps.properties) and re-ran the mlLodModules command but still the same issue.
I intend to call this custom module through port 8011 (GET http://localhost:8011/v1/resources/customModule), so where is this module supposed to be loaded? data-hub-MODULES or data-hub-final-MODULES?  In prior versions of DHF, I noticed that this gets loaded to data-hub-MODULES.
Also, any hints on why the module is not getting loaded, are appreciated.
Answer: Take a look at http://localhost/v1/config/resources and http://localhost:8010/v1/config/resources. One or both of those ought to be showing your extension. If it doesn't show up there, it didn't get deployed.
Assuming it's not being deployed, the next question is "why not?" The most likely reasons are that ml-gradle thinks it doesn't need to be deployed or that there's an error in validation.
You can rule out the first one by running "gradle mlReloadModules" instead of "gradle mlLoadModules". That command will clear out the relevant modules database, then load everything.
When you load a REST extension, MarkLogic validates its syntax and the syntax of any library modules that it depends on. If there are any validation errors, they will show up when you try to load.


How do I unlock more towers and what are their stats?

Question: I recently started playing Pixeljunk Monsters Ultimate, and I've only unlocked the six starter towers so far, but I know there are more. I've created a table for the first six towers, but it would be really helpful to know the stats of the other towers and how to unlock them.

Tower     Type    Power   Speed   Range   Spread  Cost    Research Unlock

Arrow     Both    1       1       2       0       100     -        Starter
Cannon    Ground  2       1       1       2       120     -        Starter
Anti-Air  Air     1       3       3       0       150     -        Starter
Tesla     Ground  4       1       1       0       250     10 gems  Starter
Laser     Air     2       1       3       0       300     11 gems  Starter
Mortar    Ground  4       0       3       4       400     15 gems  Starter
Answer: You can find a lot here. Not how to unlock for all tower though.
These are the 4 towers you miss:

Tower     Type    Power   Speed   Range   Spread  Cost    Unlock                          Research

Ice       Ground  1       1       2       1       200     Beat Tiki island Special 3      9 gems
Fire      Ground  4       1       2       3       350     Beat Tiki island Special 2      13 gems
Hive      Both    1       2       5       0       450     Beat Gati Gati island Special 2 14 gems
Lightning Both    1       1       5       3       500     Beat Toki island Special 2      13 gems

and unlocks for some more: (no stats for now)

Speed Potion - Beat Tiki island Special 1
Remote Mine (Bomb) - Beat Gati Gati island Special 3
Gem Tower - Beat Toki island Special 1
Interest - Beat Toki island Special 3
Comment: Thanks. For the "Unlock"  column I was actually looking for which stage you have to beat to unlock them, but I had forgotten to include the research cost. Edit: I added a column for research cost to my table.
Comment: I just unlocked the Fire tower from completing Tiki Island Special 2. The source you linked seems to be missing the Trap Tower, Gem Tower, and Land Mine (and possibly more, but those are the ones I saw from some Googling).
Comment: Added the unlock thingies. I don't play the game myself, so I didn't knew I missed some tower. Strange.
Answer: I finally unlocked everything and completed the list.

Tower     Type    Power   Speed   Range   Spread  Cost    Research Unlock

Arrow     Both    1       1       2       0       100     -        Starter
Cannon    Ground  2       1       1       2       120     -        Starter
Anti-Air  Air     1       3       3       0       150     -        Starter
Tesla     Ground  4       1       1       0       250     10 gems  Starter
Laser     Air     2       1       3       0       300     11 gems  Starter
Mortar    Ground  4       0       3       4       400     15 gems  Starter
Fire      Ground  4       1       2       3       350     13 gems  Tiki S2
Frost     Ground  1       1       2       3       200     -        Tiki S3
Trap      Both    5       0       0       1       250     10 gems  Gati Gati S1
Hive      Both    1       2       5       0       450     14 gems  Gati Gati S2
Gem       None    0       0       1       0       300      9 gems  Tiki S1
Lightning Both    1       0       5       3       500     13 gems  Tiki S2

Notes:

Fire towers continually fire at the same spot for a set duration, dealing damage over time. Enemies with green shields are weak to flame towers and burning enemies are resistant to them.
Frost towers don't deal any damage, but do slow enemies down. They can remove the burning effect from burning enemies.
Trap towers consist of both a tower and an antenna, which must be near each other with no obstructions between them. Two traps are strung between the towers, one that hits ground enemies and one that hits air enemies. Each trap causes an explosion when triggered and can only trigger once per wave.
Hive towers generate insects over time. Each insect will roam the map, smash into the first enemy that gets in its way, and then disappear. You can only have one hive tower at a time.
Gem towers do not attack. They slowly upgrade any adjacent towers around them over time. Each gem tower has limited energy, and cannot be removed even after that energy is depleted.
Lightning towers hit every enemy on the map, but only attack when enemies are near them.

In addition to towers, you can also unlock

Speed Potion

Makes TikiMan run faster. This is a permanent upgrade.
Unlock by completing Tiki S1

Remote Mine

Allows you to set a remote mine at TikiMan's location for 5 gems at any time, and detonate at will. You can only have one mine set at a time. These deal high damage over a decent range, hitting both ground and air enemies.
Unlock by completing Gati Gati S3

Interest

Increases the amount of gold acquired at the end of each wave by 5% per tier. Each tier costs more gems than the last.
Unlock by completing Toki S3


When should I start soft resetting for female fossil Pokémon in Sun?

Question: I bought the skull and cover fossils and I wanna know if it's possible to soft rest for female when you revive the fossil?
And if I save before I buy the fossils and before I revive the fossils will it make any difference?
Comment: Honestly, there's no real use for females any more, except flavor. And since you're probably going to breed anyway to get better stats, you might as well target a female then. Any other gender-related things (except determining the species in non-ditto cross species breeding) have been removed: moves, hidden abilities and balls are all passed down by both males and females now.
Answer: You can soft-reset just before reviving the fossil to get different gender. It is not determined when you buy the fossil.
I recommend saving right before talking to the NPC at the fossil restoration center (reviving the fossil) to reduce the time between attempts.
Stating this from personal experience, but this was also the case in previous games.