Can I shut off pump, stop chemical maintenance on pool that's going to be drained and refaced in 6 months?

Question: I live in temperate climate (Northern California) and have an 40 year old outdoor gunite pool. Currently we have a pool pump running 24/7 and use a service to maintain chemical balance weekly.
I plan to have the pool acid-washed and refaced in about 6 months and won't use it before that. Do I need to keep the pool pump running or continue with ph maintenance until repairs? If so, why?
Thanks!
Comment: Get on Google Earth, roll it back to about 2009 and scroll around your area.  See any green pools?   They were a big thing back then, caused by foreclosures where people walked away and didn't maintain their pools.  Mosquito breeding grounds, the cities acually had to fly aircraft around looking for them, and intervene.
Comment: Nearby municipalities have restricted filling of new pools with potable water. There might be a way to sell your current water now.
Comment: If the pump has a timer you can reduce the amount of electricity by scheduling. How much? Hard to answer.. Sunlight burns off chlorine.  Is it a salt water pool with chlorine generator? Or are you manually chlorinating?  Do you have a cover?  All are factors on how much to reduce pump time.
Answer: Your best bet would be to drain the pool, flush your plumbing and then blow it out. Then leave your drain open for rain, etc... Resurfacing your pool with algae or other nasty stuff would require more steps to remove then first to make a clean surface.
Answer: 6 months is a long time to go without chemical maintenance.  You will end up with an algae pond if there is any water in it at all, and that includes rain.
However, if you are going to completely reface the pool then it won't matter.
But algae could get into the plumbing and pumps so they will need to be flushed, dried, and capped off.
Answer: To avoid breeding mosquitoes, you need to keep it chlorinated. To keep the chlorine from burning off too quickly, you need to keep it filtered.
Or you could try stocking it with fish that will eat the skeeter larvae, I suppose. It is very unclear the health department will approve that or whether anyone has studied it, but if you insist, that would be worth investigating. Of course that may cost more than normal pool maintenance does, and you would have to deal with wildlife hunting your fish.


PDF reader problems

Question: I've got a PDF document that I would like to be able to read... but for some reason a number of the embedded pictures and graphs don't display cleanly when opened in evince or okular on Ubuntu 13.04 (they display normally in Adobe Acrobat Reader on Windows 7).  I've tried downloading and installing Adobe Acrobat Reader 9.5 and FoxIt Reader 1.1 in .deb format and get warnings about bad packaging format, etc. Even when I click thru to install anyway, the install process would hang up over and over again.
Are there any other viable options out there?
Just for reference, here is a download link for the offending file if anyone cares to test it on their machine (warning - 67+MB file):
EPRI Power System Dynamics Tutorial
Answer: I can confirm the issue on Ubuntu 12.04 with Evince 3.4.0 installed. Given how this occurs both under Evince and Okular it's likely an issue with the PDF backend, libpoppler. You might want to report a bug and link to the sample file. That's the only surefire way to get this fixed.
As a workaround I would advise to use Chrome's inbuilt (and proprietary) PDF viewer. Also, you should be able to install Adobe Reader from the Ubuntu Software Center. It should take care of all the dependency issues automatically.
Comment: I'm not seeing any entry for Adobe Acrobat Reader in the Software Center, and when I download it directly from Adobe's site (in .deb format) it generates errors about bad packaging - wrong uid, etc.  Is it possible to open an already downloaded PDF in Chrome (or Chromium) like mentioned below for Firefox?
Comment: I looked into filing a bug report against poppler w/ the cairo backend (which is what evince reports)... looks like there already is one, just need an updated version of poppler.   https://bugs.freedesktop.org/show_bug.cgi?id=70085
Comment: @memilanuk I am not quite sure - because it has been a while - but I think you have to activate the ["partners" repository](http://askubuntu.com/questions/14629/how-do-i-enable-the-partner-repository) first. Acrobat reader should appear in the USC after that. Alternatively you could try installing it from the CLI with `sudo apt-get install acroread`. As far as the web browsers are concerned: Yes, with Chrome you can just drag your local PDF file to a tab and it should open it in Chrome's inbuilt PDF viewer. I suppose the same method would work with FF as well.
Comment: @memilanuk Also if you decide to upgrade poppler and still experience the same issues you should definitely look into reporting a bug of your own. Oftentimes patches that might fix rendering in one sample file won't translate to others because the underlying issue is completely different.
Comment: Ah.  Guess I didn't have the 'partners' repo enabled... now I have Adobe Reader installed, and everything displays as it should.  Thanks!
Answer: If you are using Firefox, what happens if you drag and drop the pdf in the browser?
(Firefox has a builtin pdf viewer)
Comment: I knew FF had a built-in PDF viewer (pdf.js) for files from the web, but I didn't realize I could drag-n-drop a file from my desktop *into* a FF window and view them that way...  sweet!
Answer: I tried to open your file with Evince and embedded graphics are not display clearly. But it did not happen with Foxit Reader 6 on Wine. So this is a bug of Evince. Don't worry!

PDF reader problems


Unified place for resources used in XAML and cs files?

Question: It happens that I define a ResourceDictionary for the app colors to use it in XAML files, and have a static class for these colors to use in the cs code:
for example:
<ResourceDictionary
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyApp.Themes.AppTheme">
    <Color x:Key="BrandColor">#ffd92e</Color>
    <Color x:Key="BgColor">#343433</Color>
</ResourceDictionary>

And the opposite class:
public static class AppColors
{
    public static readonly Color BrandColor = (Color)Application.Current.Resources["BrandColor"];
    public static readonly Color BGColor = (Color)Application.Current.Resources["BgColor"];
}

Another scenario,I use icons font in both xaml and cs,
in XAML it looks like , and in cs it's: \ue8d5 . I want to save them in a file where I can reference them by a meaningful names in XAML and cs like:
IconBell = \ue8d5
Is it possible to define resources like those in one place and use them in both XAML and code?
Comment: Yeah ,it is possible. However be sure that static class `AppColors` can invoke the
wanted `Resources[...]` . **Xaml** directly using `{StaticResource TabColor}`,**.CS** using `Resources ["searchBarStyle"]` or your defined static class(Label.TextColor = AppColors.BrandColor  ).If need to convert value,you can use `IValueConverter` to do that.
Answer: About the colors issue, it's very easy to solve it. You basically have to create a class containing your colors, and reference it in your XAML, with the x:Static extension.
You can do the same for solving your icons issue, but you'll probably need to create a converter for using it in XAML. For example, the important part of your icon value is the "e8d5" part, but in C# you use the "\u" and in the XAML you use the "&#x". You'll have to create a class with the icons, reference it in the XAML using the x:Static extension and use a converter to convert from C# to XAML, for example:
public class IconConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        try
        {
            string icon = System.Convert.ToString(value);
            return icon.Replace("\u", "&#x");
        }
        catch (Exception)
        {
            throw new InvalidCastException("The value is not a valid string.");
        }
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }
}

With this, you can unify your styles in a unique C# class, and just reference it in your XAML.


Old house wiring: black, white and brown

Question: I need to install a socket in an old house which has three wires with faded colors I interpret as black, white and brown. I've determined that black is the hot one using a multimeter. The instructions I have for the socket are for black, white and green. Should I assume that I should wire the brown one as 'green'?
The colors below are faded but the hot "black" one is on the right, the "brown" one top left, the "white" one bottom left. This is in Austin, TX, USofA. The house was built in 1980.
Comment: Can you post photos of the wiring in question please?
Comment: Is the brown wire bare with no insulation/covering on it, or does it have brown wire covering?  Ground wire is a bare wire or has a green covering.
Comment: Despite the focus issue, it's clear from the picture that the "brown" wire is simply bare copper that's oxidized - there's no insulation/covering on it. Might be some brown kraft paper, but that's not really "on" the wire.
Comment: Brown wire covering
Comment: What part of the planet is this? In my part of the planet I'd guess from "old house" that it's an ungrounded system with black, white, and faded red that you see as brown. Please [edit] to add pictures and inform us where on the planet you are.
Comment: Added photo and updated the question.
Comment: Well I never... I did a 'tap test' and heard a clinging, metallic sound. So that's the bare grounding wire. Thank you that answers my question.
Answer: No, you should never assume anything about a wire based solely on its color. Get a multimeter and check actual voltage and/or actual connection to a known ground.
Comment: I was about to say that this should be a comment, but, to be fair, this exactly answers the question asked.  +1 OP just needs to ask a better question... ;)
Comment: I've already checked the voltage with a meter. That's how I was able to determine that the black one is the hot one. Not sure what else I can check.
Comment: @FreeMan "OP just needs to ask a better question". Any suggestions to how to make my question "better" would be appreciated.
Comment: They only question you asked, @Ya. was "Should I assume that I should wire the brown one as 'green'?" and this directly and correctly answers that question. Your question, after several edits, is much better.


The purpose of the question is to find out how H (harmonic mean) departs from A (Arithmetic mean).

Question: The purpose of the question is to find out how H (harmonic mean) departs from A (Arithmetic mean).
$A= \frac{x1+x2+x3}{3}$ and $H= \frac{3}{1/x1+1/x2+1/x3}$
To that end, assume that: $x1=A+e1,x2=A+e2, x3=A+e3$, and write a Taylor expansion to order 2 of: $1/x1$ and $1/x2$ and $1/x3$. then the expansion of H with respect to e1, e2, e3 supposed to be small quantities.
Show that, $A-H \stackrel{}{\approx}  \frac{e1^2+e2^2+e3^2}{3A}$ + terms of higher order
I have tried expanding the taylor series of second order and inserted them in H and then proceeded to A-H but the form requested still did not apear, I am not sure what to do.
Answer: Let $x_1=x_2-\Delta$, $x_3=x_2+\Delta$
$$A=x_2 \qquad \text{and}\qquad H=x_2 \left(1+\frac{2 \Delta ^2}{\Delta ^2-3 x_2^2}\right)$$
$$A-H=\frac{2 \Delta ^2 x_2}{3 x_2^2-\Delta ^2}\sim \frac23{\frac{\Delta ^2} {x_2}}=\frac23{\frac{\Delta ^2} {A}}$$


JsPlumb not working in ASP.net MVC

Question: I wanted to learn JsPlumb by following the example as below:
http://jsfiddle.net/aT63t/161/
I try to include this in ASP.NET MVC 4. However, it throws me with the exception of
<code>0x800a1391 - JavaScript runtime error: 'jQuery' is undefined
</code>
in my jsPlumb 1.4 version.
My jQuery version updated to latest 2.0.3 and Jquery UI with 1.10.3
Anyone have this issue before? Any idea how to fix it?
Comment: Are you sure your jQuery is loaded and linked to correctly? Check your browser console.
Comment: My mistake... the jQuery loading problem...
Answer:
make sure you've referenced jQuery in your page.
make sure that you first reference jQuery and jsPlumb after Order is important
should be like this: jQuery, jQuery UI, jsPlumb
in chrome right click the page "View Page Source" and click all the .js references to check if they are loaded, also check that you have jQuery referenced just once

JsPlumb not working in ASP.net MVC


How can I open files with spaces in their names via wine app?

Question: I have .desktop file for a wine-like app that opens MS Word:
[Desktop Entry]
Type=Application
Version=1.0
Icon=x-vmware-564d5302e9430a5d-1416be4d2596d246-Microsoft-Word-2010
Terminal=false
StartupNotify=false
NoDisplay=false
Name=Microsoft Word
StartupWMClass=Microsoft Word
Exec=vmrun -T player -gu alx -gp 123 runProgramInGuest "/home/alx/vmware/office/windows-7.vmx" -activeWindow -interactive "c:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE" Z:\lin%f
Comment=Run 'Microsoft Word 2010' in the virtual machine 'windows-7'
Name[en_US]=Word

It successfully opens docs, except the docs with names what contain spaces, it shows the error that cannot find such files, and in path it replaces spaces with %%20. Is it possible to somehow say: dono't convert spaces into %20 in file names?
Comment: Are you sure it's not the `Z:\lin` prefix that's causing the target file to be not found? I'm not sure why you'd need that (I don't use wine), but if you *do*, the backslash probably needs to be escaped or protected with quotes.
Comment: lin - is shared folder inside Win VM, the path to host files from VM i starting from Z:\lin\  the rest path - is path of file that i am trying to open. so example of file path that opens fine: `Z:\lin\home\alx\docs\myword.docx`  example of file path that couldnt be opened: `Z:\lin\home\alx\docs\my word.docx`, so in Word app error shows incorrect file path: `Z:\lin\home\alx\docs\my%20word.docx`
Comment: ps. funny is that spaces is not a problem for Excel app, it opens files with spaces  in names, just with the same .desktop configuration, might be it related to WINWORD app itself?
Answer: Alright, I sorted it out.
To correctly open MS Word docs including files with spaces in their names, we need to do 2 things:

create a sh wrapper that will start WINWORD app with correct parameters:

#!/bin/sh

vmrun -T player -gu alx -gp 123 runProgramInGuest ./vmware/office/windows-7.vmx -activeWindow -interactive "c:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE" "$(echo "$@" |sed -e 's;C:;Z:;' -e 's:/*/:\\\\:g')"

Modify the Exec line in the .desktop file to point to the wrapper above:

Exec=./bin/wordwrapper.sh Z:\\\lin%F

Where lin - shared folder inside windows VM for accessing host machine files, in case of Wine, there should be only Z:%F


How do I get to the loot in Earthen Peak poison pool?

Question: I have finished Earthen Peak (and drained the poison pool, of course). Now I was returning there on a whim and I noticed there is a pool of poison with loot and player messages. It's the pool where you can run just to the right, get ambushed by a Manikin and open the first Pharros lockstone of Earthen Peak.
How is it possible to get there? I can see player "shadows" running around in the pool so clearly it must be able to get there.
Answer: To empty the poison pool, you need to burn the windmill near the second last bonfire. You can do this by using a flame butterfly, or the torch (you can light it from the bonfire).
Once you do so, any pools of poison will be drained, including the boss room. There are several corpses that can be found in the pool, and the boss will lose her ability to regenerate. (There is still a ring of poisonous liquid around the edge of the boss room however).

As per your edit, that particular "pool" is inaccessible - basically; it's a killzone. If you can see player "Shadows" jumping in there, they are leaping to their deaths.
There is a small ledge off to the side, that leads to a small area full of Manikins that you can jump to, with a very well-aimed jump, but that pool of poison is not meant to be entered.
Comment: As I said in my OP I haver already drained the pool, that is I have burned the windmill. The pool I'm talking about is not empty DESPITE burning the mill.
Comment: @Sandokan Ohh. Yeah, you can't get into that pool. There is nothing in there, and if you ever do jump in there, you die.
Answer: Did you burn the windmill? According to this video, you need to burn the windmill towards the beginning of the level to clear the poison.
You can see where to burn the windmill here.  Looks like you'll need a fire butterfly.
Comment: As I said, I have burnt the mill
Comment: @Sandokan you should include a screenshot of the exact poison pool in question then - all sources seem to point to burning this windmill to drain the poison.
Comment: Added a screen shot to it


How to include "Empty" constant in class

Question: I have a class and I would like to include an "Empty" constant member similar to Point.Empty in System.Drawing. Is that possible?
Here's a simplified version of what is giving an error:
public class TrivialClass
{
    public const TrivialClass Empty = new TrivialClass(0);
    public int MyValue;
    public TrivialClass(int InitialValue)
    {
        MyValue = InitialValue;
    }
}

The error given is: TrivialClass.Empty is of type TrivialClass. A const field of a reference type other than string can only be initialized with null.
If it matters, I'd like to use it like this:
void SomeFunction()
{
    TrivialClass myTrivial = TrivialClass.Empty;
    // Do stuff ...
}

Comment: `yes I know this is .NET and there is no Main` Think again....
Comment: @I4V thank you for the insight. Interesting and I'll look into that later but I fail to see how that helps with the question.
Comment: @AppFzx: He's just saying that .NET *does* use a static `Main` method as the default entry point.
Comment: @mellamokb Thanks. I changed it since it was a confusing name.
Answer: You can use static readonly for these types. Constants can only be initialised with literal values (e.g. numbers, strings).
public class TrivialClass
{
    public static readonly TrivialClass Empty = new TrivialClass(0);
    public int MyValue;
    public TrivialClass(int InitialValue)
    {
        MyValue = InitialValue;
    }
}

After looking up the definition. Point.Empty is also static readonly. Reference here.
Comment: Whether or not `const` can be used has nothing to do with whether it's a reference type or a value type.  You can only assign a compile time constant to such an identifier.  For any reference value that is a compile time literal (i.e. `null` or any string literals) those can work.  For value types, they still need to be compile time literals (meaning pretty much just numeric types).  `default(...)` is not a compile time literal.
Comment: @flem I already mentioned string as a reference type, and `char` is a value type, not a reference type, but yes, there are compile time literals for characters.
Comment: Oh, and `Point` is not a reference type, it's a value type.
Comment: @Servy. Typo on my part. That paragraph may make more sense with that correction. Thanks!
Answer: Just a quick shoot, but I would suggest that Point.Empty is a static member, not a constant:
public class TrivialClass
{
    public static readonly TrivialClass Empty = new TrivialClass(0);
    ...
}

Comment: You're right, `Point.Empty` is static. It's also readonly. See my answer.


Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse () at XMLHttpRequest. ((index):32)

Question: Hi I'm currently learning how to user Javascript, JSON and PHP for a class an I'm having an issue with my code here. it's telling me that there is an Uncaught SyntaxError: Unexpected end of JSON input at JSON.parse ()  at XMLHttpRequest. ((index):32) I'm trying to incorporate this php function to make a restful api.
let xhr = new XMLHttpRequest();
        xhr.open("GET", 'api/', true);

        xhr.addEventListener("load", function () {
            let posts = JSON.parse(xhr.responseText);
            let ul = document.createElement('ul');
            document.querySelector('#app').appendChild(ul);

            for (let i = 0; i < posts.length; i++) {
                let post = posts[i];

                //lists the id
                let idLi = document.createElement('p');
                idLi.textContent = post.id;
                ul.appendChild(idLi)

                //lists the user
                let nameLi = document.createElement('p');
                nameLi.textContent = post.name;
                ul.appendChild(nameLi)

                //lists the posts
                let postsLi = document.createElement('li');
                postsLi.textContent = post.text;
                ul.appendChild(postsLi);

                //lists the likes
                let likesLi = document.createElement('p');
                likesLi.textContent = post.likes;
                ul.appendChild(likesLi)

                //lists the post dates
                let post_dateLi = document.createElement('p');
                post_dateLi.textContent = post.post_date;
                ul.appendChild(post_dateLi);

                var likeBtn = document.createElement('BUTTON');
                likeBtn.id = 'likeBtn'; //set the id of the btn to call
                var likeBtnText = document.createTextNode("Like");
                likeBtn.appendChild(likeBtnText);
                ul.appendChild(likeBtn);

                likeBtn.addEventListener('click', function () {

                }, true);
                var dislikeBtn = document.createElement('BUTTON');
                dislikeBtn.id = 'dislikeBtn'; //set the id of the btn to call
                var dislikeBtnText = document.createTextNode("Dislike");
                dislikeBtn.appendChild(dislikeBtnText);
                ul.appendChild(dislikeBtn);

                likeBtn.addEventListener('click', function () {

                }, true);
                var replyBtn = document.createElement('BUTTON');
                replyBtn.id = 'ReplyBtn'; //set the id of the btn to call
                var replyBtnText = document.createTextNode("Reply");
                replyBtn.appendChild(replyBtnText);
                ul.appendChild(replyBtn);

                replyBtn.addEventListener('click', function () {

                }, true);
            }

        });

        xhr.send();
    </script>

    class Handler {
    private $regex;
    private $func;
    private $method = null;
    public function __construct($regex, $method, $func) {
        $this->regex = $regex;
        $this->func = $func;
        $this->method = $method;
    }
    public function handle($url, $method) {
        $params = null;
        $f = $this->func;
        // todo: also check whether the method matches
        if($method !== $this->method)
        {
            return FALSE;
        }
        // preg_match does a regular expression match in PHP
        if(preg_match($this->regex, $url, $params)) {
            $f($params);
            return TRUE;
        }
        return FALSE;
    }
}
class Router {
    private $handlers = array();
    function register($regex, $method, $function) {
        $this->handlers[] = new Handler($regex, $method, $function);
    }
    // TODO: Add get, post, put and delete register
    function get($regex, $function)
    {
        $this->register($regex, 'GET', $function);

    }
    function post($regex, $function)
    {
        $this->register($regex, 'POST', $function);
    }
    function put($regex, $function)
    {
        $this->register($regex, 'PUT', $function);
    }
    function delete($regex, $function)
    {
        $this->register($regex, 'DELETE', $function);
    }
    function route($url, $method) {
        $params = null;
        foreach ($this->handlers as $handler) {
            if($handler->handle($url, $method)) {
                return;
            }
        }
    }
}
$router = new Router();

And this is the code that is using the methods from the router and handler
$router->get('#^/api/(\d+)#', function($params) {
$conn = new PDO ($DB_DSN,$DB_USER, $DB_PASSWORD);
$id = $params[1];
$query = "SELECT * FROM CinemaPost WHERE id=?";
$stmt = $conn->prepare($query);
$stmt->bindValue(1,$id, PDO::PARM_INT);
$stmt->execute();
$result = $stmt;
if($r = $result->fetch())
{
$response = [
    "id" => $row['id'],
    "name" => $row['name'],
    "text" => $row['text'],
    "post_date" => $row['post_date'],
    "likes" => $row['likes'],
    "url" => build_post_uri($row['reply_to']),
    "replies" => []
];

}
echo json_encode($response);
});

Comment: You can use the browser's devtools to check the actual response. But I can tell you there is no `$row` variable, you are using `$r` to hold the query first result
Comment: You are at the point where programming gets interesting, it is called debugging. Use the devtools as mentioned by ^^, add additional code to check the values of variables. Figuring this out by yourself will increase your programming knowledge.
Answer: in your code, try changing
let posts = JSON.parse(xhr.responseText);

to
let posts = JSON.parse(xhr.response);

That should help. I had a similar problem and after rigmarole, I fixed it by simply changing responseText to response.
I presume your data source is an array of objects.


How to schedule notification to user on specified time

Question: In my app I need to schedule notification to user on specified date and time (for example 1st May at 10:00). At this moment notification must be shown and when user clicks on this notification, my app should be open. I see two ways to do it:
1. Scheduled notifications.  But if I use the Alarm class, I can not change the title of the notification (which is "Alarm" in English version of SDK).
Reminder class mostly suits me, but when it appears atop the lock screen and user clicks it, my app doesn't open.  May be is there a way around these moments? Also I would like to get rid of listpicker with time (5 min, 10 min, 1 hour, etc.) and the "snooze" button, but it's not critical.
2. Toast (or tile) notifications from background agent.  But I'm not sure that my background agent runs at the right time. As I understand the background agents runs by the system, and their launch is limited by several factors (phone battery charge, the presence of the running applications or other background agents). It may not even start. There is a way to force the agent at a specific time by using the LaunchForTest, but everywhere write that this method can be used only for debugging purposes, and before the publication of the application it must be removed.
If I do not delete this method, will my application be certified? Also I don't like that the toast notification is only opens for 10 seconds and then disappears without a trace. Something can be done about it?
I need to notification was guaranteed shown at the right time, and when you click on it my application was open. What is the best way to do this?
If this is not possible in Windows Phone 7, is there a way to do this in Windows Phone 8?
Thanks.
Comment: You can use external notification server and send Toast notification from there.
Comment: Yes, but as far as I know push notifications do not always come at the right time (may be delays). And besides, the user may not have the internet, then push-notification will not come to him.
Answer: I think you should use the Reminders for this. When you click them your application will open.
Something like:
<code>var reminder = ScheduledActionService.Find("MyAppReminder");
if (reminder != null)
{
    ScheduledActionService.Remove("MyAppReminder");
}

reminder = new Reminder("MyAppReminder")
{
    Title = "Bla",
    BeginTime = DateTime.Now.AddDays(2),
    Content = message,
    NavigationUri = new Uri("/Start.xaml", UriKind.Relative),
    RecurrenceType = RecurrenceInterval.None
};

ScheduledActionService.Add(reminder);
</code>
As for the application not opening when the notification appears on the lock screen, it makes sense. Would be a big security hole if you could open apps directly from the lock screen! Hope it helps.
Comment: Yes, you're right about security, but Toast Notifications opens its apps when user clicks on them. But I do not like them because of their short lifetime (10 seconds and no notification center to store them. I'm really disappointed about this).


How does work function returning another function that taking another argument?

Question: I have a function from Dan Abramov`s redux course. It takes store but returning a function taking action as an argument. I know clojures but in function we didnt excute last function. addLoggingToDispatch function doesn't have action argument how does that function works?
     const addLoggingToDispatch = (store) => {
     const rawDispatch = store.dispatch;

      return (action) => {
       console.group(action.type);
       console.log('%c prev state', 'color: gray', store.getState());
       console.log('%c action', 'color: blue', action);
       const returnValue = rawDispatch(action);
       console.log('%c next state', 'color: green', store.getState());
       console.groupEnd(action.type);
       return returnValue;
      };
     };

Comment: Possible duplicate of [*How do JavaScript closures work?*](https://stackoverflow.com/questions/111102/how-do-javascript-closures-work)
Comment: Please refer javascript `closures`
Answer: The function that addLoggingToDispatch returns closes over the store parameter. Then, when that function is called, it gets passed an argument for action. So when that function that's returned is running, it has access to action (because that's one of its parameters) and store (because it closes over addLoggingToDispatch's parameter).
When a function is created inside another function and the inner function continues to exist after the outer function returns (because the outer function returns it, or it's been added to a list of functions like an event handler list, etc.), the inner function has an enduring link to the context in which it was created (the call to the outer function) and all of the in-scope parameters/variables of that context (store, in this example).
Here's a simpler example:

function createAdderFunction(a) {
  return function(b) {
    return a + b;
  };
}

var addFive = createAdderFunction(5);
// Now, `addFive` is a function that will add 5 to whatever you call it with
console.log(addFive(2));  // 7
console.log(addFive(37)); // 42

var addTen = createAdderFunction(10);
// And `addTen` is a function that will add 10 to whatever you call it with
console.log(addTen(15)); // 25

// `addFive` and `addTen` are separate from each other and work independently
console.log(addFive(0)); // 5
console.log(addTen(0));  // 10
Comment: It comes from the custom, your `dispatch` method when you use it. You are writing here your custom `dispatch` method and inserting some extra logic in it. So, with closure when you feed it with a `store` as the first argument then use this dispatch method, you feed it with an `action` as the second argument.
Comment: The problem is `console.log(addFive(37))` we execute that function to work and we give argument. But my function execute returning function auto with actions arguments. That makes me confused. Where that action argument comes from
Answer: It looks like this function is intended to replace or wrap the dispatch method that comes with your store. The dispatch method takes an action as an argument, so it has the same signature as your return function. So wherever you actually create the store, do something like this:
const store = createStore()
store.dispatch = addLoggingToStore(store)

You might clarify this post by showing us where you actually are using addLoggingToStore. But if I understand correctly this purpose of this function is to bake in logging functionality without creating any sort of additional logging middleware. Now, whenever you call dispatch(someAction), it will run your function instead of the default provided by the redux store.
Comment: yes exactly as you are guessed. This is full code https://github.com/gaearon/todos/blob/12-wrapping-dispatch-to-log-actions/src/configureStore.js


How many requests can GAE Datastore handle simultaneously?

Question: So I have 25,000 .py scripts running at the same time every 2 minutes as CRON jobs (distributed equally over 1000 servers)
They all have to access the same DB at the same time, ONLY to READ from db, not to write.
So I was wondering if Google Datastore (for example) could handle this? 25000 requests to the same DB at the same time just to read?
I couldnt find this in Google's docs.
Best Regards
Comment: Your question would best be asked on their product support forums. https://groups.google.com/forum/#!forum/google-appengine/topics
Answer: Unlike traditional databases, which have separate distinct "instances", Google Datastore is a single huge data storage, which has no explicit per-application limit on the number of requests that it can process. Your requests go the same route as all requests from all the other apps that use the Datastore.
The only limit you might face is on the write side, where one entity group should not be updated more frequently than once per second.
Comment: Wow that is amazing. I wont use Memcache because I put new data every 2mins. Thank you for your response
Comment: Memcache is much faster than Datastore and it's free. I would recommend using Memcache as long as you do more than 1 read of the same data before the next change, even if it changes every few seconds.
Comment: Does that mean that my 25,000 scripts would all be server at nearly the same time?
Comment: If you make the requests at nearly the same time, you will receive responses at nearly the same time. If you want to queue them, however, you can do it using Task API. Also, if some requests read the same data, you can use Memcache instead of reading from the Datastore each time.
Comment: As long as you're not accessing the same key you're fine, there is a limit on read per entity, if you go above it, you'll get contention error. +1 for the memcache, you can invalidate the memcache entry when you write the entity.


Can you transfer characters on a WoW account to yourself?

Question: I have played WoW for years but have not been playing for the past year or so (started in TBC, stopped about a year or more ago). I am interested in just playing around again without paying, so I am thinking about making a new account and playing a bunch of toons to level 20 just to see if the game feels fun to me again.
If I do this and end up liking it I would like to upgrade the account to paid for a month or more to get RAF benefits. If I do this, would I then be able to link my old account and my new one in some way so that I could play all characters I have ever played before?
If the answer is no, is it possible that my "son" could make a new account and do the same thing and then transfer the characters to me (since my legal name would be on the account since I would be making the account for him?)
Comment: The following forum post indicates that transferring from a starter account to a non starter account requires that you contact billing [Transferring char from starter to full](http://us.battle.net/wow/en/forum/topic/4142247711)
Answer: You can have multiple accounts that are all connected to one battle.net account.
So you would log into battle.net with your old account, and add a trial account to it, when you log into the game using the battle.net launcher, you can then select which one you want to play with. If your old account has expired, it will probably be greyed out.
The following screenshot indicates what this might look like.

I happen to have 5 live accounts and 1 starter edition account. I don't pay for the starter edition account. If I wanted to transter characters from it to my unlocked accounts I would need to contact customer services.
Comment: @Laurbert515 You can use "Recruit A Friend" to sign up new world of warcraft accounts and assign them to your battle.net account. With regards to using RAF on your existing trial account you wont be able to unless it was created from an RAF invitation.
Comment: Exactly what I was looking for. One more question, however. Say I make a trial account and get a bunch of level 20's. If I decide to upgrade, am I able to use RAF with that level 20's account or does RAF have to happen before you even make a character. Also, are you able to RAF yourself from two different accounts on the same Bnet account?
Comment: You can RAF the same bnet account that sends the RAF. Also be aware you still have to pay for a subscription on each individual account. So your main chars on the first account would be governed by one $15/mo subscription, and the new account would be governed by another $15/mo subscription.
Comment: Can you log 2 of your account at the same time?
Comment: @Damek it is possible for one person to play with multiple accounts at the same time, it is not a violation of the game terms, but there is no support for it in the game itself. for more information about that style of play see [World of Warcraft forums on dual-boxing.com](http://www.dual-boxing.com/forums/54-World-of-Warcraft)


question about class derivation in c++?

Question: i want to know some things about class derivation in c++
so i have super class x and an inherited class y
and i did this
class x{
    public:a;
    private:b;
    protected:c;
}
class y:public x{
    public:d;
}

in this case how y can access a,b,and c and by how i mean(public,protected,private)
the second case:
class x{
    public:a;
    private:b;
    protected:c;
}
class y:private x{
    public:d;
}

the same question?
the third case:
class x{
    public:a;
    private:b;
    protected:c;
}
class y:protected x{
    public:d;
}

again the same question?
sorry i think i wrote too much
bye
Comment: If you don't have one, I recommend getting one of the beginner books recommended in [The Definitive C++ Book Guide and List](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list)
Answer:
In all forms of inheritance:

y can look up to its base-class (x) and see public and protected.
Derived classes of y can see its public and protected members.
Users of y can see its public members.
Nobody can see anyone else's privates, unless they're friends.

In public inheritance:

users of y can look up to x and see public.

In protected inheritance:

both public and protected parts of x become protected in y
Derived classes of y can see them.
Users of y cannot see them.

In private inheritance:

both public and protected parts of x become private in y:
Derived lasses of y cannot see them.
Users of y cannot see them.
Private inheritance is essentially the same as composition (a private data member).

This C++ FAQ has good information on private and protected inheritance.
Comment: In the land of C++, friends can see your privates. Never say never. ;-)
Comment: Nice answer.  Thorough, complete, succint.
Answer:
A derived class can only access public and protected members of the base class. It cannot access the private members of the base class.
private/public/protected inheritance affects how the members inherited from the base class (X) are accessible to the "users" of the derived class (Y); now, the users could be a class derived from this derived class.
private inheritance is akin to declaring the public and protected members of the base class as private in the derived class.
**protected interitance** is akin to declaring the public and protected members of the base class as protected in the derived class.
**public inheritance** makes the public members of the base class public in the derived class; but the protected members of the base class remain protected in the derived class.
Answer:
Derived classes cannot access private members of the base class unless the derived class is a friend of the base class.
Inheritance permissions:

Public - all non-private members of the base class retain their permissions (base: public, derived: public; base: protected, derived: protected)
Protected - all public members of the base class become protected in the derived class; protected members in the base class are still protected (base: public, derived: protected; base: protected, derived: protected)
Private - all non-private members of the base class become private in the derived class (base: public, derived: private; base: protected, derived: private)

I can't stress enough the fact that private members of a base class are inaccessible by a derived class unless that derived class is declared to be a friend in the base class.

question about class derivation in c++?


Is it worth having custom 404 pages for different features of a web app?

Question: We've seen a lot of beautiful custom error pages for server errors such as 404 and 503, but it seems like each site or app has just has one for whatever page you cannot reach.
Is it in anyway helpful to users if we have another level of customisation for 404 pages that are specific to the type of event.
So for a meetings service, is it worth having a
- 404 for meeting not found
- 404 for recording not found
- 404 for attached document not found
I am wondering whether if we made such pages, can we reduce the friction for the user to find a solution? Would people read and be benefitted from this?
Comment: At the point where you have multiple 404 pages, you might end up needing a 404 page for when the correct 404 page isn't found. "40404 Error: Couldn't find the page you were looking for. Or the page you weren't looking for."
Comment: If you think you need multiple 404 pages, then maybe you need to think about redesigning the site? Or, there might be a more appropriate error code. Also, perhaps use analytics to see what people are looking for?
Comment: A single dynamic 404 page would be a better idea than multiple ones, so you could use a server-side language to figure out what to show the user. but how could you divine what they were *actually* looking for? the only time you could be certain is when it's a request that was sent by the webapp, not by the user, who could mistype a URL. for instance clicking the "Join Meeting" button.
Comment: How did the user get a bad URL? If you created it, don't. If the user asked for customer 27 when there are only 24, you failed to do your job of input verification. In this case you SHOULD NOT give them a bad URL but display an error message and allow them to try again.
Answer: The first problem with having multiple 404 pages, each dedicated to a particular area is that you assume users were in the right part of the website at the point when they fell on to the 404.
Bearing in mind that many links come from search engines and not necessarily from within the website, then I don't think you can guarantee that a dedicated 404 is always going to be the most helpful option for all users.
The second problem with multiple 404's is you are immediately increasing or duplicating the number of places you need to keep up to date or maintain. At some point you'll almost certainly have to decide that you'll have dedicated 404's about specific topics A, B, C, but have a generic 404 for 'everything else' and this generic 404 should probably include topics A,B,C anyway!
Apple's take on the 404 groups the possible forward options into the same group structure as the top level navigational structure.
So yes you come to one page, whatever the location that the error happened. But that's ok because it's easy to see links related to the section you were in, or wanted to be in. You can also easily see what the other sections are about in case this helps give a higher level picture.
In fact - Apple's 404 is so helpful, I'm almost tempted to bookmark it and deliberately go to Apple's 404 page in order to kick start my way around the site! It's not as long or detailed as their sitemap but is (in my opinion) easier than browsing via their top menus which aren't drop downs.

EDIT: Compare Apple with Bloomberg's 404 for example, which totally puts a lot of effort concentrated on the absolute wrong thing to display. It's animated so you have to see it to believe it. Weird!
Comment: A specific message on the 404 page would be very helpful in cases in which content was removed or expired.  In those cases you might want to consider a "410 Gone" status instead of 404 though.
Comment: The status code matters for non-human visitors such as search engine bots.  Google for example expunges 410 gone pages more quickly than 404 pages which makes it less likely that users would get to such pages.   The magic numbers do matter.
Comment: Roger, touche :)
Comment: @StephenOstermiller The average user will just about know what 404 means. So, yes, use a 410 Gone response, but as far as the UI goes, simply state that the content has been deleted, and don't bother the user with 'magic' numbers like 410. If similar content is helpful, **do** display this, but generally this is not the case
Comment: A better URL would be http://www.apple.com/404/ to go to the 404 page on the apple website. This really states that you want the 404 page and not 'itues'. With enough visits, they may redirect 'itues' to 'itunes' and you are left without your precious 404 page.
Comment: @IsmaelMiguel Good point - thanks for pointing out the real 404
Comment: It isn't a real 404, but at least shows that you *really* wanted that page and not something else. The idea is just to trigger the code. I'm pretty sure that, even if they redesign the website, this link will work. If it is the *direct* pointer to the 404 page, I'm not sure and most of us can't be. But this one is pretty much guaranteed to work for a *very* long time.
Comment: Lol "Did you try searching?" TIL the apple.com 404 page would get comment-flagged on SE.
Answer: Treat a 404 page like an error message, which it basically is. A good error message offers the users way to overcome the problem. In your example, a 404 for meetings could offer possible matches for meetings, a 404 for recordings could offer recordings, and the same for documents. The possible solutions are different for each type of entity, and the reasons for the mistake could also be different - e.g. a meeting can be outdated, but a recording can't. So yes, it would be helpful to have specific 404 pages, as long as they offer real solutions and not just say "Ooops, the page that you were trying to reach doesn't exist".
Comment: This is rather outdated thinking. If I follow a link to specific content and it is not there then the chance of finding the specific content that I wanted in a search is very low and putting the user into a loop between search and 404 is not useful. Don't link to things that don't exist, use permanent links that will never have to move, if something is cancelled or deleted confirm to the user that it has been so they can stop searching rather then send them to a 404.
Comment: @JamesRyan Outdated or not, it's a fact that 404 pages exist. The question wasn't whether they should be used - I agree that it's best to avoid them whenever possible. The question was how to use them, as long as they are already being used. Also, your assumption about the uselessness of search is unwarranted in many cases, especially in the case of webapps, which is what the OP explicitly asked about. And I actually never mentioned search :).
Comment: I guess we have different definitions of "fact" then :). https://gmail.com/lkjhlkj, https://www.facebook.com/lkuhkl.
Comment: I highly agree with @JamesRyan. It seems redundant and stressful for the user to stumble on "I didn't find anything" when in fact it is: "I did, but it's just not there and I didn't know."
Comment: @VitalyMijiritsky I did not say search is useless, I said it is not helpful at that late stage.  The fact is in a webapp you should never end up at a 404 page.
Comment: I think I disagree with both of you. It's not like it can be helped. Users stumble on 404s when they think they are going to a page when they didn't.

At the same time, it shouldn't be a straight cut away for when a user doesn't find something they are looking for. The search function should be intuitive enough to tell the user something wasn't found and suggest something instead or something was deleted and provide a clear way to move forward.
Comment: Thanks @VitalyMijiritsky I will explore a single page that does the following: 1. detects what kind of 'object' the user was trying to reach, meeting, recording, document, etc. and show a way forward from there - existing or upcoming ones,etc. provided the user is logged in. If they are not logged in, then they should see a generic error so that we don't have security issues. If we cannot detect what they are looking for from the URL or source, then we show the most common links. We don't really have much use for search since there isn't much content in the app itself.  thanks everyone!
Answer: I designed a 404 page sometime back with a function you might find interesting. it was using a recommendation engine module suggesting products the user might like and what they previously viewed. not sure what kind of website you are asking this in context to, but a golden rule i stick to is never to bring the user to a dead end.
Answer: I'm going to answer this from the perspective of a webmaster who is familiar with the error codes that your web app should produce.
A 404 Not found error is a very general error for the case when a URL was entered that cannot be parsed.   You may not know what area of the site the user was looking for.   There may even be nonsense in the URL like /xyszes/thau.   Were they looking for a meeting?   Who knows.   At the very least you need some generic 404 page for the case in which your server can't make heads or tails of the URL.
A 410 Gone is a page that I often customize for different content types.   When you remove a meeting, you should return a 410 status with a custom message like This meeting was yesterday, click here to schedule a new meeting.
For URLs that are almost correct, you should use a 301 Moved Permanantly status to take the user directly to the correct page.   You might want to take advantage of modules like mod_speling (sic) that can correct misspelled URLs.  You should also implement redirects manually for pages or sections of your website that have actually moved to a new URL.   I find it useful to implement a custom 404 script that tries the words from the URL in site search and then redirects to the first result if there is one.
Comment: It's interesting to know that there is [this level of control](http://en.wikipedia.org/wiki/List_of_HTTP_status_codes) and fine tuning - and that it's not just about 404.
Answer: I agree with Vitaly, the 404 page shouldn't be an end to the users route it should give them help on why this page might not be here and relevent ways to procceed.
In your example, suggesting things like "Is this the meeting you are looking for?" then listing relevent results helps the using keep moving forward rather than backtracking
Answer: I think the simplest answer is how much time are you willing to devote to this one portion of your website? The second question is about the clientele that you're serving. The answer to those two questions will be a starting point. If you have lots of time and your clientele is not savvy then do separate pages. If your time is short and your clientele is savvy then leave it basic.
Answer: No.
It can be a security risk to do so, and for the example you give isn't really appropriate anyway.
If I try to find a particular meeting - even from a direct link - and it doesn't exist, why throw an error in my face? I'd much prefer a site that displayed a basic "This meeting doesn't exist" message, and then displayed a list of other meetings, for example.
In this manner you can treat it exactly like a search - if a user searched for something that didn't exist, you certainly wouldn't want to render a 404! So I would suggest one of two search-based pages instead:

Treat it like an empty search with a short "not found" error message: list all available meetings|recordings|documents as applicable
Treat it like a very specific search: instead of showing a single meeting|recording|document page, use your existing search to enter the title given in the URL, which will presumably result in the standard 'no results found' message
Comment: As a software developer, anything other than a 404 error when a page isn't found is absolutely fatal. You are thinking from the point of view of a web server; there are many other applications. Playing games with standard error codes makes people want to kill the person who designed this.
Comment: You also contradict yourself by saying something like 'don't show a 404 error - show a "not found" error instead'. That's exactly what the 404 error is for. If you are saying you should not use http codes when appropriate, that is bad advice. Whether you should actually display the error code or not is a totally different matter, if that is what you meant.
Comment: You say no" but then the error message you propose is actually specific to meeting as opposed to other types.  I think you mean "yes", but be careful what you put on those pages.
Comment: @OllieFord Ok, for an empty search result an http error code would not be right. But then I don't really see why clicking a link should be treated as some kind of search in the first place. The user tries to _get_  a resource identified by a particular url - when that resource is missing, a 404 "not found" is a appropriate response. Responding with no error code could mess with search engine crawlers and hurt seo. Adding some kind of search result when visiting a dead link is not mutually exclusive with using correct error codes though. You can respond with 404 and show a search result.
Comment: @Stephen - I say no to 404. Propose specific non-404 *message* rather than failing ungracefully with a server error.
Comment: @kapep I said show a "not found" message on a search page. I didn't say "Don't show a 404 error, show a not found error page".
Comment: @kapep While they could be the same thing, they're usually not (or when they are, it's hidden). My point is that users don't care - do what's most helpful to them. If it's not found because the name changed and it broke the link, then showing a list of others helps the user to identify it more quickly.


Mysql each row fetch along with data from other table

Question: I am trying to write a code for fetching data 2 mysql table by a primary key and foreign key solution
What could be the best solution to write sync code to fetch the data.
I have tried to use Q promises and other methods.
These are my options

Async
Q
Yield
Generators

Please do let me know if there are better option to write nodejs async code to sync code
Answer: On a NodeJS system, actual synchronous code would be a huge performance bottleneck as it would block any other processing while the IO takes place.
I find that promises "look" a little more synchronous in code than callbacks, even when using a library like async. There are some other benefits to promises as well.
A library like knex, bookshelf or sequelize might make your life easier when working with with SQL and those have promises built in to get you started.
Comment: I decided to use promises for my job. And they work just as how i would expect them. I found lib Q to be very helpful. Thanks.


Will my roof rot if I put steel over wet framing?

Question: My mother's roof has been leaking for over 3 years now. Ceilings falling in in some rooms and leaks in most. She paid someone to put the roof on and he brought the all metal, put on 10 feet of roof and never came back. So now the question is... if I put the roof on myself will it simply rot everything  underneath considering there's so much moisture? My thought was to put on the roof and knock out the ceiling in the worst rooms and put in space heaters, fans, dehumidifiers, etc and then put new ceilings in once it's dried out. Would this be an option that would work (A.K.A save the the house/make it livable till it can be fixed properly by a professional)?
Comment: What sort of climate is this in?  Is there likely to be weeks (at least) of dry weather?  What is the humidity like?
Comment: This question [has been asked](https://diy.stackexchange.com/users/54507/cody-pace?tab=questions) in more or less the same fashion by this user twice before. They've also been abandoned.
Answer: First, stop the leaking. Use tarps or whatever. Next, I'd try to dry the roof structure out before installing the metal roofing. (Yes, the roof structure should be dry before installing the roofing.) I'd also check for mold, (as you say the roof has been leaking for 3 years). It may not be safe to stay in the house and continue breathing that air.
Comment: If there is mold what would be the best way to get rid of it?
Comment: @CodyPace Abating (removing) mold is dangerous. Scraping mold off any material will cause it to fly like dust. You'll need special respirators, special bags to dispose of it, special fans to contain it in your house so it doesn't float out the windows and around the neighborhood. I think you'll need an abatement contractor, but first I'd get it tested so you know the extent, type, etc.
Comment: A simple hydrogen peroxide solution at 3%  will destroy surface mold if present but nothing will stop deep spores, I live in the Pacific north west and stopping the leak is the first priority, then removing the moisture, waste time on trying temporary methods with a limited budget and then a big wind takes the tarp off and you are at square one or trying to do the job a year later oops the cheap tarp just blew off in a winter storm, wait till it is dry no way in my opinion.
Answer: (Too long for a comment)
How many layers of shingles or type of shingles are on the current roof?
Your mom paid someone; was that person licensed? This needs to be addressed. I don't like it when anyone gets ripped off but get especially upset when it is an elderly person.
Limited info provided on the existing roof:

Is there is only 1 or 2 layers of 3 tab roofing?
Was the original guy just overlaying the metal roofing?  If so continue doing that.
If there are more than 2 layers, they need to be removed including where the first 10' of metal was installed and the roofing under that.

The big thing is to stop the leaks first. Next you need to get some fans to move the air around and from the sound.
If the condition of the property several dehumidifiers. The next part is a judgment call after putting the new roof on, is the sheet rock sagging and the insulation above saturated? Then it should all be removed, however I understand if she is on a fixed budget it may be best to just remove the insulation for now so the sheetrock can dry and be replaced as funds are available.
You don't want the ceiling open when winter or cold weather is in your area or she won't be able to heat the home. I suggest removing the insulation as it as good as a sponge and will hold water for a very long time so removal will help reduce moisture levels quickly. I have additional comments and ideas but without additional information it may not be helpful.
Comment: This would have been okay to add as (many) comments to the OP.


Why doesn't my new ceiling fan's light work from the pull chain?

Question: I connected a ceiling fan/light and put white together then the blacks and capped off red.
The fan works but light doesn't turn on from the chain. Why?
Comment: Picture of the wiring (switch and fixture boxes) would help. What model fan?
Comment: Welcome to [diy.se], please take the [tour]. I've edited your question to simplify the title and to actually, you know, ask a question in the body. If I've missed something important, please feel free to [edit] again to correct any mistakes I may have made...
Comment: Does your fan have a blue wire for the light?  if so, did you connect it to the blacks?
Answer: The fan and light are often fed by two separate power wires, so the light can be controlled from a wall switch and the fan can be controlled from the chain, or other such independent setups. The fan and light have a common white wire.
Often the fan power wire is black and the light power wire is some other color, perhaps blue.
If you have no other power source, like a wall switch, that you want to control the light separately with, and you want both the fan and the light controlled by chains at the fan body, wire both the fan black and the light other-color wire to the house black wire. The fan/light white and house white go together, as you have now.
If you did want the light controlled by the wall switch (which probably powers the red wire) attach the light power wire to the red.


SecurityIntelliSense Warning: Explicit usage of accesstoken found in the code

Question: I got a securityIntelliSense warning:

Explicit usage of accesstoken found in the code: access tokens should
  be handled securely. It is recommended not to store it separately in a
  persistent storage like databases or files, unless there is a
  compelling requirement.

The code looks like this:
  public string GetAccessToken()
        {
            var authContext = new AuthenticationContext(string.Concat(_aadInstance, _tenantId));
            var credential = new ClientCredential(_clientId, _clientSecret);
            var authResult = authContext.AcquireTokenAsync(_appResourceId, credential).Result;
            return authResult.AccessToken;
        }

The warning happens in the last line: authResult.AccessToken
I was wondering if there's any way to fix the warning?
Answer:
I was wondering if there's any way to fix the warning?

It seems that you enabled the Security IntelliSense - Preview  tool.
But It just a warning information to give some tips to handle the security access token.
If you still don't want to show that waring information. You could disable  or uninstall the extension.
We could find it under Tool->Extensions and Updates


Turning Iron Ore into Iron Ingots?

Question:
Possible Duplicate:
How do you smelt ore?

I have heaps of Iron Ore and I can't use it for anything. So I was wondering how to turn Iron Ore into Iron Ingots so I can use them.
Answer: Smelt them.
Go to the nearest blacksmith and go to the Smelter, and then choose Iron Ignot and smelt them. You will get 1 Iron Ignot for every 1 Iron Ore.
Here is a list of Blacksmiths that offer Smelting.
Answer: Transmute them.
http://elderscrolls.wikia.com/wiki/Transmute_Mineral_Ore
This is a spell that with 4 castings, converts two iron ore into two gold ore, which you can then smelt into one gold ignot, which can be combined with gems to make jewelry, which is the fastest way to level Smithing.

Turning Iron Ore into Iron Ingots?


Let $a,b \in \mathbb{Z}$ and suppose that $a | b$ and $b |a$. Then $a=b$ or $a=-b$

Question: Let $a,b \in \mathbb{Z}$ and suppose that $a | b$ and $b |a$. Then $a=b$ or $a=-b$
My attempt
$a|b \Rightarrow b=k_1a$ for some $k_1$
$b|a \Rightarrow a=k_2b$ for some $k_2$
By substitution $a=k_1k_2a \Rightarrow a(1-k_1k_2)=0$
So, we have two cases:-
Case $(1)$
$k_1k_2=1 \Rightarrow k_1=k_2=\pm 1$
Thus, $a=\pm b$
Case $(2)$
I am stuck here, as $a=0 \Rightarrow b=0$.
But then division by $0$ doesn't make sense. What to do?
Note
This question is not a duplicate as it explicitly asks the question for $\mathbb{Z}$ and not $\mathbb{N}$ or nonzero integers.
Comment: In number theory we define *divisibility* by $\, a\mid b \iff an = b\ $ for some $n\in\Bbb Z.\,$ In particular $\, 0\mid b\iff b = 0.\ $  Now you can continue your proof. Note the statement concerns the *relation* "divides", not the *operation* "division" (though they are related, they are not identical).
Answer: If $a=0$ then, since $a\mid b$ by hypothesis , we must have that $0=ak=b$ for some $k\in\mathbb{Z}$.
Answer: If you read $a | b$, then you can suppose that $a \ne 0$
Comment: Read the question carefully. I specifically ask what happens when $a=0$.
Comment: @user330477 Just for clarification, when we supposed that $a|b$ and $b|a$ then its understood that $a\neq 0$ and $b\neq 0$. You don't need to ask question like what will happen if $a=0$ because that is not possible to happen.
Comment: The definition of a|b that I use allows a=0. Since I would say that a|b means "There exists k with ak=b" which is true with a=0, b=0 and k=1 or anything else, i.e. 0|0 is true. Of course, that fits the statement OP is trying to prove (see mathbeing's answer).
Comment: @Chessanator Now I am completely confused
Comment: @user330477 Precisely, you don't need case 2. Look, you already have $$a(1-k_1k_2)=0.$$ So, since $a\neq 0$, you are forced to conclude that $1-k_1k_2=0$ ,that is, $1=k_1k_2$ and hence $k_2|1$. Hence, $k_2=1$ or $k_2=-1$.
Comment: The condition $a | b$ is given, which means that $a$ cannot be zero. Otherwise the assumptions will be false.
Comment: @user330477  Zero is divided by everything...
Comment: @ΘΣΦGenSan So this means that case 2 doesn't arise as $a \neq 0$ when $a|b$. So, my proof is ok without that
Comment: @user330477 There are two sensible definitions of a|b on the integers. The one which I now think you are using (given your confusion at my comment) and which the other commentators are using is "Consider the fraction b/a. If it is a whole number then a|b". This definition doesn't allow a=0 because then you would have division by zero. If this is the defintion you are using then GenSan's comment finishes your proof.
Comment: @user330477 The other definition is the one I gave in my previous comment: it agrees with the other definition everywhere but also allows 0|0. Experience has taught me that definitions like that are better because they treat zero more naturally. Once again, mathbeing was also using this second definition and gave the conclusion of the proof using it in their answer.


Postgres: Save rows from temp table before rollback

Question: I have a main procedure (p_proc_a) in which I create a temp table for logging (tmp_log). In the main procedure I call some other procedures (p_proc_b, p_proc_c). In each of these procedures I insert data into table tmp_log.
How do I save rows from tmp_log into a physical table (log) in case of exception before rollback?
create procedure p_proc_a
language plpgsql
as $body$
begin

  create temp table tmp_log (log_message text) on commit drop;

  call p_proc_b();
  call p_proc_c();

  insert into log (log_message)
  select log_message from tmp_log;

  exception
    when others then
      begin
        get stacked diagnostics
          v_message_text = message_text;

        insert into log (log_message)
        values(v_message_text);
      end;
end;
  $body$

What is a workround to save logs into a table and rollback changes from p_proc_b and p_proc_c?
Answer: That is not possible in PostgreSQL.
The typical workaround is to use dblink to connect to the database itself and write the logs via dblink.
Comment: Thank you for tip. I make a workaround using json (inout) parameter for every procedure.
Answer: I found three solutions to store data within a transaction (im my case - for debugging propose), and still be able to see that data after rollback-ing the transaction
I have a scenario where inside, I use following block, so it may not apply to your scenario
DO $$
BEGIN
...
ROLLBACK;
END;
$$;

Two first solutions are suggested to me in the Postgres slack, and the other I tried and found after talking with them, a way that worked in other db.
Solutions
1 - Using DBLink
I don't remember how it was done, but you import some libraries and then connect to another db, and use the other DB - which maybe can support to be this db - which seem to be not affected by transactions
2 - Using COPY command
Using the
COPY (SELECT ...) TO PROGRAM 'psql -c "COPY xyz FROM stdin"'

BTW I never used it, and it seems that it requires Super User(SU) permission in Unix. And god knows how it is used, or how it output data
3 - Using Sub-Transactions
In this way, you use a sub-transaction (which I'm not sure it it's correct, but it must be called Autonomous transactions) to commit the result you want to keep.
In my case the command looks like this:
I used a Temp Table, but it seems (I'm not sure) to work with an actual table as well
CREATE TEMP TABLE
    IF NOT EXISTS myZone AS
        SELECT * from public."Zone"
        LIMIT 0;

DO $$
BEGIN
    INSERT INTO public."Zone" (...)VALUES(...);

    BEGIN
    INSERT INTO myZone
        SELECT * from public."Zone";

    commit;
    END;

    Rollback;
END; $$;

SELECT * FROM myZone;

DROP TABLE myZone;

don't ask what is the purpose of doing this, I'm creating a test scenario, and I wished to track what I did until now. since this block did not support SELECT of DQL, I had to do something else, and I wanted a clean set of report, not raising errors

According to www.techtarget.com:

*Autonomous transactions allow a single transaction to be subdivided into multiple commit/rollback transactions, each of which
will be tracked for auditing purposes. When an autonomous transaction
is called, the original transaction (calling transaction) is
temporarily suspended.

(This text was indexed by google and existed on 2022-10-11, and the website was not opened due to an E-mail validation issue)
Also this name seems to be coming from Oracle, which this article can relate

EIDTED:
Removing solution 3 as it won't work
POSTGRES 11 Claim to support Autonomous Transactions but it's not what we may expect...
For this functionality Postgres introduced the SAVEPOINT:
SAVEPOINT <name of savepoint>;

<... CODE ...>

<RELEASE|ROLLBACK> SAVEPOINT <name of savepoint>;

Now the issue is:

If you use nested BEGIN, the COMMIT Inside the nested code can COMMIT everything, and the ROLLBACK in the outside block will do none (Not rolling back anything that happened before COMMIT of inner
If you use SAVEPOINT, it is only used to rollbacks part of the code, and even if you COMMIT it, the ROLLBACK in the outside block will rollback the SAVEPOINT too
Comment: There is no "new rule". Your answer shouldn't consist primarily of a link and should stand on its own, but if you do use someone else's text or information in a question or answer, you absolutely need to attribute the source. This is same as it's been for years.
Comment: @chivracq I found this article https://stackoverflow.com/help/referencing, thank you
Comment: @chivracq thank you, I just knew that StackOverflow suggests we do not link to other resources and use the answer to write it even if it is a duplicate. I wasn't aware of new rules, or side conditions, how to add source? just link? or Quote provide an option too?


ubuntu server bind issue

Question: vi named.conf
    zone "evi.local" {
        type master;
        file "/etc/bind/evi.local.db";
};

    zone "10.168.192.in-addr.arpa" {
        type master;
        file "/etc/bind/rev.10.168.192.in-addr.arpa";
};

vi evi.local.db
$TTL    604800
evi.local.      IN      SOA     ns1.evi.local. root.evi.local. (
                        20180524        ; Serial
                        604800          ; Refresh
                        86400           ; Retry
                        2419200         ; Expire
                        604800 )        ; Negative Cache TTL
;
evi.local.      IN      NS      ns1.evi.local.
ns1             IN      A       192.168.10.10
www             IN      A       192.168.10.10
@               IN      AAAA    ::1

vi rev.10.168.192.in-addr.arpa
$TTL    604800
evi.local.      IN      SOA     ns1.evi.local. root.evi.local. (
                20180524        ; Serial
                604800          ; Refresh
                86400           ; Retry
                2419200         ; Expire
                604800 )        ; Negative Cache TTL
;
evi.local.      IN      NS      ns1.evi.local.
10              IN      PTR     ns1.evi.local.

named-checkzone evi.local evi.local.db
zone evi.local/IN: loaded serial 20180524
OK

named-checkzone rev.10.168.192.in-addr.arpa rev.10.168.192.in-addr.arpa
rev.10.168.192.in-addr.arpa:5: ignoring out-of-zone data (evi.local)
rev.10.168.192.in-addr.arpa:12: ignoring out-of-zone data (evi.local)
zone rev.10.168.192.in-addr.arpa/IN: has 0 SOA records
zone rev.10.168.192.in-addr.arpa/IN: has no NS records
zone rev.10.168.192.in-addr.arpa/IN: not loaded due to errors

what am i missing ?? why errors in rev file ??? thanx for your help
i need this for exam... please help

vi evi.local.db
$TTL    604800
@       IN      SOA     ns1.evi.local. root.evi.local. (
2018052401      ; Serial
604800          ; Refresh
86400           ; Retry
2419200         ; Expire
604800 )        ; Negative Cache TTL

evi.local.      IN      NS      ns1.evi.local.
ns1             IN      A       192.168.10.10
www             IN      A       192.168.10.10

vi rev.10 file
$TTL    604800
@               IN      SOA     ns1.evi.local. root.evi.local. (
                2018052401      ; Serial
                604800          ; Refresh
                86400           ; Retry
                2419200         ; Expire
                604800 )        ; Negative Cache TTL

        IN      NS      ns1.evi.local.
10      IN      PTR     ns1.evi.local.

like this ?
Comment: You've failed to create a proper reverse lookup zone.  Technical reasons why you're failing are in my answer, but that's why it's broken.
Comment: Regarding the "Like This": No, the zones are still not correct.  Unless you set `$ORIGIN`, you need to have in the local db for forward lookups `evi.local.  IN SOA ...` and for reverse `10.168.192.in-addr.arpa    IN SOA ...` for the SOA records.  (Then @ should behave; note the `...` means "the rest of the SOA record")
Comment: sorry but i'm not getting it. to bad you cannot upload pictues. what do you mean with $origin ? like this >>> $TTL 604800 rev.10.168.192.in-addr.arpa IN SOA ns1.evi.local. root.evi.local. ( 2018052401 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL 10 IN PTR ns1.evi.local.  ?? then in the local.db file change the @ back to evi.local. ?
Answer: You've got two problems, which ultimately combine to make the third and in turn the errors you're getting:

The SOA record in your reverse zone is not set properly, and
The A, AAAA, etc. records aren't permitted in reverse DNS zones, which means that
Your entire reverse DNS zone file is wrong, which is why bind9 complains.

rev.10.168.192.in-addr.arpa handles reverse records for 192.168.10.0/24 with the zone name of 10.168.192.in-addr.arpa.  If I have the addresses 192.168.10.15 assigned to foo.bar, and 192.168.10.16 assigned to baz.foo.bar, and I want the reverse lookups to reflect this, the records would have to look like this in the zone file:
$TTL    604800
10.168.192.in-addr.arpa.      IN      SOA     ns1.foo.bar. root.foo.bar. (
                20180524        ; Serial
                604800          ; Refresh
                86400           ; Retry
                2419200         ; Expire
                604800 )        ; Negative Cache TTL
;
15    IN PTR    foo.bar
16    IN PTR    baz.foo.bar

Note that the Reverse Zone takes numeric IP lookups, and has PTR records for the rDNS (reverse DNS) lookups for an IP address to get its hostname.
The equivalent forward-lookup zone for foo.bar that'd correspond to the *.foo.bar addresses in the reverse zone would be like this:
$TTL    604800
foo.bar.      IN      SOA     ns1.foo.bar. root.foo.bar. (
                        20180524        ; Serial
                        604800          ; Refresh
                        86400           ; Retry
                        2419200         ; Expire
                        604800 )        ; Negative Cache TTL
;
@               IN      A    192.168.10.15
baz             IN      A    192.168.10.16

And in your network, if the only 'domain' zone served by 192.168.10.0/24 is *.foo.bar, then you would have records in the rDNS which would correspond directly with A records in the forward lookup zone.

Judging by your comments, you know nothing about how BIND works, and therefore are failing to configure zones.  Other than suggesting you not take the exam you're taking, your zone files need to be the following, verbatim, as i type them.  Note that I and others hate spoon-feeding users direct answers to questions like these.  So study these zones below as I wrote them, or you will never be able to properly configure bind9.  You should also learn how BIND9 actually works to truly understand what these zones are doing.
For the evi.local.db file, use exactly this:
$TTL    604800
$ORIGIN evi.local.
@       IN      SOA     ns1.evi.local. root.evi.local. (
2018052401      ; Serial
604800          ; Refresh
86400           ; Retry
2419200         ; Expire
604800 )        ; Negative Cache TTL

@               IN      NS      ns1.evi.local.
ns1             IN      A       192.168.10.10
www             IN      A       192.168.10.10

For the rev.10.168.192.in-addr.arpa file, use exactly this:
$TTL    604800
$ORIGIN 10.168.192.in-addr.arpa.
#               IN      SOA     ns1.evi.local. root.evi.local. (
                2018052401      ; Serial
                604800          ; Refresh
                86400           ; Retry
                2419200         ; Expire
                604800 )        ; Negative Cache TTL

        IN      NS      ns1.evi.local.
10      IN      PTR     ns1.evi.local.

These zones should work without issue, and solve the issues you're seeing.  I strongly recommend you study them.  However, for your exam, they will probably replace the $ORIGIN lines with nothing, and then instead of @ IN SOA ... you need to replace the @ sign with the actual zone name (which in these examples is set with $ORIGIN).
Comment: @eds Since you *obviously* don't know how `bind` zones actually work... I'm going to spoon-feed you the exact zone files you need to use.  Study them.  Failure to study means you will fail your exam on DNS configuration in the most gloriously fiery way possible.
Comment: `$TTL    604800
rev.10.168.192.in-addr.arpa             IN      SOA     ns1.evi.local. root.evi.local. (
                2018052401      ; Serial
                604800          ; Refresh
                86400           ; Retry
                2419200         ; Expire
                604800 )        ; Negative Cache TTL

10      IN      PTR     ns1.evi.local.
`
Comment: @eds *no*, not `rev.10.168.192.in-addr.arpa.`, just `rev.10.168.192.in-addr.arpa.`  The SOA and zone need to match the declaration of the zone name at `zone "10.168.192.in-addr.arpa" {` in your config, *not* the filename.
Comment: $TTL    604800
@       IN      SOA     ns1.evi.local. root.evi.local. (
2018052401      ; Serial
604800          ; Refresh
86400           ; Retry
2419200         ; Expire
604800 )        ; Negative Cache TTL

@       IN      NS      ns1.evi.local.
ns1             IN      A       192.168.10.10
www             IN      A       192.168.10.10 for evi.local.db ??
Comment: reverse lookup file
$TTL    604800
@               IN      SOA     ns1.evi.local. root.evi.local. (
                2018052401      ; Serial
                604800          ; Refresh
                86400           ; Retry
                2419200         ; Expire
                604800 )        ; Negative Cache TTL
;
@       IN      NS      ns1.
10      IN      PTR     evi.local.
??
Comment: thank you for this, yes i now that i will need to study, but we have no info from instructor. and are left by are selfs to figure out. now i have an example so i can test if works and work from there. change things and figure out this. thank you for your time. kind regards

ubuntu server bind issue


What determines whether a character can use a weapon?

Question: I found a new bow (Rank B) on the field, and while I've given it to my Archer (Rank C), he can't seem to use it during a fight.  What determines whether a unit can use an item?
Answer: The weapon has a ranking on it and the character has a weapon ranking. If the character weapon ranking is not greater to or equal to the weapon's then they cannot use it. The ranking goes from E (lowest) to A (highest).

In the bottom left hand corner you can see the characters weapon rank.
No luck finding a picture of a weapon description though.
Comment: @fbueckert No, in previous titles there were S rank weapons but in this game it only goes up to A.
Comment: @Tony I just did the same thing and finally found a use for the Arms Scrolls I've had sitting around.
Comment: Isn't S rank the highest?  Reserved only for advanced classes?
Comment: I didn't know about the weapon ranks - thanks!
Comment: Huh.  That's too bad; S-rank weapon skill used to confer some pretty decent bonuses.
Comment: @KatieK Yes, it's good to know, I reclassed all my units before a major battle and let's just say it's not so easy when most of your army can only use bronze weapons. =(
Answer: Additionally to @Tony's answer, it is good to note, that there are some weapons, that can't be used by just anybody, even if that character meets the weapon level requirement.
Those weapons are:

Falchion (Chrom only)
Parallel Falchion (Marth only)
Wolf Berg (Walhart only)
Rapier and Noble Rapier (Lords, Great Lord and Lodestars only)
Longbow, Towering Bow and Double Bow (Archers and Snipers only)
Amatsu (Myrmidons and Swordmasters only)
(List might not be complete and will be expanded)

As well as any Dark Tome, which can only be used by Dark Mages, Sorcerers and any other tome user with the skill Shadowgift equipped, that is: Aversa and if married to the Avatar, Morgan as well. Some enemies and DLC characters may possess the Shadowgift skill as well, such as Micaiah and Katarina.


PyQt4 / QTableView : How to change the style of selection rectangle?

Question: I am trying to change the style of selection rectangle in QTableView.
I have tried with stylesheet; but it allowed me to set only the selection background color as shown in Figure 1. I wanted the selection rectangle as shown in Figure 2. (No Fill Color + Thick  black border)
Any idea?
def TableUi(self, Dialog):
    Dialog.setObjectName("Dialog")
    Dialog.resize(343, 179)

    self.tableWidget = QtGui.QTableWidget(Dialog)
    self.tableWidget.setGeometry(QtCore.QRect(10, 10, 321, 121))
    self.tableWidget.setStyleSheet("selection-color: rgb(255, 0, 127);\n"
    "selection-background-color: rgb(85, 255, 127);")
    self.tableWidget.setRowCount(3)
    self.tableWidget.setColumnCount(3)

Full Code Sample: https://justpaste.it/5fe3r
Answer: To style the selected cell you can target QTableView::item::selected in your stylesheet.
self.tableWidget.setStyleSheet('''
    QTableView::item::selected {
      border: 5px solid black;
    }
''')


Is it possible that the AI in Starcraft 2 learns?

Question: Is it possible that the AI in Starcraft 2 is learning from previous games?
If it's true, is there any way to 'reset' AI's algorithm?
I have a strange feeling that the AI in 'Left 2 Die' (official mod) on brutal difficulty somehow 'adapts' to my gameplay and is getting even more difficult after each game. Could that be true?
Answer: The SC2 AI will scout and it will respond to what you do during the specific game in question, but the knowledge doesn't carry over into different play sessions.
The closest thing the AI does to "learning" on normal maps is what happens when you play on Insane difficulty. In this mode, the AI is known to cheat in two ways:

It gets more minerals per worker trip than normal
It always knows where your units are and can create counters to your units as you are building them

Regarding Left 2 Die, the more difficult settings do not learn between play-throughs. If you employ the same strategy in one session on Brutal, it will get you just as far in another play session as well.


Need more information about API for 'Ubuntu for Phones'

Question:
Possible Duplicate:
How do I start developing applications for Ubuntu mobile?

I would like to develop a app on Ubuntu for Phones. I have already developed apps on iPhone and Android. Could you please suggest me how I can download and setup the mobile development environment for Ubuntu for Phones, and also I would like to know the API documentation.
Comment: That thing you are referencing to is called 'Ubuntu for Android'.
Comment: It is definitely not called 'Ubuntu for Android', he specifically mentions "go mobile" which points to the [Ubuntu for Phones site](http://developer.ubuntu.com/get-started/gomobile/) (a totally different thing). For some excellent information on Ubuntu for Phones see [this question](http://askubuntu.com/questions/235317/what-is-ubuntu-for-phones-and-how-can-i-get-it?lq=1).
Comment: Have you taken a look at http://developer.ubuntu.com/get-started/gomobile/ or installed their SDK?
Answer: You can read about how to get the Ubuntu SDK preview and a tutorial showing how to write an app here: http://developer.ubuntu.com/get-started/gomobile/
The QML API docs are available here: http://developer.ubuntu.com/api/ubuntu-12.10/qml/mobile/overview-ubuntu-sdk.html


Design Patterns: evaluating security across multiple modules

Question: This question is more about design patterns, dependency injection than Spring Security itself, I expect folks without specific knowledge of Spring Security to understand this question.
In Introduction to Spring Security 3/3.1 to verify whether the current user is authorized to do an action on a target object, Mike Wiesner implements a PermissionEvaluator. This bean is wired with the Security configuration and gets called on method annotations, before an action on a target object is carried on.
The purpose is to check whether an user is authorized or not to do a certain action on a specific object. He shows the following code (without null checks, for brevity, I suppose):
public class MyPermissionEvaluator implements PermissionEvaluator {

    @Override
    public boolean hasPermission(Authentication auth, Object target, Object perm) {
        if (target instanceof MyRequest) { //first class of target object...
            MyRequest req = (MyRequest) target;
            if (perm.equals("cancel")) { //action we wish to perform on the object
                return auth.getName().equals(req.getEmployee());
            } else if (perm.equals("list")) { //another action
                return !hr.getEmployee().equals("rod") || auth.getName.equals("rod");
            }
        } else if (target instanceof ...) { //second class of target object...
            ...
        }
        throw new UnsupportedOperationException("hasPermission not supported");
    }

}

He mentions that this way of implementing, is only OK for small applications, but in practice, it should be split in multiple methods or classes. It was exactly what I was thinking:

in a multi-module application, multiple modules can be unaware of one another
we should apply the Open-Close principle (when adding a new module)

My question is, how would you address the problem?
My take would be to have a global permission evaluator and one permission evaluator for each target object class.
public interface TargetPermissionEvaluator extends PermissionEvaluator {
    Class getTargetClass(); //so we know for which target class we can use it
}

public class MyGlobalPermissionEvaluator implements PermissionEvaluator {

    @Autowired
    private List<TargetPermissionEvaluator> evaluators;

    @Override
    public boolean hasPermission(Authentication auth, Object target, Object perm) {
        for (MyEvaluator evaluator : evaluators) {
             if (target instanceof evaluator.getTargetClass()) {
                  return evaluator.hasPermission(auth, target, perm);
             }
        }
        throw new UnsupportedOperationException("hasPermission not supported");
    }

}

The List of evaluators, will be defined in Spring XML configuration. What do you think? Is a good way or do you have better ideas? Am I missing some more suitable design pattern?
Answer: First, there is an issue with using instanceof against Class.  You really want to use Class#isAssignableFrom in this instance (no pun intended).  However, that is not really central to your question.
To your original question, I really like the use of structures like Google Guava's Predicate.  It contains a single method likes(T), where T is a generic type, and returns a boolean.
Create a new interface such as
interface PollablePermissionEvaulator<T> extends PermissionEvaluator, Predicate<T> {}

Then, you can have your look query likes(T) on each, and if so, invoke a nested hasPermission() call.
Answer: I think your proposed design is quite good and integrates well into Spring Security's design. After all, there are at least two other places where it is done like that:

the default AfterInvocationManager delegates to AfterInvocationProviders
the default AccessDecisionManager delegates to AccessDecisionVoters

In both cases, the interface of the delegated objects mirrors the interface of the delegator. Although it's easy to implement this makes me wonder why they didn't implement something like that for the PermissionEvaluator as well.


How can I create sheet 2 in a CSV file by using Python code?

Question: Is there is way to create sheet 2 in same csv file by using python code
Comment: Welcome to Stack Overflow! Please review [**How to ask**](https://stackoverflow.com/help/how-to-ask) questions on Stack Overflow and [what types of questions can be asked](https://stackoverflow.com/help/on-topic) and [what types should be avoided](https://stackoverflow.com/help/dont-ask)
Comment: Nope. https://stackoverflow.com/questions/29615196/is-csv-with-multi-tabs-sheet-possible
Comment: You need to expand your question. What data do you have (show examples) and what kind of output are you trying to achieve with it?
Comment: I have a dictionary like {'First':1,'Second':2}.if i save this dictionary to **my_file.csv** by using DictWriter,my result will be stored in my_file.csv's **sheet 2** not in **sheet 1**.That is my question.Is possible to make this?
Comment: Did you get the answer for this @Ashok?
Answer: yes. There is :
<code>df = pd.read_excel("C:\\DWDM\\Status.xlsx") # read ur original file

workbook = load_workbook(filename="C:\\DWDM\\Status.xlsx")

ws2 = workbook.create_sheet("Summary", 0) # other sheet with name Summary is added to the same.
</code>
and you can check the same with "workbook.sheetnames"
Answer: You can do this by using multiple CSV files - one CSV file per sheet.
A comma-separated value file is a plain text format. It is only going to be able to represent flat data, such as a table (or a "sheet")
When storing multiple sheets, you should use separate CSV files. You can write each one separately and import/parse them individually into their destination.
Comment: Can you give me a example?


Grouping a large set of ReactDOM.render() calls in a root component

Question: Let's say I have a large HTML document with numerous React Components embedded in parts of it.
For example:

...

Static Content

 id="react-component-2">...

...

As you can see, there are static elements in-between my dynamic elements. I'd imagine that this situation is common in web sites that are slowly bringing React in to there toolchain.
Right now my application works like this:
function renderPage(data) {
    ReactDOM.render(<Component {...data} />, document.getElementById("react-component-1"));
    ReactDOM.render(<Component {...data} />, document.getElementById("react-component-2"));
    ReactDOM.render(<Component {...data} />, document.getElementById("react-component-3"));
}

renderPage() is called upon the success of an ajax request. This makes my components update as intended, and it seems pretty performant.
However, it would be much nicer if I had a root React component that handled the state of the application, and pushed down changes to data as props.
I can't make a root component though because not everything on my page is dynamic, I need to preserve the static content in-between the React components.
I would love to be able to do something like this though:
class Root extends React.Component {

    constructor(props) {
        super(props);
        this.data = {...};
     }

    render() {
        ReactDOM.render(<Component {...this.state.data} />, document.getElementById("react-component-1"));
        ReactDOM.render(<Component {...this.state.data} />, document.getElementById("react-component-2"));
        ReactDOM.render(<Component {...this.state.data} />, document.getElementById("react-component-3"));
    }

    return false;
}

Is it possible to use React this way? At first I unsure of how it would be possible, because ReactDOM expects an element to render components in to, which would clear out my static content when I render my root component. Now I am thinking I could just do new Root(), but I have yet to test this.
Another option that I just thought of was keeping the renderPage() function and calling it ONCE instead of every time AJAX is loaded. Each component would then listen for a custom event that is fired on the AJAX success, which contains the new data. This seems slower though... And I might as well use Redux for the application state.
Comment: this is not the right way to approach react, the whole point is that you have modular components you can use over and over. You should think about what types of components you have, h1, h2, & p from the above as separate components, once you have that passing in static data as props is the way to go. Check this out: https://facebook.github.io/react/docs/thinking-in-react.html
Comment: i am aware of how React is intended to be used. There's no indication that inflexible or redundant components exist in my example code. You are missing the point unfortunately. The use-case here is that not all content on the page can be React. There are many elements that aren't going to be dynamic in nature, but I would like to wrap everything in a root level component so that I can leverage the component lifecycle to refresh the props of my dynamic elements.
Comment: Umm, thats exactly what I said...put the non dynamic stuff in the react component....you dont have to use props, you can just put the content in as you like: exactly like the answer below. It's not a cross roads, its how its done. Its the best practice for what you are asking for. And like the answer points out, your in for a world of hurt if this thing grows and you have to change it.
Comment: I should have been clearer in my original comment, thats on me, my bad
Answer: You shouldn't use the render method of a React component to call ReactDOM.render the way you do it in your example Root component. The render method of a component can return either a valid React element (for example,
) or null and is not supposed to do any mutations, such as modifying the DOM, etc. If a React component needs to do some DOM mutations, it should do it from lifecycle hooks such as ComponentDidMount or ComponentDidUpdate.
To answer you question, it depends whether your static content, can be included in a React component or not.
If you can, which would be ideal, you can refactor your code to have a Root component like so :
class Root extends React.Component {
    render() {
        return (
            <Component data={ this.props.data } />

Static Content

            <Component data={ this.props.data } />

            <Component data={ this.props.data } />
        );
    }
}

and to have one call to ReactDOM.render :
ReactDOM.render(<Root data={ data } />, document.getElementById('my-react-mounting-point'));

If you cannot, that is if you need to have different React render trees, your current approach is fine. If you do this, though, be careful to call ReactDOM.unmountComponentAtNode when you do not need the component anymore, or you might face memory leak issues. This article from React's blog has several nice tips about the precautions to use when having various render trees + a ReactComponentRenderer boilerplate to avoid common pitfalls.
Comment: Thanks for your response, this is the crossroads I found myself in. It would be a lot of extra work to rebuild the static content as JSX. I was a little worried about calling ReactDOM.render() multiple times on the same components, but it seems as though it's working fine and leveraging the Virtual DOM as intended to diff what needs to be replaced.
Comment: @lostPixels ok. I've added a link with some React tips about it


Show that the given function is continuous at $(0,0)$ using $\varepsilon-\delta$ definition.

Question: Consider
$$f(x,y) =\begin{cases} \frac{xy}{\sqrt{x^2 +y^2}
} & (x,y)\neq (0,0) \\
0 & (x,y)=(0,0)
\end{cases}$$
Show that $f(x,y)$ is continuous at $(0,0)$.
My method
We have,
$|f(x,y)-0| = |x||\frac{y}{\sqrt{x^2 +y^2}}| < \delta\cdot1$.
Consider, $\delta<\varepsilon$. ($\delta>0$)
Then for any $\varepsilon > 0$, there exists a $\delta<\varepsilon$ such that $|f(x,y)-0|<\varepsilon$ for all $(x,y)$ that satisfies the inequation $x^2 +y^2 < \delta^2$. Hence, $f(x,y)$ is continuous at $(0,0)$.
Is this proof correct?
Comment: For me seems fine.
Comment: It is not well written though
Answer: Your choice of $\delta$ works. Indeed, choosing $\delta = \varepsilon$ works as well; don't forget, if you were to choose this, then $\sqrt{x^2 + y^2} < \delta$ if and only if $\sqrt{x^2 + y^2} < \varepsilon$.
What's not so clear from your proof is why this choice works. You need to work on your mathematical exposition. The last we see any specifics about $f(x, y)$ is the first line. After this, the choice of $\delta$ is merely asserted. What is it about this function $f(x, y)$ that makes this choice of $\delta$ appropriate?
Here's an argument that I think your proof is missing. Note that
$$x^2 + y^2 \ge y^2$$
as $x^2 \ge 0$. Taking the square root of both sides,
$$\sqrt{x^2 + y^2} \ge |y|,$$
hence
$$\left|\frac{y}{\sqrt{x^2 + y^2}}\right| \le 1 \implies |x| \left|\frac{y}{\sqrt{x^2 + y^2}}\right| \le |x| \le \sqrt{x^2 + y^2},$$
by a similar argument as above, involving $x$ instead of $y$. Thus, if we assume $0 < \sqrt{x^2 + y^2} < \varepsilon$, then
$$|x| \left|\frac{y}{\sqrt{x^2 + y^2}}\right| < \varepsilon,$$
which implies $|f(x, y) - 0| < \varepsilon$.
Comment: I've added an answer below. Can you check whether that looks fine or not?
Comment: It's better... still seems a little terse though. But at least now it points towards why the choice of $\delta$ works.
Answer: Let $\varepsilon >0$.
Choose $\delta<\varepsilon$.
If $x^2 + y^2 < \delta \implies |x|<\delta$. Then,
$|f(x,y)-0| = |x||\frac{y}{\sqrt{x^2 +y^2}}| < \delta\cdot1 < \varepsilon$.
Hence, by $\varepsilon-\delta$ definition of continuity, $f(x,y)$ is continous at $(0,0)$.