Woocommerce: Changing the variations select default value?

Question: At my site i want to change the default value of the selecter that appears, when different variations exists. If anyone can give me a clue of how and where this is done, it would be highly appreciated!
Comment: You want to change the style rule applied to the selector, or you want to change the selector itself? The first is off-topic per the [faq] as being a pure CSS question.
Comment: Check my comments to Daniels answer :)
Answer: On the Product Edit page for the variable product, click on the "Variations" tab.
Once you setup variations for the Colour you can set a "Default selection" at the bottom: http://cld.wthms.co/7LIv
This will be the default option selected when a customer visits the page (if it is in stock).
Example: http://cld.wthms.co/YQFO
Comment: I still want a default value, but i need to change the text from "Choose and option" to "select size". On the page you have to choose a size before the buy button actually appears. If it uses a size as the default, this function would disappear.
Answer: If like me you'd like to have a default variation option selected without having to go through every Product and select a default via the admin then you need to alter the variable.php file which is located at woocommerce/templates/single-product/add-to-cart/variable.php (please do not alter the WooCommerce Plugin file - rather copy it to your Themes directory as per best practice).
The key here is the final else condition on line 35. This which determines what the default variation value will be. Simply alter:
$selected_value = '';
...to...
$selected_value = $options[0];
This will set the default value to be the first item in the array of product variations defined in the backend. That way your Add to Cart button is always shown by default and the user still has the ability to select another variation if they wish.
Why this isn't in WooCommerce core I don't know.
(Note this method still allows the admin to set a specific default variation value from the WPAdmin which will overide the default which gets set using my code above)
Comment: This is problematic when you have stock, and the first option is NOT in stock. This will trigger an alert saying 'Sorry, no products matched your selection...'.
Answer: I know it's a little late at this point but just in case anyone else runs into this problem. This should allow you to change the default value text.
Copy and paste this into your themes functions.php file. It may not be the best way to do it but it worked great for me.
/* Change Woocommerce Default Value Text */
add_filter('gettext',  'choose_option');
add_filter('ngettext',  'choose_option');

function choose_option($translated) {
     $translated = str_ireplace('Choose an option',  'Select Size',  $translated);
     return $translated;
}

NOTE: This will change the default value text throughout the entire site. Just a heads up!


When refinishing a hardwood floor do you need to strip off all of the old varnish?

Question: I'm refinishing my hardwood floors and some of the old varnish isn't coming off.
Before we apply a water based polyurethane do we need to remove all the old varnish or can some of it stay? Our floors are oak.
Comment: Sand more. Normally you don't stop with the 36 grit until it's gone.
Comment: What do you mean "isn't coming off"? Are you sanding?
Comment: Yes, we rented a drum sander with the rotating pads and sanded using 36, 60 and 120 grit, then went over with a hand sander. Some areas it's just not coming off.
Answer: You can test to be sure, but patchy leftover finish is likely to affect the uniformity of your new finish. It's generally considered best practice to completely remove the old finish.
Answer: You probably can leave it, but you might not want to, depending on what you're going for.
If water beads up on the finish, you simply can't leave it, for obvious reasons with a water-based poly. Same with stain, if you're doing that, you won't want to stain some parts and not others (where the stain didn't take because of old finish).
If the pre-finished spots can take water without beading, then you don't have to remove it, especially if abraded. The spots with old finish will likely appear darker than the bare wood. How much darker it will look depends on a lot of factors.
If you are staining or just want a smooth finish and don't mind a more rustic look, such darkness might not matter to you. If 90% of the floor is perfect (flat, clean, new-wood-like) and just a few spots are off, that's likely not going to look acceptable. If the spots/streaks are well distributed and largely confined to individual boards, then it can look quite striking, as long as you're going for something more rustic that doesn't look brand-new.
you might try renting a floor buffer instead of a sander, and using a green pad with an 80 or 100 grit screen under it. That should flex slightly to "scoop out" finish in any dips in the floor that your flat drum passed over. It also strips finish very quickly compared to sanders and is often cheaper to rent, and the screens do a lot more area than sandpaper, so you save on supplies. If the low-lying wood is in decent shape, and you remove the finish, it will look a lot like the parts you drum-sanded.
Answer: Sand more.
The leftover varnished areas will be a different colour and will look blotchy.
If you don't you will be unhappy with the results and will have remove the new and the stubborn old stuff.
Answer: You need a lower grit sandpaper then. Theres no need to go to a higher grit sandpaper until the top layer of finish is removed. The higher grits are to smooth out the wood fibers from the initial low grit paper. I'm pretty sure I started with a 20 grit when I rented a drum sander to do my floors.


Why is EMF equal to PD when circuit is "open"?

Question: I understand that the set up of a battery consists of very good, but not ideal conductor, and therefore, some internal resistance exists. Also, I get that emf is the PD that would exist if the internal resistance is zero. What I don't get, however is why EMF and PD are equal in case of an open circuit (circuit with infinite resistance). I'm sure I'm missing something here. Help is appreciated.
Comment: It's not really correct. Better to say "PD is equal to EMF", because EMF is constant most of the time. Intuitively, the charge can't go anywhere, so you have a constant separation of charge. Quantitatively - $V=\mathcal{E}-I r$. In the case of open circuit $I$ is zero, thus $V=\mathcal{E}$.
Comment: @BMS - What I mean is that there is a separation of charge between the terminals of the battery which causes the PD even when the circuit is open.
Comment: I don't understand the first part of cthulu's "constant separation of charge" argument, but the last sentence really summarizes the solution.
Answer: As you stated, we can think of a real battery as an ideal one with an internal resistance $R_i$. This battery is then connected to an external circuit with resistance $R$. Those 2 resistors form a voltage divider. If the EMF has a value of $V$ then the voltage measured across the external resistance is $V*R/(R+R_i)$.
This voltage is equal to the EMF of the battery when $R_i = 0$ (because $R/R=1$), and also when $R=\infty$ (because in that case $R_i$ can be ignored in comparison to $R$).
Answer: When a circuit is open (infinite resistance) then there is still work per unit charge being done by the battery but it just builds up charge imbalance inside the battery (and on the ends) until equilibrium is achieved when electrostatic forces can counter the battery.  So the charge imbalance grows until the electrostatic force can stop the battery's force.  The charge buildup occurs only inside the battery because of the open circuit.
When the circuit is connected, then the charge balance redistributes the charge around the circuit, and in equilibrium there are electrostatic forces due to the now-not-changing charge density and that's an electrostatic force, so has zero line integral, so the line integral of all the force per charge (battery and electrostatic) is just that due to the battery, i.e. the emf.
Answer: The electromotive force of a battery is equal to the potential difference between its terminals in an "open circuit", when there is no current being drawn. The potential difference between the terminals generally drops when the current is being drawn.
let me know if you need more explanation.


PHP/MySQL group results by column

Question: in order to keep as few SQL statements as possible, I want to do select set from MySQL:
SELECT * FROM products WHERE category IN (10,120,150,500) ORDER BY category,id;

Now, I have list of products in following manner:
CATEGORY
 - product 1
 - product 2
CATEGORY 2
 - product 37
...

What's the best and most efficent way to process MySQL result?
I thought something like (pseudo PHP)
foreach ($product = fetch__assoc($result)){
  $products[$category][] = $product;
}

and then when outputting it, do foreach loop:
foreach($categories as $category){
  foreach($products[$category] as $product){
    $output;
  }
}

Is this the best, or is something magical like mysql_use_groupby or something?
Comment: When you GROUP BY category, you only get one product per category in the result set. Is that what you want?
Comment: @mlueabke: thank you, I edited my SQL statement with proper grouping - another `ORDER` instead of `GROUP BY`
Answer: Like mluebke commented, using GROUP means that you only get one result for each category. Based on the list you gave as an example, I think you want something like this:
$sql = "SELECT * FROM products WHERE category IN (10,120,150,500) GROUP BY category ORDER BY category, id";
$res = mysql_query($sql);

$list = array();
while ($r = mysql_fetch_object($res)) {
  $list[$r->category][$r->id]['name'] = $r->name;
  $list[$r->category][$r->id]['whatever'] = $r->whatever;
  // etc
}
And then loop through the array. Example:
foreach ($list as $category => $products) {
  echo '
' . $category . '
';

  foreach ($products as $productId => $productInfo) {
    echo 'Product ' . $productId . ': ' . $productInfo['name'];
    // etc
  }

}
Answer: Nope, I think your solution is the best for this problem. It seems that what's important for you is the output later on, so you should stick with your approach.
Answer: Do you want to get a list of categories or actually get all products grouped into categories?
If it's the latter, best to do:
SELECT
p.product_id,
p.name,
p.category_id,
c.name AS category
FROM products p
JOIN categories c ON (c.category_id = p.category_id AND p.category_id IN (x,y,z))

Then in PHP you can go through the array (psuedo code):
    $cats = array();

    foreach($products as $product) {
        if(!in_array($product['category'], $cats)) {
            $cats[$product['category_id']] = $product['category'];
        }
        $cats[$product['category_id']][$product['product_id']] = $product['name'];
    }

Which will leave you with $cats as an array with products sorted into it.

PHP/MySQL group results by column


Simultaneous Continuation and Continuation-In-Part Patent Applications

Question: I submitted a continuation patent application. I submitted later a Continuation-In-Part patent application before getting the response from the continuation patent whose claims were rejected.  Can I still respond to the continuation patent application or does the Continuation-In-Part patent application take its place?   In other words, can they both co-exist and be reviewed at the same time?
Answer: They can both co-exist and be reviewed at the same time.
The continuation-in-part application contains new matter which was not supported in the parent application. Thus, you should be claiming different things in the two applications.
If the claims are not different enough (between the two applications), you may get non-statutory double patenting rejections.


Fill out google form using an api

Question: I have a private google form I need to fill out every day, so I would like to write a script to authenticate me using my google credentials, and then fill out some of the form programatically, is there an API for that? What is a recommended approach for this, without having edit access to the form?
Comment: https://developers.google.com/apps-script/reference/forms/
Comment: Ok so that is the one. I thought it was for creating forms only
Comment: The Forms Service from Google Apps Script requires edit access to the form in order to be able to create a response programatically.
Answer: I know this answer is super-late, but I just found your question via google since I had the same thought. The answer is query parameters. According to this article about using merge tags in Mailchimp to auto-populate google forms, if you pass query parameters after the form URL in the format form.url?key=value, e.g.https://docs.google.com/forms/path/to/stub?<entry.###########>=<url-encoded prefill value>. After generating the form, inspect the field you want to prefill. Its name attribute will be in the format <entry.###########>, where .###########> is some long number. Fill in <url-encoded prefill value> with whatever you want to go into that form, as long as it is properly URL-encoded. Hope that helps anyone else with the same question as us.

Fill out google form using an api


Unable to propose tag wiki

Question: I am trying to create a tag wiki for question-of-the-week, but every time I click on Propose Tag Wiki it just reloads the page and doesn't let me make the tag wiki.
Comment: +1 Confirmed, I have this for almost any tag...
Comment: It seems to work fine on SU, just not on Meta.SU
Comment: This is unrelated to Javascript and only on Meta.SU, example redirect: http://meta.superuser.com/edit-tag-wiki/163. Indeed, that's what I meant, corrected...
Comment: +1 confirmed, doesn't work for a diamond mod as well...
Comment: Probably gets propagated from Meta.SO
Answer: We're not currently allowing tag wikis to be edited on metas, as we plan to push out the shared meta tag wikis from meta.so.
This may change in the future.
Comment: That's logical, but then shouldn't the UI not be suggesting that I create a tag wiki if that can't be done?
Comment: @Jeff, status on this?
Comment: what is the procedure if we want to have info for tags which are relevant just to SU? I understand the reasons for pulling tag data from the main meta site, but some tags are specific to a particular meta. At the very least, moderators should have the ability to edit tag wikis if the tag does not exist or has no wiki on meta.SO.
Answer: Waffles says:

Works now, you can edit any wikis on per-site metas, including the ones sourced from this meta.

Unable to propose tag wiki


Lower bound for the number of solutions of the equations in Vinogradov's Mean Value Theorem

Question: I have a doubt about the number of solutions for the system $$x_1^j+\cdots+x_s^j=y_1^j+\cdots+y_s^j,\quad(1\leq j\leq k)$$
with $1\leq x_i,y_i\leq X$. It is a big breakthrough of Bourgain-Demeter-Guth, Wooley that the number of solutions has the upper bound $$X^{\epsilon}(X^s+X^{2s-k(k+1)/2}).$$ I think is known that these are optimal i.e. we can prove the same lower bound, but is this more difficult or we can prove this first? So is it trivial? Not for the diagonal solutions but the $$X^{2s-k(k+1)/2}$$ term. Thanks!!!
Comment: Yeah it's trivial once you know why it's trivial :). Write down the integral $\int_{[0,1]^k} |\sum_{n << X} e(a_1 n + a_2 n^2 + \cdots + a_k n^k)|^{2s} da_1 da_2 \cdots da_k$ and then only integrate over $|a_i| << X^{-i}$.
Comment: please edit to make your question self contained and understandable. What is $X$ for example?
Comment: What is meant by solutions of a theorem?
Comment: I messed up my account but want to thank alpoge, PeteM and Thomas Bloom for your answers, and kodlu for fixing the question to adress comments. I would like to accept the answer of Thomas Bloom but I cant now.
Answer: PeteM and alpoge have already given one explanation, but I thought I'd spell that out explicitly and give a second way to see it as well.
Let $J_s(X)$ count the number of solutions to $x_1^j+\cdots+x_s^j = y_1^j+\cdots y_s^j$ for $1\leq j\leq k$ with $1\leq x_i,y_i \leq X$. The lower bound you mention is that $J_s(X) \gg X^{2s-k(k+1)/2}$.
Let $f(\alpha_1,\ldots,\alpha_k) = \sum_{1\leq x\leq X}e(\alpha_1x+\cdots+\alpha_kx^k)$ where $e(t)=e^{2\pi it}$. Orthogonality implies that
$$ J_s(X) = \int_{[0,1]^k} \lvert f(\alpha_1,\ldots,\alpha_k)\rvert^{2s} \mathrm{d}\alpha_1\cdots \mathrm{d}\alpha_k.$$
Method 1: Note that since $\lvert 1-e(t)\rvert \ll t$ if $\lvert \alpha_1\rvert \leq 1/100X$ and so on up to $\lvert \alpha_k\rvert \leq 1/100X^k$ then $\lvert f(\alpha_1,\ldots,\alpha_k)\rvert \gg X$. Since the integrand $\lvert f\rvert^{2s}$ is non-negative, we can give a lower bound for $J_s(X)$ just from integrating over this range of $\alpha_i$. This gives
$$ J_s(X) \gg X^{-1}\cdot X^{-2}\cdots X^{-k} \cdot X^{2s} = X^{2s-k(k+1)/2}.$$
Method 2: Consider the slight generalisation $J_s(X;n_1,\ldots,n_k)$ which counts solutions to $x_1^j+\cdots+x_s^j-y_1^j-\cdots-y_s^j = n_j$ for $1\leq j\leq k$ and $x_i,y_i\leq X$. In particular, note that $J_s(X)=J_s(X;0,\ldots,0)$. By orthogonality we have
$$ J_s(X;n_1,\ldots,n_k) = \int_{[0,1]^k} \lvert f(\alpha_1,\ldots,\alpha_k)\rvert^{2s} e(-\alpha_1n_1-\cdots -\alpha_kn_k)\mathrm{d}\alpha_1\cdots \mathrm{d}\alpha_k.$$
By the triangle inequality it follows that $J_s(X;n_1,\ldots,n_k)\leq J_s(X)$ (this fact can also be proved in 'physical space' without using orthogonality). Now note that
$$ \sum_{n_1,\ldots,n_k} J_s(X;n_1,\ldots,n_k) = X^{2s},$$
since every $2s$-tuple gives a solution to some $n_1,\ldots,n_k$. Finally, observe that $J_s(X;n_1,\ldots,n_k)$ is only non-zero if $1\leq n_1\leq sX$ and so on up to $1\leq n_k\leq sX^k$. This implies that
$$ X^{2s} = \sum_{n_1,\ldots,n_k} J_s(X;n_1,\ldots,n_k) \ll J_s(X) X\cdot X^2\cdots X^k,$$
and the lower bound follows.
Answer: I'm sure I saw an argument for this once. It goes something like: only look at the part of your integral really close to 0, where your exponential sum is almost exactly 1, and this alraedy contributes at least the right amount of solutions for the 2s-k(k+1)/2 exponent. If anyone else knows how this goes, please let me know.
(The X^s I think you know comes from diagonal solutions).


fixing tornado damage

Question: We had a tornado touch down in our neighborhood last night. Everyones ok, but there's quite a lot of damage. We lost a 2'x8' section of shingles along our roofline and have water damage all throughout our drywall ceiling. The weather is supposed to be clear until Sunday. Should I cover it with a tarp immediately?  We still have all the plywood on the roof so I don't know if it would be better to let it dry or not. How should I attach the tarp? Nails, screws, tape, rope?
Answer: I agree, let it dry out as long as you dare.  When you do have to cover it up, get a tarp that is plenty large enough to cover the damaged area. A pic would be helpful. Get enough 1X3 cheap strapping and use it as a large washer with your tarps.  i'd try to go over the peak, roll the  edges of the tarp around the strapping and pull it as tight as possible and nail it down with 4 or 6d double headed nails.  Then take more strapping and install it perpendicular to the ridge line on 4 ft intervals.  This will help prevent wind from getting under the tarps but let water flow easily down the roof.
Sorry to hear of you misfortune, glad to hear you and yours are OK. A lot of people we not so lucky in the last couple of days.
Comment: +1 for the good advice, but I had to work with the materials I had on hand. Our entire county doesn't have power, and almost no stores were open where I could get supplies.
Answer: My instinct would be to let things dry out as much as possible.
To put the tarp up, I don't know if there is an official way, but my personal solution would be to install it under the first set of intact shingles and drive some nails through the shingle and tarp together, essentially turning the tarp into a temporary shingle.
If the roof ridge is near, then just run the tarp over the whole thing, drive some nails around the edges, and a few more in the middle to make sure nothing gets pulled from an up-draft.
When you pull the nails, just use a little sealant in the holes that are left.
Comment: This is pretty much what I ended up doing. I had an old blue tarp, and a roofer was coming through our neighborhood putting tarps up for people. He gave me some nails with plastic washers attached to keep the tarp down and waterproof it simultaneously. I went over the ridgeline so I didn't need to tuck it under any shingles.

fixing tornado damage


Is a Homogeneous development platform good for the industry?

Question: Is it in best interests of the software development industry for one framework, browser or language to win the war and become the de facto standard?  On one side it takes away the challenges of cross platform, but it opens it up for a single point of failure.  Would it also result in a stagnation of innovation, or would it allow the industry to focus on more important things (whatever those might be).
Answer: Defacto standards are bad because they are usually controlled by a single party. What is best for the industry is for there to be a foundation of open standards on top of which everyone can compete.
The web is a perfect example. When IE won the browser war, it stagnated for years, and is only just now starting to improve because it's hemorrhaging marketshare. The Netscape years prior to that weren't much better. The CSS 2.1 standard was released ten years ago and still isn't supported well. As a consequence, web development is a Black Art of hacks and work-arounds to get websites to render consistently.
My job would be a hundred times easier if I could build a website according to web standards and be confident it would display correctly. Just think of all the cool things we could have been working on instead of fixing IE's rendering errors.
Answer: I believe whenever there is only 1 option, it will definitely stagnate innovation.  If all we had was 1 language, then we wouldn't be able to solve anything but what that language was designed to solve.
Imperative languages like Java and C# solve a certain set of problems pretty well, but it also helps to think in a functional manner sometimes, such as with Haskell and Lisp.
Furthermore, cross platform issues are not an issue if you are talking about a web application, because you control the hardware and software (note, I am talking of the server side code of course, the browser cross platform issue is separate).
Paul Graham wrote a great essay on how the Web lets you as a developer use the tool you think will solve the problem best.
Answer: No.  Competition is good.  It may make a web developers job easier, but I think it's bad for the industry.  I personally prefer having choices.
I believe Joel Spolsky's technique of creating his own language (Wasabi) to insulate his company from being platform specific is a good one.  I also believe it is a good idea to use products that accomplish similar things that are more targeted at specific problems like JQuery.
Answer: I'm gonna have to agree with Mike on this one and say that without competition there is very little incentive to innovate.


Best value AMD CPU for under $70

Question: This CPU is for a gaming system under a tight budget. However, there is no need for an integrated GPU. In my current state, I am looking for the best AMD CPU available to buy. It can be any socket, as a new motherboard is needed anyway.
So my question is, what is the best value AMD chip under $70 for performance and value.
Answer: The best available CPU at ~70$ U.S. is the AMD Athlon X4 860K. It is an FM2+ socket Kaveri chip with for compute cores. It is clocked at 3.7 Gigahertz stock, though generally has very good overclocking potential, if interested, and also happens to be the CPU that powers my system.
Pretty much any Intel CPU beats it out in single core performance at stock, but when overclocked, it approaches i3 performance per core and has an extra 2 cores to work with.
The AMD FX-6300 is also another chip you might want to look into. It has 6 cores, each slightly inferior to the X4 860K's. However, it costs $90 and is on a dying CPU socket, the AM3+, which will be totally replaced by Zen later this year.
If you want to wait for the new Zen AMD CPUs to come out (AM4 socket), that is a good idea too, as they are supposed to actually compete with Intel i5 and i7 processors.
Comment: I thought FM2+ will be replaced by AM4 as well.
Comment: [Not what I heard](http://www.pcworld.com/article/3020184/computers/amd-zen-based-cpus-and-apus-will-unify-around-socket-am4.html). Zen supposedly unifies AMD's 3 sockets. according to every news source I've seen.
Comment: It seems like AMD will continue using FM2+ for some APU's, but move to AM4 for the nicer processors, like the FX series
Comment: I don't know much about the zen architecture, other than it is supposedly faster and more power efficient than FM2+ or AM3+. Feel free to edit the answer the answer at your discretion to add or change whatever information you would like to about Zen.
Comment: The answer is correct, but there's a lot of discussion here that needs correction: first, the 860K is a *mediocre* overclocker; it is unusual for anyone to get it going faster than 500mhz over its boost clock. Second, while FM2+ is indeed going to be replaced by AM4, just as sockets AM1 and AM3 will presumably be, it is *highly* unlikely that anything on that socket would fit the budget and so is not worth discussing. No further processors are planned for any of the existing AMD sockets.

Best value AMD CPU for under $70


Silverlight RIA Services with different database providers

Question: I want to create a Rich Internet Application in Silverlight. One of the requirements is that the back-end of the application should work with different database providers (SQLServer, PostgreSQL, Oracle).
I'm planning to use Entity Data Model to represent database objects and Domain Services to expose these objects to the client.
The problem is that I don't have a clue if the same data model can be used with different database providers and how sophisticated that would be to change the provider without recreating all the model.
I want the application to be reusable on different environments, so that i can import the same database schema to any existing database, change the provider in the ASP.NET web application and that's it.
Is it doable? Or maybe there are other ways to achieve similar functionality? Thanks in advance for any suggestions.
Answer: I would like advising you to look through existing Entity Framework Best Practices


Velocity for a straight line collision

Question: I get that the force of a collision is m(Δv/Δt). What I do not get is why the change in velocity for a straight-line collision m(2v/Δt). Why is this?
Answer: Firstly I think you might be a tad confused about what's going on. It's not the change in velocity that equals $\frac{2mv}{t}$ but that is the force.
Suppose we have a perfectly elastic collision of a ball hitting a wall. The force the ball exerts on the wall is indeed $$F=ma=m\frac{dv}{dt}$$ However we can also express this force as $$F=\frac{d}{dt}(mv)$$ As $p=mv$ it can be said that $$F=\frac{dp}{dt}$$In fact this is the original formulation of $F=ma$ and it states that the force is equal to the change in momentum over time.
For an elastic collision in a straight line where the object rebounds in the same direction the velocity after the collision will be of the same magnitude but in the opposite direction. So if an object starts out with velocity $2v$ after the collision it will have velocity $-2v$.
This means that the force, F is $$F=\frac{m(v_0)-m(-v_0))}{t}$$And therefore $$F=\frac{2mv}{t}$$I hope this is a clear explanation for you :).

Velocity for a straight line collision


Where is it possible to buy an ASIC?

Question: I know of Avalon and Butterfly Labs, but they aren't currently shipping. Does anyone know where, if anywhere it is possible to order and receive shipment before the year's out?
Answer: So far as I know, those two are the most advanced, and your best bet is going to be placing an order and waiting for it to ship.  Sadly, as I have one on order and am waiting impatiently.

Where is it possible to buy an ASIC?


User Change Event in ASP.Net

Question: We have developed a visual web part in asp.net. With using SPContext.Current.Web.CurrentUser.ID property, we control who is current user. In SharePoint, it is possible to change current user and this feature cause problem in web part. I am looking for a user change event in asp.net. Is there any event to control user change in asp.net?
Comment: If a person logs in as a different user, it'll trigger a full page request (several actually) so this isn't really a valid scenario. Every page load is a separate life cycle.
Comment: I have a session for the current user. However, after a new user login, the information of the previous user display in web part unless the new user close browser and open it again.
Answer: So the question is actually about keeping a session variable in sync when a user logs out and back in as a different user. Here's how I'd do it:
Store the user's username in a session variable. On each Page_Load, check it against the current logged in user. If they are different you know they've changed.

User Change Event in ASP.Net


Are preg_match() and preg_replace() slow?

Question: I've been coding in PHP for a while and I keep reading that you should only use preg_match and preg_replace when you have to because it slows down performance. Why is this? Would it really be bad to use 20 preg_matches in one file instead of using another PHP function.
Comment: regexes have to be compiled, strings parsed, etc... nothing WRONG with using a regex, but a lot of people abuse them by doing silly things like `preg_match('/foo/', $bar)` instead of `strpos('foo', $bar) !== false`
Comment: The answer is: it depends on what "other PHP function" you had in mind. Some cases may be faster, others not. Also, speed is not always the most important factor. Regex may be the best tool for the job regardless of speed, or it may be the wrong tool for the job even if it runs quicker.
Comment: In my case, this is so helpful as I use around 30+ preg_replace() before I render a page. I managed to cache my pages so I don't always have to iterate.
Answer: As Mike Brant said in his answer: There's nothing wrong with using any of the preg_* functions, if you need them.
You want to know if it's a good idea to have something like 20 preg_match calls in a single file, well, honestly: I'd say that's too many. I've often stated that "if your solution to a problem relies on more than 3 regex's at any given time, you're part of the problem". I have occasionally sinned against my own mantra, though.
If you are using 20 preg_match calls, chances are you can halve that number simply by having a closer look at the actual regular expressions. Regex's, especially the Perl regex, are incredibly powerful, and are well worth the time to get to know them. The reason why they tend to be slower is simply because the regex has to be parsed, and "translated" to a considerable number of branches and loops at some low level. If, say, you want to replace all lower-case a's with an upper-case char, you could use a regular expression, sure, but in PHP this would look like this:
preg_replace('/a/','A',$string);

Look at the expression, the first argument: it's a string that is passed as an argument. This string will be parsed (when parsing, the delimiters are checked, a match string is created and then the string is iterated, each char is compared to the pattern (in this case a), and if the substring matches, it's replaced.
Seems like a bit of a hasstle, especially considering that the last step (comparing substrings and replace matches) is all we really want.
$string = str_replace('a','A',$string);

Does just that, without the additional checks performed when a regular expression is parsed and validated.
Don't forget that preg_match also constructs an array of matches, and constructing an array isn't free either.
In short: regex's are slower because the expression is parsed, validated and finally translated into a set of simple, low-level instructions.
Note that, in some cases people use explode and implode for string manipulations. This, too, creates an array which is -again- not free. Considering that you're imploding that very same array shortly thereafter. Perhaps another option is more desirable (and in some cases preg_replace can be faster here).
Basically: regex's need additional processing, that simple string functions don't require. But when in doubt, there's only 1 way to be absolutely sure: set up a test script...
Answer: Don't worry about optimization unless you have a problem.
Don't look for areas of optimization without measuring with something like XDebug (http://xdebug.org).
If your code takes 100ms to run with preg_match() and 110ms via some other method, do you really care about the difference?
Write for correctness and clarity first, then consider speed.
Comment: While I totally agree with writing for correctness and clarity, writing optimized code can be just as important. As someone that works with high volume sites on a regular basis, optimized code is as important as anything.
Comment: Man I can really get behind the "Don't optimize without measuring" mantra. I've spent whole days reducing the number of database queries resulting in almost no discernable difference. Then with a real debugger I found a small cache write taking almost a second of load time combined.
Answer: It really depends on your use case. There is nothing inherently "bad" about using regex.  Sometimes it is your only available solution to a particular problem.  However, there are times when simple string manipulation functions will work just fine.  These tend to be faster than the preg* functions, so if you run into cases where you have a script that is run very frequently and/or has a large number of string manipulations to be performed, the impact of using regex can begun to be felt.
As is the case for anything, you should test in your application and environment and decide what works best for you.
Answer: Check how much time it needs (display times when STARTED and ENDED):
var_dump( microtime(true) );

//...............  your function executions here.............

var_dump( microtime(true) );

Answer: Depends on what you're doing. For complex regex just go with the preg_ functions, if you need simple substitutions or similar, go with other, more specific functions like str_replace(), strpos(), strstr()...
The web is full of discussions, like http://www.simplemachines.org/community/index.php?topic=175031.0
Answer: Performance difference is negligable for short strings (like less than few kilobytes). For long strings e.g. over 30-50 kB (typically WYSIWYG contents) performance difference becomes more significant, particularly for greedy variants - e.g. preg_match_all. Thus for long strings it would be often faster to use simple string iteration/lookup e.g. by str_pos() and extract or replace parts of the string with substr() and then only apply preg_* functions - for extracted short strings.
Comment: Yes and no. When finding said "short strings" isn't straightforward, it's possible that your algorithm for finding them could actually be slower than full regexp match.


Upgrading to 3.7.26 causes tempnam() error from twig's FilesystemCache.php

Question: I am upgrading a Craft project that I have been neglecting for a little bit too long. I am upgrading to 3.7.26 from 3.4.25; on top of this, I am upgrading from PHP 7.1 to PHP 7.4.
I'm also updating a variety of plugins on top of this as well. Attached is my composer.json file below.
After nuking my vendor file, completing the php craft update all, and installing new required dependencies (multibyte string, ext-curl, etc), I'm getting the following error.
## PHP Notice – yii\base\ErrorException
tempnam(): file created in the system's temporary directory

line 64: $tmpFile = tempnam($dir, basename($key));

I've tried nuking my vendor folder again, trying in different browsers, updating composer, searching SO a bunch, and I'm not sure where to check next.
Any thoughts would be really helpful, thanks.
My composer.json file:
{
  "require": {
    "anubarak/craft-relabel": "2.0.2",
    "born05/craft-twofactorauthentication": "2.10.0",
    "carlcs/craft-redactorcustomstyles": "3.0.4",
    "craftcms/cms": "^3.7.26",
    "craftcms/contact-form": "2.2.7",
    "craftcms/google-cloud": "1.4.1",
    "craftcms/mailgun": "2.0.0",
    "craftcms/redactor": "2.8.8",
    "doublesecretagency/craft-cpcss": "2.4.0",
    "doublesecretagency/craft-cpjs": "2.4.0",
    "ether/logs": "3.0.5",
    "ether/seo": "^3.1.0",
    "marionnewlevant/snitch": "184.108.40.206",
    "remcoov/avataaars": "1.0.1",
    "spicyweb/craft-fieldlabels": "1.3.2",
    "spicyweb/craft-neo": "2.12.1",
    "trendyminds/visor": "3.0.1",
    "unionco/calendarize": "^1.2",
    "verbb/field-manager": "2.2.4",
    "vlucas/phpdotenv": "^3.4.0",
    "whoisjuan/craft-color-mixer": "1.0.9"
  },
  "require-dev": {
    "yiisoft/yii2-shell": "^2.0.3"
  },
  "autoload": {
    "psr-4": {
      "modules\\": "modules/"
    }
  },
  "config": {
    "sort-packages": true,
    "optimize-autoloader": true,
    "platform": {
      "php": "7.4"
    }
  },
  "scripts": {
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ]
  }
}

Answer: Surprised you weren't getting this on 7.1 as well since it appears that is when that notice was added: https://github.com/Glavin001/atom-beautify/issues/1108#issuecomment-272012827
Regardless, this doesn't appear to be a Craft or Composer issue, but more of a PHP/server configuration one.
There are a couple of things to try in here as a starting point: https://bugs.php.net/bug.php?id=74189


Adding a 100 amp main panel

Question: I have a 200 amp main panel
I want to run a 100 amp service  from the 200 to my garage.
There's  nothing  on the 200 amp panel other than security cameras  and lights.
Do I need to install a 100 amp breaker  in the 200 amp maln to do this ?
Comment: Does the panel have thru lugs?  I.e. an extra set of lugs at the bottom / opposite end of the busbar from the main breaker?
Comment: Do you mean a 100A *feeder* to your garage?
Comment: Hello, and welcome to Home Improvement. If an answer is helpful, please click the large check mark next to it to accept. And, please [take our tour](//diy.stackexchange.com/tour) so you'll know the details of contributing here.
Answer: Some initial notes
You can run any amperage you please to the garage.
That thing you're running to the garage is on your side of the meter, so it's feeder not a service (that's why 310.15(B)(7) says "service and feeder").
If the garage is a separate building (i.e. if the meter is NOT mounted on the garage building), then you need a local disconnect at the garage.  It does not need to be outdoors.  The cheapest way to get a local disconnect is to select a breaker panel that has a main breaker, the size of the main breaker does not matter.  Literally anything will do, so if you like a panel with a lot of spaces and those only come in 200A, that's fine.
The wire has to be actually rated for the specific known load that you are driving, or the load calculation you have done.  But if you don't have a specific load in mind or just want to exceed those minimums, you can run any size you want.
You must protect the wire with a circuit breaker, but you get to "round up" in breaker sizes.  If the wire is rated for 115A, you get to use a 125A breaker.  There's one exception: your feeder never has to be bigger than your service wire has to be (as per 310.15(B)(7)).
Feeder in these ~100A sizes should be aluminum - it's what any electrician would use because it's 1/3 the price of copper.  The panel lugs are aluminum anyway.  (aluminum lugs are the "universal donor", they play nice with both copper and aluminum wire). So I'll be talking aluminum sizes.
Ready?
You don't need a breaker in the main panel if you simply bring over the full 200A to the garage.  Why would you do that? Well, what else would you do with it?  You don't have anything to power at the main panel if the only things on it are cameras and lights.
However the trick would be attaching 200A wires on the load side of the main breaker.  For this you'd need a main panel with "through-lugs", or a "Subfeed lug" that clips in like a regular breaker, or an actual regular breaker that is 200A. They must be made for that panel; you can't use off-brand devices (except for things UL-Classified for your panel, but nobody makes what you'd need).
But if you can do that, then you can carry 200A from the main panel to the sub on 4/0 aluminum wires.  This is allowed because 310.15(B)(7) allows 4/0 for the entire service, and you don't need any bigger than that.
There's no need to enlarge the wire for voltage-drop reasons; it isn't far enough to matter.
If you want to carry less than 200A, e.g. to save money on wire or because there's no way to get lugs of 200A breaker... then simply use a breaker appropriate for the wire size (rounding up to the next available breaker):  #2 aluminum = 90A, #1 aluminum = 100A, 1/0 aluminum = 125A.
Answer: The simplest approach is install a 100A breaker into your existing 200A panel.  Leave the 200A main panel breaker.  The 100A is just another branch circuit within that panel.  Connect the garage feeder to the 100A breaker.
On the garage side, if you have 6 or fewer branch circuits, you can avoid having a disconnect or main breaker for that building; but realistically, you shouldn't.  You don't need another 100A circuit-breaker since there's already one upstream; but you must have a disconnecting means of 6-or-fewer switch throws.  You can use a dumb switch to satisfy this and use it to supply a panel of any size inside to supply your garage loads.
<code>            Existing Service               New Garage           New Panel
                 Panel                  Outdoor Disconnect    Inside Garage

             +-----------+
             | 200A MAIN |                   +-----+            +-----+
             +-----+-----+                   | ON  |------------|  20 |
LIGHTS ----- |  15 | 100 | --- to garage --- | OFF |            |  20 |
CAMERAS ---- |  20 | 100 |                   +-----+            | ...
             |     |     |
             | ...

</code>
Comment: I'm not seeing where an **outdoor** disconnect is required. Do you have a Code cite? Why not just choose a main breaker panel and use the main breaker as the disconnect?
Comment: Although a circuit breaker isn't required in the garage it may be easier than a separate disconnect. A large panel with lots of breaker spaces that has a main breaker larger than 100A could be used because the feeder and panel is protected by the 100A breaker in the service panel.

Adding a 100 amp main panel


Why is it called "under the sea" when it should be "in the sea?"

Question: Why is the phrase "under the sea" constructed the way it is? Shouldn't it be "in the sea?" Does "sea" refer to the surface of the ocean in this case? Or is it just one of those quirks in English?
Comment: The *sea* is just a large body of water. It could be ocean, lake, etc. and your question would be the same. The real issue is *under* vs. *in* vs. *on* vs. *into*, etc. The reference is usually in relation to the water surface. Adding some example sentences to your question would be helpful, as context is often important when deciding on the correct preposition.
Comment: Resource: http://english.stackexchange.com/questions/955/why-does-under-the-sea-mean-in-the-sea
Comment: I have closed this as a duplicate of a more recent question because it is a subset of that question. I think it makes sense to collect all the answers in one place even though this question currently has a higher score.
Answer: Under is used to refer to something below a surface:
Macmillan dictionary has:

e. below the surface of water:
The ducks kept diving under the water to catch fish.
  He was the first person to claim there was oil under the North Sea.
  She jumped in the pool and went under.


Proving that the derivative operator on $L^p(0,1)$ has a closed graph

Question: Let $Tx(t) = x'(t)$ on $L_p(0,1)$, and let the domain of $T$ be only the absolutely continuous functions on $[0,1]$ whose derivatives are in $L^p(0,1)$. I need to show that this operator has a closed graph. Naturally, by the closed graph theorem, it would be sufficient to show that $T$ is a continuous operator. This seems like a standard exercise, but I can't seem to be able to do it. I don't make much progress with the definition of continuity. Is it best to try and show that $T$ is bounded?
Answer: I suppose you are taking $p>1$. Suppose $x_n \to x$ in $L^{p}$ and $x_n' \to y$ in $L^{p}$. We have to show that $x$ is absolutely continuous, $x' \in L^{p}$ and $y=x'$. By absolute continuity we have $x_n(t)=x_n(0)+\int_0^{t} x_n'(s) \, ds$ $\,\,\, (1)$. Let $n_k$ be  a subseqeunce of the integers such that $x_{n_k}$ converges almost everywhere to $x$. Since convergence in $L^{p}$ implies convergence in $L^{1}$ we get $x(t)=a+\int_0^{t} y(s)\, ds$ for some constant $a$. [In (1) LHS converges and the second term on RHS converges. Hence the first term must converge]. Since $y$ is integrable this last equation implies that $x$ is absolutely continuous [more precisely it can be modified on a null set to make it absolutely continuous] and $x'=y$.
Comment: Maybe I'm missing something, how can the derivative be bounded (given that, e.g., $ \exp(i k x)$ are in the domain) ?
Comment: $T$ is not a bounded operator. Unbounded operators can have closed graph.
Comment: Absolutely. The OP misuses the closed graph theorem as the operator is not defined on the whole space.


Modified Lebesgue differentiation theorem

Question: Let $\Omega\subset \mathbb{R}^n$ an open set and $u:\Omega\to \mathbb{R}$ be a (locally) $L^1$-function. Then it is well known that the Lebesgue differentiation theorem holds: For almost every $x\in \Omega$,
$$\frac{1}{|B_r(x)|} \int_{B_r(x)} (u(y) - u(x)) d y \to 0$$ as $r\to 0$. My question is if it is true that
$$\frac{1}{|B_r(x)|} \int_{B_r(x)} |u(y) - u(x)| d y \to 0$$ as $r\to 0$ for almost every $x\in \Omega$. I am doubtful about this, but the universal counterexample in measure theory - the (characteristic function of the) fat Cantor set - doesn't work here. If it is actually true, then it could probably further be generalized to
$$\frac{1}{|B_r(x)|} \int_{B_r(x)} |u(y) - u(x)|^p d y \to 0$$ if $u\in L^p(\Omega)$ and $p\ge 1$. Actually that is what I'm interested in.
Comment: Such a point is called a "Lebesgue point" of $u$.  Look for that in your textbook.  Here it is in Wikipedia: http://en.wikipedia.org/wiki/Lebesgue_point
Comment: To sketch the standard argument: Since countable intersections of full-measure sets is a full-measure set, a countable set of integrable functions admits a common full-measure set $S\subset\Omega$ of differentiation (that is, such that the first formula you wrote holds for every function of the family and for every $x\in S$). Consider in particular the functions $u_q(y):=|u(y)-q|$, $q$ a rational number. Then it is easy to see that for all $x\in S$ the second formula you wrote is true. Check for instance Wheeden- Zygmund, *Measure and integral*.
Answer: It's true that $$\frac{1}{|B_r(x)|}\int_{B_r(x)} |u(y)-u(x)|^p\to 0$$ for $r\to 0$. For $p=1$ this is standard (Somehow I always overlooked the absolute value signs in the definition of Lebesgue points), and the same proof carries over for $p>1$ (at least the proof used in Ziemer, "Weakly differentiable functions", where variants of this theorem for Sobolev spaces are discussed as well).


How to install ubuntu 14.04 on my Mac Pro 1,1 with a raw hard drive by a bootable USB stick

Question: I have a Mac Pro 1,1 and I replaced the original hard drive with a new 3TB hard drive (just got, never initialized).
I try to install ubuntu by a bootable USB stick which I crated on my Mac
When I fellow the instruction on [https://help.ubuntu.com/community/MacPro][2]
However I find out it does not work.
And in this instruction, it mentioned Mac pro 1,1 is EFI incompatibilities, That is also the reason I can not install rEFind. This instruction has a link [http://cdimage.ubuntu.com/releases/11.04/release/][3] seems can help my situation, but that page is not available.
Now the bootable USB stick never show up when I restart my Mac pro with pressing the option button.
I appreciate any answer can help me out.
Comment: Please refer to [this question](http://askubuntu.com/questions/272120/mac-boot-from-ubuntu-installed-on-a-usb-drive?rq=1) for some tips.
Comment: Some of the old macs can be tricked to boot from USB by using both a DVD and a USB stick. The Mac should pick up the DVD to boot from, then once booted the USB should automatically take over for the installation. That way you don't have to suffer through the slow DVD install. There are also some MACS that will boot form DVD but fail to install from that DVD, making this the only way to install on those devices. That's where this trick comes from.
Comment: regarding a link not working, you can get a live daily build of the various releases at http://cdimage.ubuntu.com
Answer: Look for the ISO's with "amd64+mac" in the name. There are both Desktop and Server versions.
Go to this page: http://cdimage.ubuntu.com/releases/14.04/release/ to see the full list of available ISO's for download. Again, look for the "amd64+mac." It's faster to download them as torrents if you can.
My aim is to convert three of these Mac Pros into Ubuntu servers along with an XServe 1,1 as their master for a private cloud at work. All of them have 32GB RAM installed, and these machines are still in great condition. I'd hate to have to discard them just because Apple will no longer update Mac OS X Lion when Yosemite is released.
Answer: The Mac Pro 1,1 is special in that it has a 32-bit EFI. Later models have a 64-bit EFI which does not have as many issues installing linux.
The easiest way to run Ubuntu (or any linux, really) on a Mac Pro 1,1 (2006) is installing VirtualBox on your MacOsX, and running linux in a virtual machine.
The alternative is described here: https://wiki.debian.org/DebianOnIntelMacPro
But, again, save yourself a lot of hassle and just run linux in a virtual machine.
Comment: Although your answer is 100% correct, it might also become 100% useless if that link is moved, changed, or the main site just disappears... :-( Therefore, please [edit] your answer, and copy the relevant steps from the link into your answer, thereby guaranteeing your answer for 100% of the lifetime of this site! ;-) You can always leave the link in at the bottom of your answer as a source for your material...
Answer: What I had to do is install the amd64 version of Ubuntu 12.04, and then go through the upgrade to 14.04, and then 16.04.  Pain in the posterior extremus, but it worked, and much more satisfactory than what I had to do before, which was run 32-bit Ubuntu (on a Mac Pro with dual quad-core 64-bit processors.)


What does 'broad' mean in the following sentence?

Question:
It was inevitable, given the conceptual and empirical content of development
  economics in the mid 1970s, that the early World Development
  Reports painted with a broad brush.
Comment: Here is an explanation: http://idioms.thefreedictionary.com/paint+with+a+broad+brush
Comment: wide paintbrush (crude lines, versus "fine" brush)
Answer: paint with a broad brush is an idiomatic expression. The sentence simply says that the early World Development Reports regarded things in general terms without getting deeply into the specifics.
Look here for the details (it has got some very good examples under the quotations section). Here's specifically the part of interest:

paint with a broad brush(idiomatic) To describe a class of objects or a kind of phenomenon in general terms, without specific details and without attention to individual variations.
Comment: Guess what, I was in the process of editing the answer while you down-voted it.
Comment: @AlanCarmack - Was there a request for the meaning of the expression" paint with a broad brush" or for the meaning of the adjective "broad" in collocation with the noun "brush"? Can't the latter be looked up in a dictionary to provide a definition in the answer?
Answer: The idiom having been explained, here's the picture of a broad paintbrush for, as TRomano mentioned, painting crude lines:

To see why it is broad, here's the picture of a fine (thin in thickness) one for painting small details:


DTD ATTLIST Range of Numbers

Question: Hi is it possible to only allow a range of numbers in an ATTLIST?
I know you can have an enumeration of a set as follows:

But it is possible to have 0 - 100, without having to type all 100 numbers?  Thank you.
Answer: Because DTD's don't support a type system (other than specialized notational types such as NOTATIONS, and IDREFS and NMTOKENS inside of attributes) there isn't any way to actually specify a type as numeric, much less give it a range.
Every element that can contain text is PCDATA, or parsed character data.
If you were to use XML Schemas (XSDs vs. DTDs), there is a way to apply a range to an integer.
Answer: No, it's not
DTD does not distinguish data types (e.g. string vs integer) and thus has no notion of ranges.

DTD ATTLIST Range of Numbers


English / French speech to IPA

Question: Are there any open-sourced library / Deep Learning models that convert an audio clip of a word to its IPA representation? In this case, the audio is from a non-native speaker and the goal is to generate the corresponding IPA representation of the word as uttered by the speaker. This representation is expected to be much different than the 'correct' or 'true' IPA representation. Basically I want to understand the deep learning model behind https://elsaspeak.com/en/
Answer: There is no program that converts samples speech to IPA. Some program might appear to do that, by converting an utterance of language Z into its orthographic form then following conventional text-to-IPA rules to yield a psuedo-trancription, which that would not detect variations (among native speakers) between [i] and [ɛ] as the first vowel of "economic". There is an insufficient corpus of expert IPA productions to make such a program possible (example: there are no expert samples of coda consonant; there are no expert samples of [t] between high vowels or round vowels). For what you are describing, you need actual expert reference values, not well-meaninged attempts at producing reference values (such as the Smalley tapes).

English / French speech to IPA


"It won't take but a moment"

Question:
I open the door.
"Marlena!" I say,
  swinging the door farther open than I intend to. "What are you doing
  up? I mean, are you okay? Do you want to sit down?"
"No," she says. Her face is inches from mine. "I'm all
  right. But I'd like to speak to you for a moment. Are you alone?"
"Uh, no. Not exactly." I say, glancing back at
  Walter, who's shaking his head and waving his hands furiously.
"Can you come to the stateroom?" Marlena says. "It won't
  take but a moment."
"Yes. Of course."
-- Sara Gruen, Water for Elephants

What does but mean? (The sentence seems like it won't take time except that it takes only a moment, I suppose.)
Comment: @snailboat I don't think you can classify this as an exceptive; it is paralleled by "It won't take only a moment". Both the *but* and *only* versions are colloquial double negatives, and are, I surmise, not conscious emphatics but casual use of unanalyzed fixed phrases--compare "I couldn't care less".  None of these would be accepted in a formal register.
Comment: @StoneyB: Yes, there's definitely something of the "optional double negative" in such constructions. Semantically it makes no real difference whether either or both elements (negated verb *and/or* a qualifier such as ***but, only, just***) are included. It's just that including *neither* implies the speaker thinks the amount of time is at least *long enough* to bother mentioning, and including *both* is informal/dialectal.
Comment: [*Billy is prejudiced cause Jacks father is **nothing only but just** a humble butcher*](https://www.google.com/search?q=%22father+is+nothing+only+but+just+a+humble+butcher%22&btnG=Search+Books&tbm=bks&tbo=1) is perhaps a rather extreme example, but it'd mean exactly the same (and still be in the same "register") if it'd been ***ain't*** instead of ***is***. In such constructions, so long as you have at least *one* negating/minimising qualifier, it makes little difference semantically (except perhaps by adding *emphasis*) if you add more such terms.
Comment: "but" in this content means "only". Only a moment. So the sentence means the same as "It won't take a moment". (That is, it will take even less than one moment.)
Comment: @MrLister I agree with the first part of your comment.  It does not, however, mean "it will take even less than one moment".  (Not that there's a big difference between one moment and less than one moment, mind you...)
Comment: Hm, then what is the difference between "it _will_ take but a moment" (from your answer) and "it _won't_ take but a moment" (from the question)?
Comment: A negative with *but* is like a positive with *only*.  It's an **exceptive construction**; like when you say "No one but Joe ate cake", you mean "Only Joe ate cake".  Here, "not but a moment" means "only a moment".  I apologize for my answer being unclear!
Comment: @MrLister Ah, I see your question. I think they mean the same thing.  *Not ... but* means "only", and *but* can mean "only", as well!
Comment: @Mr Lister, snailboat: I think the presence or absence of ***but*** is irrelevant to the fact that for many speakers in many contexts the negation itself also makes no inherent difference to the "duration" meaning. The biggest difference between *"It won't take a minute"* and *"It will take a minute"* is nothing to do with whether it takes exactly one minute, or more, or less. It's that (unless it includes the word "only") the non-negated version implies that a minute is *a relatively long time*, in the context of whatever "it" is that might be done.
Comment: @FumbleFingers Nicely discriminated.
Answer: This is sense 10 in Collins:

just; merely; only ⇒ "he was but a child", "I can but try"

Here, the sentence means "it will only take a moment".  In other words, it won't take more than one moment.
Comment: "Merely", yes, that was the word I was looking for.

"It won't take but a moment"


What is the difference between PTP 1588 and 802.1 AS?

Question: What are the use cases where one is preferred over other ?
Comment: Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can post and accept your own answer.
Answer: IEEE1588 PTP is implemented on top of the UDP transport layer.
802.1AS is essentially the same protocol, but implemented directly on the Ethernet layer instead.
You have to use 802.1AS in situations where you need precise time, but don't necessarily have an IP address.
For example "Time-Sensitive Networking".
You have to use IEEE1588 PTP in situations where you don't necessarily run on Ethernet, or don't have access to the Ethernet layer.
Answer: The Precision Time Protocol PTP is defined in IEEE 1588 (currently IEEE 1588-2019).
PTP allows for several degrees of freedom in an implementation. One of the implementation profiles is defined in IEEE 802.1AS(-2020) for the use with Audio-Video Bridging and Time-Sensitive Networking.
Answer: PTP is an IEEE Standard which means it is simply a published document establishing specifications. It is up to vendors to implement the standard.
Per Wikipedia's List of PTP implementations

Precision Time Protocol (PTP) is a widely adopted protocol for
delivery of precise time over a computer network. A complete PTP
system includes PTP functionality in network equipment and hosts. PTP
may be implemented in hardware, software or a combination of both.

Wikipedia's Precision Time Protocol page states:

IEEE 802.1AS is an adaptation of PTP for use with Audio Video Bridging
and Time-Sensitive Networking.


How to control the order of images displayed within a Google Photo Album?

Question: I want to be able to control the order of the images that are displayed in a Photo Album. I do not want them to be displayed vertically as well.  The use-case is to upload scanned images one by one and have them show in that order such that the person viewing the album can look at them in that same order. Is there a way to do that?
Comment: done. updated...
Comment: did you try to rename them if the ordering obeys the A-Z chrono order?
Comment: Good question: I did expect that it would obey the lexicographical order of the filename itself, but I tested it out by creating a new photo album from a bunch of images with numeric page numbers embedded in the file names, and it seemed to just list them in reverse order. Perhaps because the file timestamps will be in that order due to my conversion software I'm using. So I will recheck it by artificially changing the timestamps to be such that it maintains the same lexicographical ordering of the filenames themselves, and report back here.
Comment: @user0 That worked splendidly.  I had to cook up a script to change the timestamps on the files with a 60s difference in each, in reverse chronological order, but now the images show exactly how I want them to. If you post an answer, I'll mark it as the correct answer!
Comment: glad it helped.
Comment: @user0 Your answer is not correct as per my findings. It is not the lexicographical order of the filenames but their modification stamps on the filesystem when uploading from the host to the Google Photos. If you can alter our answer accordingly, I'll mark it as the answer.
Answer: One way would be to rename all your images in such a way that your desired order would match with lexicographical order of modification stamps on the filesystem when uploading from the host to the Google Photos as most of the Google products obey such sorting by default.
Answer: Unfortunately, we had thought that @user0's answer in https://webapps.stackexchange.com/a/130189/14529 was sufficient.  But I tried using that approach again and found it did not work. I speculate that at one time it did actually work, because I tested it out, but as of 2018-08-26, it does not affect the ordering.
So, from further experimentation, I determined that the GPS date/time stamp EXIF tags in the image files are what Google Photos seems to use for sorting the images in the album, and seems to ignore the modification or creation date EXIF tags.
So in order to fix this, in Ubuntu, I used the exiftool (you can install it via sudo apt install exiftool) in the following script (explanation follows afterwards):
#!/bin/bash

in_dir=/path/to/your/directory/full/of/image/files/with/EXIF/tags

t0=$(date +"%s")
find $in_dir -type f | sort -r -n | while read file
do
  echo "Processing $file ..."

  # Get the date/time stamp for the -AllDates option:
  t0_datetime=$(date -d "@$t0" +"%Y-%m-%d %H:%M:%S")

  # Get the date/time stamps for the -GPSDateStamp and -GPSTimeStamp options:
  t0_date=$(date -d "@$t0" +"%Y-%m-%d")
  t0_time=$(date -d "@$t0" +"%H:%M:%S")

  # Modify the EXIF tags for those dates, making them all the same:
  #
  #   It is not understood why -AllDates doesn't also modify the GPS date/time stamps.
  #
  exiftool -AllDates="$t0_datetime" -GPSDateStamp="$t0_date" -GPSTimeStamp="$t0_time" -overwrite_original $file

  # Modify the filesystem date/time stamps:
  #
  #   This is likely not really necessary but do it anyhow for consistency when examining the file listing on Linux:
  #
  touch -d "@$t0" "$file"

  # Go in reverse, by bumping back by a minute:
  ((t0 = t0 - 60))
done

What this script does: Find all of the image files (which should have names that sort lexicographically such as having page numbers of 001, 002, etc), sort them in reverse numerical order for those page numbers (sort -r -n), and calls the exiftool on each one to set the date/time stamp EXIF tags.  Each date/time stamp is separated by 60s (1 min), and I've not experimented with other time deltas to see if it matters. For my purposes of forcing Google Photos to sort them in order, the particular date doesn't matter, so I started with the current date and work backwards.


Navigation URL Rules for Intelligencia.UrlRewriter.dll

Question: I m using Intelligencia.UrlRewriter.dll for URL ReWritting
I wrote below line of code in web config.
<code><rewrite url="~/Reservation/" to="~/Division.aspx?DIV=5&amp />
<rewrite url="~/Tours/ " to="~/Division.aspx?DIV=10/>
</code>
Here my navigation steps are :
1.From Default.aspx i will click on URL Reservations
  In Default,aspx  Reservations
  corresponding code for Reservations in web.config is
< rewrite url="~/Reservation/" to="~/Division.aspx?DIV=5&amp>
---------This is working fine when i will click on link Reservations in Defaul.aspx It is redirecting to Division.aspx with path in browser written as
http://localhost/Test/Reservation/ .
2.When i will click on link Tours it should redirect to http://localhost/Test/tours/ .
In tours.aspx < a id="hlnav2_0" href="tours/"> Tours
But it is showing http://localhost/Test/Reservation/tours .
how to write rule to get required out put.
Answer: Removing the space from "~/Tours/ " may work.


Centaur as a race level adjustment

Question: So reviewing the centaur race from races of the wild I note that the race has a +2 level adjustment. It also states that thy start with 4 monstrous humanoid levels granting 4d8 hd. Does this mean a centaur begins play as an effective level 6 character?
Answer: Yes.
Here is the rule for effective character levels, from the SRD:

To determine the effective character level (ECL) of a monster character, add its level adjustment to its racial Hit Dice and character class levels.

Your centaur is effectively a 6th level character before taking any class levels. If they do take a class, they treat their "6 levels" of centaur as a favored class.
Comment: And please house rule in the PF favored class. Don't punish people for trying to escape an stereotype...

Centaur as a race level adjustment


Is there any way to unmerge meshes such as toes after remeshing?

Question: So, after remeshing to 0.01, for my human body, my toes ended up merging. When I tried to use the lasso trim tool to separate them, it just freezes my program and I'm forced to close down my program and reopen it. Is there any way to solve this?
Answer: I suggest before applying the remesh modifier, separate the toes to different meshes such that each one has the remesh modifier. Then add boolean union to the body with all the toes. I used "Fast" boolean to make things easier. This works okayish, you can then smooth and tweak the intersecting areas for finer results.


Do metabreath feats require a cooldown?

Question: There has been a bit of a discussion in our party. One player is playing a Dragonfire Adept. His class has given him quite a variety of breath weapons, and only one of them has an actual cooldown (and thus behaves like a normal Dragon breath attack.) He has taken a metabreath feat that has the pre-requisite of having a breath attack with a cooldown. Now that he has taken the feat, can he also apply it to breath weapons without a cooldown? I am currently not aware what the feat in question is, but will add that info when I find out.
Comment: The exact feat and its text is almost certainly necessary to answer this. I'm putting this question on hold until it's complete, to avoid having answers submitted that are well-meaning but turn out to be off-topic after it's updated.
Comment: I'm still interested in an updated question that explains which feat it is. One possibility is [here](http://rpg.stackexchange.com/q/34422/8610).
Comment: @SevenSidedDie I agreed with you, but then I did a little looking, and metabreath feats have a categorical answer to this, regardless of which is actually being used, so it's actually *not* unclear. I agree that it would have been a much better practice to have a complete question, but in this case it's not actually unclear.
Comment: @KRyan Oh cool, that's useful. Do you think there's any value in waiting for the update anyway, to ensure that the particular feat inspiring the confusion becomes searchable on RPG.se?
Comment: @SevenSidedDie I think the metabreath keyword should be sufficient, personally.
Comment: @KRyan Good point; done and done.
Answer: RAW: yes, he can use it
The rules for metabreath feats in Draconomicon (and the one from Dragons of Faerûn) state that they require a "breath weapon with a cooldown," which the dragonfire adept's breath weapon arguably lacks (some do make the argument that it has a 1-round cooldown, but Dragon Magic itself never describe it in those terms).
However, these same rules state that this is a requirement for taking and using the feat, but do not state that the effect of the feat applies only to such breath weapons. These feats add some number of rounds to the cooldown, but the wording they used to do so is, e.g. from Lingering Breath,

When you use this feat, add +2 to the number of rounds you must wait before using your breath weapon again.

Note how it doesn't even reference any "cooldown," it just adds some time before you can use your breath weapon. This effectively gives it a cooldown if it didn't have one.
Thus, RAW, a dragonfire adept arguably needs to get some second breath weapon that has a cooldown to take and use these feats, but once he's got one and has taken a metabreath feat, he can apply it to any breath weapon he has, including the dragonfire adept one, not just to the one he used to meet the requirement.
In practice, this may be a case of "the rules don't say I can't," but...
It's not uncommon for feats in 3.5 to have requirements that are more narrow than their effects, such as this case where you need a particular sort of breath weapon but the effect does not repeat that limitation and applies to just "breath weapons." It is pretty common to use RAW here, and accept that as how things work, but it is also a situation that may not sit well with some DMs.
However, at least in this case, the restriction of metabreath feats to only those breath weapons that have cooldowns seems unnecessary. It seems to exist to make them more "dragon-y," but the dragonfire adept is plenty dragon-y (at least as much as the dragon shaman, whose breath weapon definitely does qualify). It may also have been added thinking that it would be necessary to make the cooldown extensions work correctly, but as we've seen, the wording ended up such that they work just fine even if the breath weapon previously did not have a cooldown.
As such, I recommend allowing dragonfire adepts to use metabreath feats, and without making them jump through the hoop of getting some breath weapon with a cooldown. They aren't very powerful.
Also, side note: Races of the Dragon has "Breath" feats rather than "Metabreath" feats. These do not require a cooldown to begin with, and work just fine for a dragonfire adept, RAW and without hoop-jumping.
Answer: Draconomicon states that you need to have a breath weapon "whose time between breath is expressed in rounds. Therefore a hellhound (which can breathe once every 2d4 rounds) can take MB. feats, whereas a behir (breath weapon usable 1/minute) cannot." (Drac. p. 66) So all other types of time expression are explicitly ruled out (1/day etc.).
So if there is no explicit mention of rounds between uses of his breath weapon, he cannot take a metabreath feat by RAW. If he has at least one type of breath weapon with a "time between uses" given in rounds, he can take metabreath feats and apply the feat to all breath weapons he has, no matter the "cooldown".
As player breath weapons tend to not break the power bank, I see no reason to not let him use it that way.
Edit to address comments:
I think the important point is that the "cooldown" has to explicitly be given in a number of rounds. Thus the behir is excluded. From the rules it is impossible to "convert" minutes to rounds in this context, as the behir passage shows. If the DFA only has e.g.: "As a standard action, use this breath weapon", then RAW it would not be eligible to metabreath feats. Does this make sense? No. But this is the RAW.
Comment: Welcome to the site. Take the [tour]. While examples aren't rules, it's always struck me as odd that the description tries to bar the [behir](http://www.d20srd.org/srd/monsters/behir.htm) from taking metabreath feats when the behir has a breath weapon that's a "20-foot line, once every 10 rounds." Thanks for participating and have fun.
Comment: It seems to me that this answer is either missing a major point in the question, or its kind of burying the actual answer. The dragonfire adept in question already has a breath weapon that "has an actual cooldown (and thus behaves like a normal Dragon breath attack.)" Thus, the "If he has at least one type of breath weapon with a "time between uses" given in rounds," condition in the last sentence of the second paragraph is already known to be true, so the only part of this answer that directly relates to the situation in the question is the end of that sentence.

Do metabreath feats require a cooldown?


Mask web application ipaddress:port with domain name

Question: I have a node js web application running on static ipaddress with port 4000. I can access my application on the internet successfully using port forwarding in router, now I want to mask my public ipaddress+port with a domain name. By that, I have obtained a domain name in freenom and use cloudflare to create DNS record, it went smooth if my web application is running in port 80 and I can't change it to 4000, port 80 is already occuppied in our local server. What will I do to achieve my goal?
This is my CloudFlare DNS record
Answer: Cloudflare by default can proxy HTTP/HTTPS on a list of standard ports (source). See list below as of today.
If you would like to proxy on a different port (such as 4000), then you should consider using Cloudflare Spectrum which is designed for this scenario. Alternatively, change your application so that it uses one of the supported ports below.
Answer: you cant do port forwarding using dns an alternative solution is using a cloudflare tunnel inside your server and point your tunnel to port 4000 and add a cname record with the tunnel address
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).


What is the biblical basis for the rejection of purgatory?

Question: Often from protestants, I get asked the biblical basis for purgatory. But I want to flip the question around and ask protestants this: What is the biblical basis against the cleansing of the soul before full entry into heaven?
Comment: I don't regard this as a duplicate. This asks for a biblical basis, the other does not which is apparent in the answers.
Comment: @steveowen the accepted answer does list 3 scriptures
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/133722/discussion-between-luke-hill-and-spirit-realm-investigator).
Answer: The standard Protestant answer to this (from Protestants who really understand what purgatory is) is that Scripture says Jesus paid the penalty for all of our sins. Therefore, to say that we need to pay a temporal penalty for sins is heresy (essentially, they don't usually use that word). Here is a link to a gotquestions article about it.
Of interest is the fact that this phrase, Jesus died for ALL of our sins, to my knowledge is not in scripture. Scripture says that Jesus died for our sins, to be sure. And I would not disagree with the notion that, in a general and broad sense, Jesus died for all of them. However, as justification for rejecting a doctrine like purgatory, this argument seems weak, especially because the notion that Jesus died for all of our sins does not undermine the notions we have about justice in this life, namely that one who wrongs another must make temporal recompense (eg restoring money that you stole). Jesus died for your sin of theft. That absolves you from hell, to be sure. It most certainly does not mean you may keep the money you stole.
The linked GQ article cites two passages "Jesus died to pay the penalty for all of our sins (Romans 5:8). Isaiah 53:5" Neither of these state that Jesus died for ALL of our sins. Later, the same article states plainly that Jesus died for our sins and cites 1 Corinthians 15:3, which says "For I delivered to you as of first importance what I also received: that Christ died for our sins in accordance with the Scriptures."
Another GQ article making the same claim cites 2 Corinthians 5:21, which says "For our sake he made him to be sin who knew no sin, so that in him we might become the righteousness of God."
An unrelated Protestant site features an article making this claim and citing 1 Cor. 15:3, which you will see above says nothing about ALL sins.
Now, I haven't read every single verse on sin in the New Testament in order to sus out whether this phrase actually appears, but it seems to me that a Protestant making this claim would more likely than not cite such a passage instead of a weaker passage, if such a passage exists. I would be interested if someone could point me to such a passage.

Another common objection is that Scripture appears to plainly state that those who die go directly to heaven or hell, from the LCMS FAQ

QUESTION: What's the Lutheran response to the Roman Catholic teaching of purgatory?
ANSWER: Lutherans have always rejected the traditional Roman Catholic teaching regarding purgatory because 1) we can find no scriptural basis for it, and 2) it is inconsistent, in our view, with the clear teaching of Scripture that after death the soul goes directly either to heaven (in the case of a Christian) or hell (in the case of a non-Christian), not to some "intermediate" place or state.
What Scripture teaches concerning the death of the Christian is summarized as follows by Lutheran theologian Edward Koehler in his book, A Summary of Christian Doctrine:
In the moment of death the souls of the believers enter the joy of heaven. Jesus said to the malefactor: "Today shalt thou be with Me in paradise" (Luke 23:43). Stephen said in the hour of death: "Lord Jesus, receive my spirit" (Acts 7:59). Whoever dies in the Lord is blessed "from henceforth" (Rev. 14:13).

Here we see another problem. These are all particular examples. Nothing in the doctrine of purgatory precludes certain holy individuals from being admitted into heaven upon death. And in fact, the Catholic Church offers many means of receiving just such a grace, through indulgences. So, it is evident that the Catholic Church has no issue with the idea that at least some people go straight to heaven. Furthermore, it has always been Catholic teaching that the damned go straight to hell.
Luke 23:43 refers to the penitent thief, whose repentance at death's doorstep amounts to a baptism of desire. The Catholic Church teaches that those who are baptized are, at that moment, free from all sin. And, should they die at that moment, they go straight to heaven. Those who die with a legitimate baptism of desire have the same experience.
Acts 7:59 refers to Saint Stephen's martyrdom. The Catholic Church has always taught that legitimate martyrs do not go to purgatory and instead go straight to heaven.
With the above verses put in context, citing Rev. 14:13 loses a lot of the weight it had, especially since it is a very non-literal writing. Alone, it is insufficient to promote the idea that all souls go to either heaven or hell and nowhere else immediately upon death. In light of a passage like Matt 5:25-26, it seems it should be interpreted according to Catholic tradition.
Comment: This does not answer the question. The question asked Protestants for biblical support against purgatory. Your answer is a support of the Catholic Church's assertion of purgatory. Nor have you cited the main texts _against_ purgatory. The question was asked of Protestants . . . .   and you are not one. And your answer is biased.
Comment: I cited two mainstream protestant sources form two mainstream protestant denominations. If you feel I've missed the main texts against purgatory, take it up with those websites. If you feel that you can answer the question better, then please submit an answer. I have no problem admitting I am biased; I think anyone offering an answer to this question will be.
Comment: Job 11:6 has Zophar telling Job "Know this: God has even forgotten some of your sin." If you read Zophar's argument, Job's rebuttal and expression of a need for someone to ransom all his sins and God's answer that the friends spoke incorrectly about him, you have a strong argument that God forgives all sins as a result of the actions of the promised savior.
Comment: @PaulChernoch I don't dispute that God does, ultimately, forgive all sins of the blessed. What I reject is the notion that these are all forgiven in an instantaneous act or without any inclination of the will on the part of Christians towards forgiveness. My point about the bible not mentioning the forgiveness of ALL sins was merely a minor observation that some Protestants rebut claims about purgatory with this claim, but the verses they cite don't say what they are saying (for this one claim).
Answer: What is the biblical basis against the cleansing of the soul before full entry into heaven?
The idea of some place or state between death and the new life is not biblical, but requires some reading-in of such ideas. Without these ideas, we have a clear revelation of the process God has planned - including both those called in this life, and those called in the next.

But now, having died to what bound us, we have been released from the law, so that we serve in the new way of the Spirit, and not in the old way of the written code. Rom 7:6

Being released from the law - the law of what? Of sin and death - the death caused by sin. The law requires a life to pay for sin - unless a perfect, all inclusive sacrifice is offered, each must pay their own penalty - death.

For in Christ Jesus the law of the spirit of life set you free from the law of sin and death. Rom 8:2

So if there is no longer a law of sin and death caused by sin, there is no need for further forgiveness - obviously for those so included in Christ - the sheep.

reckon yourselves to be dead indeed to sin, but alive to God in Christ Jesus our Lord. Rom 6:11

Those who are counted in Christ are alive! We are to 'reckon' ourselves in such a state of new life - yet to be fully experienced, but by the deposit (2Cor 1:22) of spirit in us, it has begun in this life but by no means finished.

I am the resurrection and the life. The one who believes in me will live, even though they die John 11:25

Plainly, once death for those in Christ has occurred - either in reality and in the grave, or figuratively through baptism etc, then the new life has commenced and they will be raised or transformed at Jesus' return. There is no need for other complex arrangements. Nor is there any support for going to heaven and being cleansed when we get there, the raised and transformed saints will rule with Christ on earth. 1Cor 6:2, Rev 20:6
Allowing another construct would contradict these and many more texts that speak the same thing - by Jesus' death, sin is resolved. It does not need to keep being resolved for the faithful.
Those NOT in Christ at his return will be part of the nations Jesus and his saints will rule over for 1000 years. After this, Satan is released and there will be a resurrection to judgement - not to condemnation - judgement. Yes, all are found guilty, but the resurrection is an offer to repent. Having been made aware of the deception (Rev 20:2), they may now freely choose choose life for the first time OR death and go to the second death which eliminates them forever. The erroneous idea that one may somehow choose God while totally deceived is without merit or scriptural support. The Father calls and makes truth available to each in His own time. Removing the devil and his deception from amongst humanity is a general calling to truth for all 'unbelievers' after the first resurrection.

Jesus said, "This is why I told you that no one can come to me unless the Father has granted it to him." John 6:65 (2Pet 3:9, 1Tim 2:3-4)

Those in Christ have been judged already!

Truly, truly, I tell you, whoever hears my word and believes Him who sent me has eternal life and will not come under judgment. Indeed, he has crossed over from death to life. John 5:24
Comment: Interesting, I've never encountered the claim that the unrepentant have another chance to repent at the resurrection. Where does this idea come from?
Comment: Did I say, "another chance"? no. If you think the deceived can choose Christ on their own wit and wisdom - this is not biblical either. God calls them and gives them to Christ - he will offer this to all according to His plan - not the church's plan.
Comment: But you do write that ***"the resurrection is an offer to repent."*** That seems to imply a second chance!
Comment: Yes, it is a chance to repent - otherwise He might as well leave them dead. If you think it's a second chance that's for you to work through, but that is not what the bible says or implies. Why bother with binding Satan/deception if they are going to die *again* anyway!?
Comment: @steveowen how is the resurrection a chance to repent, but at the same time wrongly called a second chance?


What does `$hash{$key} |= {}` do in Perl?

Question: I was wrestling with some Perl that uses hash references.
In the end it turned out that my problem was the line:
$myhash{$key} |= {};

That is, "assign $myhash{$key} a reference to an empty hash, unless it already has a value".
Dereferencing this and trying to use it as a hash reference, however, resulted in interpreter errors about using a string as a hash reference.
Changing it to:
if( ! exists $myhash{$key}) {
  $myhash{$key} = {};
}

... made things work.
So I don't have a problem. But I'm curious about what was going on.
Can anyone explain?
Comment: In current Perl it would be `$myhash{$key} //= {}` most likely.
Answer: Perl has shorthand assignment operators. The ||= operator is often used to set default values for variables due to Perl's feature of having logical operators return the last value evaluated. The problem is that you used |= which is a bitwise or instead of ||= which is a logical or.
As of Perl 5.10 it's better to use //= instead. // is the logical defined-or operator and doesn't fail in the corner case where the current value is defined but false.
Answer: The reason you're seeing an error about using a string as a hash reference is because you're using the wrong operator. |= means "bitwise-or-assign." In other words,
  $foo |= $bar;

is the same as
  $foo = $foo | $bar

What's happening in your example is that your new anonymous hash reference is getting stringified, then bitwise-ORed with the value of $myhash{$key}. To confuse matters further, if $myhash{$key} is undefined at the time, the value is the simple stringification of the hash reference, which looks like HASH(0x80fc284). So if you do a cursory inspection of the structure, it may look like a hash reference, but it's not. Here's some useful output via Data::Dumper:
   perl -MData::Dumper -le '$hash{foo} |= { }; print Dumper \%hash'
   $VAR1 = {
             'foo' => 'HASH(0x80fc284)'
           };

And here's what you get when you use the correct operator:
  perl -MData::Dumper -le '$hash{foo} ||= { }; print Dumper \%hash'
  $VAR1 = {
            'foo' => {}
          };

Comment: $Data::Dumper::Useqq=1 can be important; by default, DD will spit out strings that include characters not immediately identifiable to the eye.
Comment: Always use `Data::Dumper`, when debugging.
Answer: I think your problem was using "|=" (bitwise-or assignment) instead of "||=" (assign if false).
Note that your new code is not exactly equivalent.  The difference is that "$myhash{$key} ||= {}" will replace existing-but-false values with a hash reference, but the new one won't.  In practice, this is probably not relevant.
Answer: Try this:
my %myhash;
$myhash{$key} ||= {};

You can't declare a hash element in a my clause, as far as I know. You declare the hash first, then add the element in.
Edit: I see you've taken out the my. How about trying ||= instead of |=? The former is idiomatic for "lazy" initialisation.
Comment: Silly me. ||=.

I blame a few months' resting from Perl, in other languages.


Parsing JSON on google app engine (java)

Question: i use org.json library to work with JSON-data in my apps. But it seems that google app engine doesn't allow to use it, what's the best way to work with JSON on GAE-apps?
Answer: I had the similar question a week ago and after comparing a number of Java JSON libraries (including JSonLIB and GSON) I have chosen Jackson. Check other comparisons on StackOverflow, most of them would recommend Jackson out of the rest.
After two weeks using it on Google Appengine, I just love it. Not only it has more features than the other mentioned libraries, it is also much faster (see benchmarks here). It is a Json engine in Jersey which I would recommend as well if you want to do anything  Restful on Appengine.
It is stable and still actively developed, with version 2 has just been released couple of weeks ago.
UPDATE: here is a sample demo for using Jackson with GAE.
Comment: People considering using Jackson with AppEngine should also take a look at https://github.com/icoloma/jackson4gae/ to serialize AppEngine classes. (Fair warning: I'm the developer, but it still is a common need for GAE+Jackson projects)
Comment: The last sample link is rotten. The description is in the answer is unclear to me and I am unable to follow it.
Answer: try Gson
http://code.google.com/p/google-gson/
Answer: I hope this helps
you can also the google-json api here
Comment: First link has rotten. Unless someone can provide its content, the answer is not useful now.
Answer: Use fast JSON is a very productive API. Jackson take too much code.
http://code.alibabatech.com/wiki/display/FastJSON/Home
https://github.com/alibaba/fastjson
Just copy the library into WEB-INF/lib folder and use the static methods of com.alibaba.fastjson.JSON like JSON.toJSONString(object)


Is there a standard wallet format?

Question: Is there a standard wallet format that can be read with different bitcoin clients, and that is likely to be compatible to future bitcoin clients as well and thus is usable for long term storage of bitcoins? Or how am I supposed to transfer bitcoins between different bitcoin clients/computers/client versions?
Comment: The existing wallet.dat is likely to not be used at some point in the future by Bitcoin-Qt even.
Answer: There is the Wallet Import Format, which should be a standard for Bitcoin wallets. As to how popular it is, I don't have any data on it. Alternatively, storing the raw private key should suffice, as it can be converted to any other fancy format whenever needed.
Comment: The wallet import format for private keys is by no means a format for wallets. Wallets contain transactions and keys, in its most basic form, and tons of metadata.

Is there a standard wallet format?


closing a command line window in Java

Question: I have created a small Java application in which there is some code that executes a batch file. The execution of the batch file leads to the command line window to be opened and to display some output messages. I would like to know if there is some way in Java to call this command line window to be closed from within the program...Thanks!
Comment: maybe an example or more details would help to understand the real problem... Do you really need a batch file? Is it not possible to run the commands directly from Java?
Comment: Many answers seem to misunderstand the question. This is *not* about how to close the window after the command terminates, and *not* about avoiding a command window for the java process; it's about avoiding a command window for a bat launched *by the java process* (using `Runtime.exe` or similar, I presume).
Answer: the command window should close automatically when the batch file completes.
and to run a batch file in background/invisibly, check other questions
Answer: Start java by using javaw or javaw.exe.
java (java.exe) runs with an associated console window,
javaw (javaw.exe) is the same but without the console window.
see the documentation for the java command.
On Windows also use start to invoke another shell
start javaw ClassName

I'm not sure for Linux&Co. Try using an & after the command to run it in the background
javaw ClassName &

The other way, closing the window from a batch started by Java:
I don't believe that is possible directly from within Java. You can only close the batch file by itself.
Is hard to help without knowing what that batch file is doing. You may try using the start command on windows or the & in Linux to run the process in the background (start has an option to open the window minimized [/MIN] or in the background [/B]).
Or try some hack like using AutoHotKey or some system functionality (some WinAPI-DLL or equivalent in other systems).
Comment: That's not the question. The question is about a bat file launched *from the java process*, not about java.exe's command window.
Answer: As an addition to NimChimpsky's answer:
If you run a batch file in Windows, Windows will automatically open a command window for the batch file, in case the batch file wants to print output or prompt for input. This also applies if you launch the bat file from a Java process.
Unfortunately, Windows itself apparently provides no way to launch a batch file without such a window. To avoid the window, you will have to run the batch file via some helper program. There are several available; google for "run bat no window" to find some.
If you just want the window to go away after the batch file terminates: That should happen automatically. If it does not, some program launched by the batch file is still running.
Answer: start /b [bat file name]
Comment: This is the way to run a bat file without opening a new window *from within an existing batch file* (i.e. while running inside `cmd.exe`). You cannot use this to directly launch a batch file from e.g. Java. You could use an intermediate batch file which just contains the "start" line, but *that* batch file would still quickly flash a window...
Comment: I haven't tried it myself, but if the java program is running in cmd window, would it still do the same?

closing a command line window in Java


How do I place a call from my original phone number if Google Voice is the default handler?

Question: I have a AT&T Galaxy SII running CM9 and primarily use my Google Voice number and all of the Google Voice integration on the phone. I'd like to be able to place a call using my native (non-GV) number. Is there any way that I can place a call without using Google Voice?
Answer: Not sure if you mean you still want to use GV services, but with your phones' native number? Or do you mean you want to completely circumvent using GV sometimes?
If you meant still use GV, but with your native number:
Voice->Settings->This phone's number
Then just choose your phone's native number (you're still using GV services, but caller-id will show your phone's number, not your GV number).
If you meant completely circumvent GV and use your phone as if GV wasn't installed:
Voice->Settings->Making calls.
choose either Do not use Google Voice to make any calls or Ask every time I make a call
Comment: It was the second option I was looking for, circumventing GV completely for some calls. I had been hunting through the system settings and dialer settings and not finding the proper option. Thanks!


should question about HTML5 be on topic?

Question: I would say that asking about HTML5 is not within the scope of the site, as opposed for example to EPUB3: but I'd like to know what other think about it.
Answer: I think it will depend on the context of the HTML5 question, but in many cases, yes. For example, many web-based reader software, such as the Kindle Cloud Reader and the Kobo Cloud Reader are developed in HTML5.
There is a decent blog here about the relevance of HTML5 (and EPUB3) in the future of electronic reading.
Quick intro excerpt:

Digital Publishing is one of the fastest growing segments and most
  major publishers are now seeing 21% of their total revenues stem from
  it. Publishers cannot decide on what the future of publishing will
  entail. There are three main aspects that the vast majority of
  companies employing for their strategy. We are seeing strong growth
  with dedicated e-reading apps, HTML5, and ePub3/ePub2 as the main
  factors for content delivery. In the next three weeks, we will be
  talking to some of the leading digital publishers that are currently
  living in this space. They will be talking  about the future and
  current state of digital publishing and how the industry will look in
  2013-2014.
Answer: Ebook authoring is considered one of the on-topic areas of the site. By extension, so too will be HTML(5) in the context of writing ebooks. Questions purely about HTML would be off-topic here.
Comment: +1 for *"in the context of writing ebooks"* and I think you should emphasize that part? By extension, off-topic examples would include questions about http, servers, domains, SEO, etc.?