问:
Scramble a floating point number?
I need a repeatable pseudo-random function from floats in [0,1] to floats in [0,1].  I.e. given a 32-bit IEEE float, return a "different" one (as random as possible, given the 24 bits of mantissa).  It has to be repeatable, so keeping tons of internal state is out.  And unfortunately it has to work with only 32-bit int and single-float math (no doubles and not even 32x32=64bit multiply, though I could emulate that if needed -- basically it needs to work on older CUDA hardware).  The better the randomness the better, of course, within these rather severe limitations.  Anyone have any ideas?

(I've been through Park-Miller, which requires 64-bit int math, and the CUDA version of Park-Miller which requires doubles, Mersenne Twisters which have lots of internal state, and a few other things which didn't work.)

答:
Best I understand the requirements, a hash accomplishes the desired functionality. Re-interprete the float input as an integer, apply the hash function to produce an integer approximately uniformly distributed in [0,2^32), then multiply this integer by 2^-32 to convert the resulting integer back to a float roughly uniformly distributed in [0,1]. One suitable hash function which does not require multiplication is Bob Jenkin's mix(), which can be found here: http://www.burtleburtle.net/bob/hash/doobs.html.

To re-interpret the bits of a float as an integer and vice versa, there are two choices in CUDA. Use intrinsics, or use C++-style reinterpretation casts:

```<code>float f;
int i;
i = __float_as_int(f);
f = __int_as_float(i);
i = reinterpret_cast<int&>(f);
f = reinterpret_cast<float&>(i);
</code>```

So as a self-contained function, the entire process might look something like this:

```<code>/* transform float in [0,1] into a different float in [0,1] */
float scramble_float (float f)
{
    unsigned int magic1 = 0x96f563ae; /* number of your choice */
    unsigned int magic2 = 0xb93c7563; /* number of your choice */
    unsigned int j;
    j = reinterpret_cast<unsigned int &>(f);
    mix (magic1, magic2, j);
    return 2.3283064365386963e-10f * j;
}
</code>```

Title: Scramble a floating point number?

Body:
Best I understand the requirements, a hash accomplishes the desired functionality. Re-interprete the float input as an integer, apply the hash function to produce an integer approximately uniformly distributed in [0,2^32), then multiply this integer by 2^-32 to convert the resulting integer back to a float roughly uniformly distributed in [0,1]. One suitable hash function which does not require multiplication is Bob Jenkin's mix(), which can be found here: http://www.burtleburtle.net/bob/hash/doobs.html.

To re-interpret the bits of a float as an integer and vice versa, there are two choices in CUDA. Use intrinsics, or use C++-style reinterpretation casts:

float f;
int i;
i = __float_as_int(f);
f = __int_as_float(i);
i = reinterpret_cast<int&>(f);
f = reinterpret_cast<float&>(i);

So as a self-contained function, the entire process might look something like this:

/* transform float in [0,1] into a different float in [0,1] */
float scramble_float (float f)
{
    unsigned int magic1 = 0x96f563ae; /* number of your choice */
    unsigned int magic2 = 0xb93c7563; /* number of your choice */
    unsigned int j;
    j = reinterpret_cast<unsigned int &>(f);
    mix (magic1, magic2, j);
    return 2.3283064365386963e-10f * j;
}


来源: stackexchange

问:
how could I make click events pass through a window using python?
I want to add overlays to my screen that displays some shapes using python and I am trying to achieve this by making a window transparent and make click events pass through the window. I am using python 3.6 (i can change the version if neccesary) and I am on windows 10.

Note: similar questions have been asked in the past here and here but neither answer my question.

Thanks in advance

答:
Tkinter does not have passing events to parent widgets. But it is possible to simulate the effect through the use of  bindtags

Making a binding to a widget is not equal to adding a binding to a widget. It is binding to a bindtag which has the same name as the widget, but it's not actually the widget.

Widgets have a list of bindtags,  when an event happens on a widget, the bindings for each tag are processed.

```<code>import Tkinter as tk

class BuildCanvas(tk.Frame):
    def __init__(self, parent):
        tk.Frame.__init__(self, parent)

        self.main = tk.Canvas(self, width=250, height=250,
                              borderwidth=0, highlightthickness=0,
                              background="linen")
        self.main.pack(side="top", fill="both", expand=True)

        self.main.bind("<1>", self.on_main_click)

        for x in range(10):
            for y in range(10):
                canvas = tk.Canvas(self.main, width=35, height=35,
                                   borderwidth=1, highlightthickness=0,
                                   relief="groove")
                if ((x+y)%2 == 0):
                    canvas.configure(bg="yellow")

                self.main.create_window(x*45, y*45, anchor="nw", window=canvas)

                bindtags = list(canvas.bindtags())
                bindtags.insert(1, self.main)
                canvas.bindtags(tuple(bindtags))
                canvas.bind("<1>", self.on_sub_click)

    def on_sub_click(self, event):
        print("sub-canvas binding")
        if event.widget.cget("background") == "yellow":
            return "break"

    def on_main_click(self, event):
        print("main widget binding")

if __name__ == "__main__":
    root = tk.Tk()
    BuildCanvas(root).pack (fill="both", expand=True)
    root.mainloop()
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Tkinter does not have passing events to parent widgets. But it is possible to simulate the effect through the use of  bindtags

Making a binding to a widget is not equal to adding a binding to a widget. It is binding to a bindtag which has the same name as the widget, but it's not actually the widget.

Widgets have a list of bindtags,  when an event happens on a widget, the bindings for each tag are processed.

import Tkinter as tk

class BuildCanvas(tk.Frame):
    def __init__(self, parent):
        tk.Frame.__init__(self, parent)

        self.main = tk.Canvas(self, width=250, height=250,
                              borderwidth=0, highlightthickness=0,
                              background="linen")
        self.main.pack(side="top", fill="both", expand=True)

        self.main.bind("<1>", self.on_main_click)

        for x in range(10):
            for y in range(10):
                canvas = tk.Canvas(self.main, width=35, height=35,
                                   borderwidth=1, highlightthickness=0,
                                   relief="groove")
                if ((x+y)%2 == 0):
                    canvas.configure(bg="yellow")

                self.main.create_window(x*45, y*45, anchor="nw", window=canvas)

                bindtags = list(canvas.bindtags())
                bindtags.insert(1, self.main)
                canvas.bindtags(tuple(bindtags))
                canvas.bind("<1>", self.on_sub_click)

    def on_sub_click(self, event):
        print("sub-canvas binding")
        if event.widget.cget("background") == "yellow":
            return "break"

    def on_main_click(self, event):
        print("main widget binding")

if __name__ == "__main__":
    root = tk.Tk()
    BuildCanvas(root).pack (fill="both", expand=True)
    root.mainloop()


问:
get array values in python
I have the values arr1  as 25,26 and arr2 values as A,B

Its always that the number of values in arr1 and arr2 are equal

My question is that

```<code>          for i in arr1.split(","):
                print i //prints 25 and 26
</code>```

is it not possible to get the values of arr2 in the same loop or should  another loop be written only for this purpose.Basically the idea is that map the values of arr1 and arr2

答:
```<code>for i in (arr1, arr2):
    for j in i.split(","):
        print j
</code>```

Results in output:

```<code>25
26
A
B
</code>```

And so does:

```<code>for i in ",".join((arr1, arr2)).split(","):
    print i
</code>```

Although I think this 2nd version is slower, a lot less readable and difficult to work out what's going on. So I'd stick with the first solution, even if it does have an extra loop

ContentLicense: CC BY-SA 3.0

Title: get array values in python

Body:
I have the values arr1  as 25,26 and arr2 values as A,B

Its always that the number of values in arr1 and arr2 are equal

My question is that

          for i in arr1.split(","):
                print i //prints 25 and 26

is it not possible to get the values of arr2 in the same loop or should  another loop be written only for this purpose.Basically the idea is that map the values of arr1 and arr2

Body:
for i in (arr1, arr2):
    for j in i.split(","):
        print j

Results in output:

25
26
A
B

And so does:

for i in ",".join((arr1, arr2)).split(","):
    print i

Although I think this 2nd version is slower, a lot less readable and difficult to work out what's going on. So I'd stick with the first solution, even if it does have an extra loop


问:
Kivy add items to accordion programmatically
I have a simple tabbed application.
Now in every tab i am going to have an accordion

I have created the layout in a *.kv file.
Now my question is (might be a stupid one but i am fairly new on how kivy works): How can i add items and sub items in the accordion i created.

In this example i am building a tv viewing app.
So for example Live Tv will have the accordion titles as the groups of the channels and inside the channels (which i am going to get from a db)

Here is my python code:

```<code>from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.config import Config
from kivy.uix.accordion import Accordion, AccordionItem

class LiveTV(Accordion):
    def ListItems(self):
        root = Accordion()
        for x in range(1, 3, 1):
            item = AccordionItem(title='Page % d' % x)
            root.add_widget(item)
        return root

class Display(TabbedPanel):
    def __init__(self, **kwargs):
        super(Display, self).__init__(**kwargs)
        rootAc = LiveTV.ListItems(self)

class IptvApp(App):
    def build(self):
        Config.set('graphics', 'width', '1366')
        Config.set('graphics', 'height', '768')
        Config.set('graphics', 'resizable', False)
        # Change to auto for full screen app
        Config.set('graphics', 'fullscreen', '0')
        # Maximized for full resolution app
        Config.set('graphics', 'window_state', 'visible')
        # To remove right click orange dot (touch emulation)
        Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
        Config.write()
        return Display()

if __name__ == '__main__':
    IptvApp().run()
</code>```

And here is my *.kv file

```<code><Button>:
font_size: 40
color:0.3,0.6,0.7,1
size_hint: 0.4, 0.05

<Display>
    tab_width: 600
    size_hint: 1, 1
    do_default_tab: False

    TabbedPanelItem:
        text: 'Live TV'
        FloatLayout:
            Accordion:
                size_hint: 0.3,0.2
                pos_hint: {"top": 1}
                orientation: 'vertical'
                AccordionItem:
                    title: 'Plot'
                AccordionItem:
                    title: 'Number'
                AccordionItem:
                    title: 'Another number'

    TabbedPanelItem:
        text: 'Video On Demand'
        FloatLayout:
            Label:
                text: 'Second tab content area'
            Button:
                pos_hint: {"top": 0.4, "right": 0.7}
                text: 'Button that does nothing'

    TabbedPanelItem:
        text: 'Series'

    TabbedPanelItem:
        text: 'Settings'
</code>```

And here is the display:

How can target programmatically that accordion i did in the *.kv file so i can populate with items and sub items?

Regards,

答:
Ok so i figured it out. For all those who end up here this is how its done:

in the kv file the element you want to target programmatically add an new property id i.e. for example

```<code>Button:
    id: btn_submit
</code>```

and in the parent "class" in my case <Display> define that element i.e.

```<code><Display>
    btnSubmit: btn_submit
</code>```

Now in python code where class Display is defined you can target the button by simply writing: self.btnSubmit.* you can for example add_widget or anything you want.

Body:
I have a simple tabbed application.
Now in every tab i am going to have an accordion

I have created the layout in a *.kv file.
Now my question is (might be a stupid one but i am fairly new on how kivy works): How can i add items and sub items in the accordion i created.

In this example i am building a tv viewing app.
So for example Live Tv will have the accordion titles as the groups of the channels and inside the channels (which i am going to get from a db)

Here is my python code:

from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel
from kivy.config import Config
from kivy.uix.accordion import Accordion, AccordionItem

class LiveTV(Accordion):
    def ListItems(self):
        root = Accordion()
        for x in range(1, 3, 1):
            item = AccordionItem(title='Page % d' % x)
            root.add_widget(item)
        return root

class Display(TabbedPanel):
    def __init__(self, **kwargs):
        super(Display, self).__init__(**kwargs)
        rootAc = LiveTV.ListItems(self)

class IptvApp(App):
    def build(self):
        Config.set('graphics', 'width', '1366')
        Config.set('graphics', 'height', '768')
        Config.set('graphics', 'resizable', False)
        # Change to auto for full screen app
        Config.set('graphics', 'fullscreen', '0')
        # Maximized for full resolution app
        Config.set('graphics', 'window_state', 'visible')
        # To remove right click orange dot (touch emulation)
        Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
        Config.write()
        return Display()

if __name__ == '__main__':
    IptvApp().run()

And here is my *.kv file

<Button>:
font_size: 40
color:0.3,0.6,0.7,1
size_hint: 0.4, 0.05

<Display>
    tab_width: 600
    size_hint: 1, 1
    do_default_tab: False

    TabbedPanelItem:
        text: 'Live TV'
        FloatLayout:
            Accordion:
                size_hint: 0.3,0.2
                pos_hint: {"top": 1}
                orientation: 'vertical'
                AccordionItem:
                    title: 'Plot'
                AccordionItem:
                    title: 'Number'
                AccordionItem:
                    title: 'Another number'

    TabbedPanelItem:
        text: 'Video On Demand'
        FloatLayout:
            Label:
                text: 'Second tab content area'
            Button:
                pos_hint: {"top": 0.4, "right": 0.7}
                text: 'Button that does nothing'

    TabbedPanelItem:
        text: 'Series'

    TabbedPanelItem:
        text: 'Settings'

And here is the display:

How can target programmatically that accordion i did in the *.kv file so i can populate with items and sub items?

Regards,

Body:
Ok so i figured it out. For all those who end up here this is how its done:

in the kv file the element you want to target programmatically add an new property id i.e. for example

Button:
    id: btn_submit

and in the parent "class" in my case <Display> define that element i.e.

<Display>
    btnSubmit: btn_submit

Now in python code where class Display is defined you can target the button by simply writing: self.btnSubmit.* you can for example add_widget or anything you want.


问:
cordova-plugin-admob-free producing error during build process?
While building the android app using cordova, i encountered following error log:-

```<code>BUILD FAILED in 1m 21s
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\gradlew: Command failed with exit code 1 Error output:
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:5: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                              ^
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:243: error: cannot find symbol
@NonNull
 ^
symbol:   class NonNull
 location: class AdMob
 2 errors

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
</code>```

As specified in question, it's occuring due to cordova-plugin-admob-free.How can i remove the error?

答:
If anyone is encountering the same issue, I managed to solve it even if the fix is "dirty" but sometimes you just need to be able to build at any costs...

You need to modify platforms/android/app/src/main/java/name/ratson/cordova/admob/AdMob.java file.

Replace line 5 of file:

import android.support.annotation.NonNull;
```

<p>by</p>

<pre class="lang-java prettyprint-override"><code>import androidx.annotation.NonNull;
</code>```

You'll also need cordova-plugin-androidx plugin to be installed.

Body:
While building the android app using cordova, i encountered following error log:-

BUILD FAILED in 1m 21s
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\gradlew: Command failed with exit code 1 Error output:
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:5: error: package android.support.annotation does not exist
import android.support.annotation.NonNull;
                              ^
C:\Users\gagan\Projects\hybrid\framework\error\framework7\quotes\cordova\platforms\android\app\src\main\java\name\ratson\cordova\admob\AdMob.java:243: error: cannot find symbol
@NonNull
 ^
symbol:   class NonNull
 location: class AdMob
 2 errors

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

As specified in question, it's occuring due to cordova-plugin-admob-free.How can i remove the error?

Body:
If anyone is encountering the same issue, I managed to solve it even if the fix is "dirty" but sometimes you just need to be able to build at any costs...

You need to modify platforms/android/app/src/main/java/name/ratson/cordova/admob/AdMob.java file.

Replace line 5 of file:

import android.support.annotation.NonNull;

by

import androidx.annotation.NonNull;

You'll also need cordova-plugin-androidx plugin to be installed.


问:
How push element to an array using Array.prototype.splice() method?
I know we can push/append a new element to an array using Array.prototype.push(), however i was thinking if i can achieve same behaviour using Array.prototype.splice()?

I tried to give index -1 but it doesn't seem to give me expected result and i found correspond Q&A here:

const arr = ['a', 'b']
arr.splice(-1, 0, 'c')

console.log(arr) // ['a', 'c', 'b']```

Therefore i was wondering if i could simulate Array.prototype.push() using Array.prototype.splice() API?

答:
```<code>arr.splice(arr.length, 0, 'c')
</code>```

Body:
I know we can push/append a new element to an array using Array.prototype.push(), however i was thinking if i can achieve same behaviour using Array.prototype.splice()?

I tried to give index -1 but it doesn't seem to give me expected result and i found correspond Q&A here:

const arr = ['a', 'b']
arr.splice(-1, 0, 'c')

console.log(arr) // ['a', 'c', 'b']

Therefore i was wondering if i could simulate Array.prototype.push() using Array.prototype.splice() API?

Body: arr.splice(arr.length, 0, 'c')


问:
Why do these constant functions performance differ?
In the following snippet, why is py_sqrt2 almost twice as fast as np_sqrt2?

from time import time
from numpy import sqrt as npsqrt
from math import sqrt as pysqrt

NP_SQRT2 = npsqrt(2.0)
PY_SQRT2 = pysqrt(2.0)

def np_sqrt2():
    return NP_SQRT2

def py_sqrt2():
    return PY_SQRT2

def main():
    samples = 10000000

    it = time()
    E = sum(np_sqrt2() for _ in range(samples)) / samples
    print("executed {} np_sqrt2's in {:.6f} seconds E={}".format(samples, time() - it, E))

    it = time()
    E = sum(py_sqrt2() for _ in range(samples)) / samples
    print("executed {} py_sqrt2's in {:.6f} seconds E={}".format(samples, time() - it, E))

if __name__ == "__main__":
    main()

```

<pre class="lang-none prettyprint-override"><code>$ python2.7 snippet.py
executed 10000000 np_sqrt2's in 1.380090 seconds E=1.41421356238
executed 10000000 py_sqrt2's in 0.855742 seconds E=1.41421356238
$ python3.6 snippet.py
executed 10000000 np_sqrt2's in 1.628093 seconds E=1.4142135623841212
executed 10000000 py_sqrt2's in 0.932918 seconds E=1.4142135623841212
</code>```

Notice that they are constant functions that just load from precomputed globals with the same value, and that the constants only differ in how they were computed at program start.

Moreover the disassembly of these functions show that they do as expected and only access the global constants.

```<code>In [73]: dis(py_sqrt2)
  2           0 LOAD_GLOBAL              0 (PY_SQRT2)
              2 RETURN_VALUE

In [74]: dis(np_sqrt2)
  2           0 LOAD_GLOBAL              0 (NP_SQRT2)
              2 RETURN_VALUE
</code>```

答:
After running perf record on two versions of the script one using only PY_SQRT2 and the other only NP_SQRT2 it seems that the one using the numpy constant is making extra calls.

This made me realize the two constants have different types:

```<code>In [4]: type(PY_SQRT2)
Out[4]: float

In [5]: type(NP_SQRT2)
Out[5]: numpy.float64
</code>```

And so operating with sum on (and maybe loading?) numpy.float64s is slower than native floats.

This answer helped as well.

Body:
In the following snippet, why is py_sqrt2 almost twice as fast as np_sqrt2?

from time import time
from numpy import sqrt as npsqrt
from math import sqrt as pysqrt

NP_SQRT2 = npsqrt(2.0)
PY_SQRT2 = pysqrt(2.0)

def np_sqrt2():
    return NP_SQRT2

def py_sqrt2():
    return PY_SQRT2

def main():
    samples = 10000000

    it = time()
    E = sum(np_sqrt2() for _ in range(samples)) / samples
    print("executed {} np_sqrt2's in {:.6f} seconds E={}".format(samples, time() - it, E))

    it = time()
    E = sum(py_sqrt2() for _ in range(samples)) / samples
    print("executed {} py_sqrt2's in {:.6f} seconds E={}".format(samples, time() - it, E))

if __name__ == "__main__":
    main()

$ python2.7 snippet.py
executed 10000000 np_sqrt2's in 1.380090 seconds E=1.41421356238
executed 10000000 py_sqrt2's in 0.855742 seconds E=1.41421356238
$ python3.6 snippet.py
executed 10000000 np_sqrt2's in 1.628093 seconds E=1.4142135623841212
executed 10000000 py_sqrt2's in 0.932918 seconds E=1.4142135623841212

Notice that they are constant functions that just load from precomputed globals with the same value, and that the constants only differ in how they were computed at program start.

Moreover the disassembly of these functions show that they do as expected and only access the global constants.

In [73]: dis(py_sqrt2)
  2           0 LOAD_GLOBAL              0 (PY_SQRT2)
              2 RETURN_VALUE

In [74]: dis(np_sqrt2)
  2           0 LOAD_GLOBAL              0 (NP_SQRT2)
              2 RETURN_VALUE

Body:
After running perf record on two versions of the script one using only PY_SQRT2 and the other only NP_SQRT2 it seems that the one using the numpy constant is making extra calls.

This made me realize the two constants have different types:

In [4]: type(PY_SQRT2)
Out[4]: float

In [5]: type(NP_SQRT2)
Out[5]: numpy.float64

And so operating with sum on (and maybe loading?) numpy.float64s is slower than native floats.

This answer helped as well.


问:
Drawing scaled bitmaps on a SurfaceView -- no antialiasing
I'm sorry if this topic has been brought before, but all my searches on the web and google groups did not help me.

I'm currently developing a little game with the Android SDK, and use hi-res bitmaps that I resize accordingly to match the device's resolution (letting the system do it for me is
not "crisp" enough).

I use a SurfaceView, on which I paint in one pass a canvas filling the whole surface. The paint uses setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)) to allow masking.
Beforehand, I retrieve various bitmaps -- which are resized at initialization with createScaledBitmap() and put in a cache -- and I apply the bitmaps with a paint on this canvas, before drawing this canvas on the SurfaceView.

My problem is, whatever I try, whatever paint settings I use (dithering, antialias, etc..), the resized bitmaps are not antialiased and the drawing present jagged edges. I tried everything.
The only little success I had was using inSampleSize to approach the desired scaled size and force a first pass of antialiasing, before invoking createScaledBitmap on the retrieved
hi-res bitmap, but it is not beautiful enough. I just can't allow to create multitudes of pre-sized bitmaps for every combination of resolution. What did I miss ?

Thanks a lot in advance

答: If it comes down to it, you can manually antialias without too much trouble.  Just apply a simple lowpass filter (something like an NxN average) to the pixel data before asking the bitmap object to rescale itself.</p>


问:
.Net Core - Editing ListBoxFor - selected options are not shown
I'm trying to edit the multi-select list.

In my view model, I have these fields: (among others)

```<code>            public List<string> BloodExamsSelected { get; set; }
            public List<BloodExamsRef> BloodExams { get; set; }
            public List<string> UrineExamsSelected { get; set; }
            public List<UrineExamsRef> UrineExams { get; set; }
            public List<SelectListItem> _dbBloodExams { get; set; }
            public List<SelectListItem> _dbUrineExams { get; set; }
</code>```

On the controller, I'm passing the values from the database to the _dbBloodExams and _dbUrineExams.
Also, BloodExams and UrineExams are hard-coded and predefined.

```<code>x.BloodExams = new List<BloodExamsRef>
                {
                    new BloodExamsRef(){BloodTest="Blood01T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood02T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood03T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood04T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood05T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood06T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood07T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood08T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood09T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood010T",Unit="m/L",Low=1.2,High=4.9}
                };
            x.UrineExams = new List<UrineExamsRef>
                {
                    new UrineExamsRef(){UrineTest="Urine01T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine02T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine03T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine04T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine05T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine06T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine07T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine08T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine09T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine010T",ReferenceInterval="Od do",Unit="mol/dL"}
                };

            x._dbBloodExams = _db.BloodExaminations.Where(ui => ui.ReferralsId == x.Id).Select(z => new SelectListItem
            {
                Value = z.BloodTest,
                Text = z.BloodTest,
                Selected = true

            }).ToList();

            x._dbUrineExams = _db.UrineExaminations.Where(ui => ui.ReferralsId == x.Id).Select(z => new SelectListItem
            {
                Value=z.UrineTest,
                Text = z.UrineTest,
                Selected =true

            }).ToList();
</code>```

On the Edit View, I'm having a problem! The whole predefined list is shown but it is not selected what's already in the database!!!

```<code><div class="d-inline-block">
        @Html.LabelFor(Model => Model.BloodExamsSelected, new { @class = "col-sm-12" })
        @Html.ListBoxFor(Model => Model.BloodExamsSelected, new MultiSelectList(Model.BloodExams, "BloodTest", "BloodTest", Model._dbBloodExams), new { htmlAttributes = new {@name="MSL", @class = "form-control", @multiple = "multiple" } })<br />
        @Html.ValidationMessageFor(Model => Model.BloodExamsSelected, "", new { @class = "text-danger" })
    </div>
    <div class="d-inline-block">
        @Html.LabelFor(Model => Model.UrineExamsSelected, new { @class = "col-sm-12" })
        @Html.ListBoxFor(Model => Model.UrineExamsSelected, new SelectList(Model.UrineExams, "UrineTest", "UrineTest", Model._dbUrineExams), new { htmlAttributes = new { @name = "MSL", @class = "form-control", @multiple="multiple" } })<br />
        @Html.ValidationMessageFor(Model => Model.UrineExamsSelected, "", new { @class = "text-danger" })
    </div>
</code>```

Is there any way to make this work?
Thanks in advance!

答:
The trick was to fill the list of selected objects on the controller and to pass it to the view, as well:

```<code>x.BloodExamsSelected= _db.BloodExaminations.Where(bi => bi.ReferralsId == x.Id).Select(n => n.BloodTest).ToList();
x.UrineExamsSelected = _db.UrineExaminations.Where(ui => ui.ReferralsId == x.Id).Select(n => n.UrineTest).ToList();
</code>```

(Probably, on the view, selected objects(Model._db?????Exams) are comparing with the array of Model.?????ExamsSelected !?)

```<code> @Html.ListBoxFor(Model => Model.BloodExamsSelected, new MultiSelectList(Model.BloodExams, "BloodTest", "BloodTest", Model._dbBloodExams), new { @style = "height:200px; width:200px; text-align:center;", @name = "MSL1", @class = "form-control", @multiple = "multiple" })
@Html.ListBoxFor(Model => Model.UrineExamsSelected, new MultiSelectList(Model.UrineExams, "UrineTest", "UrineTest", Model._dbUrineExams), new { @style = "height:200px; width:200px; text-align:center;", @name = "MSL2", @class = "form-control", @multiple = "multiple" })
</code>```

Anyway, now it works as it is meant to work :D

Body:
I'm trying to edit the multi-select list.

In my view model, I have these fields: (among others)

            public List<string> BloodExamsSelected { get; set; }
            public List<BloodExamsRef> BloodExams { get; set; }
            public List<string> UrineExamsSelected { get; set; }
            public List<UrineExamsRef> UrineExams { get; set; }
            public List<SelectListItem> _dbBloodExams { get; set; }
            public List<SelectListItem> _dbUrineExams { get; set; }

On the controller, I'm passing the values from the database to the _dbBloodExams and _dbUrineExams.
Also, BloodExams and UrineExams are hard-coded and predefined.

x.BloodExams = new List<BloodExamsRef>
                {
                    new BloodExamsRef(){BloodTest="Blood01T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood02T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood03T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood04T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood05T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood06T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood07T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood08T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood09T",Unit="m/L",Low=1.2,High=4.9},
                    new BloodExamsRef(){BloodTest="Blood010T",Unit="m/L",Low=1.2,High=4.9}
                };
            x.UrineExams = new List<UrineExamsRef>
                {
                    new UrineExamsRef(){UrineTest="Urine01T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine02T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine03T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine04T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine05T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine06T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine07T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine08T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine09T",ReferenceInterval="Od do",Unit="mol/dL"},
                    new UrineExamsRef(){UrineTest="Urine010T",ReferenceInterval="Od do",Unit="mol/dL"}
                };

            x._dbBloodExams = _db.BloodExaminations.Where(ui => ui.ReferralsId == x.Id).Select(z => new SelectListItem
            {
                Value = z.BloodTest,
                Text = z.BloodTest,
                Selected = true

            }).ToList();

            x._dbUrineExams = _db.UrineExaminations.Where(ui => ui.ReferralsId == x.Id).Select(z => new SelectListItem
            {
                Value=z.UrineTest,
                Text = z.UrineTest,
                Selected =true

            }).ToList();

On the Edit View, I'm having a problem! The whole predefined list is shown but it is not selected what's already in the database!!!

        @Html.LabelFor(Model => Model.BloodExamsSelected, new { @class = "col-sm-12" })
        @Html.ListBoxFor(Model => Model.BloodExamsSelected, new MultiSelectList(Model.BloodExams, "BloodTest", "BloodTest", Model._dbBloodExams), new { htmlAttributes = new {@name="MSL", @class = "form-control", @multiple = "multiple" } })

        @Html.ValidationMessageFor(Model => Model.BloodExamsSelected, "", new { @class = "text-danger" })

        @Html.LabelFor(Model => Model.UrineExamsSelected, new { @class = "col-sm-12" })
        @Html.ListBoxFor(Model => Model.UrineExamsSelected, new SelectList(Model.UrineExams, "UrineTest", "UrineTest", Model._dbUrineExams), new { htmlAttributes = new { @name = "MSL", @class = "form-control", @multiple="multiple" } })

        @Html.ValidationMessageFor(Model => Model.UrineExamsSelected, "", new { @class = "text-danger" })

Is there any way to make this work?
Thanks in advance!

Body:
The trick was to fill the list of selected objects on the controller and to pass it to the view, as well:

x.BloodExamsSelected= _db.BloodExaminations.Where(bi => bi.ReferralsId == x.Id).Select(n => n.BloodTest).ToList();
x.UrineExamsSelected = _db.UrineExaminations.Where(ui => ui.ReferralsId == x.Id).Select(n => n.UrineTest).ToList();

(Probably, on the view, selected objects(Model._db?????Exams) are comparing with the array of Model.?????ExamsSelected !?)

 @Html.ListBoxFor(Model => Model.BloodExamsSelected, new MultiSelectList(Model.BloodExams, "BloodTest", "BloodTest", Model._dbBloodExams), new { @style = "height:200px; width:200px; text-align:center;", @name = "MSL1", @class = "form-control", @multiple = "multiple" })
@Html.ListBoxFor(Model => Model.UrineExamsSelected, new MultiSelectList(Model.UrineExams, "UrineTest", "UrineTest", Model._dbUrineExams), new { @style = "height:200px; width:200px; text-align:center;", @name = "MSL2", @class = "form-control", @multiple = "multiple" })

Anyway, now it works as it is meant to work :D


问:
Unable to deploy to Heroku, no changes were made
I'm running into a deployment issue with Heroku. Yesterday, I was able to deploy without issues -- this morning, I built a new cluster on MongoDB and pushed a change to git with the new connection string. No other changes were made.

After pushing to git, I ran git push heroku master, and was faced with the below error:

```<code>. . .
remote:        added 1812 packages from 857 contributors and audited 932744 packages in 66.192s
remote:
remote:        65 packages are looking for funding
remote:          run `npm fund` for details
remote:
remote:        found 0 vulnerabilities
remote:
remote:
remote:        > client@0.1.0 build /tmp/build_3fd8925946ec2800b115594ca20fb426/client
remote:        > react-scripts build
remote:
remote:        Creating an optimized production build...
remote:        Failed to compile.
remote:
remote:        ./node_modules/simple-react-lightbox/dist/index.es.js
remote:        Cannot find module: 'fast-deep-equal/react'. Make sure this package is installed.
remote:
remote:        You can install this package by running: yarn add fast-deep-equal/react.
. . .
</code>```

Naturally, the first thing I did was try to run yarn add fast-deep-equal/react as advised, which threw the next error,

```<code>error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads ssh://git@github.com/fast-deep-equal/react.git
Directory: /Users/me/my-app
Output:
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
</code>```

I've been debugging for several hours now, and I can't seem to figure out a solution.

What could be going on here?

答:
In a similar case when I tried to deploy to Heroku I got identical messages. After trying some things (at random) I found the problem is the devDependencies. You would rather transfer all of them to normal dependencies:

```<code>npm install <module_name> --save-prod
</code>```

That solved my error, good luck!

Body:
I'm running into a deployment issue with Heroku. Yesterday, I was able to deploy without issues -- this morning, I built a new cluster on MongoDB and pushed a change to git with the new connection string. No other changes were made.

After pushing to git, I ran git push heroku master, and was faced with the below error:

. . .
remote:        added 1812 packages from 857 contributors and audited 932744 packages in 66.192s
remote:
remote:        65 packages are looking for funding
remote:          run `npm fund` for details
remote:
remote:        found 0 vulnerabilities
remote:
remote:
remote:        > client@0.1.0 build /tmp/build_3fd8925946ec2800b115594ca20fb426/client
remote:        > react-scripts build
remote:
remote:        Creating an optimized production build...
remote:        Failed to compile.
remote:
remote:        ./node_modules/simple-react-lightbox/dist/index.es.js
remote:        Cannot find module: 'fast-deep-equal/react'. Make sure this package is installed.
remote:
remote:        You can install this package by running: yarn add fast-deep-equal/react.
. . .

Naturally, the first thing I did was try to run yarn add fast-deep-equal/react as advised, which threw the next error,

error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads ssh://git@github.com/fast-deep-equal/react.git
Directory: /Users/me/my-app
Output:
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I've been debugging for several hours now, and I can't seem to figure out a solution.

What could be going on here?

Body:
In a similar case when I tried to deploy to Heroku I got identical messages. After trying some things (at random) I found the problem is the devDependencies. You would rather transfer all of them to normal dependencies:

npm install <module_name> --save-prod

That solved my error, good luck!


问:
Image "gradient blur"
in my application, I need to apply a blur-filter to an image. However, the effect should get stronger, the further the pixel is away from a line the user may draw freely in the image.

Lets assume the line the user draws splits the image horizontally exactly in the middle. Then along this line, the effect of the gradient should be 0%, half the way up and down from this line, the effect should be 50% etc. (If you have Picasa on your machine, there's a similar effect for an elliptic gradient)

Now I thought I might try the following (which I have not, so far - I'm just collecting ideas here): I might create a 100% blurred version of the image and combine it with the original image using an alpha-mask. This alpha-mask would be created from a simple black/white linear gradient.

Do you think this might work? Are there other implementations possible using filters directly?

答:
Yes, the approach you have in mind will work just fine.  Here are two images, the left is a normal image and the right is composed of two images on top of each other where the bottom is normal and the top is blurred and the top uses an opacity mask to blend the two together:

```<code><UniformGrid Columns="2">
    <Image Source="http://thecybershadow.net/misc/stackoverflow.png"/>
    <Grid>
        <Image Source="http://thecybershadow.net/misc/stackoverflow.png"/>
        <Image Source="http://thecybershadow.net/misc/stackoverflow.png">
            <Image.Effect>
                <BlurEffect Radius="5"/>
            </Image.Effect>
            <Image.OpacityMask>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="Transparent" Offset="0"/>
                    <GradientStop Color="White" Offset="1"/>
                </LinearGradientBrush>
            </Image.OpacityMask>
        </Image>
    </Grid>
</UniformGrid>
</code>```

And this is what it looks like with the right image progressively blurred as you go top to bottom:

Title: Image "gradient blur"

Body:
Yes, the approach you have in mind will work just fine.  Here are two images, the left is a normal image and the right is composed of two images on top of each other where the bottom is normal and the top is blurred and the top uses an opacity mask to blend the two together:

<UniformGrid Columns="2">
    <Image Source="http://thecybershadow.net/misc/stackoverflow.png"/>
    <Grid>
        <Image Source="http://thecybershadow.net/misc/stackoverflow.png"/>
        <Image Source="http://thecybershadow.net/misc/stackoverflow.png">
            <Image.Effect>
                <BlurEffect Radius="5"/>
            </Image.Effect>
            <Image.OpacityMask>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="Transparent" Offset="0"/>
                    <GradientStop Color="White" Offset="1"/>
                </LinearGradientBrush>
            </Image.OpacityMask>
        </Image>
    </Grid>
</UniformGrid>

And this is what it looks like with the right image progressively blurred as you go top to bottom:


问:
Conditional Preprocessor macro expansion in C
I have a macro, SOME_MACRO. It takes an argument.

Definition of SOME_MACRO:

#define SOME_MACRO(arg)  __SOME_MACRO(arg)

Further I want __SOME_MACRO(arg) to expand to "ABC" if arg is 0. And if arg is not zero, __SOME_MACRO(arg) should expand to "DEF"

Suppose I call with argument 0, that is: SOME_MACRO(0)
I need to test at preprocessing time, whether the argument is zero or not.

```<code>#if <argument is zero>     // line 1
#define __SOME_MACRO(arg) "ABC"
#elif
#define __SOME_MACRO(arg) "DEF"
#endif
</code>```

My question is: What should be at line 1?

Taking an example:

SOME_MACRO(2) should expand to "DEF"

SOME_MACRO(0) should expand to "ABC"

答:
This is not possible.  The expression given to #if is only evaluated once, at the line where #if is encountered.  There is no way to have it evaluated again each time you invoke your macro.

As  Eric Postpischil says, C does not have any general way to make the expansion of a macro conditional on its arguments.

A couple of possible alternatives:

Use an expression with the ternary ?: operator, as pmg suggested in a comment:

```<code>#define __SOME_MACRO(arg) ((arg) ? "DEF" : "ABC")
</code>```

Then SOME_MACRO(0) will expand to ((0) ? "DEF" : "ABC").  Any reasonable compiler will notice that the condition is a constant, and compile this just as if you had only written "ABC"; it should not generate code for a test nor for the unreachable branch.  Conditionals with the ternary operator can even be used in expressions that must be compile-time constants, as long as the condition is itself a compile-time constant; e.g. __SOME_MACRO(0) can be used to initialize a global or static variable.

Of course this will not work if the desired expansion is not syntactically an expression, e.g. if you are trying to use your macro to create declarations or definitions or something more syntactically elaborate.

If you know that only a small set of possible arguments will be used, you could use token pasting with the ## operator to expand the macro as one of another set of macros:

```<code>#define __SOME_MACRO_0 "ABC"
#define __SOME_MACRO_1 "DEF"
#define __SOME_MACRO_2 "DEF"
#define __SOME_MACRO(arg) __SOME_MACRO_ ## arg
</code>```

Then __SOME_MACRO(0) expands to "ABC" and __SOME_MACRO(2) expands to "DEF".  However __SOME_MACRO(3) will not compile unless you write a corresponding __SOME_MACRO_3 macro, and __SOME_MACRO(0+1) cannot be made to work at all, at least not in any way that I know of.

(As written, __SOME_MACRO(0+1) expands to "ABC"+1, which is equivalent to "BC" and will probably cause you a lot of confusion before you figure out what is wrong.  __SOME_MACRO(1-1) is even worse...)

Also, #define ZERO 0 followed by __SOME_MACRO(ZERO) doesn't work as it stands, thought it can be fixed by doing

```<code>#define SECOND_MACRO(arg) __SOME_MACRO_ # arg
#define __SOME_MACRO(arg) SECOND_MACRO(arg)
</code>```

Body:
I have a macro, SOME_MACRO. It takes an argument.

Definition of SOME_MACRO:

#define SOME_MACRO(arg)  __SOME_MACRO(arg)

Further I want __SOME_MACRO(arg) to expand to "ABC" if arg is 0. And if arg is not zero, __SOME_MACRO(arg) should expand to "DEF"

Suppose I call with argument 0, that is: SOME_MACRO(0)
I need to test at preprocessing time, whether the argument is zero or not.

#if <argument is zero>     // line 1
#define __SOME_MACRO(arg) "ABC"
#elif
#define __SOME_MACRO(arg) "DEF"
#endif

My question is: What should be at line 1?

Taking an example:

SOME_MACRO(2) should expand to "DEF"

SOME_MACRO(0) should expand to "ABC"

Body:
This is not possible.  The expression given to #if is only evaluated once, at the line where #if is encountered.  There is no way to have it evaluated again each time you invoke your macro.

As  Eric Postpischil says, C does not have any general way to make the expansion of a macro conditional on its arguments.

A couple of possible alternatives:

Use an expression with the ternary ?: operator, as pmg suggested in a comment:

#define __SOME_MACRO(arg) ((arg) ? "DEF" : "ABC")

Then SOME_MACRO(0) will expand to ((0) ? "DEF" : "ABC").  Any reasonable compiler will notice that the condition is a constant, and compile this just as if you had only written "ABC"; it should not generate code for a test nor for the unreachable branch.  Conditionals with the ternary operator can even be used in expressions that must be compile-time constants, as long as the condition is itself a compile-time constant; e.g. __SOME_MACRO(0) can be used to initialize a global or static variable.

Of course this will not work if the desired expansion is not syntactically an expression, e.g. if you are trying to use your macro to create declarations or definitions or something more syntactically elaborate.

If you know that only a small set of possible arguments will be used, you could use token pasting with the ## operator to expand the macro as one of another set of macros:

#define __SOME_MACRO_0 "ABC"
#define __SOME_MACRO_1 "DEF"
#define __SOME_MACRO_2 "DEF"
#define __SOME_MACRO(arg) __SOME_MACRO_ ## arg

Then __SOME_MACRO(0) expands to "ABC" and __SOME_MACRO(2) expands to "DEF".  However __SOME_MACRO(3) will not compile unless you write a corresponding __SOME_MACRO_3 macro, and __SOME_MACRO(0+1) cannot be made to work at all, at least not in any way that I know of.

(As written, __SOME_MACRO(0+1) expands to "ABC"+1, which is equivalent to "BC" and will probably cause you a lot of confusion before you figure out what is wrong.  __SOME_MACRO(1-1) is even worse...)

Also, #define ZERO 0 followed by __SOME_MACRO(ZERO) doesn't work as it stands, thought it can be fixed by doing

#define SECOND_MACRO(arg) __SOME_MACRO_ # arg
#define __SOME_MACRO(arg) SECOND_MACRO(arg)


问:
i have a problem with saving data to database using LARAVEL
this is all my codes after cliking on button doesn't save to database i try to change method of saving but not work

```<code>    use App\makereservations;
use Illuminate\Http\Request;

class reservationController extends Controller
{
    public function hreservation()
    {
        return view('hreservation');
    }
    public function reserve (Request $request)
    {
        $this->validate($request ,[
            'name' => 'required',
            'email' => 'required',
            'phone' => 'required|email',
            'date' => 'required',
            'time' => 'required',

        ]);
        $reservation  = new makereservations();
        $reservation  =  $request->input('name');
        $reservation  =  $request->input('email');
        $reservation  =  $request->input('phone');
        $reservation  =  $request->input('date');
        $reservation  =  $request->input('time');
        $reservation  =  $request->input('personne');
        $reservation -> statu =  false;
        $reservation -> save();
        return redirect()->back();
    }
}
</code>```

this is the roote
route::post('reserve',  'reservationController@reserve' )->name('reserv.sent');

答:
You missed the -> arrow sign.

```<code>$reservation  = new makereservations();
$reservation->name  =  $request->input('name');
$reservation->email  =  $request->input('email');
$reservation->phone  =  $request->input('phone');
$reservation->date  =  $request->input('date');
$reservation->time  =  $request->input('time');
$reservation->personne  =  $request->input('personne');
$reservation-> statu =  false;
$reservation-> save();
return redirect()->back();
</code>```

Body:
this is all my codes after cliking on button doesn't save to database i try to change method of saving but not work

    use App\makereservations;
use Illuminate\Http\Request;

class reservationController extends Controller
{
    public function hreservation()
    {
        return view('hreservation');
    }
    public function reserve (Request $request)
    {
        $this->validate($request ,[
            'name' => 'required',
            'email' => 'required',
            'phone' => 'required|email',
            'date' => 'required',
            'time' => 'required',

        ]);
        $reservation  = new makereservations();
        $reservation  =  $request->input('name');
        $reservation  =  $request->input('email');
        $reservation  =  $request->input('phone');
        $reservation  =  $request->input('date');
        $reservation  =  $request->input('time');
        $reservation  =  $request->input('personne');
        $reservation -> statu =  false;
        $reservation -> save();
        return redirect()->back();
    }
}

this is the roote
route::post('reserve',  'reservationController@reserve' )->name('reserv.sent');

Body:
You missed the -> arrow sign.

$reservation  = new makereservations();
$reservation->name  =  $request->input('name');
$reservation->email  =  $request->input('email');
$reservation->phone  =  $request->input('phone');
$reservation->date  =  $request->input('date');
$reservation->time  =  $request->input('time');
$reservation->personne  =  $request->input('personne');
$reservation-> statu =  false;
$reservation-> save();
return redirect()->back();


问:
Why HTTP was designed to be a pull protocol?
I was watching many presentations about Html 5 WebSockets , where server can initialize connection with client and push the data without the request from the client.

We don't need Polling etc.

And , I am curious , why Http was designed as a "pull" and not full duplex protocol in the first place ? What where the reasons behind that kind of decision ?

答:
Http was designed for simply retrieving hypertext documents from a server. There were no reasons to push anything to the client when the pages were just pure, static html without scripting capabilities.

Since there was no need at the time for pushing things back to the client, the protocol was kept simple.


问:
How to convert JSON to a key-value dictionary using typescript?
I have the following json example:

```<code>{
    "MyTest:": [{
            "main": {
                "name": "Hello"
            },
            "test2": {
                "test3": {
                    "test4": "World"
                },
                "test5": 5
            }
        },
        {
            "main": {
                "name": "Hola"
            },
            "test6": [{
                    "name": "one"
                },
                {
                    "name": "two"
                }
            ]
        }
    ]
}
</code>```

I'm trying to convert it to an array of arrays with key-values

```<code>[[main.name: "Hello",test2.test3.test4: "World", test2.test5: 5] ,
[main.name = "Hola", test6.name: "one", test6.name: "two"] ];
</code>```

Looking for some function like "is leaf" - so I will know that is the value.

Any advise for deep iteration will be very appriciated.

答:
The flattenObject() function returns an object of one level, with the keys built from all sub keys. The recursive function checks if the current value is an object. If it is, it iterates the object with _.flatMap() and calls itself on each property with the keys collected so far. If the value is not an object, it returns an object with a single property (the joined keys), and the value.

It then merges the array of { key: value } objects to a single object.

const flattenObject = val => {
  const inner = (val, keys = []) =>
    _.isObject(val) ? // if it's an object or array
      _.flatMap(val, (v, k) => inner(v, [...keys, k])) // iterate it and call fn with the value and the collected keys
      :
      { [keys.join('.')]: val } // return the joined keys with the value

  return _.merge({}, ...inner(val))
}

const obj = {"MyTest":[{"main":{"name":"Hello"},"test2":{"test3":{"test4":"World"},"test5":5}},{"main":{"name":"Hola"},"test6":[{"name":"one"},{"name":"two"}]}]}

const result = obj.MyTest.map(flattenObject)

console.log(result)```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.js"></script></code>```

Body:
I have the following json example:

{
    "MyTest:": [{
            "main": {
                "name": "Hello"
            },
            "test2": {
                "test3": {
                    "test4": "World"
                },
                "test5": 5
            }
        },
        {
            "main": {
                "name": "Hola"
            },
            "test6": [{
                    "name": "one"
                },
                {
                    "name": "two"
                }
            ]
        }
    ]
}

I'm trying to convert it to an array of arrays with key-values

[[main.name: "Hello",test2.test3.test4: "World", test2.test5: 5] ,
[main.name = "Hola", test6.name: "one", test6.name: "two"] ];

Looking for some function like "is leaf" - so I will know that is the value.

Any advise for deep iteration will be very appriciated.

Body:
The flattenObject() function returns an object of one level, with the keys built from all sub keys. The recursive function checks if the current value is an object. If it is, it iterates the object with _.flatMap() and calls itself on each property with the keys collected so far. If the value is not an object, it returns an object with a single property (the joined keys), and the value.

It then merges the array of { key: value } objects to a single object.

const flattenObject = val => {
  const inner = (val, keys = []) =>
    _.isObject(val) ? // if it's an object or array
      _.flatMap(val, (v, k) => inner(v, [...keys, k])) // iterate it and call fn with the value and the collected keys
      :
      { [keys.join('.')]: val } // return the joined keys with the value

  return _.merge({}, ...inner(val))
}

const obj = {"MyTest":[{"main":{"name":"Hello"},"test2":{"test3":{"test4":"World"},"test5":5}},{"main":{"name":"Hola"},"test6":[{"name":"one"},{"name":"two"}]}]}

const result = obj.MyTest.map(flattenObject)

console.log(result)

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.js"></script>


问:
Flutter Hot Reload not working in IntelliJ
new to flutter. created a new project using Intellij flutter plugin. Ran the app on an ios simulator using the play icon on the intellij, which runs the app in an IphoneX simulator. Made some cosmetic changes to the main.dart file but i) the hot reload, lightning, button is disabled ii) also code gets auto saved in intellij, so not sure what i need to do to test hot reload.

as a matter of fact, i have to delete the app from my iPhoneX simulator and rerun from IntelliJ to pick up the changes.

答:
Try to invalidate cache and restart Android Studio, as well as run the command to clean the flutter build.

Concrete instructions
In Android Studio, go to File --> Invalidate Caches/Restart --> Invalidate and Restart

After restart, run the command in the terminal: flutter clean

After that, your reload should be working again.


问:
expected 'while' or expected '}' Answered before yes, but I can't fix it myself
I have already checked all the other questions but I just can't fix it.. I am a nuub at coding.
I don't know why it says it needs a while or where to put it, and it gives the wrong answer for the LOCS function also is there anything i can do about the default pointer warning. this is just a start i will be extending this later so it would be a big help and i have tried while and closing brackets everywhere lol

Btw if anyone can tell me how I can use the input as decision as you can see I am using 1 and 2, but If I could use permanent and casual that would be great.

```<code>// Calculate an employee's weekly salary
// Use a do while loop, and an if else statement to have user input data and display the correct values

#include <iostream>
using namespace std;

void main()
{
    //Declaring the constant variables
    const double BONUS_RATE = 5.0;

    //Declaring the variables
    int hours;
    int sales;
    int Status;

    string permanent, casual, Name, status, result, employee;

    double rate, sale_bonus, netPay, gross;

    //set decimal point to 2 positions
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);

    //Display name
    cout << "Calculate an employee's weekly salary\n\n";

    //Do while loop to get hourly rate
    do {

        cout << "Enter employee name: ";
        cin >> Name;

        cout << "Please enter 1 if employee is permanent or 2 if casual: ";
        cin >> Status;

        Status = 0;
        while (Status < 1 || Status > 2);

        if (Status = 1)
        {

            cout << "Permanent employees have a fixed salary of $1000 per week" << endl;

            sales = 0;
            (sales < 1 || sales > 10);

            cout << "If any please enter how many sales employee made this week:";
            cin >> sales;

            sale_bonus = sales * BONUS_RATE;
            netPay = 1000 + sale_bonus;

            cout << endl;

            cout
                << "Hours Worked: \t" << hours << endl
                << "Gross Pay:  \t" << gross << endl
                << "Net Pay  \t" << netPay << endl;

        }
        else if (Status = 2) {

            cout << "Casual employee's hourly rate is $15";
            rate = 15.00;
            cout << endl;

            //while loop for hours

            hours = 0;
            while (hours < 1 || hours > 60)
            {
                cout << "Please enter how many hours you have worked this week:" << endl;
                cout << "Minimum hours is 1" << endl;
                cout << "Maximum hours are 60" << endl;
                cout << "Enter hours worked: ";

                cin >> hours;

            }

            //while loop for bonus

            sales = 0;
            while (sales < 1 || sales > 10)
            {
                cout << "Please enter how many sales you made this week:";
                cin >> sales;
            }

            //Calculate pay

            gross = hours * rate;
            sale_bonus = sales * BONUS_RATE;
            netPay = gross + sale_bonus;

            //Display the results
            cout << endl
                << "Hourly Rate:  \t" << rate << endl
                << "Hours Worked: \t" << hours << endl
                << "Gross Pay:  \t" << gross << endl
                << "Net Pay  \t" << netPay << endl;

        }

    }
}
</code>```

答:
```<code>#include <iostream>
using namespace std;

void main()
{
    //Declaring the constant variables
    const double BONUS_RATE = 5.0;

    //Declaring the variables
    int hours;
    int sales;
    int Status;

    string permanent, casual, Name, status, result, employee;

    double rate, sale_bonus, netPay, gross;

    //set decimal point to 2 positions
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);

    //Display name
    cout << "Calculate an employee's weekly salary\n\n";

    //Do while loop to get hourly rate
    do {

        cout << "Enter employee name: ";
        cin >> Name;

        cout << "Please enter 1 if employee is permanent or 2 if casual: ";
        cin >> Status;

   } while (Status < 1 || Status > 2); // add while after do block with }

        if (Status == 1)// use '==' equality check not '=' .
        {

            cout << "Permanent employees have a fixed salary of $1000 per week" << endl;

            sales = 0;
            (sales < 1 || sales > 10);

            cout << "If any please enter how many sales employee made this week:";
            cin >> sales;

            sale_bonus = sales * BONUS_RATE;
            netPay = 1000 + sale_bonus;

            cout << endl;

            cout
                << "Hours Worked: \t" << hours << endl
                << "Gross Pay:  \t" << gross << endl
                << "Net Pay  \t" << netPay << endl;

        }
        else if (Status == 2) { // use '==' equality check not '=' .

            cout << "Casual employee's hourly rate is $15";
            rate = 15.00;
            cout << endl;

            //while loop for hours

            hours = 0;
            while (hours < 1 || hours > 60)
            {
                cout << "Please enter how many hours you have worked this week:" << endl;
                cout << "Minimum hours is 1" << endl;
                cout << "Maximum hours are 60" << endl;
                cout << "Enter hours worked: ";

                cin >> hours;

            }

            //while loop for bonus

            sales = 0;
            while (sales < 1 || sales > 10)
            {
                cout << "Please enter how many sales you made this week:";
                cin >> sales;
            }

            //Calculate pay

            gross = hours * rate;
            sale_bonus = sales * BONUS_RATE;
            netPay = gross + sale_bonus;

            //Display the results
            cout << endl
                << "Hourly Rate:  \t" << rate << endl
                << "Hours Worked: \t" << hours << endl
                << "Gross Pay:  \t" << gross << endl
                << "Net Pay  \t" << netPay << endl;

        }

}
</code>```

I have made the suitable changes :

Use == to check equality instead of = operator!

Syntax of do while : do { //code... } while(condition).

The while must follow the do after closing the block!

Your Mistake

the main mistake is you have not close the do while loop, ask in comment for more clarification!
PS. I recommend you first copy my code and then run, and then analyse the issue!

Body:
I have already checked all the other questions but I just can't fix it.. I am a nuub at coding.
I don't know why it says it needs a while or where to put it, and it gives the wrong answer for the LOCS function also is there anything i can do about the default pointer warning. this is just a start i will be extending this later so it would be a big help and i have tried while and closing brackets everywhere lol

Btw if anyone can tell me how I can use the input as decision as you can see I am using 1 and 2, but If I could use permanent and casual that would be great.

// Calculate an employee's weekly salary
// Use a do while loop, and an if else statement to have user input data and display the correct values

#include <iostream>
using namespace std;

void main()
{
    //Declaring the constant variables
    const double BONUS_RATE = 5.0;

    //Declaring the variables
    int hours;
    int sales;
    int Status;

    string permanent, casual, Name, status, result, employee;

    double rate, sale_bonus, netPay, gross;

    //set decimal point to 2 positions
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);

    //Display name
    cout << "Calculate an employee's weekly salary\n\n";

    //Do while loop to get hourly rate
    do {

        cout << "Enter employee name: ";
        cin >> Name;

        cout << "Please enter 1 if employee is permanent or 2 if casual: ";
        cin >> Status;

        Status = 0;
        while (Status < 1 || Status > 2);

        if (Status = 1)
        {

            cout << "Permanent employees have a fixed salary of $1000 per week" << endl;

            sales = 0;
            (sales < 1 || sales > 10);

            cout << "If any please enter how many sales employee made this week:";
            cin >> sales;

            sale_bonus = sales * BONUS_RATE;
            netPay = 1000 + sale_bonus;

            cout << endl;

            cout
                << "Hours Worked: \t" << hours << endl
                << "Gross Pay:  \t" << gross << endl
                << "Net Pay  \t" << netPay << endl;

        }
        else if (Status = 2) {

            cout << "Casual employee's hourly rate is $15";
            rate = 15.00;
            cout << endl;

            //while loop for hours

            hours = 0;
            while (hours < 1 || hours > 60)
            {
                cout << "Please enter how many hours you have worked this week:" << endl;
                cout << "Minimum hours is 1" << endl;
                cout << "Maximum hours are 60" << endl;
                cout << "Enter hours worked: ";

                cin >> hours;

            }

            //while loop for bonus

            sales = 0;
            while (sales < 1 || sales > 10)
            {
                cout << "Please enter how many sales you made this week:";
                cin >> sales;
            }

            //Calculate pay

            gross = hours * rate;
            sale_bonus = sales * BONUS_RATE;
            netPay = gross + sale_bonus;

            //Display the results
            cout << endl
                << "Hourly Rate:  \t" << rate << endl
                << "Hours Worked: \t" << hours << endl
                << "Gross Pay:  \t" << gross << endl
                << "Net Pay  \t" << netPay << endl;

        }

    }
}

Body:
#include <iostream>
using namespace std;

void main()
{
    //Declaring the constant variables
    const double BONUS_RATE = 5.0;

    //Declaring the variables
    int hours;
    int sales;
    int Status;

    string permanent, casual, Name, status, result, employee;

    double rate, sale_bonus, netPay, gross;

    //set decimal point to 2 positions
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);

    //Display name
    cout << "Calculate an employee's weekly salary\n\n";

    //Do while loop to get hourly rate
    do {

        cout << "Enter employee name: ";
        cin >> Name;

        cout << "Please enter 1 if employee is permanent or 2 if casual: ";
        cin >> Status;

   } while (Status < 1 || Status > 2); // add while after do block with }

        if (Status == 1)// use '==' equality check not '=' .
        {

            cout << "Permanent employees have a fixed salary of $1000 per week" << endl;

            sales = 0;
            (sales < 1 || sales > 10);

            cout << "If any please enter how many sales employee made this week:";
            cin >> sales;

            sale_bonus = sales * BONUS_RATE;
            netPay = 1000 + sale_bonus;

            cout << endl;

            cout
                << "Hours Worked: \t" << hours << endl
                << "Gross Pay:  \t" << gross << endl
                << "Net Pay  \t" << netPay << endl;

        }
        else if (Status == 2) { // use '==' equality check not '=' .

            cout << "Casual employee's hourly rate is $15";
            rate = 15.00;
            cout << endl;

            //while loop for hours

            hours = 0;
            while (hours < 1 || hours > 60)
            {
                cout << "Please enter how many hours you have worked this week:" << endl;
                cout << "Minimum hours is 1" << endl;
                cout << "Maximum hours are 60" << endl;
                cout << "Enter hours worked: ";

                cin >> hours;

            }

            //while loop for bonus

            sales = 0;
            while (sales < 1 || sales > 10)
            {
                cout << "Please enter how many sales you made this week:";
                cin >> sales;
            }

            //Calculate pay

            gross = hours * rate;
            sale_bonus = sales * BONUS_RATE;
            netPay = gross + sale_bonus;

            //Display the results
            cout << endl
                << "Hourly Rate:  \t" << rate << endl
                << "Hours Worked: \t" << hours << endl
                << "Gross Pay:  \t" << gross << endl
                << "Net Pay  \t" << netPay << endl;

        }

}

I have made the suitable changes :

Use == to check equality instead of = operator!

Syntax of do while : do { //code... } while(condition).

The while must follow the do after closing the block!

Your Mistake

the main mistake is you have not close the do while loop, ask in comment for more clarification!
PS. I recommend you first copy my code and then run, and then analyse the issue!


问:
The 'gems' configuration option has been renamed to 'plugins'.?
When I use the latest jekyll and start its server, a certain warning below shows up:

$ jekyll serve Configuration file:
  /Users/ishida/git/gipcompany.github.io/_config.yml
         Deprecation: The 'gems' configuration option has been renamed to 'plugins'. Please update your config file accordingly.

I guess the following gems should be replaced with plugins, and then the warning won't show up, but I couldn't find any official documentation. Is my guess correct?

```<code>$ cat _config.yml
(omit)
gems:
  - jekyll-feed
</code>```

答:
You're right, in order to fix that, follow these steps:

Open your _config.yml file

Find the line beginning with gems:

Replace gems with plugins

Body:
When I use the latest jekyll and start its server, a certain warning below shows up:

$ jekyll serve Configuration file:
  /Users/ishida/git/gipcompany.github.io/_config.yml
         Deprecation: The 'gems' configuration option has been renamed to 'plugins'. Please update your config file accordingly.

I guess the following gems should be replaced with plugins, and then the warning won't show up, but I couldn't find any official documentation. Is my guess correct?

$ cat _config.yml
(omit)
gems:
  - jekyll-feed


问:
Creating a windows directory on a vsphere_virtual_machine using terraform
Using terraform I'm trying to create vsphere_virtual_machine resource. As part of it, I'm trying to find out how to mount virtual disks to a specific folder on a created virtual machine.  For example :

Terraform

```<code>disk {
  label = "disk0"
  size = "100"
}

disk {
  label = "disk1"
  size = "50"
}

</code>```

How to mount disk0 to volume path D:\mysql\conf and disk1 to volume path D:\mysql\databases on a windows vm created using terraform vsphere_virtual_machine ? Could someone please share your insights here . Thanks in Advance !!

答:
There's nothing in the vsphere_virtual_machine provider that will handle internal operations like that against the Virtual Machine, and I'm not aware of any other provider which can do that either.

Couple workarounds:

check out the remote-exec provisioner, this will let you run some PowerShell or other CLI commands to perform the task you need.

If you're doing this on a regular basis, check out Packer. It can be used to build out a virtual machine, OS and all. You could establish the disk configuration there, then use Terraform to deploy it.

Lastly, look into configuration management utilities. Ansible, PowerShell DSC, Puppet, Chef, etc. These tools will let you make modifications to the VM after they've been deployed.

Body:
Using terraform I'm trying to create vsphere_virtual_machine resource. As part of it, I'm trying to find out how to mount virtual disks to a specific folder on a created virtual machine.  For example :

Terraform

disk {
  label = "disk0"
  size = "100"
}

disk {
  label = "disk1"
  size = "50"
}

How to mount disk0 to volume path D:\mysql\conf and disk1 to volume path D:\mysql\databases on a windows vm created using terraform vsphere_virtual_machine ? Could someone please share your insights here . Thanks in Advance !!


问:
Is WCF MessageBuffer.CreateMessage thread safe?
http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.messagebuffer(v=vs.85).aspx is somewhat vague when it says that "Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe."

As a general rule, it seems like instance members do not have the thread-safe guarantee.

However, I'm guessing that some instance member methods are reentrant and thread-safe and others are not.

MessageBuffer.CreateMessage is an instance method.
Has anyone confirmed whether this specific method is reentrant (or whether callers need to implement locking around calls to the method) ?

答:
MessageBuffer.CreateMessage is abstract, so it doesn't make sense to ask whether it's thread safe or not. The subclasses of MessageBuffer in WCF are all internal, so they can potentially be changed. As Chandermani said, you should assume that it is not thread-safe.

Update: it is not thread-safe. The created message may have dependencies on other components, such as serialization of the message body. If those components aren't thread-safe, then the CreateMessage call cannot be considered thread-safe either.

In the example below, the serialized version of the object is time-dependent (it could have some additional dependencies as well), so the order in which the CreateMessage calls are made impacts the result.

```<code>public class StackOverflow_6209650_751090
{
    [DataContract]
    public class MyDC
    {
        [DataMember]
        public DateTime SerializedTime
        {
            get { return DateTime.Now; }
            set { }
        }
    }
    public static void Test()
    {
        Message message = Message.CreateMessage(MessageVersion.None, "foo", new MyDC());
        var buffer = message.CreateBufferedCopy(int.MaxValue);
        Console.WriteLine(buffer.CreateMessage());
        Console.WriteLine();
        Console.WriteLine(buffer.CreateMessage());
    }
}
</code>```

Body:
MessageBuffer.CreateMessage is abstract, so it doesn't make sense to ask whether it's thread safe or not. The subclasses of MessageBuffer in WCF are all internal, so they can potentially be changed. As Chandermani said, you should assume that it is not thread-safe.

Update: it is not thread-safe. The created message may have dependencies on other components, such as serialization of the message body. If those components aren't thread-safe, then the CreateMessage call cannot be considered thread-safe either.

In the example below, the serialized version of the object is time-dependent (it could have some additional dependencies as well), so the order in which the CreateMessage calls are made impacts the result.

public class StackOverflow_6209650_751090
{
    [DataContract]
    public class MyDC
    {
        [DataMember]
        public DateTime SerializedTime
        {
            get { return DateTime.Now; }
            set { }
        }
    }
    public static void Test()
    {
        Message message = Message.CreateMessage(MessageVersion.None, "foo", new MyDC());
        var buffer = message.CreateBufferedCopy(int.MaxValue);
        Console.WriteLine(buffer.CreateMessage());
        Console.WriteLine();
        Console.WriteLine(buffer.CreateMessage());
    }
}


问:
Conditional rendering in React Native with global variable
I know this is horrible convention, but I'm trying to quickly conditionally render screens in my React Native app with global variables (so no redux):

App.js:

```<code>if (global.clickStatus !== 'clicked') {
      return <Screen1 />;
}

return <Screen2 />;
</code>```

The app begins on Screen1, where there is a button that makes global.clickStatus = 'clicked'. When this is clicked, I want Screen2 to render. The problem is, the global.clickStatus doesn't seem to update on my App.js (even though global.clickStatus is changed, it still renders Screen1.

How can I get it to update?

答:
I believe in <App /> component because it is a function component you can introduce a state if your button is clicked. Then with clicked state you can manipulate which component to show.

Similarly like the following - obviously this is a simplified example:

```<code>const App = () => {
   const [clicked, setClicked] = useState(false);

   return <>
      <div onClick={() => setClicked(true)}>Click me</div>

      { clicked ? <Screen2 /> : <Screen1 /> }
   </>
}
</code>```

Suggested read is Using the State Hook.

Body:
I know this is horrible convention, but I'm trying to quickly conditionally render screens in my React Native app with global variables (so no redux):

App.js:

if (global.clickStatus !== 'clicked') {
      return <Screen1 />;
}

return <Screen2 />;

The app begins on Screen1, where there is a button that makes global.clickStatus = 'clicked'. When this is clicked, I want Screen2 to render. The problem is, the global.clickStatus doesn't seem to update on my App.js (even though global.clickStatus is changed, it still renders Screen1.

How can I get it to update?

Body:
I believe in <App /> component because it is a function component you can introduce a state if your button is clicked. Then with clicked state you can manipulate which component to show.

Similarly like the following - obviously this is a simplified example:

const App = () => {
   const [clicked, setClicked] = useState(false);

   return <>
      <div onClick={() => setClicked(true)}>Click me</div>

      { clicked ? <Screen2 /> : <Screen1 /> }
   </>
}

Suggested read is Using the State Hook.


问:
RSA Machine Keys folder is empty - Windows 10
I am trying to test the aspnet_regiis.exe encryption function for a WPF app using the default RsaProtectedConfigurationProvider.  The encryption command runs successfully, and I can see the connection string section is encrypted; however, the application crashes at startup.  It works fine without the encryption.  I have added proper permissions to the machine keys folder as well as the key container, but I also noticed this folder is empty.  The path is: C:\Windows\System32\Microsoft\Crypto\RSA\MachineKeys

I have also tried exporting from my dev machine and importing the keys on a separate machine (still giving the proper permissions).  No matter what I try, the machine keys folder is empty and the app fails to launch.

My questions are:

Shouldn't my imported keys be showing up in the machine keys folder, and given the appropriate permissions, shouldn't the configuration section be decrypted at runtime allowing the app to work as expected?

I have checked the windows event logs and found the error(s) which I will share along with the configuration file if necessary.

I always appreciate any tips or advice, and appreciate your time.

Side note - I know this isn't the most secure security practice.

-Thank you

答:
On Windows 10 if you cannot see folder All Users, Find folder on this location

C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys


问:
Implementing events in C++
After some research on internet for an efficient way to implement events in C++, I found the following methods

Interface class - Applications can override the virtual functions in the derived class

Normal Callback mechanism using function pointers

Delegates using Boost.function

Signals and slots (as used in Qt)

I am confused on advantages and disadvantages of each of these and when to use anyone of this.
Which is the best method and why?
Is there any other solutions which are better than the ones listed?

答:
You can use Observer design pattern. Here is an example C++ source of it.
http://sourcemaking.com/design_patterns/observer/cpp/3</p>

Title: Implementing events in C++