text:
Q: Automatically serving @2x and @3x images using ImageResizer on MVC Theme that we are building our websties utilizes Retina.Js on the frontend, which automatically tries to load @2x and @3x images according to users device in such way that;
If we are serving our sliders for the desktop using image resizer as follows;
/Images/home/slides/slide-1.jpg?width=300
(in which 1 is the DbId of the image)
This script automatically request the following images if the visitor is using high dpi mobile device;
/Images/home/slides/slide-1@2x.jpg?width=300
/Images/home/slides/slide-1@3x.jpg?width=300
We are using ImageResizer with SqlReader and DiskCache Plugins, so that the images read from database and cached on the disk.
When the script requests @2x and @3x naming convetion images from server, of course ImageResizer returned error for those images since it could not find an image with id '1@2x' in the db, but fortunately we were able to overcome this obstacle by using Pipeline.Rewrite;
ImageResizer.Configuration.Config.Current.Pipeline.Rewrite += delegate (IHttpModule s, HttpContext context, ImageResizer.Configuration.IUrlEventArgs ev)
        {

            if (ev.VirtualPath.StartsWith(VirtualPathUtility.ToAbsolute("~/kitimages/"), StringComparison.OrdinalIgnoreCase))
            {
                if (ev.VirtualPath.Contains("@2x"))
                {
                    ev.VirtualPath = ev.VirtualPath.Replace("@2x", string.Empty);
                }

            }

        };

so that now we are able serve the images which are @2x (or@3x in that manner) on the desktop resolution.
But what we could not achieve that change resolution of the desires @2x or @3x image. Since we are calling image '?width=300' with querystring parameter these images also served as desktop resolution.
We tried to change
ImageResizer.Configuration.Config.Current.Pipeline.ModifiedQueryString["width"]

to newly calculated value which had no effect.
Set new value to width under
context.Items["resizer.modifiedQueryString"]

property which had no effect.
Also tried to use the following with no luck;
ImageResizer.Configuration.Config.Current.Pipeline.Modify( new ResizeSettings() { Width = 600 } );
ImageResizer.Configuration.Config.Current.CurrentImageBuilder.SettingsModifier.Modify(new ResizeSettings() {Width = 600});
ImageResizer.Configuration.Config.Current.Pipeline.GetImageBuilder().SettingsModifier.Modify(new ResizeSettings() { Width = 600 });

Now the question is; is there any way to change the resize settings on the fly while using SqlReader and DiskCache plugins and serve @2x and @3x images with the correct resolutions?
Thanks in advance,

A: ImageResizer offers a zoom parameter that does the math for you, essentially multiplying the width and height paramters.
ev.QueryString["zoom"] = 2; // 3, etc,


text:
Q: Why does my  not expand to height:100%? I have 3 divs that correspond to this.
I have #wrapper which wraps around everything. That is #EEE
I have #contain which is inside #wrapper right after. That is #FFF (part with the content)
I have #secondaryContent which is height:100% perfectly fine, position:fixed. which is inside both of those divs.

I added borders to all the main divs to see what's up.
Okay so, the bottom of the middle div is supposed to extend to the bottom at 100% showing no grey from the wrapper. If you look closely at the top of the page You can see a purple line. That's actually a div called #content, which is supposed to have all of the posts in it. I don't know what it's showing as if there's nothing in it but it should  //(* fixed * - see second answer).
You can see what I mean via my server.
Server

FIX***
the class '.container' that is applied to the #wrapper div is what screwed everything up.

A: I think this is because there are floats in the #Content div.
You can add this class "hasFloats" to both your css file and in the #content div as well.
UPDATED
.hasFloats { _height: 1%; }

.hasFloats:after { content: "."; visibility: hidden; display: block; clear: both; height: 0; font-size: 0; }

<div id="content" class="hasFloats">

hope this helps.

A: You need to set your body to have a height: 100% otherwise it will not take up the full screen.
EDIT: Sorry I answered before viewing the site. If it's not taking up the full height have you checked for excess margin or padding?

A: There is a class called 'container' that is applied to the div 'wrapper'. This class container is from a different stylesheet provided by the Habari CMS I use. By removing this class from the div, the height now expands to the document window.

redpajama_set_name: RedPajamaStackExchange


text:
Q: What's the meaning of 'Had you?' in the lines from Michael and Mary (1930) by A. A. Milne? Could someone help me understand 'Had you?' in the following lines from Michael and Mary (1930) written by A. A. Milne?

Michael. Oh, well, I've read enough to dine out on. (He throws it on to the sofa. She picks it up and looks at the back.)
Mary. Never heard of him.
Michael. Yes, he would pretend to like that, but really he wouldn't.
Mary. Had you?
Michael. Certainly. I'm a well-read man.
Mary. Do you think he's more famous than you are?
Michael (hiding a smile). Much.

A: She is referring back to her previous statement that she had "never heard of him", and is asking "had you heard of him?"
It's quite common to ask questions like "I haven't, have you?" In this example though, the remark by Michael breaks it up.

A: This is an upgrade of a comment to an answer as suggested by D Clayworth. I didn't post as an answer initially because I have no supporting evidence.
It's a shortened form of "Had you heard of him." It's not absolutely necessary for Mary to repeat "heard of him" as her statement was so recent. To some extent she's ignoring Michael's statement about the author and continuing her previous speech. She could have said "I've never heard of him, have you?" as her first line but Milne has written the dialogue as a casual, and more dynamic, conversation.


text:
Q: build website handheld device friendly I want to adapt a method to convert my fixed width website to handheld device friendly website. Could anybody please suggest which method would be the best. Considering it should not compromise the loading time of website. I believe Responsive Web Design should work but I from research I found responsive images used in responsive webdesign sometimes compromise the websie loading time.

A: I think it is wise to detect a mobile browser user agent string (server side) and display content accordingly.
If you are building using PHP, then check out this awesome script.
Usage is something like this:
if($isMobile){
   header('Location: http://m.youdomain.com/' . urlencode($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));
   exit();
}

Also check out the Switcher


text:
Q: Is there any way to get the exact audio .wav from a .mp4 video? (same length and same duration) I extracted .wav files from many short mp4 videos. (3-6 seconds) But the extracted xxx.wav can not be aligned with .mp4 videos in Premiere. Some videos are 1 frame, and some 2 frames behind.
I used ffmpeg as the following command line:
ffmpeg -i xxx.mp4 xxx.wav
I tried -async or -vsync, but not worked. Here is an example:
1 frame shift
Here is the source mp4 and the extracted wav:
https://drive.google.com/drive/folders/1BFS0JLCPqA3YDMIahlorXTaRTFTJaPfU?usp=share_link
Do you know what caused the problem? Is there any way to get the exact audio .wav from a .mp4 video? (Aligned with frame level) Thank you very much.


text:
Q: При сборке проекта libgdx через gdx-setup, он мне пишет что не смог выделить 1,5гб места из озу При сборке проекта libgdx через gdx-setup, он мне пишет что не смог выделить 1,5гб места из озу, хотя у меня на компе 4гб озу. Из-за чего это?

A: Не знаю почему, но после того как я поменял 1,5гб требуемого озу на 1гб, все заработало


text:
Q: Check if android app has a newer version on playStore I want to know if it is possible to check if the app that the user is running is the latest version that is available at Google PlayStore. I have read some answers and they say that this is not possible, but I see some apps that do this.
Can someone tell me how can I do this? I can see that this is possible.

A: Indeed the Google Play Services do not expose such API.
But you could use a workaround to check for newer versions: a simple request on your serveur could do, parsing the Play Store page could do too etc.

A: You can create an api on your server for these kind of operations.
Your api can return values such as currentVersionCode, minVersionCode and an updateMessage.
You can compare your apps version code, currentVersionCode and minVersionCode and show a dialog for nice to update or force update.


text:
Q: Why my variable type char using variable++ or variable+1 return different returns? I'm learning C, malloc and pointers specifially, I'm testing this code:
#include<stdio.h>
#include<stdlib.h>

int main(){

char test[5] = "ayolw";
printf(" \nmy string : %s\n", test);

char *testa = (char *)malloc(sizeof(char));
testa = test;

printf("%c", *testa);
printf("%c", *testa+1);
printf("%c", *testa+2);
printf("%c", *testa+3);
printf("%c\n", *testa+4);

while(*testa!='\0'){
    printf("%c ", *testa);
    *testa++;
}
printf("\n\n");

return 0;
}

My output:
my string : ayolw
abcde // output using *testa+1,*test+2,...;
a y o l w // output using *testa++;

I understand my first output are returning testa[0] ASCII value + number. howhever why using *testa++ are returning correctly if testa++ is equivalent to testa+1
And another question, how can I print my output using a lign like *testa+2 if I can't use testa[2]. That its possible?

A:
howhever why using *testa++ are returning correctly if testa++ is equivalent to testa+1

Because testa++ is not equivalent to testa+1.  Not even very close.  It differs in several significant regards, among them:

*

*testa++ evaluates to the value of testa, and as a side effect, modifies testa's stored value, increasing that by 1.  On the other hand, testa+1 evaluates to one more than the value of testa and does not modify testa's stored value.

*The postfix ++ operator has higher precedence than unary *, whereas the binary + operator has lower precedence than unary *.  That means that *testa+1 is equivalent to (*testa)+1, whereas *testa++ is equivalent to *(testa++).
Taking these together,

*

*the value of testa does not change in the various *testa+x cases.  It always points at the first character of test, and the *testa part always evaluates to the value of that character.  The addition is applied to that character value (promoted to an int).

*the value of testa does change in the various *testa++ cases.  Each evaluation of that expression returns the character to which testa currently points, and also updates testa to point to the next character.

As a separate matter, note that in ...

char *testa = (char *)malloc(sizeof(char));
testa = test;

...

*

*you do not need to cast the return value of malloc() in C, nor should you.

*that particular malloc() is wasteful, as you immediately replace the only pointer to the allocated memory with a pointer to the first byte of array test.  The dynamically allocated memory is leaked.  Better would be any of
char *testa;
testa = test;

OR
char *testa = test;

OR
char *testa;
testa = &test[0];

OR
char *testa = &test[0];

, all of which are equivalent to each other for your definition of test as an array of char.

A: First of all, you don't have testa++ and testa+1, you have *(testa++) vs (*testa)+1. Notice that you are adding one to different things.
Secondly, x++ is NOT equivalent to x+1. ++x is closer, but it's not equivalent either.
x++ evaluates to the original value of x. Assigns x plus 1 to x.
x+1 evaluates to x plus 1. Does not modify x.
++x evaluates to x plus 1. Assigns x plus 1 to x.


text:
Q: How to add image src to the state in multi step form in react TLDR
I'm making an multiStep form for my project that is inspired from Brad Traversy's Tutorial of making Multi-Step form in React.
So as per the basic structure of this form

I made a main Parent component called Multiform as below
import React, { Component } from 'react'
import StepOne from './StepOne'
export class Multiform extends Component {
    state = {
    step:1,
    CountryFlag: 'https://raw.githubusercontent.com/MeRahulAhire/country-calling-code-html/master/phone_icon.png',
    CountryCode: ''
};
handleChange = (input) => (e) => {
    this.setState({ [input]: e.target.value });
};

countryFlagHandler = () =>{
    this.setState({CountryFlag : this.props.state.flagImg})
  }
render() {
    const { CountryFlag, CountryCode } = this.state;
    const values = {CountryFlag, CountryCode };

    switch (step) {
        case 1:
          return(
            <StepOne
            handleChange={this.handleChange}
            countryFlagHandler={this.countryFlagHandler}
            values={values}
            />

          )
         default:
             return (
hello React App
)

    };
}
}

export default Multiform

and a child component  StepOne as below
import React, { Component } from 'react'
    export class StepOne extends Component {

        state = {
    flagImg: '',
};
render() {
    const { values, handleChange, countryFlagHandler } = this.props;

    const selectCountryChange = () => {
        const img = document.querySelector('#img');
        const select = document.querySelector('#country');
        img.src = `https://flagpedia.net/data/flags/h80/${select.selectedOptions[0].dataset.countrycode.toLowerCase()}.webp`;

        this.setState({
            flagImg: `https://flagpedia.net/data/flags/h80/${select.selectedOptions[0].dataset.countrycode.toLowerCase()}.webp`
        });
        countryFlagHandler()
    };
    return (

            <select id="country" onChange={handleChange('select')} defaultValue={values.select}>
                <option data-countryCode="IN" value="91">India</option>
                <option data-countryCode="US" value="1">US</option>
                <option data-countryCode="GB" value="44">UK</option>
            </select>

    )
}
    }

    export default StepOne

what I'm trying to do is actually to sync and persist the data of <Select/> and  in Multiform.js Component as typically what we see in a stepper form.
But, As in the StepOne

the img.src is actually manipulated by the function selectCountryChange and to keep the value of img.src persisted I thought of creating countryFlagHandler in Multiform and importing it to StepOne
but when i selected any value, it gave me this error:
TypeError: Cannot read property 'flagImg' of undefined
Registration.countryFlagHandler
C:/Users/Rahul/Desktop/cfm-usersignup/src/public/form/registration.js:53
  50 |   this.setState({ [input]: e.target.value });
  51 | };
  52 | countryFlagHandler = () =>{
> 53 |   this.setState({CountryFlag : this.props.state.flagImg})
     | ^  54 | }
  55 |
  56 |

&
selectCountryChange
C:/Users/Rahul/Desktop/cfm-usersignup/src/public/form/credential.js:31
  28 |  this.setState({
  29 |      flagImg: `https://flagpedia.net/data/flags/h80/${select.selectedOptions[0].dataset.countrycode.toLowerCase()}.webp`
  30 |  });
> 31 |  countryFlagHandler();
     | ^  32 | };
  33 | return (
  34 |

Can anyone please tell me how to rectify my error?
You can also checkout my project repo for more info.

A: As I see from your code, you try to get the flagImg propery from object that doesn't exist. If I understood your logic correctly, you need to update the selectCountryChange and countryFlagHandler methods:
const selectCountryChange = () => {
    const img = document.querySelector('#img');
    const select = document.querySelector('#country');
    const flagImg = `https://flagpedia.net/data/flags/h80/${select.selectedOptions[0].dataset.countrycode.toLowerCase()}.webp`;
    img.src = flagImg;

    this.setState({
        flagImg
    });
    countryFlagHandler(flagImg)
};

and in the countryFlagHandler method take it from argumnets:
countryFlagHandler = CountryFlag =>
    this.setState({ CountryFlag })

Also, your logic looks pretty dirty, maybe you could generate the flagImg property, when you select a country, set it to Multiform, and finally pass it through props to StepOne.

A: Shor answer
You're getting an error because countryFlagHandler is not getting the value it's expected, it doesn't have access to the StepOne component's state. You would need to pass the value as an argument to the parent component.
  // flagImg will come as an argument from the child Component
   countryFlagHandler = (flagImg) =>{
      this.setState({ CountryFlag : flagImg })
   }

    const selectCountryChange = () => {
    const img = document.querySelector('#img');
    const select = document.querySelector('#country');
    img.src = `https://flagpedia.net/data/flags/h80/${select.selectedOptions[0].dataset.countrycode.toLowerCase()}.webp`;

    this.setState({
        flagImg: `https://flagpedia.net/data/flags/h80/${select.selectedOptions[0].dataset.countrycode.toLowerCase()}.webp`
    });
    const countryFlag = `https://flagpedia.net/data/flags/h80/${select.selectedOptions[0].dataset.countrycode.toLowerCase()}.webp`;
    // CountryFlag would be passed as an argument
    countryFlagHandler(countryFlag);
   };

Long Answer
I would recommend refactoring your code a bit and moving all the data to the parent component rather than keeping them in two different states. And also one function would be enough to handle all the data manipulation.
Parent Component Multiform
import React, { Component } from 'react'
import StepOne from './StepOne'
export class Multiform extends Component {
state = {
    step: 1,
    CountryFlag: 'https://raw.githubusercontent.com/MeRahulAhire/country-calling-code-html/master/phone_icon.png',
    CountryCode: ''
};

handleSelectChange = (event) => {
    const value = event.target.value;
    const countryCode = event.target[event.target.selectedIndex].getAttribute('data-country-code');
    const countryFlagImg = `https://flagpedia.net/data/flags/h80/${countryCode.toLowerCase()}.webp`;

    this.setState({
        select: value,
        CountryFlag: countryFlagImg
    });
}

render() {
    const { CountryFlag, CountryCode, step } = this.state;
    const values = { CountryFlag, CountryCode };

    switch (step) {
        case 1:
            return (
                <StepOne
                    handleChange={this.handleSelectChange}
                    countryFlagHandler={this.countryFlagHandler}
                    values={values}
                />

            )
        default:
            return (
hello React App
)

    };
  }
}

And child Component StepOne
import React, { Component } from 'react'
class StepOne extends Component {
render() {
    const { values, handleChange } = this.props;

    return (

            <select id="country" onChange={this.props.handleChange} defaultValue={values.select}>
                <option data-country-code="IN" value="91">India</option>
                <option data-country-code="US" value="1">US</option>
                <option data-country-code="GB" value="44">UK</option>
            </select>

    )
  }
}

Running Example


text:
Q: How to select between two lines like Matlab in Vim? In Matlab, there is a way to select code between two predefined typed markers. I want to replicate the same thing on Python using ## as the block marker. For example, let's say the cursor is in Block 2 on the variable y1:
## Block 1
import numpy as np
import matplotlib.pyplot as plt

## Block 2
x = np.linspace(0, np.pi*4, 100)

y1 = np.sin(x)  # <== My cursor is here
y2 = np.cos(x)
y3 = np.tan(x)

## Block 3
for i in range(5):
    print(i)
plt.plot(x, y)
plt.show()

I would like to yank the following block into my register
## Block 2
x = np.linspace(0, np.pi*4, 100)

y1 = np.sin(x)  # <== My cursor is here
y2 = np.cos(x)
y3 = np.tan(x)

===============================================
Edit 1: I have searched all over stackoverflow, and I couldn't find anybody asking a similar question. Most of it is how to select functions or classes in python. I know it's possible because I found a plugin that does do this action, wmvanvliet/jupyter-vim (see the first thing on the readme for a video of it working). But it's a full on REPL and it adds 200ms to my start up time.
I'm sure there is a simple vim way to do this. I just can't find it

A: You can use
/^## to find the block start and end locations.
If your cursor is in the middle, you can use N to go to the previous hit (i.e., the start of the block), press v to enter visual mode, and hit n to go to the next block start. Since you don't want to yank the next block start, you'll need to move up a line with k (there are other ways, but this works nicely since you have an empty line between blocks anyway).
Putting it all together:
/^##<CR>Nvnk

will select the block your cursor is in.
You can make this into a function or a macro, if that's too many characters to type. Here is a good tutorial on how to put commands together into a macro. If we wanted to make a macro and save it in register b (for block, I guess?), we could do
qb/^##<CR>Nvnkq

and execute the macro with @b.


text:
Q: creating RecurrentPaymentsProfile on ExpressCheckout I saw several question on this subject here but all are without answers.
So i hope somebody will help me.
How to provide subscription through NVP API?
For example i sell accounts for $10 per month.
So i provide ExpressCheckout for 1 month and get $10 for it. And then i create subscribtion on this account for every month but with startdate from next (after already payed by ExpressCheckout one month) month?

A: You would call CreateRecurringPaymentsProfile and set the PROFILESTARTDATE to one month ahead in the future. This would subsequently start billing after one month.
See also https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_CreateRecurringPayments
as well as
https://www.x.com/node/2760


text:
Q: Cannot see my internal Hard Disk I'm a newbie and moved from Windows 10 to Ubuntu 22.04.1 LTS. I installed Ubuntu to my 120GB SSD and other personal files are on my internal 1 TB HDD. After installing Ubuntu, I can only see the SSD drive and its contents but not my HDD drive.
Please help me to so I can access my HDD.

A: The problem is that that disk has used Windows proprietry LDM partitions:
see this link My NTFS partitions are being showed as LDM Data Partitions (the comment from oldfred is probably more useful than the answer).
It's not straightforward to access that drive from Ubuntu.
You have a few options:
(1) Use a tool to access that data (eg ldmtool): This link may help you
https://stackoverflow.com/questions/8427372/windows-spanned-disks-ldm-restoration-with-linux
(2) Reformat the drive and copy your data back from backup. To format the drive, click on the gear cog at the bottom left on Disks and you should get options to create partitions / format the drive.
(3) If you don't have a backup (but you really should!), your safest option is to use Windows to access the data, back it up then format in Ubuntu. Either (1) remove the drive and put it in a Windows machine - I think you should be able to access it then - or (2) reinstall Windows on your SSD, access your HDD's data, copy it externally and then reinstall Ubuntu and copy the data across.
Do let us know how you get on.


text:
Q: What does DXGI_MODE_SCALING_UNSPECIFIED scaling mode mean in list of modes, returned from IDXGIOutput.GetDisplayModeList? I'm trying to create Direct3D 10/11 application with support of full screen mode. In order to do so, I have to provide list of available video modes to user. Also, it would be great to choose current desktop settings as default video mode in order to minimize video mode changing.
It was very simple to do it in Direct3D 9. For example, here is my mode list, supplied by Direct3D 9:
Current mode: 1920x1080x60Hz 32bit X8R8G8B8
Available modes:
Front buffer format 32bit X8R8G8B8: 35
1: 1920x1080x60Hz
2: 640x480x60Hz
3: 640x480x72Hz
4: 640x480x75Hz
5: 720x480x56Hz
6: 720x480x60Hz
7: 720x480x72Hz
8: 720x480x75Hz
9: 720x576x56Hz
10: 720x576x60Hz
11: 720x576x72Hz
12: 720x576x75Hz
13: 800x600x56Hz
14: 800x600x60Hz
15: 800x600x72Hz
16: 800x600x75Hz
17: 1024x768x60Hz
18: 1024x768x70Hz
19: 1024x768x75Hz
20: 1152x864x75Hz
21: 1280x720x60Hz
22: 1280x768x60Hz
23: 1280x800x60Hz
24: 1280x960x60Hz
25: 1280x1024x60Hz
26: 1280x1024x75Hz
27: 1360x768x60Hz
28: 1366x768x60Hz
29: 1600x900x59Hz
30: 1600x900x60Hz
31: 1600x1024x59Hz
32: 1600x1024x60Hz
33: 1680x1050x59Hz
34: 1680x1050x60Hz
35: 1440x900x60Hz

But doing the same simple thing via DXGI is a little bit complicated. What confuses me the most, is the fact, that IDXGIOutpit.GetDisplayModeList method returns up to 3 copies of the same video mode. The difference is in scaling mode provided:
DXGI_MODE_SCALING_UNSPECIFIED = 0
DXGI_MODE_SCALING_CENTERED = 1
DXGI_MODE_SCALING_STRETCHED = 2

Here it is:
List of modes for format 32bit R8G8B8A8 UNorm:
640x480x60Hz Progressive Unspecified
640x480x72Hz Progressive Unspecified
640x480x75Hz Progressive Unspecified
720x480x56Hz Progressive Unspecified
720x480x56Hz Progressive Centered
720x480x56Hz Progressive Stretched
720x480x60Hz Progressive Unspecified
720x480x60Hz Progressive Centered
720x480x60Hz Progressive Stretched
720x480x72Hz Progressive Unspecified
720x480x72Hz Progressive Centered
720x480x72Hz Progressive Stretched
720x480x75Hz Progressive Unspecified
720x480x75Hz Progressive Centered
720x480x75Hz Progressive Stretched
720x576x56Hz Progressive Unspecified
720x576x56Hz Progressive Centered
720x576x56Hz Progressive Stretched
720x576x60Hz Progressive Unspecified
720x576x60Hz Progressive Centered
720x576x60Hz Progressive Stretched
720x576x72Hz Progressive Unspecified
720x576x72Hz Progressive Centered
720x576x72Hz Progressive Stretched
720x576x75Hz Progressive Unspecified
720x576x75Hz Progressive Centered
720x576x75Hz Progressive Stretched
800x600x56Hz Progressive Unspecified
800x600x60Hz Progressive Unspecified
800x600x72Hz Progressive Unspecified
800x600x75Hz Progressive Unspecified
1024x768x60Hz Progressive Unspecified
1024x768x70Hz Progressive Unspecified
1024x768x75Hz Progressive Unspecified
1152x864x75Hz Progressive Unspecified
1280x720x60Hz Progressive Unspecified
1280x768x59Hz Progressive Unspecified
1280x768x59Hz Progressive Centered
1280x768x59Hz Progressive Stretched
1280x800x59Hz Progressive Unspecified
1280x960x60Hz Progressive Unspecified
1280x1024x60Hz Progressive Unspecified
1280x1024x75Hz Progressive Unspecified
1360x768x59Hz Progressive Unspecified
1360x768x59Hz Progressive Centered
1360x768x59Hz Progressive Stretched
1366x768x59Hz Progressive Unspecified
1366x768x59Hz Progressive Centered
1366x768x59Hz Progressive Stretched
1440x900x59Hz Progressive Unspecified
1600x900x59Hz Progressive Unspecified
1600x900x59Hz Progressive Centered
1600x900x59Hz Progressive Stretched
1600x1024x59Hz Progressive Unspecified
1600x1024x59Hz Progressive Centered
1600x1024x59Hz Progressive Stretched
1680x1050x59Hz Progressive Unspecified
1920x1080x60Hz Progressive Unspecified

First I thought, that DXGI_MODE_SCALING_STRETCHED = this mode requires stretching (back buffer is smaller, then front one, resolution may be not physical), DXGI_MODE_SCALING_CENTERED = in this mode image may not occupy the whole screen (back buffer is smaller, then front one, but physical resolution is preserved), DXGI_MODE_SCALING_UNSPECIFIED = "normal mode" (sizes of back and front buffer match, but physical resolution is not guaranteed). I.e. I should show list only those modes, that has Scaling = DXGI_MODE_SCALING_UNSPECIFIED.
But then I tried to determine the current mode. According to MSDN, when using IDXGIOutput.FindClosestMatchingMode method, if you don't specify one of the parameters, then this method gravitates towards current desktop settings, prioritizing parameters, that are set and using some sort of priority (ScanlineOrdering>Scaling>Format>Resolution>RefreshRate) to choose other ones. So I created the device (in order to be able to specify format as DXGI_FORMAT_UNKNOWN) and passed fully undetermined mode to this method (including Scaling = DXGI_MODE_SCALING_UNSPECIFIED).
Here is the result:
Suggested mode: 32bit B8G8R8A8 UNorm 1600x1024x59Hz Progressive Stretched
Suggested mode 1.1: 32bit B8G8R8A8 UNorm 1600x1024x59Hz Progressive Stretched Mono

As you can see, it doesn't match the current desktop mode, which is 1920x1080x60Hz. I've tried to change current desktop mode to different one and found out, that IDXGIOutput.FindClosestMatchingMode tends to choose closest available mode with parameters, that are close to desktop parameters, but with Scaling = DXGI_MODE_SCALING_STRETCHED, simply ignoring Scaling = DXGI_MODE_SCALING_UNSPECIFIED, specified by me.
Current mode: 32bit B8G8R8A8 UNorm 1024x768x75Hz Progressive Unspecified
Suggested mode: 32bit B8G8R8A8 UNorm 1280x768x59Hz Progressive Stretched
Suggested mode 1.1: 32bit B8G8R8A8 UNorm 1280x768x59Hz Progressive Stretched Mono

This leaded me to a stunning conclusion, that DXGI_MODE_SCALING_UNSPECIFIED is treated as invalid value for Scaling parameter at least for IDXGIFactory.CreateSwapChain method (otherwise why IDXGIOutput.FindClosestMatchingMode, which is used to choose modes, that will be supplied to IDXGIFactory.CreateSwapChain in most cases, refuses to choose 1920x1080x60Hz?).
I guess that IDXGIFactory.CreateSwapChain even calls IDXGIOutput.FindClosestMatchingMode internally to determine, which "physical" mode to use. But then... What does it mean? I can't provide modes, that doesn't have Scaling = DXGI_MODE_SCALING_CENTERED or DXGI_MODE_SCALING_STRETCHED to user, cuz this modes are not "physical" ones - i.e. IDXGIFactory.CreateSwapChain will choose other mode anyway?
But then why DXGI_MODE_SCALING_UNSPECIFIED is returned in list of available modes? If Scaling parameter is used only when calling IDXGIFactory.CreateSwapChain method to specify whether I want to center image or scale it, if supplied mode doesn't match any "physical" one and it's unused when calling IDXGISwapChain.ResizeTarget, cuz this method requires "physical" modes only, then why Scaling parameters are mixed in one list, returned by IDXGIOutpit.GetDisplayModeList?
What modes should I show to user? Only those, that have Scaling <> DXGI_MODE_SCALING_UNSPECIFIED? Or should I do the opposite thing? And how to determine current mode via DXGI itself, instead of using legacy Win API?
Can anyone explain it to me? Cuz there is nothing clarified about it in MSDN.

A: This problem have been blowing my brain for a long time already, but suddenly, when I decided to ask somebody else about this question, I got an insight and answered my question by myself. My initial assumptions were right - the problem is in strange behaviour of DXGI or my video card's driver.
The problem is in fact, that for some unknown reasons DXGI or my video driver always treats my current desktop mode as DXGI_MODE_SCALING_STRETCHED instead of DXGI_MODE_SCALING_UNSPECIFIED. This is the root of all problems, cuz when "gravitate towards current desktop mode" comes into effect, the fact, that modes are being filtered by Scaling parameter fist, causes terrible result.
This is what happens:
My current desktop mode is
32bit B8G8R8A8 UNorm 1920x1080x60Hz Progressive Stretched (instead of Unspecified)

IDXGIOutput.FindClosestMatchingMode tries to find mode, closest to it, but filters by Scaling mode first. The problem is in fact, that there is no 1920x1080x60Hz mode with Scaling = DXGI_MODE_SCALING_STRETCHED. That's why instead of choosing 1920x1080x60Hz, it chooses closest mode with DXGI_MODE_SCALING_STRETCHED, which is 1600x1024x59Hz.


text:
Q: Prove or disprove that if the sum of the probabilities of three events is 1, then the events are mutually exclusive
Which of the following statements is true? If a statement is true,
  prove it. If it is false, give a counterexample.
If $P(A)+P(B)+P(C)=1$, then the events A, B, and C are mutually
  exclusive.

I started my proof with the theorem below:
$$P(A ∪ B ∪ C) = P(A) + P(B) + P(C) – P(AB) – P(AC) – P(BC) + P(ABC)$$
We know that $P(A)+P(B)+P(C)=1$, so substituting that into the equation above:
$$P(A ∪ B ∪ C) = 1 – P(AB) – P(AC) – P(BC) + P(ABC)$$
Since $P(A)+P(B)+P(C)=1$, then $P(A ∪ B ∪ C) = 1$. Therefore:
$$P(AB) + P(AC) + P(BC) = P(ABC)$$
I know that to prove these events are mutually exclusive, I have to show that $P(AB) + P(AC) + P(BC) = P(ABC)=0$. However, I have no idea how to go about doing this.

A: If $P(A)=\frac 1  3$ and $B=C=A$ then $P(A)+P(B)+P(C)=1$ but the events are not mutually exclusive.


text:
Q: Immutable types (especially collections) and covariance in java Suppose I have this class WidgetHolder that holds Widget instances. Internally, I back it up with a List<Widget>. I guarantee that it is immutable so after construction no widget is added to the holder.
WidgetHolder also exposes a getWidgets() operation that returns an immutable view of the widget list.
I would like to have a derived SpecificWidgetHolder class that holds SpecificWidget instances, and whose return type for getWidgets() is Collection<SpecificWidget>.
I have the same guarantee, i.e. the SpecificWidgetHolder constructor takes a collection of SpecificWidget instances and does not modify it in any way.
Given that both WidgetHolder and SpecificWidgetHolder are immutable, the usual objections that justify generic invariance do not seem to apply (?)
Is there a clean way of expressing this in Java?
Thanks!

A: The scenario that you described is very common: You store a collection of objects internally, and want to expose a read-only version of this collection. This is often accomplished using the Collections#unmodifiableCollection method (and the specific ones for other collection types) :
class WidgetHolder {
    private final List<Widget> widgets = new ArrayList<Widget>();

    public List<Widget> getWidgets() {
        return Collections.unmodifiableList(widgets);
    }
}

But note that if the collection is unmodifiable anyhow, you can achieve the desired covariance by exploiting the fact that the collection is unmodifiable. When it is unmodifiable, you can declare the return type as
public List<? extends Widget> getWidgets() { ... }

This way, everybody will be able to use the list in the same way as before. He can read and iterate it. He can not add new elements, because it is unmodifiable - and a nice side-effect is that this unmodifiability is (to some extent) visible here syntactically:
List<Widget> widgets = widgetHolder.getWidgets();
widgets.add(new Widget()); // throws UnsupportedOperationException AT RUNTIME!

vs.
List<? extends Widget> widgets = widgetHolder.getWidgets();
widgets.add(new Widget()); // Does not compile!

(Note that calls like widgets.remove(x) or widgets.add(null) would still compile but throw an UnsupportedOperationException - it's only a subtle hint)

The key point, regarding your question, is that you can override this method with a more specific return type. This is the real covariance here.
So in a class SpecificWidgetHolder you have the choice between 3 ways of overriding this method:

*

*Using the same type as in the superclass:
public List<? extends Widget> getWidgets()

*Using the specific type, of which you know that it is assignable to the type of the superclass:
public List<SpecificWidget> getWidgets()

*Using the the wildcard type again, leaving room for further specializations (like a VerySpecificWidgetHolder):
public List<? extends SpecificWidget> getWidgets()

There are subtle differences of how the class may be used. Particularly, whether the information about the "specificness" is available to a caller. I tried to point this out in this example:
// With option 1, you only receive Widgets - even
// from a SpecificWidgetHolder
List<? extends Widget> widgets = specificWidgetHolder.getWidgets();
Widget widget = widgets.get(0);

// With option 3., you still know that a SpecificWidgetHolder
// provides a list of SpecificWidgets
List<? extends SpecificWidget> specificWidgets = specificWidgetHolder.getWidgets();
SpecificWidget specificWidget = specificWidgets.get(0);

Basically, you have to decide whether someone who has a SpecificWidgetHolder should be able to obtain the SpecificWidget instances from it or not.

A side note: As shown in another answer, this can be solved with generics as well. But I don't think that this is necessary here. And I'm usually a bit hesitant with attaching type parameters to classes, because they may be harder to understand and maintain than non-generic types. Generics (type parameters) are like salt: At the right place and the right dose they may make things simply better. But when you get carried away with them, and end up with nested generics and method signatures like <S, T extends Number> Foo<S, ? super T> getFoo(), this may hinder readabiliy and maintainability quite a lot

A: Try this:
public class WidgetHolder<T extends Widget>
{
  public List<T> getWidgets()
  {
    return (widgets);
  }

  private List<T> widgets;

} // class WidgetHolder

public class SpecificWidgetHolder extends WidgetHolder<SpecificWidget>
{
}


text:
Q: AWS dynamoDB to Athena Cross Account I've just started to use AWS, I have a question.
I'm trying to send data from DynamoDB (Account A) to Athena (Account B).
What I would like to do is,

*

*Transfer and update everyday the tables which are stored in Account A's DynamoDB TO ANOTHER ACCOUNT which is Account B.

*Account B is going to execute queries in Athena with the tables received from Account A.

Do you have any solution ?
Thanks a lot !

A: Note that we can not transfer data to Athena, which does not hold data itself.
If the query data source is in the same account, Athena Federated Query would be useful, but it does not seem to be supported cross-account yet.
So for your case, export DynamoDB table to S3 like this aws blog.
Then query S3 data using Athena.
Amazon EventBridge can be used for everyday scheduled actions.


text:
Q: Is it possible to make a Social Sign Up with Twitter Account? I am using HybridAuth on my project and added Facebook, Twitter and LinkedIn social providers in order for the user to be able to sign up/ sign in.
What I have encountered is that Twitter API does not return the users' email. Thus the user obviously can't sign up with his Twitter account.
Furthermore if the user has logged out - he can't even sign in with his Twitter account if he hasn't connected it to your application account, because the Twitter API won't use the email for searching the user in its' database. In order to be able to use Twitter Sign In, the user has to be signed in to your app and connect his Twitter account.
Is there anything I am missing and there is an actual way to Sign Up with Twitter?


text:
Q: Service.type has no subscript members import UIKit

class ServicesTableViewController: UITableViewController {
    var services = [Service]()

    override func viewDidLoad() {
        super.viewDidLoad()
        //load services data
        loadServices()
    }

    private func loadServices(){
        let photo1 = UIImage(named: "blank")
        let photo2 = UIImage(named: "blank1")
        let photo3 = UIImage(named: "blank2")

        guard let Service1 = Service(titled: "blank", description:"Test", imageName: photo1) else {
            fatalError("Unable to instantiate Service1")
        }
        guard let Service2 = Service(titled: "blank1", description:"Test", imageName: photo2) else {
            fatalError("Unable to instantiate Service1")
        }
        guard let Service3 = Service(titled: "blank2", description:"Test", imageName: photo3) else {
            fatalError("Unable to instantiate Service1")
        }
        services += [Service1,Service2,Service3]

    }

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return services.count
    }

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        // Table view cells are reused and should be dequeued using a cell identifier.
        let cellIdentifier = "ServicesTableViewCell"

        guard let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as? ServicesTableViewCell  else {
            fatalError("The dequeued cell is not an instance of ServicesTableViewCell.")
        }

        // Fetches the appropriate service for the data source layout.
        let services = Service[indexPath.row]

        cell.titleLabel.text = service.titled
        cell.photoImageView.image = service.image
        cell.descriptionLabel.text = service.description

        return cell
    }

I keep getting the error Service.type has no subscript members. I am trying to input this data into a table view controller, this is the code inside of the table view controller, I can post the cell code and the service.swift file also if necessary.

A: you should change this:
let services = Service[indexPath.row] // this is a class, not an array

in
let service = services[indexPath.row]

I also see that you initialize your Service passing an argument called imageName of type UIImage, so it may be confusing for you and I guess might be a problem in your cellForRowAt, because of:
cell.photoImageView.image = service.image

hence, be sure you have declared such property (image != imageName) in your Service.


text:
Q: Convert native swift Set into array I need to convert a Set into an array of either [AnyObject] or [String] is this possible? I know with an NSSet I can use .allObjects but there doesn't seem to be any functions for this with a native set

A: Just coerce directly to an Array:
let arr = Array(mySet)


text:
Q: Server Side Rendering React Using Spring Boot I was looking over the following tutorial using Spring Boot and React.
https://spring.io/guides/tutorials/react-and-spring-data-rest/
Would the React be server-side rendered here, since it is being rendered into the Thymeleaf template? For context I have placed the Thymeleaf template and React file code from the tutorial below.
src/main/resources/templates/index.html
<!DOCTYPE html>

    <meta charset="UTF-8"/>
    <title>ReactJS + Spring Data REST</title>
    <link rel="stylesheet" href="/main.css" />

src/main/js/app.js - rendering code
ReactDOM.render(
    <App />,
    document.getElementById('react')
)

A: In the given example React is not rendered server-side. The Thymeleaf HTML is outputted as is. Data is fetched client-side by calling services setup in the Spring Boot backend as shown in the tutorial.

A: There's no reason you cannot combine the two. Your example doesn't use any Thymeleaf templating, though, but if you did add it, and make Spring render it, then it would have both client-side ReactJS DOM components post-rendered after Spring's server-side HTML response.
As one example, you could do conditional rendering


text:
Q: Why is this Gradle exec command failing when it works from command prompt? I have a gradle build script with this in it:
exec {
    commandLine 'cmd', '/c', 'C:/cygwin64/bin/bash', '-lc', "'file /cygdrive/c'"
}

This fails showing the following error:
/usr/bin/bash: file /cygdrive/c: No such file or directory

However executing this direct from command prompt seems to work fine:
PS D:\s\u\deployment\backend> cmd /c C:/cygwin64/bin/bash -lc 'file /cygdrive/c'
/cygdrive/c: directory

Why is this not working in my gradle script? Any suggestions on how I could make this work?
More generally, I'm wanting a way to execute arbitrary commands via cygwin.

A: Please try:
exec {
    commandLine 'cmd', '/c', 'C:/cygwin64/bin/bash', '-lc', 'file /cygdrive/c'
}

Without " around 'file /cygdrive/c'.

A: If anyone is interested in the 'running arbitrary commands via cygwin' bit, I've ended up with:
import org.apache.tools.ant.taskdefs.condition.Os
def isWindows() {
    return Os.isFamily(Os.FAMILY_WINDOWS)
}

def runFromCommandLine (String... args) {
    List<String> arguments
    if (isWindows()) {
        arguments = ['cmd', '/c', 'C:/cygwin64/bin/bash', '--login', '-c', args.join(' ')].toList()
    }
    else {
        arguments = args.toList()
    }

    exec {
        commandLine arguments
    }
}

// usage
runFromCommandLine('file', '/cygdrive/c')


text:
Q: Does every sequence $4^nx_0+\frac{4^n-1}{3}$ contain a prime?
Does every sequence $4^nx_0+\dfrac{4^n-1}{3}$ contain a prime?

Fix some odd positive integer $x_0$ and define the sequence $x_0,x_1,x_2,\ldots$ as follows:
$x_n=4^nx_0+\frac{4^n-1}{3}$
So for example choosing $x_0=1$ gives the sequence:
$1,5,21,85,\ldots$
And choosing $x_0=3$ gives the sequence:
$3,13,53,214,\ldots$

Does every such sequence contain a prime number?

Dirichlet's Theorem states that there are infinitely many primes in every arithmetic progression:
$a, a+d, a+2d,\ldots$
where $a,d$ are coprime.  But I'm unaware of similar results for other progressions.  I found this paper (which is beyond me) but my rudimentary understanding suggests this is saying the result is unknown for geometric progressions.
The progressions I'm asking about are exponential in nature.  These are in fact the canonical set of linear combinations of the Lucas Sequences $U_1(5,4)$ and $V_1(5,4)$ over the odd integers.
Every successor $x_n:n\geq0$ is of course $\equiv 5\mod 8$ while every sequence for which $x_0\not\equiv\{1,3,7\}\mod 8$ is a subsequence of a longer sequence (with a smaller starting number), which does start with $x_0\equiv\{1,3,7\}\mod 8$.
So the set of all odd integers can be canonically indexed according to membership of the sequences starting with $x_0\equiv\{1,3,7\}\mod 8$.
I suspect these sequences have a close relationship with the kernel of the 2-adic logarithm, although I don't know a lot about that.
EDIT
So far we have found that $5$ is the only prime in $1,5,21,85,...$ so not every sequence has infinitely many primes.
UPDATE
Peter posted this related question for a candidate for a sequence with no primes and Paolo Leonetti has elegantly verified it has no primes, plus provided a class of such sequences which contain no primes; those for which $3x_0+1$ is a square number.

A: Aside of the nice solution provided in the other thread, which uses the algebraic factorization of the original formula when $3 x_0+1$ is a square, I have found a list of further solutions for $x_0$ such that the associated sequence contains no primes/only composites.
The sequences from $$x_0 \in \{371,495,775,1671,2171,3211,3955,4215,4655,4711,... \} \\
\text{have as well no prime entries.} \hspace{160pt} $$
This can easily be proved by looking at the small primefactors $p \in \{3,5,7,13\}$ : their cyclical occurences in the respective iteration sequence $S(x_0)$ have lengthes $\text{cyclen}(x_0,p) \in \{2,3,6\}$ and cover completely the $6$ leading entries of their sequence. Due to cyclicity each entry of the sequences $ \gt 13$ cannot be prime.
Example for $x_0=371$:
 N     primefact's x_N   Covering periodically
                          6 of 6 residueclasses
- - - - - - - - - - - - - - - - - -
[ 0           "7.53"]       __7_        == 371
[ 1       "3^3.5.11"]       35__        == 4*371+1
[ 2         "13.457"]       ___1        == 4*(4*371+1)+1
[ 3       "5.7^2.97"]       _57_
[ 4        "3.31687"]       3___
[ 5      "5.113.673"]       _5__
- - - - - - - - - - -
[ 6     "7.11.19753"]       __7_
[ 7    "3.5^2.81119"]       35__
[ 8    "13.293.6389"]       ___1
[ 9  "5.7.1427.1949"]       _57_
[10 "3^2.1423.30403"]       3___
[11  "5.11.28317907"]       _5__
- - - - - - - - - - - -
 ... ... ... ...  ...

Unfortunately I didn't find any further algebraical expression of this phenomenon, like the style of the one that has already been given with the $3x_0+1 \text{ -is-square}$ class of solutions.
Moreover there might be some further characteristics in/by the following list of $x_0$. The list has been created by checking the computing time up to $1000$ iterates, where the ones with $0$ msecs have been the suspect ones, and which gave the examples of the above mentioned covering-primefactors-solutions:
$$ \quad \text{covering } \; \mid \; \text{ heuristics}  \phantom{sequence beginning at $35$ has a prime (see update at bottom)} \\
\small \begin{array} {rrr||rrr}
 x_0 & \# & \text{msecs}& x_0 & \# & \text{msecs}\\ \hline
 371 & 0 & 0 & 35 & 0 & 125  & \text{sequence beginning at $35$ has a prime (see update at bottom)}\\
 495 & 0 & 0 & 603 & 0 & 171 \\
 775 & 0 & 0 & 1195 & 0 & 282 \\
 1671 & 0 & 0 & 1335 & 0 & 218 \\
 2171 & 0 & 0 & 1379 & 0 & 266 \\
 3211 & 0 & 0 & 1611 & 0 & 31 \\
 3955 & 0 & 0 & 1751 & 0 & 141 \\
 4215 & 0 & 0 & 2755 & 0 & 172 \\
 4655 & 0 & 0 & 2775 & 0 & 234 \\
 4711 & 0 & 0 & 2791 & 0 & 156 \\
 4971 & 0 & 15 & 3179 & 0 & 250 \\
 5195 & 0 & 0 & 3379 & 0 & 140 \\
 5831 & 0 & 16 & 4011 & 0 & 204 \\
 5955 & 0 & 0 & 4235 & 0 & 94 \\
 6235 & 0 & 0 & 5395 & 0 & 141 \\
 7131 & 0 & 0 & 5495 & 0 & 47 \\
 7631 & 0 & 0 & 5751 & 0 & 93 \\
 8671 & 0 & 0 & 5975 & 0 & 125 \\
 9415 & 0 & 0 & 6215 & 0 & 93 \\
 9675 & 0 & 0 & 6571 & 0 & 141 \\
 10115 & 0 & 0 & 6671 & 0 & 140 \\
 10171 & 0 & 0 & 6875 & 0 & 126 \\
 10431 & 0 & 0 & 7551 & 0 & 171 \\
 10655 & 0 & 0 & 7775 & 0 & 203 \\
 ... & ... & ... & ... & ... & ...
 \end{array}$$
where "#" denotes the number of primes found up to tested  iterations.
The timings were measured for up to $N=1000$ iterations
(using primecertifying isprime() in Pari/GP vers. 2.14, 64 bit.
updated table:The column headed with "covering" contains that cases of $x_0$ for which the covering by the small primes occurs, so this gives proven non-prime sequences, the column headed with "heuristics" contains the cases, where the primecertification showed all iterates being composite but only up to $N=1000$ (for up to $N=8000$ iterations I used the ispseudoprime() test).
For instance, $x_0=35$ needs further work to discern whether the iterations sequence has primes or not; there have been a couple of prime-canditates by a fast (pseudo)prime-test for $N>1000$ but which were certificated to be composite with the more intense isprime()-function. The time to do this increases excessively and unpredictable, so I stopped testing of $x_N$ at $N=2000$.
update 3.feb.2022 The sequence beginning at $x_0=35$ seems to contain a prime at $(106 \cdot 4^{4553}-1)/3$ as certified by the prime-tester of Dario Alpern. The number $x_{4553}$ has $2743$ digits and leading and trailing digits $5 337343 165620  \ldots 969933 010261$


text:
Q: ADO.NET Entity Data Model BUG I have a project in visual studio ultimate 2010 (MVVM) and database, in SQLITE.
Everything worked fine, but now I have a problem with the ADO.NET Entity Data Model.
I searched for information about this and have not found much .. Every time I want to open the wizard, it just closes.
I think I should reinstall Visual Studio, but before doing so if anyone has had this error before and know what can be, I'd be grateful.

A: I had this problem with VS 2013 (Entity Model Wizard disappearing). I solved it by first uninstalling the MySQL .NET/Connector (I had 6.8.3) and installing it back, and then retrying the wizard. Wizard completes and I could select tables etc.

A: I've found this can be a bug with third party data adapters being left in strange states.  Open your View > Server Explorer and remove your third-party data connections. Then, try opening the wizard again.

A: Try deleting the following file
c:\users\myusername\appdata\roaming\microsoft\visualstudio\10.0\SeverExplorer\DefaultView.SEView.

A: If you are creating a web application such as through MVC check the AttachDBFilename in web.config for characters such as |.
I had the same issue and was unable to resolve it by removing connections from Server Explorer.
I attached a visual studio debugger to visual studios.
Turned on CLI exceptions and turned off Just my Code.
I then saw the hidden exception.
The wizard was throwing an exception with the message "Invalid Character in Path" in System.IO.Path.CheckInvalidPathChars(string path, bool checkAdditional).
The value of path was "|DataDirectory|\\aspnet-Mvs4Dummy1-20140402113853.mdf".
I realised that this was the database that visual studios had automatically generated with my MVC application and that the offending character was probably the '|' symbol.
So I performed a Grep search of my directory and found that this was being stored in my web.config in this apparently unsupported format.
I changed the entry to a full local path and the wizard stopped disappearing.

A: Open VS,
View->Server Explorer and delete connections under the data connection files.
I had already this error before and solve it doing like this.

A: My solution for VS2015 was:
Install MySQL.NET Connector 6.9.8 to replace 6.9.5.
I already has installed MySQL for Visual Studio 1.2.6 and had got the appropratiate MySQL NuGet packages (MySQL.Data, MySQL.Data.Entity.EF6, MySQL.Web).

A: I solved the problem by doing some steps below:
1/ Open "Server Explorer" window in Visual Studio
2/ Delete all Connections under "Data Connections" sections
3/ Then, Add the ADO.net Entity Data Model as normal


text:
Q: Finding the dimension of the solution space of a differential equation What's the dimension of the differential equation
\begin{equation}
y''(x)-2xy'(x)-2y(x)=0
\end{equation}
It's easy to verify that the solution space is a vector space, but how to find its dimension without calculating the solutions explicitly. Mathematica 11 tells me that the solution is a vector space of dimension 2 but the solution is kinda complicated.

A: The solution space of any homogeneous linear differential equation of order $m$ (on an interval in which the Existence and Uniqueness Theorem applies) has dimension $m$.  One way to see this is that you can parametrize the solutions by the values of $y, y', \ldots, y^{(m-1)}$ at a particular $x$ in the interval: for any such initial condition there is exactly one solution to the differential equation that satisfies that initial condition.
In this case it's a second order equation, so the dimension is indeed $2$.


text:
Q: Impossible to create a yo meanjs project I am trying to begin this online tutorial:
http://www.bradoncode.com/tutorials/mean-stack-tutorial-part-1-setup/
Everything seems to be installed and ready, but when asked to 'yo meanjs', I got this error msg:

Have I done something wrong?

A: I think its just need sudo. I see yo is not able to create dir for express.
Try:
sudo yo meanjs


text:
Q: if statement in Javascript function I am beginner in Javascript
I am always getting true returned whatever the values of my variables,
It should return true if a and b are both even, but false otherwise.
Thanks for your help.
https://repl.it/9nH/1675

var a = 4;
var b= 5;
function areBothEqual (a, b) {
    if(a===b) {
        return true;
    }else {
        return false

    }
}

var result = areBothEqual();
document.write(result)

A: you are not passing the arguments to your function:
areBothEqual(a,b)

you had:
areBothEqual()

cheers

A: The issue is that you are requesting the arguments a and b in the line function areBothEqual (a, b), but they are never actually passed. Just replace the (a, b) with empty brackets (), as you can use the previously defined a and b instead.
var a = 4;
var b= 5;
function areBothEqual() {
    if(a===b) {
        return true;
    } else {
        return false

    }
}
areBothEqual()

A: var a = 4;
var b= 5;
function areBothEqual (a, b) {
    console.log(a);
    console.log(b);
    if(a===b) {
        return true;
    }else {
        return false

    }
}
areBothEqual();

They are 'undefined' both are equals...


text:
Q: Infrared divergency in the correction to the electron vertex Function in QED/ Question to Schwartz "Quantum Field Theory and the Standard Model I'm currently studying Mathew Schwartz's "Quantum Field Theory and the Standard Model". In the chapter on Infrared divergences (Page 359 (7th edition, hard cover))
he calculates the infrared divergent correction to the electron vertex.

I tried to confirm equation (20.17) but I have no idea how to perform the integral. That is, I managed to do the y-integration but then I get to something, I don't know how to integrate and also don't know how to expand in the photon mass. I would really like to understand how the result emerges, because this is the first time we see a Sudakov double Logarithm in the book and I want to see, how it emerges.
Any help would be very much appreciated!

A: It's actually possible to do the integral explicitly. To do so, it's convenient to decouple the x- and y-integration. Thus introduce $ \tilde{x}=1-x$ and $y= \tilde{x} \tilde{y}$ and define $r \equiv \frac{m^2_{\gamma}}{-Q^2}$. The integral reads now (dropping the tildes)
$$ \int_0^1 dx \frac{-x}{1-x-r} \int_0^1 dy \frac{1-x \; y}{y+\frac{r}{1-x-r}}$$. Doing the y integration gives $$ \frac{a x(x-(1+a x)\log\left( 1+ \frac{1}{a}\right))}{r}$$, where we abbreviated $a \equiv \frac{r}{1-x-r}$. Now the x integration can be done and the zeroth order term in $r$ gives equation (20.17). The Sudakov double logarithm appears when expanding the dilogarithm $$ \text{Li}_2\left(1-\frac{1}{r} \right) = -\frac{\log^2(r)}{2} - \frac{\pi^2}{6} +\mathcal{O}(r).$$


text:
Q: Subscribing to a subject does nothing I've build a service that shares data between components following the answer provided by SrAxi . All works fine until in the receiver component I implement the subscribe to the subject: the response and nothing else inside that subscribe method is showing, neither a simple console.log of a string; it is like Angular doesn't enter in that method at all.
I tried to do the subscription into OnInit, AfterViewInit and AfterContentInit: nothing changed. Also used setTimeOut(); nothing.
Then I've found the answer of Julius Dzidzevičius and then changed the subject into behaviorSuject and subscribed to it; again nothing changed.
This is driving me crazy, hope you could help
Code:
Sender component
 private actionsInfoObj = {
    fromAction: null,
    showForm: null,
    data: null
};
.....
 addNewRow() {
    this.actionsInfoObj.fromAction = 'addRow';
    this.actionsInfoObj.showForm = true;
    this.bus.actionInfo(this.actionsInfoObj);
    this.addRow.emit( this.actionsInfoObj );
}

Service (ButtonsUtilitiesService)
getActionInfo$: Observable<any>;
   private getActionInfoSubject = new Subject<any>();

constructor() {
    this.getActionInfo$ =
    this.getActionInfoSubject.asObservable();
}

actionInfo(data) {
    console.log(data);
    this.getActionInfoSubject.next(data);
}

Receiver component
constructor(
    private fb: FormBuilder,
    private bus: ButtonsUtilitiesService
) {
    this.bus.getActionInfo$.subscribe( (data: object) => {
        this.actionInfo = data;
    })
}

EDIT: forgot to say that (for now) both sender and receiver are in the same parent component:

            <app-table (addRow)="addRow($event)"></app-table>

            <app-dynamic-form></app-dynamic-form>


text:
Q: How to share chronicle queue between multiple micro services in AWS We had a micro service approach for one of our systems using Kafka as an event bus.
We had some latency problems and experimented with replacing Kafka topics with a bunch of Chronicle queues. When running locally on a developer machine the results were amazing, one of our most expensive work flows was processing ten to thirty times faster.
Given the initial good results we decided to take the experiment further and deploy our proof on concept in AWS which is where our system runs. Our micro services run in docker containers across a bunch of EC2s.
We created an EFS volume and mounted it on each docker container. We verified the volume was accessible from each micro service and the right read write permissions were granted.
Now the problem:
MS1 receives a message (API call) does some processing and emits an event in a chronicle queue. We can see on the EFS file system the chronicle queue file is touched. MS2 is supposed to consume that event and do some further processing. This is not happening. Eventually restarting MS2 would trigger the message processing but this is not always the case. Easy to imagine the disappointment.
The question:
Is our EFS approach wrong? If yes what would be the way to go?
Thank you in advance  for your inputs.

A: Chronicle Queue cannot work on a Network File System like EFS, as discussed in this previous question and also documented here: https://github.com/OpenHFT/Chronicle-Queue/#usage
To communicate between hosts you need Chronicle Queue Enterprise which supports TCP/IP replication.
Please note also doco for running with docker


text:
Q: Operations on bits when doing binary long division This is from the number theory chapter in CLRS.
We are asked to prove that binary "paper and pencil" long division a/b with result q and reminder r does O((1+lgq)lgb) operations on bits.
The way I see it is we do 1 subtraction of b for each bit in q. So assuming that subtracting b does lgb operations (one for each bit in b), then we have a total of O(lgblgq) operations, which is not what is requested.
If you take into account that the first subtraction operation you do might result in a 0 bit (for example, dividing 100b by 11b), then, OK, you can add 1 to lgq to compensate for this subtraction. But... the same could be said of the subtraction itself - it can take lgb operations or it can take lg(b)+1 operations depending on the numbers (in the 100b and 11b example, the second subtraction will be 100b-11b which takes 3 operations to complete).
So if we're factoring these cases, then the number of operations should be O((1+lgb)(1+lgq)).
So the question is, how can you show that the division takes O((1+lgq)lgb) operations?

A: When you subtract 100b-11b, you can actually ignore the leading bit in the first number, because you already know that the corresponding bit in the result will be 0. Had it been 1, you would have done a subtraction instead of a shift in the previous step. So the subtraction always considers exactly lg b bits.


text:
Q: 64-bit managed process: out-of-proc 32-bit COM server non-default interfaces not available I am migrating an Excel add-in originally written in VB6 to managed code and 64-bit Excel. The add-in interoperates with some legacy 32-bit COM DLL servers through COM surrogates, and an issue has been encountered where only methods and properties in the coclasses' respective default interfaces are available at runtime. Attempts to call methods and properties in any other interfaces exposed by the components results in System.MissingMethodExceptions.
The non-default interfaces are available when the migrated add-in is used with 32-bit Excel and the servers run in-process.
Is there anything that can be done to make the non-default interfaces available to the add-in in 64-bit mode?

A: The solution was to use type library marshaling (also known as universal marshaling), using the system-provided marshaling engine in oleaut32.dll. The universal marshaler can be used with any custom interface, provided that the parameters are variant-compatible.
To use the universal marshaler for an interface, the interface is tagged with oleautomation, as in this sample interface:
[
    object,
    oleautomation,
    uuid(23D4EC0B-96DA-4D18-82BD-40E3AA0483FD),
    version(1.0),
    dual,
    helpstring("Description of ICustomInterface1"),
    pointer_default(unique)
]
interface ICustomInterface1 : IDispatch
{
    // Methods and properties …
}

Universal marshaling also requires the following Registry entries:

*

*HKCR\TypeLib<type library GUID><type library version>

*HKCR\TypeLib<type library GUID><type library version>\0

*HKCR\TypeLib<type library GUID><type library version>\0\win32 = "path to type library file"

*HKCR\TypeLib<type library GUID><type library version>\Flags

*HKCR\TypeLib<type library GUID><type library version>\HelpDir = "path to help folder"

*[HKEY_CLASSES_ROOT\Interface<interface GUID> @="Interface name"

*[HKEY_CLASSES_ROOT\Interface<interface GUID>\ProxyStubClsid32
="{00020424-0000-0000-C000-000000000046}"

*HKCR\Interface<interface GUID\TypeLib = type library GUID
With this type information, the universal marshaler creates a proxy-stub at runtime, eliminating the need for a custom proxy-stub DLL.
In our case, given that the components were ATL-based, the Registry entries were created automatically once the interfaces were tagged with 'oleautomation' and the components rebuilt. For non-ATL projects, this can be done programmatically with the Win32 API's LoadTypeEx() (which I haven't tried).
Once this was done, non-default interfaces of our ATL-based components became available out-of-process to our migrated-to-VB.NET Excel COM add-in.
All this is detailed in Chapter 5 of "Developer's Workshop to COM and ATL 3.0."


text:
Q: How to find who is connected to my computer from MAC address? When I type in the command netstat -an into cmd, I get information that one of my ports is opened from some MAC address. My qestion is how to close that port and how to find from the MAC address what ip the other computer has?
I get this output:
UDP    [fe80::b970:58f1:a42a:a333%11]:1900  *:*
UDP    [fe80::b970:58f1:a42a:a333%11]:50524  *:*

A: Looking at your output, I don't think those are MAC addresses.  Rather they are IPv6 addresses.  Also, I think the carriage returns got mangled in your question.  I don't think that it is showing any computers connected, rather just that you have process(es) listening on those ports.
To find out what Windows process is involved, you can do a netstat -anb (you may have to do this with Administrator priviledges).
Port 1900 is used for the ssdp protocol.  You could turn this off by disabling the SSDP Discovery service.
I'm not sure what corresponds to port 50524, but on my system, that same SSDP Discovery service is listening on a number of high numbered ports... it may be the same for you.

A: If you run netstat -b, you can see the applications that have the specific ports listening. You can't (to the best of my knowledge) close ports on demand, only terminate the processes that are accepting the connections.
Also, I think you're confusing MAC addresses with IPv6 addresses. fe80::b970:58f1:a42a:a333 is not a MAC address; it's an IPv6 address. Problem solved; you've got the IP.
(Information below this line is irrelevant if you don't have a MAC address)

Furthermore, even if you knew the MAC address, I don't know if there is a RARP (Reverse Address Resolution Protocol) for Windows. I know there used to be rarpd for Linux, but RARP support was removed version 2.3 of the kernel. You could always fire up WireShark or something similar if you're on a wireless connection or connected to a hub (not a switch) and check the destination addresses of the frames.


text:
Q: How are references implemented in Oracle's JVM? While searching for an explanation on how a reference variable is implemented in Java I came across this question:
What's inside a reference variable in Java?
In there was a comment by Samuel_xL saying that specifying the vendor name would be a better question.
So my question is that how an instance variable in implemented in Oracle JVM? Is it a pointer to an address? I know that a reference holds bits that tell the JVM how to access the object.
But how is it structured??

A: From what I've been able to determine, object references are stored either as a type called oop (ordinary object pointer) or narrowOop, depending on whether the JVM is using compressed object pointers or not. An oop is a C++ class that wraps a pointer to a Java object, and a narrowOop is a 32-bit unsigned integer that has to be converted into a proper pointer in order to access the object; they have no internal structure. You can find the declarations here: http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/share/vm/oops/oopsHierarchy.hpp


text:
Q: val a = month(start_date),year(to-date) I have a requirement, that I have a string like below input and I want string like below output. can anyone please help me ?
example 1
val input = "month(start_date),year(to_date),month(to_date)"

output = "start_date,to-date"

example 2
input = "abc(start),xyz(end)"

output = "start,end"

A: You need a regex to get the value inside parenthesis
val input = "month(start_date),year(to_date),month(to_date)"
val regex = "(?<=\\()[^)]+(?=\\))".r
val output = regex.findAllIn(input).toSet.mkString(",")

for regex explanation you can find it here How do I match the contents of parenthesis in a scala regular expression
toSet to remove the duplicated
and mkString to join the set with comma


text:
Q: Create a "listener" to slider in Matlab I am creating a GUI in which I display a 3D image and navigate through it using a slider. I want to draw some points (using a "WindowButtonDownFcn" callback, i.e., I do not have any information about the position of the slider once I call the drawing function) over a certain slice using the mouse and that point should appear over all other slices and be editable as soon as the user uses the slider to switch between slices.
One possible solution that came to my mind is use "listeners", so whenever the user moves the slider, my drawing function is notified and the slider position is passed to it.
.
Following the MATLAB tutorial, I defined my classes so I can include the listener to my code, but it is not working.
.
How can I implement this functionality?
Code for GUI:
function varargout = teste_window(varargin)

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @teste_window_OpeningFcn, ...
                   'gui_OutputFcn',  @teste_window_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

function teste_window_OpeningFcn(hObject, eventdata, handles, varargin)

load IMG.mat
nimgs = 10;
imgs = zeros(size(img, 1), size(img, 2), nimgs);
for ii = 1: nimgs
    imgs(:, :, ii) = img;
end

imshow(imgs(:, :, 1), [], 'Parent', handles.axs_plot);
handles.imgs   = imgs;
handles.nimgs  = nimgs;
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes teste_window wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = teste_window_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;

% --- Executes on button press in btn_ok.
function btn_ok_Callback(hObject, eventdata, handles)

btns = findobj(hObject, 'Style', 'pushbutton');
set(btns, 'Enable', 'Off');
[x, y] = getRoi4(handles.axs_plot)
handles.xcoord = x;
handles.ycoord = y;
set(btns, 'Enable', 'On');
guidata(hObject, handles);
% dragDrop(handles.axs_plot);

% --- Executes on slider movement.
function sld_img_pos_Callback(hObject, eventdata, handles)
nimgs = handles.nimgs;
set(handles.sld_img_pos, 'Max', nimgs);
set(handles.sld_img_pos, 'SliderStep', [1/nimgs , 1/nimgs]);
sld_val = round(get(handles.sld_img_pos, 'Value'));
if (sld_val < 1)
    sld_val = 1;
elseif (sld_val > nimgs)
    sld_val = nimgs;
end
imshow(handles.imgs(:, :, sld_val), [], 'Parent', handles.axs_plot);

% --- Executes during object creation, after setting all properties.
function sld_img_pos_CreateFcn(hObject, eventdata, handles)

if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end

Code for getRoi4:
    function [x, y, xc, yc] = getRoi4(axeshandle)

zoom off;
x  = [];
y  = [];
xc = [];
yc = [];
th   = linspace(0., 2.*pi, 40);
fig = ancestor(axeshandle, 'figure');
xlim = get(axeshandle, 'XLim');
ylim = get(axeshandle, 'YLim');
set(axeshandle, 'XLim', xlim, 'YLim' , ylim, 'NextPlot', 'add');
set(fig, 'KeyPressFcn', @keyRead, 'WindowButtonDownFcn', @mouseRead);

uiwait(fig);

    function keyRead(src, callback)
        key = callback.Key;
        returnPressed = strcmp(key, 'return');
        %         deletePressed = strcmp(key, 'backspace');
        if returnPressed
            set(fig, 'KeyPressFcn', '');
            set(fig, 'WindowButtonDownFcn', '');
            uiresume(fig);
        end
    end

    function mouseRead(src, callback)
        mouseKey = get(fig, 'SelectionType');
        leftMouse   = strcmp(mouseKey, 'normal');
        rigthMouse  = strcmp(mouseKey, 'alt');
        middleMouse = strcmp(mouseKey, 'extend');
        % LEFT CLICK:
        if leftMouse
            cp = get(axeshandle, 'CurrentPoint');
            x = [x, cp(1, 1)];
            y = [y, cp(1, 2)];
            plot(axeshandle,  x,  y, '*b');
            hold on;
            [xc, yc] = getCirc(x, y, xc, yc);
            npts = size(xc, 1);
            for ii = 1: npts
                plot(axeshandle, xc(ii, :), yc(ii, :), 'c')
            end

            % RIGHT CLICK
        elseif rigthMouse
            lc      = get(axeshandle, 'CurrentPoint');
            dist    = sqrt((lc(1, 1) - xc).^2. + (lc(1, 2) - yc).^2);
            [ix, ~] = find(min(min(dist)) == abs(dist));
            ix      = ix(1);
            set(fig, 'WindowButtonMotionFcn', @(xc, yc, index)dragPoint, 'WindowButtonUpFcn', @(s,e)stopDrag);

            % MIDDLE CLICK
        elseif middleMouse
            cp = get(axeshandle, 'CurrentPoint');
            if ~isempty(x)
                [~, ind] = min((x - cp(1,1)).^2 + (y - cp(1,2)).^2);
                ind    = ind(1);
                x(ind) = [];
                y(ind) = [];
                xc(ind, :) = [];
                yc(ind, :) = [];
                dots = findobj(get(axeshandle, 'Children'), 'Type', 'Line');
                set(dots, 'XData', x, 'YData', y, 'color', 'blue', 'Marker', '*', 'LineStyle', 'None');
                npts = size(xc, 1);
                for ii = 1: npts
                    plot(axeshandle, xc(ii, :), yc(ii, :), 'c')
                end
            end
        end

        % DRAG AND DROP:
        function dragPoint(src, callback)
            xcenter = x(ix);
            ycenter = y(ix);
            cp      = get(axeshandle, 'CurrentPoint');
            radius  = sqrt((cp(1, 1) - xcenter)^2. + (cp(1, 2) - ycenter)^2.);
            newxc   = radius*cos(th) + xcenter;
            newyc   = radius*sin(th) + ycenter;
            dots = findobj(get(axeshandle, 'Children'), 'Type', 'Line');
            set(dots, 'XData', x, 'YData', y, 'color', 'blue', 'Marker', '*', 'LineStyle', 'None');
            xc(ix, :) = newxc;
            yc(ix, :) = newyc;
            npts = size(xc, 1);
            for jj = 1: npts
                plot(axeshandle, xc(jj, :), yc(jj, :), 'c')
            end
        end

        function stopDrag(src, callback)
            set(fig, 'WindowButtonMotionFcn', '');
            set(fig, 'WindowButtonUpFcn', '');
        end

    end

    function [xc, yc] = getCirc(x, y, xc, yc)

        r    = 10;
        npts = length(x);
        xc(npts, :) = r*cos(th) + x(npts);
        yc(npts, :) = r*sin(th) + y(npts);

    end

end

Thank you all in advance,


text: Q: What's the onload equivalent for most elements? How to add onload event to a div element points out that the onload attribute only works for  and external sources (like


text:
Q: Auto-hiding plasma panel vs visual changes while hidden I have my main plasma panel hidden by default to remove visual clutter and not get distracted. This works fine.
What would make it even better: if visual changes to the panel would happen even when it's hidden.
Common examples are systray icons from messengers: I get a message and next time I show the panel, the messenger gets a little indicator that there are new messages. Now I jump to my virtual desktop where the messengers are, activate the program, read the message and jump back to my main desktop. Next time I show the panel that includes the messenger icons, it will still have the message indicator, but will quickly remove it, but not before I see it and think I have another message.
The same thing happens for tasks that have been closed, e.g. a copying progress indicator from Krusader (I've set them to pop out and run in their own little windows). It'll finish but will only be removed the next time I activate the panel.
Is there any way to change this behavior? I'd prefer for the panels to always reflect the current state, not the state they were in when they were visible the last time I opened them + a quick transition to the current state.


text:
Q: Why can do some commands execute in terminal but not in script? I'm writing a basic script to practice working with arrays. When I run the script I get errors but when I run the same command in the terminal it executes.
#!/bin/bash

declare -a StringArray

StringArray=("blue" "green")

for  val in ${StringArray[@]}; do
    echo $val
done

I've given the script executable permission. What am I missing?

A: With the command sh script.sh, you try to run the script with sh. sh is symlinked to dash. dash is the standard command interpreter of Ubuntu. It is a different shell than bash, essentially with more minimal features, but very fast. Bash is much better for interactive use, so remains the default interpreter for the interactive prompt. Here is an excellent answer on the difference between these command interpreters.
Instead, run your script with
bash script.sh

to have it executed under the proper shell.
If you place your script in a directory in your PATH and make it executable, you can run it at the command prompt merely by typing script.sh. At that moment, the shebang line, #!/bin/bash tells the system that bash should be used. When running the script as bash script.sh or sh script.sh, that shebang line is just a comment and not interpreted at all.


text:
Q: Is it possible to create a dynamic array of pointers in C? Basically I need to save a certain number of strings received from stdin in a dynamic list, but the number of strings is different for each node of my list. What I'm trying to do is to have a double pointer to char, so that I can have an array of strings (an array of pointers to char). But maybe it doesn't work this way.
Simplifying I have:
typedef struct table {
    int rowsNumber;
    char **array;
    struct content * next;
} content;

table* node=NULL;

int main() {
    ...
    nodecreate();
    ..
}

Then I need to create the table, but here is where I'm getting errors.
void nodecreate()
{
    char line[MAXLENGHT];
    scanf("%d", table->rowsNumber);
    for (i=0; i<rowsNumber, i++) {
        fgets(line, MAXLENGHT, stdin);
        node->array[i] = malloc(strlen(line) * sizeof(char));
        strcpy(node->array[i], line);
    }
}

A: These declarations
typedef struct table {
    int rowsNumber;
    char **array;
    struct content * next;
} content;

table* node=NULL;

are incorrect.
For example in this typedef declaration
typedef struct table {
    int rowsNumber;
    char **array;
    struct content * next;
} content;

there are declared the type struct table its alias content and one more type struct content. The types struct table and struct content are two different types.
For this declaration
table* node=NULL;

the compiler shall issue a message that the name table is not declared.
It seems you mean the following
typedef struct table {
    int rowsNumber;
    char **array;
    struct table *next;
} content;

content *node = NULL;

In this function
void nodecreate()
{
char line[MAXLENGHT];
scanf("%d",table->rowsNumber);
for(i=0;i<rowsNumber,i++){
    fgets(line,MAXLENGHT,stdin);
    node->array[i]=malloc(strlen(line)*sizeof(char));
    strcpy(node->array[i],line);
}

where a closing brace is absent there is used the null pointer node. So the function will at least invoke undefined behavior. The same problem exists with the data member node->array that has an indeterminate value.
To use the function strcpy you need to reserve also a character for the terminating zero character like
    node->array[i]=malloc(strlen(line)*sizeof(char) + 1);

Also pay attention to that after this call of scanf
scanf("%d",table->rowsNumber);

the following first call of fgets will read an empty string (containing only the new line character '\n') because the input buffer will contain the new line character '\n'. You have to remove it.
In any case the function does not make sense because the function as it is followed from its name nodecreate shall create a new node. So this means as the function does not have parameters that the function shall return a created node that can be added to the list.

A: malloc the array of pointers first.
//assuming you malloc'd the table somewhere before calling this...
void nodecreate()
{
char line[MAXLENGHT];
scanf("%d",table->rowsNumber);

node->array = malloc(sizeof(char*)*table->rowsNumber);
for(i=0;i<table->rowsNumber,i++){
    fgets(line,MAXLENGHT,stdin);
    node->array[i]=malloc(strlen(line)*sizeof(char));
    strcpy(node->array[i],line);
}

//don't forget to free both every char * and the char ** somewhere...

A: You cant malloc array[i] if you havent already allocated some memory to array
You need to do 3 steps:
Step 1: Malloc the table node
node = (content*)malloc(sizeof(table));
node->rowsNumber = 5; // change to whatever you want

Step2:
Malloc the array of pointers:
node->array = (char**)malloc(sizeof(char*)*(node->rowsNumber));

Step3: Malloc individual strings in array
for(i=0;i<node->rowsNumber,i++){
    node->array[i]=malloc(sizeof(char) * 8);// Change 8 to whatever size you want
}


text:
Q: Spark - how does it distribute data around the nodes? How does spark distribute data to workers?
Do the workers read from the data source, or does the driver reads it and sends it to workers? And when a worker needs data that is in another worker, do they communicate directly?
Thanks!

A: If you use distributed input methods like SparkContext.textFile then workers read directly from your data source (or if you explicitly open HDFS files from inside worker task code then of course those will also occur on the workers).
If you manually read data in on your main driver program, and then used SparkContext.parallelize, then indeed your driver will be sending data to your workers.
Data dependencies from worker to worker are generally referred to as the shuffle; this type of worker-to-worker communication is in a lot of ways the heart of most big data processing systems, precisely because it's tricky to do efficiently and reliably. Conceptually you can treat it more-or-less as "communicating directly", but there may be a lot more going on under the hood depending on how the data dependency is taken on.


text:
Q: Return Tibble as Json I am new to R and I am trying to use the Hansard Library.
Is there any way I could export the results of any of the queries as Json rather than a tibble?
library(hansard)
library(tibble)

#example query
z <- mp_vote_record(172, "aye", start_date = "2017-01-01", end_date = "2017-05-03")

print(z)

Giving the output:
# A tibble: 38 x 5
   about  title       uin    date_value          date_datatype
   <chr>  <chr>       <chr>  <dttm>              <chr>
 1 722300 Early Parl~ CD:20~ 2017-04-19 00:00:00 POSIXct
 2 714865 Pension Sc~ CD:20~ 2017-03-29 00:00:00 POSIXct
 3 714866 Pension Sc~ CD:20~ 2017-03-29 00:00:00 POSIXct
 4 714868 Pension Sc~ CD:20~ 2017-03-29 00:00:00 POSIXct
 5 713962 Bus Servic~ CD:20~ 2017-03-27 00:00:00 POSIXct
 6 713963 Bus Servic~ CD:20~ 2017-03-27 00:00:00 POSIXct
 7 714005 Bus Servic~ CD:20~ 2017-03-27 00:00:00 POSIXct
 8 710264 Reproducti~ CD:20~ 2017-03-13 00:00:00 POSIXct
 9 708770 Children a~ CD:20~ 2017-03-07 00:00:00 POSIXct
10 708773 Children a~ CD:20~ 2017-03-07 00:00:00 POSIXct
# ... with 28 more rows

A: You can just transform the tibble into json using jsonlite package. An example using the built-in data set iris:
library(dplyr)
library(jsonlite)

mydata <- as_tibble(iris)
toJSON(mydata)


text:
Q: Return all properties of class, not null c# I've been looking and found this which describes to return a bool if value is null. The code, I'm using is from this snippet
    Client client = new Client{ FirstName = "James"};
client.GetType().GetProperties()
.Where(pi => pi.GetValue(client) is string)
.Select(pi => (string) pi.GetValue(client))
.Any(value => string.IsNullOrEmpty(value));

But instead of returning if the value is null or not (the bool) I would like to retrieve all the properties values where they are not null.
I've tried making changes to the code, but unsuccessful.
Many thanks
EDIT
public class Client
{
   public string FirstName { get; set; }
   public string LastName { get; set; }
   //...
}

Client client = new Client();
client.FirstName = "James";
client.LastName = "";

Using my 'Client' class, I would like to iterate over all the properties within my class, and where the value isn't null or empty string, I would return the value, in this example, I would only return a string "James".
Hope that makes sense.

A: There are some issues:
return myObject.GetType().GetProperties()
.Where(pi => pi.GetValue(myObject) is string) // this wastes time getting the value
.Select(pi => (string) pi.GetValue(myObject))
.Any(value => string.IsNullOrEmpty(value)); //  Any will return a bool

So change this to:
return myObject.GetType().GetProperties()
.Where(pi => pi.PropertyType == typeof(string)) // check type
.Select(pi => (string)pi.GetValue(myObject)) // get the values
.Where(value => !string.IsNullOrEmpty(value)); // filter the result (note the !)

Also, ensure that your properties are properties and not fields.

A: Use Where instead of Any. Also you were missing an ! at !string.IsNullOrEmpty(value).
I modified your code to return a dictionary with property values indexed by name.
var stringPropertyValuesByName = client.GetType().GetProperties()
    .Where(pi => pi.PropertyType == typeof(string)) // use type check as Steve Harris suggested
    .Select(pi => new { Val = (string) pi.GetValue(client), Name = pi.Name })
    .Where(pi => !string.IsNullOrEmpty(pi.Val))
    .ToDictionary(pi => pi.Name, pi => pi.Val);

C# Fiddle

A: If you want to get all not null properties that are also not empty strings i suggest:
using System;
using System.Linq;

class Cls
{
    public string Prop1 {get; set;}

    public object Prop2 {get; set;}

    public int Prop3 {get; set;}

    public string Prop4 {get; set;}

}

public class Program
{
    public static void Main()
    {
        var obj = new Cls() { Prop1 = "abc", Prop3 = 5 };

        var props = obj
            .GetType()
            .GetProperties()
            .Select(p => p.GetValue(obj))
            .Where(x => x != null || ( x is string && (string)x != ""))
            .ToList();

        Console.WriteLine(string.Join(",", props));
    }
}

produces:

abc,5


text:
Q: Telerik Button's text is not showing I have a simple form consists of several text boxes and 3 buttons which all are Telerik buttons.
 .RadButton_Metro.rbSkinnedButton {
            height: 32px !important;
        }
    </style>

<telerik:RadCodeBlock runat="server">

</telerik:RadCodeBlock>

<telerik:RadAjaxPanel ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" runat="server" EnableAJAX="true">

        <asp:Panel ID="pnlContent" runat="server">

                    <fieldset>
                        <legend>General</legend>

                                Board Name :

                                <asp:TextBox class="form-control" ID="txt_Instituton_Branch_Name" runat="server" style="width: 230px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv_branchname" runat="server" ControlToValidate="txt_Instituton_Branch_Name" CssClass="errorClass"
                                    Text="*" ErrorMessage="Please, enter Board Name!" Display="None">
                                </asp:RequiredFieldValidator>

                                Email :

                                <asp:TextBox class="form-control" ID="txt_Email" runat="server" TextMode="Email" style="width: 230px !important;height: 22px;"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv_email" runat="server" ControlToValidate="txt_Email" CssClass="errorClass"
                                    Text="*" ErrorMessage="Please, enter email!" Display="None">
                                </asp:RequiredFieldValidator>

                                Board-Admin UserName :

                                <asp:TextBox class="form-control" ID="txt_admin_username" runat="server" style="width: 230px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv_board_admin_username" runat="server" ControlToValidate="txt_admin_username" CssClass="errorClass"
                                    Text="*" ErrorMessage="Please, enter username!" Display="None">
                                </asp:RequiredFieldValidator>

                                Board-Admin Password :

                                <asp:TextBox class="form-control" ID="txt_Password" runat="server" TextMode="Password" style="width: 230px"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv_password" runat="server" ControlToValidate="txt_Password" CssClass="errorClass"
                                    Text="*" ErrorMessage="Please, enter password!" Display="None">
                                </asp:RequiredFieldValidator>

                    </fieldset>
                    <fieldset>
                        <legend>Additional Info</legend>

                                Address Line 1 :

                                <asp:TextBox class="form-control" placeholder="address" ID="txt_adress" style="width: 230px" runat="server"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv_adress" runat="server" ControlToValidate="txt_adress" CssClass="errorClass"
                                    Text="*" ErrorMessage="Please, enter Board adress" Display="None">
                                </asp:RequiredFieldValidator>

                                Phone/Mobile No :

                                <asp:TextBox class="form-control" placeholder="Mobile No" ID="txt_Mobile" runat="server" style="width: 230px !important" TextMode="Phone"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfv_mobile" runat="server" ControlToValidate="txt_Mobile" CssClass="errorClass"
                                    Text="*" ErrorMessage="Please, enter Board adress" Display="None">
                                </asp:RequiredFieldValidator>

                    </fieldset>

                            <asp:Panel ID="pnlEventLine" runat="server">

                                    <telerik:RadButton ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" Width="100%" UseSubmitBehavior="true" OnClientClicked="showNotification">
                                        <Icon PrimaryIconCssClass="rbSave" />
                                    </telerik:RadButton>

                                    <telerik:RadButton ID="btnReset" runat="server" Text="Cancel" Width="100%" OnClientClicked="redirect" AutoPostBack="false">
                                        <Icon PrimaryIconCssClass=" rbCancel" />
                                    </telerik:RadButton>

                                    <telerik:RadButton ID="btn_View" runat="server" Text="View Board"
                                        Width="169%" AutoPostBack="false">
                                        <Icon PrimaryIconCssClass=" rbSearch" />
                                    </telerik:RadButton>

                            </asp:Panel>

        </asp:Panel>

    <telerik:RadNotification RenderMode="Lightweight" ID="RadNotification1" runat="server" Width="300" Animation="FlyIn"
        OnClientShowing="CheckIfShow" EnableRoundedCorners="true" EnableShadow="true"
        LoadContentOn="PageLoad" Title="Fix these"
        TitleIcon="warning" EnableAriaSupport="true" ShowSound="warning" AutoCloseDelay="7000">
        <ContentTemplate>
            <asp:ValidationSummary ID="ValidationSummary1" runat="server"></asp:ValidationSummary>
        </ContentTemplate>
    </telerik:RadNotification>
</telerik:RadAjaxPanel>

any of the button text is not showing.

and also please notice these two textboxes , Email and phoneNumber. These textboxes having textmode property email and phone respectively. But while rendering its showing its width 224px instead of 230px.

Here is my requirement,
1. How to display text of those buttons
2. How to fix textboxes width issue.


text:
Q: Remove parent or child element on page load using jquery I want to remove the anchor element surrounding a block of code upon page load.
When the page loads, I want this code:

<nobr>
Employee Announcements

</nobr>

To turn into this code:

<nobr>
Employee Announcements

</nobr>

I have tried to get this working using unwrap but I am still struggling because I want to leave the surrounding nobr elements.

A: jQuery has an .unwrap() function that removes an element's parent.
http://api.jquery.com/unwrap/
example:
$(function() {
   $('#WebPartCaptionWPQ3').unwrap();
});

A: $(function() {
    var target = $('a[accesskey="W"]');
    var keep = target.children();
    target.replaceWith(keep);
});


text:
Q: Set authentication token to chai-Http I have created some test cases in node express framework which return successfully. However there are some API calls which need to have authenticated before I can make them. I can call the API that requires authentication in reactJs via ajax and It give a success response, however when I set the same header in chai-Http, it fails with invalid token.
var chai = require('chai');
var should = chai.should();
var chaiHttp = require('chai-http');

chai.use(chaiHttp);
var server = require('../app');

describe('routes : index', function() {
var token = '';
beforeEach(function(done) {
     done();
});
before(function(done) {
    chai.request(server)
        .post('/doSignin')
        .send({uname:'ruzan@test.com',password:'123123'})
        .end(function(err, res) {
            res.redirects.length.should.equal(0);
            res.status.should.equal(200);
            token = res.body.user.token;
            res.type.should.equal('application/json');
            done();
        });
});

afterEach(function(done) {
    done();
});

describe('Test FolderController', function() {
    it('should list all the folders', function(done) {
        console.log(token); // here it print the same token
        chai.request(server)
            .get('/notes/get-notes')
            .set('prg-header' , token)
            .end(function(err, res) {
               // console.log(res);
                res.status.should.equal(200);
                done();
            });
    });
});
});

ReactJs:
$.ajax({
        url: '/notes/get-notes',
        method: "GET",
        dataType: "JSON",
        headers: { 'prg-header':loggedUser.token }
    }).done( function (data, text) {
        console.log(data);
        if(data.status.code == 200){
            // it come here the data
        }
    }.bind(this));


text:
Q: Insert data to two table with primary and foreign key I tried to find solution for my problem on other questions, but I couldn't. Maybe my problem is in the database tables. I made an application that connects to a Firebird database, and I try to insert data into two tables. One of them is like this:

Id
Name
AddressId

2
NameOfCustomer
1

and second

Id
Address
Default
CustomerId

1
Long Street 1, 88300 London
1
2

I write insert in SQL like this:
EXECUTE BLOCK AS
declare variable id_customer bigint;
declare variable id_address bigint;
BEGIN
select gen_id(CUSTOMER_ID_GEN, 1) from rdb$database into :id_customer;
select gen_id(CUSTOMER_ADDRESSES_ID_GEN, 1) from rdb$database into        :id_address;
INSERT INTO CUSTOMER (Id, Name, AddressId) values (:id_customer, 'Name', :id_address);
INSERT INTO CUSTOMER_ADDRESS (Id, Address, Default, CustomerId) values   (:id_address, 'Short Street 1', 1, :id_customer);
END

When I run code I have exception like this:

violation of FOREIGN KEY constraint "CUSTOMER_ADDRESS_ID_FK" on table
"CUSTOMER"
Foreign key reference target does not exist.

Maybe someone know how to write this SQL in Firebird without error? Should I disable foreign key for a while, and then try to insert data?
Below DLLs of two tables:
CREATE TABLE CUSTOMER
(
  ID Integer NOT NULL,
  NAME STRING50_D NOT NULL,
  ADDRESS_ID Integer,
  PRIMARY KEY (ID)
);

ALTER TABLE CUSTOMER ADD CONSTRAINT CUSTOMER_ADDRESS_ID_FK FOREIGN KEY (ADDRESS_ID) REFERENCES CUSTOMER_ADDRESS (ID) ON DELETE SET DEFAULT;

CREATE TABLE R3_CONTACT_ADDRESSES
(
  ID Integer NOT NULL,
  ADDRESS STRING200_D,
  DEFAULT BOOLEAN_D,
  CUSTOMER_ID Integer NOT NULL,
  PRIMARY KEY (ID)
);

ALTER TABLE CUSTOMER_ADDRESS ADD CONSTRAINT CUSTOMER_ADDR_CUSTOMER_ID_FK FOREIGN KEY (CUSTOMER_ID) REFERENCES CUSTOMER (ID) ON UPDATE CASCADE ON DELETE CASCADE;

A: Your definition has a cyclic dependency, because CUSTOMER has a foreign key to CUSTOMER_ADDRESS, and CUSTOMER_ADDRESS has a foreign key to CUSTOMER. Constraints in Firebird are not deferred until commit, but checked immediately. As a result, you cannot insert CUSTOMER because the referenced address does not exist yet, and you cannot insert CUSTOMER_ADDRESS first either, because then the customer does not exist yet.
To fix this, you need to take one of the following approaches

*

*Insert CUSTOMER with ADDRESS_ID set to NULL (or leave it out of the insert), and update CUSTOMER to set ADDRESS_ID after you inserted the record into ADDRESS_ID.

*If a customer has a single address, then put the address information in CUSTOMER and drop CUSTOMER_ADDRESS.

*Remove ADDRESS_ID from CUSTOMER, and rely on CUSTOMER_ID in CUSTOMER_ADDRESS to link the records.

*Remove CUSTOMER_ID from CUSTOMER_ADDRESS, and rely in ADDRESS_ID in CUSTOMER to link the records. With this approach you need to insert CUSTOMER_ADDRESS first. If this works for you, then taking approach 2 might be the better choice.