text:
Q: How to change VARCHAR length in PRIMARY KEY in SQL Server 2014 I need to change the VARCHAR length from 20 to 25 in a code column in a library table in SQL Server 2014, but SSMS wants to DROP and RE-CREATE all my tables where the library table in question is linked to.
Is there a way to change the VARCHAR length of a PRIMARY KEY without dropping all the tables?

A: As you are increasing the length you can just do an alter column, for example:
CREATE TABLE dbo.T1
    (
      C1 VARCHAR(20) NOT NULL
                     CONSTRAINT PK_T1 PRIMARY KEY ,
      C2 INT
    );
GO

INSERT  INTO dbo.T1
VALUES  ( 'test', 1 ),
        ( 'test2', 2 );
GO

ALTER TABLE dbo.T1 ALTER COLUMN C1 VARCHAR(25) NOT NULL;

Further reading on the ALTER TABLE syntax at https://learn.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact-sql

A: You will want to use the ALTER TABLE command, as in Nic's answer. However, the problem is that there are foreign keys that reference your table.
To get around this, you'll want to script out the foreign keys, drop them to make the change, and then recreate them after you've updated the tables.
Here's a link to a script by Aaron Bertrand for scripting out the command to drop and create your foreign keys.
NOTE: I would also update the column in the other tables that use it, to make sure that all allowed values will fit in those other tables.

A: Try to uncheck "Deny saving changes which needed recreation of a table".
In SQL Managenet St. click on bar, choise Service - Parameters, select Diesigners - Table and Database Constructors. Then unscheck "Deny saving changes which needed recreation of a table".


text:
Q: How can I freely move JComponents in IntelliJ GUI Designer? I have the IntelliJ-Idea Ultimate Edition but I am sure it applies in the community edition as well. I cannot freely move any components (buttons, text fields) in the JPanel. They only move to fixed places and it annoys me. Is there a way to fix that?
The process I followed is:

*

*I created a new Java project.

*I created a new package.

*I right clicked on the new package and selected "Swing UI Designer" -> "GUI Form"

*By default a JPanel was created.

And then tried to edit it as I explained above.

A: If you're asking how to manually drag and drop a component in the editor, you can do it by clicking the component name in the component tree and dragging it to a new position:

redpajama_set_name: RedPajamaStackExchange


text:
Q: Send Openssl Client Hello with extended master secret disabled For testing purpose, I need to simulate a SSL request with EMS - Extended master secret disabled on my Ubuntu machine.
I checked the official openssl page https://wiki.openssl.org/index.php/Compilation_and_Installation, but could not find any flags/options that I could use in order to compile openssl without the EMS option.
The client always reports EMS as 'Yes', how do I set it to 'No'? Please provide inputs.
openssl version
OpenSSL 1.1.1-dev  xx XXX xxxx

openssl version -a
OpenSSL 1.1.1-dev  xx XXX xxxx
built on: reproducible build, date unspecified
platform: linux-x86_64
compiler: gcc -DDSO_DLFCN -DHAVE_DLFCN_H -DNDEBUG -DOPENSSL_THREADS -DOPENSSL_NO_STATIC_ENGINE -DOPENSSL_PIC -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DPADLOCK_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/compssl\"" -DENGINESDIR="\"/usr/local/lib/engines-1.1\""  -Wa,--noexecstack
OPENSSLDIR: "/usr/local/compssl"
ENGINESDIR: "/usr/local/lib/engines-1.1"
Seeding source: os-specific

Server:
sudo openssl s_server -key 384private-key.pem -cert 384server.pem -accept 443 -www -cipher ALL:COMPLEMENTOFALL -comp

Client:
sudo openssl s_client -connect 10.92.0.10:443 -cipher ECDHE-ECDSA-AES128-SHA -comp
CONNECTED(00000003)
depth=0 C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
verify error:num=18:self signed certificate
verify return:1
depth=0 C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
verify return:1
---
Certificate chain
 0 s:C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
   i:C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
---
Server certificate
-----BEGIN CERTIFICATE-----
MIICDTCCAZSgAwIBAgIJAN7qjHB4CZ1mMAoGCCqGSM49BAMCMEUxCzAJBgNVBAYT
AkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBXaWRn
aXRzIFB0eSBMdGQwHhcNMTcwNzI3MjIwODQzWhcNMTkwNzI3MjIwODQzWjBFMQsw
CQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50ZXJu
ZXQgV2lkZ2l0cyBQdHkgTHRkMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE3nDWwzwX
RGLwdOARyQdM3yvQc7FlXIlsIIi2ISWjQlrDEcIilDIYAqPYnBjzPhp23BgqwGWR
mHGcsAP6kkX3EyitAhAJxSBaW/c1Wnq/XodcnOUPc7g4yCS6p7dOgRMHo1AwTjAd
BgNVHQ4EFgQUh+zW2Ny3wElGGZJHq9bcabpAP20wHwYDVR0jBBgwFoAUh+zW2Ny3
wElGGZJHq9bcabpAP20wDAYDVR0TBAUwAwEB/zAKBggqhkjOPQQDAgNnADBkAjA4
1EQEQVkxMPFQ2BR+PqkUyFD+L+Umu0Ab7nL86Qrqgcmz+oGeZP16ZzY37D2rWeYC
MH1ff4dhrhJnaUdQ7xypzT2WOAHT1zpW7Hms9XYuNAmYasRDvoZmRVjMvU7gne7R
eQ==
-----END CERTIFICATE-----
subject=C = AU, ST = Some-State, O = Internet Widgits Pty Ltd

issuer=C = AU, ST = Some-State, O = Internet Widgits Pty Ltd

---
No client certificate CA names sent
Peer signing digest: SHA256
Peer signature type: ECDSA
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 1050 bytes and written 272 bytes
Verification error: self signed certificate
---
New, TLSv1.0, Cipher is ECDHE-ECDSA-AES128-SHA
Server public key is 384 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-ECDSA-AES128-SHA
    Session-ID: 56A50DE80262675795C00BFAFE1A63B6487A83FFE0A7D3AD691C2086E63124DC
    Session-ID-ctx:
    Master-Key: A3D769131534FAFAB0E5DE59FE9B332911F3C1F28D7668C9AF14078E412AEEF0B04DAB969EDCEC1D1CA963AC58097630
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    TLS session ticket lifetime hint: 7200 (seconds)
    TLS session ticket:
    0000 - 39 47 ea b2 1a 38 54 09-56 a7 76 d0 21 81 d2 6a   9G...8T.V.v.!..j
    0010 - 6e d9 b2 10 2f 02 ff 6f-d9 0e 23 4b 3a 7e 84 01   n.../..o..#K:~..
    0020 - f8 86 80 fb ef b1 dc bf-f7 ba 62 c7 e8 eb 48 da   ..........b...H.
    0030 - 6e 03 c2 2d 07 51 e9 b3-df 63 a6 27 06 78 e7 79   n..-.Q...c.'.x.y
    0040 - 20 b4 32 a9 6d 8a ab b8-f2 59 c5 f7 76 25 b9 e7    .2.m....Y..v%..
    0050 - 5e 99 66 4f 45 d1 b1 2b-df f4 0b 7e 70 f7 93 b3   ^.fOE..+...~p...
    0060 - 92 98 51 ee ac d4 ce 68-a0 95 fa de c5 e9 f2 d6   ..Q....h........
    0070 - ed 37 93 e3 64 05 91 1a-32 e9 f2 19 d3 43 98 31   .7..d...2....C.1
    0080 - 72 48 89 0c 37 53 67 1b-b6 09 f9 ce 22 20 9f de   rH..7Sg....." ..
    0090 - a2 12 68 db 8c 44 f9 5b-de a2 fd 39 cd fc e2 1f   ..h..D.[...9....
    00a0 - 30 c0 1a 87 42 25 86 e0-c4 44 9b 53 ee a9 f3 90   0...B%...D.S....

    Start Time: 1508783166
    Timeout   : 7200 (sec)
    Verify return code: 18 (self signed certificate)
    Extended master secret: yes

A: Looking at the source code in OpenSSL there seems to be no way to disable extended master secrets without changing the source code (search for EXTMS). But you could simply use a version of OpenSSL which does not support extended master secrets yet: instead of using bleeding edge 1.1.1dev simply use 1.0.2 (which should be the default OpenSSL on current Ubuntu anyway).


text:
Q: Trouble with Cross Compiling Asterisk
I've trying to Cross Compile Asterisk for Armhf platform.
I was using g++-arm-linux-gnueabihf && gcc-arm-linux-gnueabihf packages for cross-compiling Asterisk with 2 following prerequisite :
SQlite3 :

./configure --prefix=/usr/arm-linux-gnueabihf --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc
  make && make install

Ncurses :

./configure --host=arm-linux-gnueabihf --prefix=/usr/arm-linux-gnueabihf CXX=arm-linux-gnueabihf-g++
  make && make install

When I cross compile Asterisk :

./configure --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc --prefix=MY_RESULT_DEST_DIR --disable-xmldoc --build=i686-pc-linux-gnu
  make menuselect && make && make install

It works great, but thing I dont understand is that why the configure script recognize my ncurses && sqlite3 result directory?
Bug appears when I install ncurses and sqlite3 on particular directories, and then configure asterisk source with 2 params --with-ncurses && --with-sqlite3,

./configure --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc --prefix=MY_RESULT_DEST_DIR --disable-xmldoc --build=i686-pc-linux-gnu --with-ncurses=NCURSES_RESULT --with-sqlite3=SQLITE3_RESULT

It works for configuring but failed for making, and the following error thrown with make

checking for tgetent in -ltermcap... no
  checking for tgetent in -ltinfo... no
  checking for tgetent in -lcurses... no
  checking for tgetent in -lncurses... no
  configure: error: termcap support not found
  make[1]: * [editline/libedit.a] Error 1
  make: * [main] Error 2

So, what should I do to fix this problem? Any help would be appreciated.
Thanks in advance
Dang Loi

A: Yeah, thank you arheops.
I did edit the main/editline/configure file by turning ac_cv_lib_$ac_lib_var into yes to bypass the termcap checking when running make, and it works all the time.

if { (eval echo configure:1282: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && t$
  rm -rf conftest*
  eval "ac_cv_lib_$ac_lib_var=yes"
else
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
  rm -rf conftest*
  eval "ac_cv_lib_$ac_lib_var=yes"
fi

A: You should instal pkgconfig or do change Makefile for you manual path
Note, asterisk make file not tested for your architecture.
But it opensource, so you are free test,do changes and commit. Or hire someone who can do that.


text:
Q: Jquery dropdown menu changes font weight on hover I've made a menu with a dropdown in jQuery and everything works fine besides when you view it in safari on mac it changes the font weight when the dropdown shows.
I'm pretty clueless in terms of what i need to change in order to fix it. Can you guys give me a hand, would be appreciated:
You can see the live version: autooffer.dk (hover "mærker") and notice the other menu change font weight
jQuery:
  /* DROPDOWN & MENU ANIMATIONS */

var mindicator = $('.dropdown_indicator');
mindicator.hide();
var dropdown = $('.dropdown')
dropdown.hide();

$(".hover_brands").hover(
      function () {
         dropdown.finish().slideDown(200);
         /*mindicator.css("display","block");*/
      },
      function () {
         dropdown.finish().slideUp(200);
        /* mindicator.css("display","none");*/
      }
);

dropdown.mouseover(
  function () {
    dropdown.stop(true, true).slideDown(0);
    /*mindicator.css("display","block");*/
  }
);

dropdown.mouseleave(
  function () {
    dropdown.finish().slideUp(200);
    /*mindicator.css("display","none");*/
  }
);

 mindicator.mouseover(
  function () {
    dropdown.stop(true, true).slideDown(0);
  }
);

mindicator.mouseleave(
  function () {
    dropdown.finish().slideUp(200);
  }
);

CSS:
#menu
{
    width: 100%;
    height: 45px;
    background: #3e6f9b;
    color: #fff;
    position: relative;
    font-size: 16px;
}

#menu ul
{
    margin:0px;
    padding: 0px;
    list-style: none;
    position: relative;
    top: 10px;
    margin-left: 60px;
}

#menu ul li
{
    display: block;
    float: left;
    margin-right: 35px;
    color: #fff;
    text-decoration: none;
    -webkit-transition: 0.3s; /* Safari */
    transition: 0.3s;
    border-radius: 5px;
    padding:2px 5px 2px 5px;
}

#menu ul li:hover
{
    -webkit-transition: 0.3s; /* Safari */
    transition: 0.3s;
    background: #36536e;
}

#dropdown
{
    width: 100%;
    height: auto;
    min-height: 150px;
    background: #28abe3;
    position: relative;
    display: none;
    color: #fff;
    font-weight: normal;
    font-size: 15px;
    padding-top: 30px;
    padding-bottom: 30px;
    z-index: 2;
}

HTML:

Vælg bil

Tilbud

Mærker

#LOOP_CARMAKES_ACTIVE#

               #CARMAKE_NAME#

            #END#

A: Font rendering issue, try this:
body {
  -webkit-font-smoothing: subpixel-antialiased;
}


text:
Q: Debug content of shared memory I got two processes. In process A, application Alpha is prepared for using shared memory. In process B, my windows console application with a main method accesses this shared memory. It works, I can connect to the memory. Unfortunately if I store the memory content in a variable (here pBuf) and inspect the variable via MsVisualStudioDebugger, there is only one letter in the buffer - what went wrong? How am I able to look in the memory/file to get a clue, what objects are stored in the memory? Thanks in advance.
Here is the code of my console app:
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <tchar.h>
#pragma comment(lib, "user32.lib")
using namespace std;
#define BUF_SIZE 256
TCHAR szName[] = TEXT("SIMITSHM"); // Name des SHMs;
int main(void){
    std::cout << "*** start SharedMemory  ***\n";
    HANDLE hMapFile;
    LPCTSTR pBuf;
    hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, szName);
    if (hMapFile == NULL){
        MessageBox(NULL, TEXT("Could not open file mapping object"), TEXT("FEHLER"), MB_OK);
        return 1;
    }
    pBuf = (LPTSTR) MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, BUF_SIZE);
    if (pBuf == NULL){
        MessageBox(NULL, TEXT("Could not map view of file"), TEXT("FEHLER"), MB_OK);
        CloseHandle(hMapFile);
        return 1;
    }
    MessageBox(NULL, pBuf, TEXT("SIMIT-SHM"), MB_OK); // content of memory
    UnmapViewOfFile(pBuf);
    CloseHandle(hMapFile);
    std::cout << "*** close app by typing a number. ***\n";
    int a = 0;
    cin >> a;
    return 0;
}

UPDATE: after doing more research on this issue, I guess the problem is the casting of the return value of MapViewOfFile()-function.
UPDATE-2: Thanks Hans! I was able to look the pBuf content as a hexdump, see:

UPDATE-3: Thanks Hans! Due to your advice I was able to use fwrite() to put the shared-memory-content in a file on my local machine. Moreover I am able to see some familiar names, i.e. names like EingangMotor1 which I configured in application-Alpha and it seems this content was stored in shared memory. Now I hope to play around with application-Alpha, recognize the related changes in shared-memory and afterwards hopefully I will be able to change the values of the shared memory variable values, so application-Alpha will change its behaviour on the fly.

UPDATE-4: current code - thanks in advance for feedback, which lines needs to be improved.
#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include <tchar.h>
#include <strsafe.h>
#include <fstream>
#include <sstream>
#include <vector>
#pragma comment(lib, "user32.lib")
using namespace std;
#define BUF_SIZE 256
TCHAR szName[] = TEXT("SIMITSHM"); // Name des SHMs;
int main(void){
    std::cout << "*** Start SharedMemory  ***\n";
    HANDLE hMapFile;
    FILE * pBuf;
    hMapFile = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, szName);
    if (hMapFile == NULL){
        MessageBox(NULL, TEXT("Could not open file mapping object"), TEXT("ERROR"), MB_OK);
        return 1;
    }
    // MapViewOfFile return a pointer to void, so you need to cast it to a suitable structure
    pBuf = (FILE*) MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, BUF_SIZE);
    if (pBuf == NULL){
        MessageBox(NULL, TEXT("Could not map view of file"), TEXT("ERROR"), MB_OK);
        CloseHandle(hMapFile);
        return 1;
    }
    // write file
    FILE * pFile;
    pFile = fopen ("shm-main-simit-content-fwrite.txt","w");
    fwrite(pBuf, 50, 20, pFile);
    UnmapViewOfFile(pBuf);
    CloseHandle(hMapFile);
    std::cout << "*** close app by typing a number. ***\n";
    int a = 0;
    cin >> a;
    return 0;
}

A: Yes, you certainly have a type mismatch.  That file is very unlikely to contain a properly zero-terminated C string.  Using the TCHAR macros adds to the randomness, there is no point in using them anymore.  The last non-Unicode version of Windows died 10 years ago.
Answering the question: use Debug + Windows + Memory + Memory 1 and put "pBuf" in the Address box.  You'll see a raw hex dump of the shared memory content.


text:
Q: URI schemes for Add new and Edit contact in windows phone 8.1 I am a newbie in windows phone programming. I am looking for a way to call "Add new contact" and "Edit contact" by clicking a button. One solution for this is used Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:"));. However in this list of URI schemes (https://msdn.microsoft.com/en-us/library/windows/apps/jj662937(v=vs.105).aspx) , there is no thing what I am looking for.
Anyone has another solution for this? Or you know the related URI schemes for adding and editing contact?
Thank you.

A: To add a new contact you don't need a Uri scheme as its actually a Phone Task.
For windowsphone os 8 and below there is a specific library to implement all such functions as Microsoft.Phone.Tasks
Your contact Add problem solution example can be found here


text:
Q: Question on normal and geodesic curvature I've worked through a problem my professor gave me on normal/geodesic curvature. I believe there was an error in his solution because in his answer he states the geodesic curvature in the following problem is zero, which I believe is wrong.
The elliptic paraboloid $S: z = x^2 + y^2$ is parametrized by $\sigma(u,v) = (u\cos(v), u\sin(v), u^2)$.
a) Find the second fundamental form of $\sigma$.
Solution:
$\mathrm{I\!I} = L\mathit{du}^2 + 2M\mathit{du dv} + N\mathit{dv}^2$
$n = \frac{\sigma_u \times \sigma_v}{||\sigma_u \times \sigma_v||} = \frac{1}{\sqrt{4u^2 + 1}}(-2u\cos(v),-2u\sin(v),1)$
$L = \sigma_{uu} \cdot n = \frac{2}{\sqrt{4u^2 + 1}}$
$M = \sigma_{uv} \cdot n = 0$
$N = \sigma_{vv} \cdot n = \frac{2u^2}{\sqrt{4u^2 + 1}}$
$\mathrm{I\!I} = \frac{2}{\sqrt{4u^2 + 1}} \mathit{du^2} + \frac{2u^2}{\sqrt{4u^2 + 1}} \mathit{dv^2}$
b) Find the normal and geodesic curvatures of the circle $x^2 + y^2 = 4$ on $S$.
Solution:
$\gamma(t) = (2\cos(t), 2\sin(t), 4)$
$\dot{\gamma}(t) = (-2\sin(v), 2\cos(t), 0)$
$\ddot{\gamma}(t) = (-2\cos(v), -2\sin(v), 0)$
Find unit-speed reparametrization:
$c(s) = (2\cos(\frac{t}{2}), 2\sin(\frac{t}{2}, 4)$
$\dot{c}(s) = (-\sin(\frac{s}{2}), \cos(\frac{s}{2}), 0)$
$\ddot{c}(s) = (-\frac{1}{2}\cos(\frac{s}{2}), -\frac{1}{2}\sin(\frac{s}{2}), 0)$
$n(c(s)) = \frac{1}{\sqrt{4(2^2) + 1}}(-4\cos(\frac{s}{2}), -4\sin(\frac{s}{2}), 1)$
Using $K_n = \ddot{\gamma}(t) \cdot n(\gamma(t))$,
$K_n = \frac{2}{\sqrt{17}}$, but since $x^2 + y^2 = 4$ is ultimately a circle of radius 2, its curvature K should be $\frac{1}{2}$. In the notes, the geodesic curvature is said to be 0, but when doing $K_g = \ddot{\gamma}(t) \cdot (n \times \dot{\gamma} (t))$, I get $K_g = \frac{1}{2\sqrt{17}}$. And when checking with the property $K^2 = K_n^2 + K_g^2$, $K_g$ should not be zero. My question is if $K_g$ is indeed not zero, what does it mean for this circle to have geodesic curvature? Does the curvature only exist because it lies on the surface? If this circle were on a cylinder of radius 2 would it still have the same geodesic curvature?


text:
Q: How to assign value to public class properties? I have a  e.g. Customer.php and Address.php class, I want to assign value from an array to public properties defined on the class.
In my Customer.php has following properties:
public string id;
public string name;
public Address $address;

I am using loop to assign value to the properties listed
protected function useState(array $state): void
{
    foreach ($state as $key => $value) {
        $this->$key = $value;
    }
}

But there's an problem when trying to assign to Address because it's not an instance of Address, array used.
Is there any idea i can assign the value to the Address?


text:
Q: SOAP Call from iOS to PHP Script I am currently building a simple iOS that that calls a php page on my server called "SoapTest.php". I currently have a test function that takes in a variable called "$x". I am sending a request to this function and it can take one variable. But where I am running into the issue is having the function taking in more then one variable or sending back one or more variables.
I understand that this PHP function will only work with one variable ($x), but how do it get it work with multiple variables.
Here is my PHP function:
function test($x)
{
  return $x;
{

A: If you simply want to add varaibles to the function do this:
function test($x, $y, $z)
{
  /*Do stuff here*/
  return $x;
{

This will accept 3 variables, $x, $y, $z. You'll then have access to all 3


text:
Q: Rx Java Android Needs to call multiple api's in a sequence and save each results I want to call multiple Rest Api's in a Sequence and having each Response Dto is different from each other.
Please help me to get rid from this situation that, How can i call these Api's using Rx Java Observables in Android.

A: no, you should use map() or doOnNext(), it will look like this
Observable.just(1)
    .doOnNext(value -> {
        someRequestX().execute();
    })
    .map(value -> {
        return nextRequestY().execute();
    })
    .doOnNext(requestYResponse-> {
        someRequesZ(requestYResponse.someValue).execute();
    })
    .map(requestYResponse-> {
        return someRequesK(requestYResponse.someValue).execute();
    })
    .map(requestKResponse -> {
        return someRequesJ(requestKResponse.someValue).execute();
    })
    .subscribe(requestJResponse -> {
       doSOmethingWithFinalResponse(requestJResponse );
    })

A: First of all, for network requests is better to use Single then Observable, because there always will be only one item. To switch from one requests to another, you can use flatMap.
Assuming your code is similar, you can try this:
class Dto1 {}

class Dto2 {}

class Dto3 {}

public interface Api {

    Single<Dto1> getDto1();

    Single<Dto2> getDto2();

    Single<Dto3> getDto3();
}

private Api api;

public void callApi() {
    api.getDto1()
            .doOnSuccess(dto1 -> {/*do something with dto1*/})
            .flatMap(dto1 -> api.getDto2())
            .doOnSuccess(dto2 -> {/*do something with dto2*/})
            .flatMap(dto2 -> api.getDto3())
            .doOnSuccess(dto3 -> {/*do something with dto3*/})
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe()
}

A: For the same scenario, i use concat operator which takes multiple Observables and concatenates their sequence
If response sequence doesn't require then you can use merge operator also.
Concat VS Merge operaror

A: try doOnNext() or map() method of Observable and use sync execute() of each response and pass them further


text:
Q: How to create arrays for each values - PHP
// ARRAY
(
    [apple] => one
    [orange] => two
    [strawberry] => three
)

// NEW ARRAY
(
    [0] => Array
        (
            [0] => apple
            [1] => one
        )

    [1] => Array
        (
            [0] => orange
            [1] => two
        )

    [2] => Array
        (
            [0] => strawberry
            [1] => three
        )

)

I want to create an array for each key of the current array, so i can use this in a foreach later. Is it possible?
I've tried everything without success.

A: You can loop through every elements in your associative array and create an empty array before the loop. Then push the key as well as value to the new array. This way you can get that desirable output:
<?php

$assocArray = [
    "apple" => "one",
    "orange" => "two",
    "strawberry" => "three"
];

echo "Before: \n\r";
print_r($assocArray);

$newArray = [];

foreach ($assocArray as $key => $item) {
    $newArray[] = [$key, $item];
}

echo "After: \n\r";
print_r($newArray);

Output
Before:
Array
(
    [apple] => one
    [orange] => two
    [strawberry] => three
)
After:
Array
(
    [0] => Array
        (
            [0] => apple
            [1] => one
        )

    [1] => Array
        (
            [0] => orange
            [1] => two
        )

    [2] => Array
        (
            [0] => strawberry
            [1] => three
        )

)
``

A: You can also do this:
$array = [
    'apple' => 'one',
    'orange' => 'two',
    'strawberry' => 'three',
];

$output = array_map(function($k, $v) {
    return [$k, $v];
}, array_keys($array), $array);

var_dump($output);


text:
Q: Hardware shopping: Can all M Key Slot work with NVMe? I have a NP500R5H-XD3BR (Expert X50) Notebook from Samsung.
It's the 2015 model, with I7 5500.
I didn't get this information from Samsung, however I know that it has a Key M slot for SSD M.2.
My question is:
Knowing that I have a M.2 slot with key M, if I buy a NVMe, will it work?
I want to buy a 1TB SSD M.2 but I do not want to spend a lot of money (around R$ 800 (Brazil)).
What would you suggest?

A: I am unable to find in the product specification that an NVMe drive can be used with your PC. NVMe requires additional circuitry in its drive controller. Unless you can obtain the hardware manual or spec sheet for your laptop AND it says NVMe is supported, that's a firm NO.
Therefore, you are limited to SATA-II or SATA-III M.2 drives, which are available in terabyte sizes.  Some M.2 slots are for SATA-II, others will accept SATA-II and SATA-III.
Make sure that M.2 slot is not for an MMC card. I have two laptops with MMC only, and they will not accept the standard M.2 drive.
Also make sure the dimensions within the PC allow the length of the M.2 drive; those drives are found in multiple lengths, so make sure you buy what will fit.


text:
Q: R Highcharter hcaes- Area chart staking by only 1 factor... with 2 grouping factors I am trying to achieve something like what is reported in this post (group by two columns in ggplot2), but with an additional feature.
I am currently creating my highchart grouping by 2 factors: this solution is working just fine.
What I would like to achieve is: I would like to stack the area chart by only 1 of the 2 factors, and use the other one to have 2 overlapping "stacked" area charts
Do you have any clue how to make it?
Best,
Lorenzo

A: Based on your comments, you approved that you are trying to achieve something like this: https://jsfiddle.net/BlackLabel/43ncukmw/
Here you have the R code of this chart:
library(highcharter)

highchart() %>%
  hc_plotOptions(series = list(stacking = 'normal')) %>%
  hc_yAxis_multiples(
    list(min = 0, max = 20),
    list(min = 0, max = 16, opposite = TRUE)
  ) %>%
  hc_add_series(data = c(1, 2, 3, 4, 5, 6), type = 'area') %>%
  hc_add_series(data = c(10, 10, 10, 10, 10, 10), type = 'area') %>%
  hc_add_series(data = c(1, 3, 2, 3, 5, 3), type = 'column', yAxis = 1) %>%
  hc_add_series(data = c(2, 3, 2, 3, 2, 3), type = 'column', yAxis = 1)


text:
Q: Run functions for each row in dataframe I have a dataframe df1, like this:
date        sentence
29/03/1029  I like you
30/03/2019  You eat cake

and run functions getVerb and getObj to dataframe df1. So, the output is like this:
date        sentence      verb   object
29/03/1029  I like you    like   you
30/03/2019  You eat cake  eat    cake

I want those functions (getVerb and getObj) run for each line in df1. Could someone help me to solve this problem in an efficient way?
Thank you so much.

A: Each column of a pandas DataFrame is a Series. You can use the Series.apply or Series.map functions to get the result you want.
df1['verb'] = df1['sentence'].apply(getVerb)
df1['object'] = df1['sentence'].apply(getObj)

# OR

df1['verb'] = df1['sentence'].map(getVerb)
df1['object'] = df1['sentence'].map(getObj)

See the pandas documentation for more details on Series.apply or Series.map.

A: Assume you have a pandas dataframe such as:
import pandas as pd, numpy as np

df = pd.DataFrame([[4, 9]] *3, columns=['A', 'B'])
>>>df
   A  B
   4  9
   4  9
   4  9

Let's say, we want sum of columns A and B row wise and column wise. To accomplish it, we write
df.apply(np.sum, axis = 1) # for row-wise sum
Output: 13
        13
        13
df.apply(np.sum, axis = 0) # for column-wise sum
Output: A 12
        B 27

Now, if you want to apply any function for specific set of columns, you may choose a subset from the data-frame.
For example: I want to compute sum over column A only.
df['A'].apply(np.sum, axis =1)

Dataframe.apply
You may refer the above link as well. Other than that, Series.map, Series.apply could be handy as well, as mentioned in the above answer.
Cheers!

A: Using a simple loop: (assuming that columns already exist in the data frame having names 'verb' and 'object')
for index, row in df1.iterrows():
    df1['verb'].iloc[index]= getVerb(row['sentence'])
    df1['object'].iloc[index]= getObj(row['sentence'])


text:
Q: Linq to XML Parsing WMS Capabilities Document I'm really new to LINQ and I'm having trouble parsing an xml file. The file is this ->
<?xml version='1.0' encoding="UTF-8"?>
<!DOCTYPE WMT_MS_Capabilities SYSTEM "http://schemas.opengis.net/wms/1.1.1/capabilities_1_1_1.dtd"
><WMT_MS_Capabilities version="1.1.1">
 <Service>
  <Name>OGC:WMS</Name>
  <Title>Minnesota composite aerial photography</Title>
  <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://geoint.lmic.state.mn.us/"/>
 </Service>
 <Capability>
  <Request>
   <GetCapabilities>
    <Format>application/vnd.ogc.wms_xml</Format>
    <DCPType>
     <HTTP>
      <Get>
       <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://geoint.lmic.state.mn.us/cgi-bin/mncomp"/>
      </Get>
     </HTTP>
    </DCPType>
   </GetCapabilities>
   <GetMap>
    <Format>image/jpeg</Format>
    <DCPType>
     <HTTP>
      <Get>
       <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://geoint.lmic.state.mn.us/cgi-bin/mncomp"/>
      </Get>
     </HTTP>
    </DCPType>
   </GetMap>
  </Request>
  <Exception>
   <Format>application/vnd.ogc.se_xml</Format>
  </Exception>
  <Layer>
   <Title>Minnesota composite aerial photography</Title>
   <SRS>EPSG:26915</SRS>
   <Style>
    <Name>default</Name>
    <Title>Normal</Title>
    <Abstract>Colors as in original imagery</Abstract>
   </Style>
   <Style>
    <Name>stretch</Name>
    <Title>Contrast Stretch</Title>
    <Abstract>Two standard deviation contrast stretch</Abstract>
   </Style>
   <Layer queryable="0" opaque="1">
    <Name>mncomp</Name>
    <Title>Minnesota Composite Imagery</Title>
    <SRS>EPSG:26915</SRS>
    <LatLonBoundingBox minx="-102.05" miny="40.46" maxx="-85.90" maxy="51.37"/>
    <BoundingBox SRS="EPSG:26915" minx="-131108.45" miny="4505093.25" maxx="994071.55" maxy="5715117.75" resx="28.5" resy="28.5"/>
    <MetadataURL type="FGDC">
     <Format>text/html</Format>
     <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.mngeo.state.mn.us/chouse/metadata/naip09.html"></OnlineResource>
    </MetadataURL>
   <ScaleHint min="11.40" max="40334"/>
   </Layer>
   </Layer>
 </Capability>
</WMT_MS_Capabilities>

I have a class called "Layer". For each layer in the XML, I want to add the name, title, and the subsequent styles(name tag) related to it to a new Layer object.
This is what I have so far.
public class Layer
{
    public string Name { get; set; }
    public string Title { get; set; }
    public string SRS { get; set; }

    public List<string> Styles = new List<string>();
}

Query
XDocument xdoc = XDocument.Load(localFilename);

var layers = from p in xdoc.Descendants("Layer")
             select new Layer
             {

                 Name = p.Element("Name").Value,
                 Title = p.Element("Title").Value,
                 SRS = p.Element("SRS").Value,
                 //Styles = //How do I get the list of styles for each layer?,
             };

This compiles fine with my other code. When I run my application, I get a object reference not set to an instance of an object error. I think it's because there isn't a name element for one of the layers. I don't want to ask two questions in one post so I'll just work out the null checking somehow, but any suggestions on extracting the information from the XML to my object? Thanks in advance. Sorry if my question is not as straightforward as it needs to be, I'm new to the online question asking thing.
@Sergey Berezovskiy your solution works just fine for this specific XML document. For some reason I'm not having the same luck with another XML. Since I'll be hitting different servers I need to make sure it works across the board. Any insight as to why I can extract layers from that xml file, but not the one below? Thank you so much.
<?xml version="1.0" encoding="UTF-8"?>
<WMS_Capabilities version="1.3.0"
  xmlns="http://www.opengis.net/wms"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:esri_wms="http://www.esri.com/wms"
  xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.esri.com/wms http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer?version=1.3.0&service=WMS&request=GetSchemaExtension">
  <Service>
    <Name><![CDATA[WMS]]></Name>
    <Title><![CDATA[Latest]]></Title>
    <Abstract>WMS</Abstract>
    <KeywordList><Keyword><![CDATA[]]></Keyword></KeywordList>
    <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer"/>
    <ContactInformation>
      <ContactPersonPrimary>
        <ContactPerson><![CDATA[]]></ContactPerson>
        <ContactOrganization><![CDATA[]]></ContactOrganization>
      </ContactPersonPrimary>
      <ContactPosition><![CDATA[]]></ContactPosition>
      <ContactAddress>
        <AddressType><![CDATA[]]></AddressType>
        <Address><![CDATA[]]></Address>
        <City><![CDATA[]]></City>
        <StateOrProvince><![CDATA[]]></StateOrProvince>
        <PostCode><![CDATA[]]></PostCode>
        <Country><![CDATA[]]></Country>
      </ContactAddress>
      <ContactVoiceTelephone><![CDATA[]]></ContactVoiceTelephone>
      <ContactFacsimileTelephone><![CDATA[]]></ContactFacsimileTelephone>
      <ContactElectronicMailAddress><![CDATA[]]></ContactElectronicMailAddress>
    </ContactInformation>
    <Fees><![CDATA[]]></Fees>
    <AccessConstraints><![CDATA[]]></AccessConstraints>
    <MaxWidth>2048</MaxWidth>
    <MaxHeight>2048</MaxHeight>
  </Service>
  <Capability>
    <Request>
      <GetCapabilities>
        <Format>application/vnd.ogc.wms_xml</Format>
        <Format>text/xml</Format>
        <DCPType>
          <HTTP><Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer"/></Get></HTTP>
        </DCPType>
      </GetCapabilities>
      <GetMap>
        <Format>image/bmp</Format>
        <Format>image/jpeg</Format>
        <Format>image/tiff</Format>
        <Format>image/png</Format>
        <Format>image/png8</Format>
        <Format>image/png24</Format>
        <Format>image/png32</Format>
        <Format>image/gif</Format>
        <Format>image/svg+xml</Format>
        <DCPType>
          <HTTP><Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer"/></Get></HTTP>
        </DCPType>
      </GetMap>
      <GetFeatureInfo>
        <Format>application/vnd.esri.wms_raw_xml</Format>
        <Format>application/vnd.esri.wms_featureinfo_xml</Format>
        <Format>application/vnd.ogc.wms_xml</Format>
        <Format>text/xml</Format>
        <Format>text/html</Format>
        <Format>text/plain</Format>
        <DCPType>
          <HTTP><Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer"/></Get></HTTP>
        </DCPType>
      </GetFeatureInfo>
      <esri_wms:GetStyles>
        <Format>application/vnd.ogc.sld+xml</Format>
        <DCPType>
          <HTTP><Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer"/></Get></HTTP>
        </DCPType>
      </esri_wms:GetStyles>
    </Request>
    <Exception>
      <Format>application/vnd.ogc.se_xml</Format>
      <Format>application/vnd.ogc.se_inimage</Format>
      <Format>application/vnd.ogc.se_blank</Format>
      <Format>text/xml</Format>
      <Format>XML</Format>
    </Exception>
    <Layer>
      <Title><![CDATA[Layers]]></Title>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-80.57007947624</westBoundLongitude><eastBoundLongitude>-71.0436841582623</eastBoundLongitude><southBoundLatitude>39.9768836585495</southBoundLatitude><northBoundLatitude>45.5666140920784</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84"  minx="-80.57007947624" miny="39.9768836585495" maxx="-71.0436841582623" maxy="45.5666140920784"/>
<BoundingBox CRS="EPSG:4326"  minx="-80.57007947624" miny="39.9768836585495" maxx="-71.0436841582623" maxy="45.5666140920784"/>
<BoundingBox CRS="EPSG:3857"  minx="-8969020.22046862" miny="4862583.64415499" maxx="-7908546.74457592" maxy="5711168.75110067"/>
      <Layer queryable="1">
        <Name>0</Name>
        <Title><![CDATA[2007]]></Title>
        <Abstract><![CDATA[2007]]></Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-79.4438365409271</westBoundLongitude><eastBoundLongitude>-71.4767021272613</eastBoundLongitude><southBoundLatitude>40.4072997752793</southBoundLatitude><northBoundLatitude>43.5397759908541</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84"  minx="-79.4438365409271" miny="40.4072997752793" maxx="-71.4767021272613" maxy="43.5397759908541"/>
<BoundingBox CRS="EPSG:4326"  minx="-79.4438365409271" miny="40.4072997752793" maxx="-71.4767021272613" maxy="43.5397759908541"/>
<BoundingBox CRS="EPSG:3857"  minx="-8843647.43040006" miny="4925307.70532643" maxx="-7956750.08438922" maxy="5394495.50256152"/>
        <Style>
          <Name>default</Name>
          <Title>0</Title>
          <LegendURL width="0" height="0">
            <Format>image/png</Format>
            <OnlineResource xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=0" xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" />
          </LegendURL>
        </Style>
      </Layer>
      <Layer queryable="1">
        <Name>1</Name>
        <Title><![CDATA[2008]]></Title>
        <Abstract><![CDATA[2008]]></Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-80.137061507241</westBoundLongitude><eastBoundLongitude>-72.9541406362735</eastBoundLongitude><southBoundLatitude>40.2418907294155</southBoundLatitude><northBoundLatitude>45.3235137050738</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84"  minx="-80.137061507241" miny="40.2418907294155" maxx="-72.9541406362735" maxy="45.3235137050738"/>
<BoundingBox CRS="EPSG:4326"  minx="-80.137061507241" miny="40.2418907294155" maxx="-72.9541406362735" maxy="45.3235137050738"/>
<BoundingBox CRS="EPSG:3857"  minx="-8920816.88065531" miny="4901155.6944707" maxx="-8121217.78689084" maxy="5672596.70078496"/>
        <Style>
          <Name>default</Name>
          <Title>1</Title>
          <LegendURL width="0" height="0">
            <Format>image/png</Format>
            <OnlineResource xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=1" xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" />
          </LegendURL>
        </Style>
      </Layer>
      <Layer queryable="1">
        <Name>2</Name>
        <Title><![CDATA[2009]]></Title>
        <Abstract><![CDATA[2009]]></Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-78.2508704377383</westBoundLongitude><eastBoundLongitude>-72.9360410898466</eastBoundLongitude><southBoundLatitude>40.6557323735188</southBoundLatitude><northBoundLatitude>45.2365820956616</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84"  minx="-78.2508704377383" miny="40.6557323735188" maxx="-72.9360410898466" maxy="45.2365820956616"/>
<BoundingBox CRS="EPSG:4326"  minx="-78.2508704377383" miny="40.6557323735188" maxx="-72.9360410898466" maxy="45.2365820956616"/>
<BoundingBox CRS="EPSG:3857"  minx="-8710847.05125945" miny="4961694.11943618" maxx="-8119202.954599" maxy="5658843.70875853"/>
        <Style>
          <Name>default</Name>
          <Title>2</Title>
          <LegendURL width="0" height="0">
            <Format>image/png</Format>
            <OnlineResource xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=2" xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" />
          </LegendURL>
        </Style>
      </Layer>
      <Layer queryable="1">
        <Name>3</Name>
        <Title><![CDATA[2010]]></Title>
        <Abstract><![CDATA[2010]]></Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-78.8352781843513</westBoundLongitude><eastBoundLongitude>-71.5135529969056</eastBoundLongitude><southBoundLatitude>40.3408670985968</southBoundLatitude><northBoundLatitude>43.5222862097287</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84"  minx="-78.8352781843513" miny="40.3408670985968" maxx="-71.5135529969056" maxy="43.5222862097287"/>
<BoundingBox CRS="EPSG:4326"  minx="-78.8352781843513" miny="40.3408670985968" maxx="-71.5135529969056" maxy="43.5222862097287"/>
<BoundingBox CRS="EPSG:3857"  minx="-8775903.02402806" miny="4915600.50131933" maxx="-7960852.30443332" maxy="5391810.05477954"/>
        <Style>
          <Name>default</Name>
          <Title>3</Title>
          <LegendURL width="0" height="0">
            <Format>image/png</Format>
            <OnlineResource xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=3" xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" />
          </LegendURL>
        </Style>
      </Layer>
      <Layer queryable="1">
        <Name>4</Name>
        <Title><![CDATA[2011]]></Title>
        <Abstract><![CDATA[2011]]></Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-79.4439599225417</westBoundLongitude><eastBoundLongitude>-72.9501226871704</eastBoundLongitude><southBoundLatitude>41.8707392833946</southBoundLatitude><northBoundLatitude>44.5521070703263</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84"  minx="-79.4439599225417" miny="41.8707392833946" maxx="-72.9501226871704" maxy="44.5521070703263"/>
<BoundingBox CRS="EPSG:4326"  minx="-79.4439599225417" miny="41.8707392833946" maxx="-72.9501226871704" maxy="44.5521070703263"/>
<BoundingBox CRS="EPSG:3857"  minx="-8843661.16517858" miny="5141636.43859296" maxx="-8120770.51084265" maxy="5551283.37379781"/>
        <Style>
          <Name>default</Name>
          <Title>4</Title>
          <LegendURL width="0" height="0">
            <Format>image/png</Format>
            <OnlineResource xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=4" xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" />
          </LegendURL>
        </Style>
      </Layer>
      <Layer queryable="1">
        <Name>5</Name>
        <Title><![CDATA[2012]]></Title>
        <Abstract><![CDATA[2012]]></Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-80.0942239470773</westBoundLongitude><eastBoundLongitude>-73.3855444518878</eastBoundLongitude><southBoundLatitude>40.3409427412789</southBoundLatitude><northBoundLatitude>43.5208041873471</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84"  minx="-80.0942239470773" miny="40.3409427412789" maxx="-73.3855444518878" maxy="43.5208041873471"/>
<BoundingBox CRS="EPSG:4326"  minx="-80.0942239470773" miny="40.3409427412789" maxx="-73.3855444518878" maxy="43.5208041873471"/>
<BoundingBox CRS="EPSG:3857"  minx="-8916048.22527106" miny="4915611.54885857" maxx="-8169241.4399713" maxy="5391582.5351876"/>
        <Style>
          <Name>default</Name>
          <Title>5</Title>
          <LegendURL width="0" height="0">
            <Format>image/png</Format>
            <OnlineResource xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=5" xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" />
          </LegendURL>
        </Style>
      </Layer>
      <Layer queryable="1">
        <Name>6</Name>
        <Title><![CDATA[2013]]></Title>
        <Abstract><![CDATA[2013]]></Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-74.7479376518685</westBoundLongitude><eastBoundLongitude>-71.6430956456583</eastBoundLongitude><southBoundLatitude>40.4458244329041</southBoundLatitude><northBoundLatitude>42.5823674302754</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84"  minx="-74.7479376518685" miny="40.4458244329041" maxx="-71.6430956456583" maxy="42.5823674302754"/>
<BoundingBox CRS="EPSG:4326"  minx="-74.7479376518685" miny="40.4458244329041" maxx="-71.6430956456583" maxy="42.5823674302754"/>
<BoundingBox CRS="EPSG:3857"  minx="-8320902.35725337" miny="4930941.35317504" maxx="-7975272.92612848" maxy="5248618.41994531"/>
        <Style>
          <Name>default</Name>
          <Title>6</Title>
          <LegendURL width="0" height="0">
            <Format>image/png</Format>
            <OnlineResource xlink:href="http://www.orthos.dhses.ny.gov/arcgis/services/Latest/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=6" xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink" />
          </LegendURL>
        </Style>
      </Layer>
    </Layer>
  </Capability>
</WMS_Capabilities>

A: Some Layer elements do not have Name child. Thus p.Element("Name") returns null. And you have NullReferenceException when trying to get its value p.Element("Name").Value.
It's easy to fix if you will use casting instead of accessing Value property (casting to string will return null if element not found, without throwing exception):
var layers = from l in xdoc.Descendants("Layer")
             select new Layer
             {
                 Name = (string)l.Element("Name"),
                 Title = (string)l.Element("Title"),
                 SRS = (string)l.Element("SRS"),
                 Styles = l.Elements("Style")
                           .Select(s => (string)s.Element("Name"))
                           .ToList()
             };

NOTE: Thus you have Styles as list of strings in your layer class, then I used style name as its value in list.

Query returns following two layers:
[
  {
    Styles: [ "default", "stretch" ],
    Name: null,
    Title: "Minnesota composite aerial photography",
    SRS: "EPSG:26915"
  },
  {
    Styles: [],
    Name: "mncomp",
    Title: "Minnesota Composite Imagery",
    SRS: "EPSG:26915"
  }
]


text:
Q: Counters for claims I want to redefine the claim environment so that it will be numbered but I'm having a hard time with the counters.
I want the following:
\begin{theorem}
thm 1
\end{theorem}
\begin{proof}
  \begin{claim}
  blah 1
  \end{claim}

  \begin{claim}
  blah 2
  \end{claim}
\end{proof}

\begin{theorem}
thm 2
\end{theorem}
\begin{proof}
  \begin{claim}
  blah 3
  \end{claim}
\end{proof}

to produce:
Theorem 1: thm 1
Claim 1.1: blah 1
Claim 1.2: blah 2

Theorem 2: thm 2
Claim 2.1: blah 3

A: Here's a MWE that shows how to do this.
\documentclass{article}
\usepackage{amsmath,amssymb,amsthm}
\newtheorem{thm}{Theorem}
\newcounter{claimcounter}
\numberwithin{claimcounter}{thm}
\newenvironment{claim}{\stepcounter{claimcounter}{Claim \theclaimcounter:}}{}
\begin{document}

\begin{thm}
    Just testing.
\end{thm}
\begin{proof}
    \begin{claim}
        first
    \end{claim}

    \begin{claim}
        second
    \end{claim}

    \begin{claim}
        third
    \end{claim}
\end{proof}

\begin{thm}
    Just testing.
\end{thm}

\begin{thm}
    Just testing.
\end{thm}

    \begin{claim}
        first
    \end{claim}

    \begin{claim}
        second
    \end{claim}

    \begin{claim}
        third
    \end{claim}

\end{document}

The command \numberwithin allows the claims to be counted with respect to the theorem they are most closely associated with.  \newenvironment allows you to create the environment for the claim---I haven't done much here other than issue out claim numbers.


text:
Q: Lossless data compression for extremely large data - Planetary artificial intelligence I want to create an environment for artificial intelligence, with planetary size. It will simulate underground life on a very large world. According to Wikipedia, planet Earth has a surface area of 510,072,000 Km^2, I want to create a square of similar proportions, maybe bigger. I will store one meter on each bit, where 0 means dirt and 1 means wall of dirt.
Let's first calculate how to store a single line of this square. One line would be 510072000000m and each byte can store 8 meters, so one line would be 59.38GB and the entire world would be 3.44PB. And I would like to add at least water and lava to each square meter, that would multiply the results by 2.
I need to compress this information with lossless data compression algorithms. I first tried a very direct approach with 7zip and I tried it with a smaller world, where one line would be 6375B. In theory, the world should be 6375^2B = 38.76MB, but when I try it I get a file of 155MB, I do not know why this difference. But when I compress it with 7Zip, I get a file of 40.1MB. It is a huge difference, and with that ratio I would convert my 3.44PB world file into a 912.21GB file.
My first thought is, why am I having such a large file, when maths tell me it should be smaller? Maybe the problem is the code, maybe the problem is that I had errors on maths. The code is as follows: (C#)
// 510072000000m each line = 63759000000B
const long SIZE = 6375;

// Create the new, empty data file.
string fileName = tbFile.Text;

FileStream fs = new FileStream(fileName, FileMode.Create);

// Create the writer for data.
BinaryWriter w = new BinaryWriter(fs);

// Use random numbers to fill the data
Random random = new Random();
// Write data to the file.
for (int i = 0; i < SIZE; i++)
{
    for (int j = 0; j < SIZE; j++)
    {
        w.Write(random.Next(0,256));
    }
}

w.Close();

fs.Close();

And the maths are so basic that if I did something wrong I cannot see it.
Can you give me any advice? Just focus on data compression, artificial intelligence is not a problem because I have experience with evolutionary algorithms and the world does not need to be real time, it can take all the time it needs.
Thank you all for your time.

A: I don't know about C#, but it seems you are currently writing 4 bytes each time (6375 * 6375 * 4 Bytes in MB = 155 MB). So I guess the Write method currently writes a 32 bits integer.

A: @Scharron has correctly answered the specifics of your question, but I think there is a more fundamental issue:
It is theoretically impossible to compress random data significantly. Indeed most compression algorithms will increase the storage size when given random input data. Perhaps the specifics of your AI algorithm will introduce some patterns than can be compressed, but if you are starting with truly random input data, you will have to store those multiple PB.
The reason you were seeing significant compression is that, as @Scharron pointed out, you were writing 3 zero bytes for every byte of data, leading to much more easily compressible data.


text:
Q: Yii2 $_GET parameter in URL I'm relatively new to yii2, and I wonder how can I make my url look good. The question is:
I have my url: /path/projects/?url=my-link
and I need it to be like this: /path/projects/my-link/
It would be amazing if someone can send me direct solution, not links to documentation

A: Inside your config, where you declare your components, add or modify the urlManager like this:
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => false,
            'rules' => [
                'projects/<url>' => 'projects/ACTION',
            ],
        ],

In order for this to work, first, the path projects/action has to match your controller action, and then projects/<url> means that when you build a link you need to pass the parameters required with the url, example:
test
Yii then will transform the url to the pretty url you want.
I recommend you to use the slug field, and use the default behavior sluggable


text:
Q: How to use Maximum in Crystal reports i want to filter my rows and only select/ display my rows when the field AMSD135.AB is the latest date date in that group.
So i got a report with some groups where the last group is grouped on AMSD135.AB. Now i created a formula to hide the section.
AMSD135.AB <> Maximum({AMSD135.AB}, {AMSD135.AB})

but i always get the following error message:
There must be a group that matches this field.

if i use
AMSD135.AB <> Maximum({AMSD135.AB})

it searches for the max in all rows.

A: It works when i use the following formula:
{AMSD135.AB} <> Maximum({AMSD135.AB},{Arbeitsgang.AGNR})

with {Arbeitsgang.AGN} being the group above. Which makes more sense, since when i group by AB, Max(AB) is always AB. But shouldnt it still work.


text:
Q: What is the accurate configuration to inform the Zend framework about the new module? So if you follow the Zend framework documentation to build a skeleton application, when you get to the part where you have to inform Zend of about the new module, the documentation provides this example:
return array(
     'modules' => array(
         'Application',
         'Album',                  // <-- Add this line
     ),
     'module_listener_options' => array(
         'config_glob_paths'    => array(
             'config/autoload/{{,*.}global,{,*.}local}.php',
         ),
         'module_paths' => array(
             './module',
             './vendor',
         ),
     ),
 );

If you look at the actual file it looks like this:
<?php
/**
 * If you need an environment-specific system or application configuration,
 * there is an example in the documentation
 * @see https://docs.zendframework.com/tutorials/advanced-config/#environment-specific-system-configuration
 * @see https://docs.zendframework.com/tutorials/advanced-config/#environment-specific-application-configuration
 */
return [
    // Retrieve list of modules used in this application.
    'modules' => require __DIR__ . '/modules.config.php',

    // These are various options for the listeners attached to the ModuleManager
    'module_listener_options' => [
        // This should be an array of paths in which modules reside.
        // If a string key is provided, the listener will consider that a module
        // namespace, the value of that key the specific path to that module's
        // Module class.
        'module_paths' => [
            './module',
            './vendor',
        ],

        // An array of paths from which to glob configuration files after
        // modules are loaded. These effectively override configuration
        // provided by modules themselves. Paths may use GLOB_BRACE notation.
        'config_glob_paths' => [
            realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php',
        ],

        // Whether or not to enable a configuration cache.
        // If enabled, the merged configuration will be cached and used in
        // subsequent requests.
        'config_cache_enabled' => true,

        // The key used to create the configuration cache file name.
        'config_cache_key' => 'application.config.cache',

        // Whether or not to enable a module class map cache.
        // If enabled, creates a module class map cache which will be used
        // by in future requests, to reduce the autoloading process.
        'module_map_cache_enabled' => true,

        // The key used to create the class map cache file name.
        'module_map_cache_key' => 'application.module.cache',

        // The path in which to cache merged configuration.
        'cache_dir' => 'data/cache/',

        // Whether or not to enable modules dependency checking.
        // Enabled by default, prevents usage of modules that depend on other modules
        // that weren't loaded.
        // 'check_dependencies' => true,
    ],

    // Used to create an own service manager. May contain one or more child arrays.
    // 'service_listener_options' => [
    //     [
    //         'service_manager' => $stringServiceManagerName,
    //         'config_key'      => $stringConfigKey,
    //         'interface'       => $stringOptionalInterface,
    //         'method'          => $stringRequiredMethodName,
    //     ],
    // ],

    // Initial configuration with which to seed the ServiceManager.
    // Should be compatible with Zend\ServiceManager\Config.
    // 'service_manager' => [],
];

This is my guess:
return [
    // Retrieve list of modules used in this application.
    'modules' => require __DIR__ . '/modules.config.php',

    'modules' => [
        'Application',
        'Article',
    ],

    // These are various options for the listeners attached to the ModuleManager
    'module_listener_options' => [
        // This should be an array of paths in which modules reside.
        // If a string key is provided, the listener will consider that a module
        // namespace, the value of that key the specific path to that module's
        // Module class.
        'module_paths' => [
            './module',
            './vendor',
        ],

I ask because I am getting this error:
Fatal error: Uncaught exception 'Zend\ModuleManager\Listener\Exception\RuntimeException' with message 'Could not find a valid ServiceManager for RoutePluginManager' in /Users/ldco2016/Projects/kbase/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php on line 202
( ! ) Zend\ModuleManager\Listener\Exception\RuntimeException: Could not find a valid ServiceManager for RoutePluginManager in /Users/ldco2016/Projects/kbase/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php on line 202

So I am wondering if the configuration for informing Zend about the new module is incorrect and that's why it can't find a valid ServiceManager or if, despite the fact that I added a classmap file in module/Article of:
return array();

do I still have to add a getAutoloaderConfig() { } and add it to composer.json file? So I did add a getAutoloaderConfig() {} and now I get this error:
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (Application) could not be initialized.' in /Users/ldco2016/Projects/kbase/vendor/zendframework/zend-modulemanager/src/ModuleManager.php on line 203
( ! ) Zend\ModuleManager\Exception\RuntimeException: Module (Application) could not be initialized. in /Users/ldco2016/Projects/kbase/vendor/zendframework/zend-modulemanager/src/ModuleManager.php on line 203

I have pored over documentation and cannot find a straight answer here.

A: I am confused about what version of ZF and what version of the skeleton you are using...
In the current version (ZF3), the module config has been moved to a different file that is then included in the main one: modules.config.php.
That is where you stick your new module name.
As of ZF3, you do not need the getAutoloaderConfig method. Zend Autoload has been completely removed anyway, in favour of the Composer autoloader (PSR-0/PSR-4): Composer autoload config. You need to add your own module in there, and then use the composer dump-autoload command to enable the autoloader.


text:
Q: remove every thing from a line in Perl up to a specific word I need to remove every thing from a line in Perl up to a specific word .
suppose i have these 3 lines
Helicobacter Contig1
Helicobacter contig1
Helicobacter .Contig1

I want to have contig1 or Contig 1
I have tried
$test=s/^(.*?)^(contig|Contig)//g;

but it is not working. Any idea?

A: remove the second ^
your regex should be s/^(.*?)(?=contig|Contig)//g;
the .*? is non-greedy, so it will stop as soon as it can (i.e when it sees contig or Contig). you could also use the \i modifier to make the match case insensitive, so you don't have to check for two different strings.


text:
Q: How to run gobuster inside a bash script properly? (Invalid URL espace error) I'm writing a simple bash script, which runs gobuster inside a bash script. Outside bash it works totally fine, but within the script I'm getting "invalid URL espace" errors for some of the parsings
Gobuster v3.0.1
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@_FireFart_)
===============================================================
[+] Url:            http://10.10.112.95:80/
[+] Threads:        10
[+] Wordlist:       common.txt
[+] Status codes:   200,204,301,302,307,401,403
[+] User Agent:     gobuster/3.0.1
[+] Timeout:        10s
===============================================================
2020/06/01 14:41:45 Starting gobuster

[ERROR] 2020/06/01 14:41:52 [!] parse http://10.10.112.95:80/!@#$%^: invalid URL escape "%^"

My bash script is as simple as just running gobuster
gobuster dir -w common.txt -u $1

$1 is the IP address like 10.10.112.95. What goes wrong here and how can I fix it? The wordlist contains special characters. Words from the wordlist without special characters are working. Thanks in advance for the answer!


text:
Q: How Do I create an .ics file with rails and ri_cal? I am using rails 3 and the ri_cal gem. I am not able to produce a valid .ics file. It gets generated, but AppleCalendar or GoogleCalendar say it's empty. What did I do wrong?
Help appreciated, thanks in advance :)
My Controller
class WebsitesController < ApplicationController
  def index

    respond_to do |format|

      format.ics

    end
  end
end

and index.ics.builer
RiCal.Calendar do
    event do
      description "MA-6 First US Manned Spaceflight"
      dtstart     DateTime.parse("2/20/1962 14:47:39")
      dtend       DateTime.parse("2/20/1962 19:43:02")
      location    "Cape Canaveral"
      add_attendee "john.glenn@nasa.gov"
      alarm do
        description "Segment 51"
      end
    end
  end

A: I was able to succeed in getting an ICS created by
def index
 cal =RiCal.Calendar do
   event do
     description "MA-6 First US Manned Spaceflight"
     dtstart DateTime.parse("1962-02-20")
     dtend DateTime.parse("1962-02-20")
     location "Cape Canaveral"
     add_attendee "john.glenn@nasa.gov"
     alarm do
       description "Segment 51"
     end
   end
 end
 respond_to do |format|
  format.ics { send_data(cal.export, :filename=>"mycal.ics", :disposition=>"inline; filename=mycal.ics", :type=>"text/calendar")}
 end
end

no need for the discrete builder


text:
Q: How to select "input type" value dinamically created through JS When i got an HTML page which has a form like this
<form name='form'>
Title <input id = "larger_title" type='text' maxlenght="100" name='ticket_title' value=''>

i select its value by using
    const form=document.forms['form'];
    form.addEventListener('submit',create);
     ...
    form.ticket_title.value

But when i do create an input type element through JS, so dinamically, for example as if i have an array of elements, each of them with a button that enables a function where are sent data that includes these input text, how do i select the values of these like i used to with form, but now without a form, straight from js itself?
var input = document.createElement("input");
    input.type = "text";
    input.name="post_solution";
    input.value="";

This code is outside the function related to the button, but how do i select its values in the function?
How should i select the text inserted in the input area whenever the user submits the button?

A: Interacting with a dynamically created element is no different than interacting with a static one - - you access its properties and methods the same way.
Your problem is that although your code to create a new dynamic element isn't actually inserting the element into the document, so although it exists, it can't be found in the DOM. It should be appended to the document first:

const form=document.forms['form'];
form.addEventListener('submit',create);

function create(event){
  form.ticket_title.value;
  form.post_solution.value = "TEST";
}

var input = document.createElement("input");
input.type = "text";
input.name="post_solution";
input.value="";

// Now, insert the element into the document
document.querySelector("form >  div").appendChild(input);
<form name='form'>

    Title <input id = "larger_title" type='text' maxlenght="100" name='ticket_title' value=''>

<button>Submit</button>
</form>

But, accessing your form fields through the use of document.forms[] is quite ancient and really should be retired and instead use the modern .querySelector() instead. .querySelector() accepts any valid CSS selector as a way of locating the first matching elment.

document.querySelector("form").addEventListener('submit',create);

function create(event){
  form.ticket_title.value;
  form.post_solution.value = "TEST";
}

var input = document.createElement("input");
input.type = "text";
input.name="post_solution";
input.value="";

// Now, insert the element into the document
document.querySelector("form >  div").appendChild(input);
<form name='form'>

    Title <input id = "larger_title" type='text' maxlenght="100" name='ticket_title' value=''>

<button>Submit</button>
</form>

A: First you add an id or class property to the input:
var input = document.createElement("input");
input.type = "text";
input.name="post_solution";
input.id = "myInput";
input.value="";

Then you use document.getElementById:
const input = document.getElementById('myInput');
input.addEventListener('onchange', handleChange);


text:
Q: Flickering with dynamic  list I want to populate md-menu-content with a dynamic list based on whether the user is logged or not. The code:
     <md-menu>
        <md-button class="md-icon-button" aria-label="Account" ng-click="$mdOpenMenu($event)">
            <md-icon md-svg-icon="~/../Content/img/icons/ic_account_box_white_48px.svg" class="s48" aria-label="Account"></md-icon>
        </md-button>
        <md-menu-content width="4">
            <md-menu-item ng-if-start="vm.user.isLogged">

Logged as: {{ vm.user.username }}

            </md-menu-item>
            <md-menu-divider></md-menu-divider>
            <md-menu-item>
                <md-button ng-click="vm.myProfile($event)">
                    My profile
                </md-button>
            </md-menu-item>
            <md-menu-item ng-if-end>
                <md-button ng-click="vm.logout($event)">
                    Logout
                </md-button>
            </md-menu-item>

            <md-menu-item ng-if-start="!vm.user.isLogged">
                <md-button ng-click="vm.openRightSideNav('login')">
                    Login
                </md-button>
            </md-menu-item>
            <md-menu-item>
                <md-button ng-click="vm.openRightSideNav('register')">
                    Register
                </md-button>
            </md-menu-item>
            <md-menu-item class="menu-item-facebook" ng-if-end>
                <md-button ng-click="vm.openRightSideNav('register')">

                    Log in with Facebook
                </md-button>
            </md-menu-item>
        </md-menu-content>
    </md-menu>

This works, but there is a flicker once the user logs out. I mean, for a split second all menu items are being shown. Using ng-switch removes the flickering, but extra dom element breaks the menu:
         <md-menu-content width="4">
            <ng-switch on="vm.user.isLogged">

                ...

                    ...

            </ng-switch>
        </md-menu-content>

Any suggestions how to deal with the situation?

A: You are right. There is a flickering in your case. I tried to implement in many different ways and got one solution. It is not the best solution I must say but there will not be any flickering. You just try to use two seperate menu for logIn and logOut.
Here is the example code.
<md-menu ng-if="vm.user.isLogged">
 //md-menu-item
</md-menu>
<md-menu ng-if="!vm.user.isLogged">
 //md-menu-item
</md-menu>

Here is a working example. http://codepen.io/next1/pen/wWzebw


text:
Q: How to link navigation/buttons to the whole site using one file? Is there a quicker way to make the navigation bar/buttons go onto all my pages of my site instead of going into each .php file and copying and pasting it. How would I link up the class="button" to another file so that it changes the whole navigation on my site?

A: Just use an include statement.
include 'nav.php';
on each page.
Nav.php could then contain nothing more than just the navigation.

A: First Separate  your php file as header.php for header menu and footer.php for footer menu.
And then include the file in pages .
See this example for reference.


text:
Q: What does it mean when the jvm address of an object is 0? I have an object, Mutation, that I have "new"ed. But when it prints out with toString(), the object says Mutation@0. That doesn't seem good to me. What might that mean?

A: That is Unsigned hexadecimal representation
As per Docs of toString() method in Object class

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

That zero  in the sense the Hashcode not yet calculated.
Source Code:
   public String toString() {
237        return getClass().getName() + "@" + Integer.toHexString(hashCode());
238    }

A: If you look at the source code of Mutation, a good chance is you'll find this in there:
@Override public int hashCode() {
   //TODO: implement this properly!
   return 0;
}

The default implementation of toString() just reports this fact that hashCode returned 0.


text:
Q: Drag-and-Drop not working for Qt Widgets Application captured and embedded using QWidget::createWindowContainer I have an application that is capturing and embedding another application using QWidget::createWindowContainer. Here's the code responsible for this:
void MainWindow::capture( WId wid )
{
    auto window = QWindow::fromWinId( wid );
    auto widget = QWidget::createWindowContainer( window );
    ui->ContentFrame->layout()->addWidget( widget );
}

The application is captured and added to the layout successfully, but drag-and-drop does not work within the captured application. When dragging a widget the cursor displays an X while the widget is held over the captured application, and dropping results in nothing.
I have tried to ensure that drag-and-drop is actually enabled using both setAcceptsDrops() and setAttribute( Qt::WA_AcceptDrops ) on the newly created widget, the widget it is being embedded into, and the capturing dialog, but none of this seems to make a difference.
Drag-and-drop does work for the captured application when launched on its own and not captured. It seems to be the capturing process that breaks the drag-and-drop. Is there something I need to manually do to ensure it works in my scenario?
Some additional information: I am developing with Qt 5.5.1 on Ubuntu 16.04. The application being captured is started using a QProcess in the capturing application.


text:
Q: Display User details in Flutter Home page from Django Rest Framework Data using FutureBuilder approach In my Flutter app I have home page which appears after logging in and I want to add the first & last name of the logged in user.
I have created a file under the name of config.dart which is showing the url that I want to get the user details from which:
class Config {
  static const String apiURL = "http://00.0.0.00:0000/";
  static const String userProfileAPI = "api/dj-rest-auth/user/";

Also I created a model for the user_profile.dart as following:
class User_Profile {
  int? pk;
  String? username;
  String? email;
  String? firstName;
  String? lastName;

  User_Profile(
      {this.pk, this.username, this.email, this.firstName, this.lastName});

  User_Profile.fromJson(Map<String, dynamic> json) {
    pk = json['pk'];
    username = json['username'];
    email = json['email'];
    firstName = json['first_name'];
    lastName = json['last_name'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['pk'] = this.pk;
    data['username'] = this.username;
    data['email'] = this.email;
    data['first_name'] = this.firstName;
    data['last_name'] = this.lastName;
    return data;
  }
}

in my api_service.dart
  static Future<String> getUserProfile() async {
    var loginDetails = await SharedService.loginDetails();

    Map<String, String> requestHeaders = {
      'Content-Type': 'application/json',
      'Authorization': 'Basic ${loginDetails!.key}'
    };

    var url = Uri.parse(Config.apiURL + Config.userProfileAPI);
    var response = await client.get(
      url,
      headers: requestHeaders,
    );
    print(response.body);

    if (response.statusCode == 200) {
      return response.body;
      print(response.body);
    } else {
      return "";
    }
  }

My question how can I proceed forward to get the data and show it in the home page in the following section of the homepage:

class HomeScreen extends StatelessWidget {
  const HomeScreen({Key? key}) : super(key: key);

//................reduced unrelated code.......................

Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            // TODO Change to User Name
                            "Hi, [firstname] [lastname]!",
                            style: Styles.headLineStyle1,
                          ),
                        ],
                      ),

Required outcome: I want to be able to get the information of the logged in user from Django Rest Framework and add his first name and last name in the home page. I am doing this for learning purposes to be able to implement the same concept further.

A: You need to use like this
FutureBuilder<User_Profile>(
          future: getUserProfile(),
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              return Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    SizedBox(
                      height: size.height / 15,
                    ),
                    const Padding(
                      padding: EdgeInsets.all(8.0),
                      child: UserImage(),
                    ),
                    Poppins(
                        size: 20, text: "Hi" + snapshot.data!.firstname +snapshot.data!.lastname, color: blue),

                  ]);
            } else if (snapshot.hasError) {
              return Text("${snapshot.error}");
            }
            // By default show a loading spinner.
            return const LoadingAnimation();
          },
        ),

Poppins is a custom Text Widget .
getUserProfile() is your API call


text:
Q: Dealing with .csv files: Error: only integer scalar arrays can be converted to a scalar index enter image description herePython Machine Learning dealing with .csv files: Error: only integer scalar arrays can be converted to a scalar index
import pandas as pd
df = pd.read_csv('EURGBP.csv')
df.columns = [['date', 'open', 'high', 'low', 'close', 'volume']]
df.date = pd.to_datetime(df.date,format='%d.%m.%Y  %H:%M:%S.%f')
df = df.set_index(df.date)
print(df.head())

Error: only integer scalar arrays can be converted to a scalar index

A: Problem is you pass nested list to columns names, so created 'broken' one level MultiIndex, need remove outer []:
df.columns = ['date', 'open', 'high', 'low', 'close', 'volume']


text:
Q: @OneToMany in abstract class generates unusable schema I have the following model classes:
@Entity
@Inheritance
public abstract class BasePage {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;

    @OneToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
    @MapKey(name="locale")
    private Map<String, Localized> text = new HashMap<String, Localized>();

    @OneToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
    @MapKey(name="locale")
    private Map<String, Localized> title = new HashMap<String, Localized>();

    // ....
}

@Entity
public class Localized {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;

    private String locale;

    @Lob
    @Type(type="org.hibernate.type.StringClobType")
    private String text;

    @Lob
    @Type(type="org.hibernate.type.StringClobType")
    private String synopsis;

    // ....
}

@Entity
@DiscriminatorValue("FLATPAGE")
public class FlatPage {
}

@Entity
@DiscriminatorValue("INSTITUTION")
public class Institution {
    @OneToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
    @MapKey(name="locale")
    private Map<String, Localized> contact;
}

So far so good, I have a small Entity class to hold localized (HTML) strings and an abstract class that is the base for specific types of nodes/articles in my application.
The SQL that is generated for the entities looks good, however I have a problem with the table that maps BasePage entities to Localized entities.
With Hibernate (4.3.4) and PostgreSQL (9.1), the following schema is generated:
CREATE TABLE basepage_localized
(
    basepage_id BIGINT NOT NULL,
    contact_id BIGINT NOT NULL,
    synopsis_id BIGINT NOT NULL,
    text_id BIGINT NOT NULL,
    PRIMARY KEY ( basepage_id, synopsis_id ),
    FOREIGN KEY ( basepage_id ) REFERENCES basepage ( id ),
    FOREIGN KEY ( text_id ) REFERENCES localized ( id ),
    FOREIGN KEY ( contact_id ) REFERENCES localized ( id ),
    FOREIGN KEY ( synopsis_id ) REFERENCES localized ( id )
);

The problem is that I can not create FlatPage entities, since contact_id has a NOT NULL constraint. I suspect there might be more problems with my schema, but that is the one that I currently struggle with....


text:
Q: Javascript | Dynamic array of Characters based on consecutive letters conditions I was doing a codewar challange, and couldn't find a solution, but I really want to know how we can solve this problem.
So we getting two integers, let's say N and D and we should return a string containing exactly N letters 'n' and exactlly D letters d with no three consecutive letters being same.
For example if we get N=5 and D=3 we should return "nndnndnd" or "nbnnbbnn" or any other correct answer
another example like if we get N=1 D=4 the only accepted answer should be "ddndd"
What I did was making a helper function like this :
function generateArray (char,q){
let arr= []
for(let i=0; i<q; i++){
    arr.push(char)
}

return arr
}

and inside the main function :
function solution(N, D) {
let arrayOfchar = generateArray('n',N)

    arrayOfchar.reduce((prev,current,index) => {
        for(let i=0; i<D; i++) {
        if(prev===current) {
            arrayOfchar.splice(index, 0, "d")
        }
    }
    })
}

But I don't know hoe should I put the "d" only after two or less consecutive "n"
Anyone clue?

A: Rather than creating an entire array of the same character at the very start, I think it would make more sense to create the array piece-by-piece, until N and D come out to 0.
Here's one possible implementation. The general idea is to try to push whichever character count is larger, or if that's not possible due to 3-in-a-row, push the other character, and subtract the appropriate character count by one. Repeat until both counts are 0:

function solution(n, d) {
  const arr = [];
  function canPush(char) {
    const { length } = arr;
    return (arr[length - 1] !== char || arr[length - 2] !== char);
  }
  function push(char) {
    arr.push(char);
    if (char === 'n') n--;
    else if (char === 'd') d--;
  }

  while (n > 0 || d > 0) {
    if (n > d) {
      if (canPush('n')) push('n');
      else if (d === 0) return console.log('Impossible');
      else push('d');
    } else if (d >= n) {
      if (canPush('d')) push('d');
      else if (n === 0) return console.log('Impossible');
      else push('n');
    }
  }
  console.log(JSON.stringify(arr));
  // return arr;
}
solution(5, 3);
solution(1, 4);
solution(1, 5);
solution(5, 1);
solution(2, 5);
solution(2, 6);
solution(2, 7);

A: Here is another solution to this interesting problem. The idea is not to go one by one but to figure which one is the larger number and then do an array of pairs of that letter while doing a simple array of the smaller and then just concat them one with another ... so you have 5 and 3 ... nn + d + nn + d + n. 2 pairs of the bigger plus one of the smaller etc.

const fillArray = (length, letter, bigNumber) => {
   var arr = []
   for(var index=0; index < length; index++) {
      arr.push([letter, bigNumber%2 && index+1 === length ? null : letter])
   }
   return arr;
}
const getString = (n, d) => {
  var swtch = d > n, arr = [],
   bigger = {number: swtch ? d : n, letter: swtch ? 'd' : 'n', ceil: Math.ceil((swtch ? d : n)/2)},
   smaller = {number: swtch ? n : d, letter: swtch ? 'n' : 'd', ceil: Math.ceil((swtch ? n : d)/2)}

   if(Math.abs((bigger.number/2) - smaller.number >= 1.5)) {
     return 'Not possible with given parameters!'
   }

   var bigWorkArray = fillArray(bigger.ceil, bigger.letter, bigger.number)
   var smallWorkArray = n === d ? fillArray(smaller.ceil, smaller.letter, smaller.number) : Array(smaller.number).fill(smaller.letter)

   for(var i=0; i < bigWorkArray.length; i++) {
     arr.push(...bigWorkArray[i],...smallWorkArray[i] || '')
   }
   return arr.join('');
}

console.log(getString(5,3))
console.log(getString(1,4))
console.log(getString(1,5))
console.log(getString(5,1))
console.log(getString(2,5))
console.log(getString(2,6))
console.log(getString(2,7))


text:
Q: Powershell: Directory file structure into JSON Hello I am new to PowerShell. I have a filepath which is 4 level.
Rootedirectory\directory1\directory2\directory3\ files
The filestructure always remains the same.
Here is my code, the issue is it's repeating the same values
#Place Root Folder in desktop
$Fullpath = 'C:\Users\Glen Sale\Desktop\donor'
$rootDir = $Fullpath.Split('\')[4]

#Get Creationtime of matching root folder
$session = Get-ChildItem 'C:\Users\Glen Sale\Desktop' -Filter $rootDir

    $organfolder = Get-ChildItem 'C:\Users\Glen Sale\Desktop\donor' -Directory
foreach ($dir in $organfolder){
    Get-ChildItem $dir.FullName -File
    $biospyfolder = Get-ChildItem $dir.FullName -Directory
    foreach($dir2 in $biospyfolder){
        gci $dir2.fullname -File
        $sectionfolder = gci $biospyfolder.fullname -Directory
        foreach($dir3 in $sectionfolder){
           $tiffFiles= gci $dir3.fullname -File
        }
    }
}

function recurse {

    Get-ChildItem -LiteralPath $Fullpath   |
    ForEach-Object {
        $Obj = [ordered]@{
             session_id = $session.CreationTime | Get-Date -f ("yyyyMMdd")
             session_date = $session.CreationTime | Get-Date -f ("yyyy/MM/dd")
                #$rootDir
                organ=@{
                     organ_id= $organfolder.namer#[0]
                        biospy= @(
                            @{biospy_id = $biospyfolder.name#[0]
                                section= @(
                                    @{section_id= $sectionfolder.name#[0]
                                      tiff_files = $tiffFiles.name#[0]
                                    }
                                )
                        })
           }
        }
    } {
        $Obj
    }
}

recurse  | ConvertTo-Json -Depth 100 #| out-file ''

The output I am getting is being repated.
Results:
[
    {
        "session_id":  "20210418",
        "session_date":  "2021/04/18",
        "organ":  {
                      "organ_id":  [
                                       "FBG01",
                                       "FBG02"
                                   ],
                      "biospy":  [
                                     {
                                         "biospy_id":  "FBG01.12.1",
                                         "section":  [
                                                         {
                                                             "section_id":  [
                                                                                "FBG01.12.1.1",
                                                                                "FBG01.12.1.2"
                                                                            ],
                                                             "tiff_files":  [
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d0.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d1.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d2.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d3.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f01d0.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f01d1.TIF"
                                                                            ]
                                                         }
                                                     ]
                                     }
                                 ]
                  }
    },
    {
        "session_id":  "20210418",
        "session_date":  "2021/04/18",
        "organ":  {
                      "organ_id":  [
                                       "FBG01",
                                       "FBG02"
                                   ],
                      "biospy":  [
                                     {
                                         "biospy_id":  "FBG01.12.1",
                                         "section":  [
                                                         {
                                                             "section_id":  [
                                                                                "FBG01.12.1.1",
                                                                                "FBG01.12.1.2"
                                                                            ],
                                                             "tiff_files":  [
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d0.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d1.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d2.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d3.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f01d0.TIF",
                                                                                "No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f01d1.TIF"
                                                                            ]
                                                         }
                                                     ]
                                     }
                                 ]
                  }
    }
]

These is the result that I want which is categorize correctly
{
  "session_id": "20210409",
  "session_date": "2021/04/09",
  "organ": {
    "organ_id": "FBG01",
    "biopsy": [
      {
        "biopsy_id": "FBG01.12.1",
        "section": [
          {
            "section_id": "FBG01.12.1.1",
            "tiff_files": [
              "FBG01 12 hr_Bottom Slide_R_p01_0_A01f00d0.TIF",
              "FBG01 12 hr_Bottom Slide_R_p01_0_A01f01d0.TIF",
              "FBG01 12 hr_Bottom Slide_R_p01_0_A01f02d0.TIF"
            ]
          },
          {
            "section_id": "FBG01.12.1.2",
            "tiff_files": [
              "FBG01 12 hr_Bottom Slide_R_p01_0_A01f20d0.TIF",
              "FBG01 12 hr_Bottom Slide_R_p01_0_A01f21d0.TIF",
              "FBG01 12 hr_Bottom Slide_R_p01_0_A01f22d0.TIF"
            ]
          }
        ]
      },
      {
        "biopsy_id": "FBG01.18.1",
        "section": [
          {
            "section_id": "FBG01.18.1.1",
            "tiff_files": [
              "FBG01 12 hr_Bottom Slide_R_p01_0_A01f00d0.TIF",
              "FBG01 12 hr_Bottom Slide_R_p01_0_A01f01d0.TIF",
              "FBG01 12 hr_Bottom Slide_R_p01_0_A01f02d0.TIF"
            ]
          },
          {
            "section_id": "FBG01.18.1.2",
            "tiff_files": [
              "FBG01 18 hr_Bottom Slide_R_p01_0_A01f20d0.TIF",
              "FBG01 18 hr_Bottom Slide_R_p01_0_A01f21d0.TIF",
              "FBG01 18 hr_Bottom Slide_R_p01_0_A01f22d0.TIF"
            ]
          }
        ]
      }
    ]
  }
}

If you need to see what the directory looks like
C:\USERS\GLEN SALE\DESKTOP\DONOR
+---FBG01
|   \---FBG01.12.1
|       +---FBG01.12.1.1
|       |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f02d3.TIF
|       |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f03d0.TIF
|       |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f03d1.TIF
|       |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f03d2.TIF
|       |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f03d3.TIF
|       |
|       \---FBG01.12.1.2
|               No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d0.TIF
|               No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d1.TIF
|               No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d2.TIF
|               No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d3.TIF
|               No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f01d0.TIF
|               No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f01d1.TIF
|
\---FBG02
    \---FBG01.12.1
        +---FBG01.12.1.1
        |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f02d3.TIF
        |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f03d0.TIF
        |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f03d1.TIF
        |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f03d2.TIF
        |       No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f03d3.TIF
        |
        \---FBG01.12.1.2
                No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d0.TIF
                No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d1.TIF
                No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d2.TIF
                No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f00d3.TIF
                No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f01d0.TIF
                No Sample 0.05 40X_Bottom Slide_R_p00_0_A01f01d1.TIF

A: It comes from the way you write your recurse function because Foreach-object has a special syntax.
Look at :
1..3| foreach-object {$n=0}{$a=$n++}{$a}

gives  :
3

First script block is initiator executed once before the loop, second is the loop executed as many times as the number of objects and the third executed once at the end.
But you are using just two
1..3| foreach-object {$a=$n++}{$a}

which gives :
3
3
3

First script block initiator executed once and the loop {$obj} executed multiple times.

A: I figured out the solution to my issue using class and nested loop
class section
{
    [System.String]$section_id = ''
    [System.String[]]$tiff_files = @()
}
class biopsy
{
    [System.String]$biopsy_id = ''
    [section[]]$section = @()
}
class organ
{
    [System.String]$organ_id = ''
    [biopsy[]]$biopsy = @()
}
class session
{
    [System.String]$session_id = ''
    [System.String]$session_date = ''
    [organ[]]$organ = @()
}

$session = [session]@{
    session_id = 'session_id'
    session_date = 'session_date'
}
foreach($o in Get-ChildItem -Directory -Path C:\Users\v-mtouri\Desktop\donor)
{
    $organ = [organ]@{organ_id = $o.Name}
    $session.organ += $organ
    foreach ($b in Get-ChildItem -Directory -Path $o.FullName)
    {
        $biopsy = [biopsy]@{biopsy_id = $b.Name}
        $organ.biopsy += $biopsy
        foreach ($s in Get-ChildItem -Directory -Path $b.FullName)
        {
            $section = [section]@{
                section_id = $s.Name
                tiff_files = Get-ChildItem -File -Path $s.FullName | Select-Object -ExpandProperty Name
            }
            $biopsy.section += $section
        }
    }
}

$session | ConvertTo-Json -Depth 10


text:
Q: Unable to run cdk commands on my windows having python installed Installed aws-cdk using pip on windows10. After restart, when i run cdk --version on cmd prompt, it says 'cdk' is not recognized as an internal or external command,
operable program or batch file.
aws --version
aws-cli/2.0.30 Python/3.7.7 Windows/10 botocore/2.0.0dev34
python --version
Python 3.8.1
Do I need to install NodeJS as well?
Please help me setup cdk on my windows10 laptop....

A: Based on the official documentation you need to have Node.js installed.
And I'll quote from the documentation

All CDK developers need to install Node.js 10.3.0 or later, even those working in languages other than TypeScript or JavaScript.

Also..

Install the AWS CDK Toolkit globally using the following Node Package Manager command.

npm install -g aws-cdk

After that you should be able to run cdk --version without any issues

A: I have been driven into the same issue for using lower node version. If you have been install CDK in your computer previously and has been running CDK commands early.
Please check your local machine has newer Node version.
You can use NVM to manage node versions in your local machine.


text:
Q: Bootstrap 3: Collapse on hover e fixa no click Gostaria de saber como fazer para que o Collapse do Bootstrap 3 abra no hover e caso seja clicado ele fique fixo (Não feche) e só feche caso outro collapse seja clicado (E este outro collapse abra).
Com o seguinte código eu consegui fazer com que ele abra no hover, mas nao consigo fixa-lo no click.
// Classe .menu-header abraça todo o collapse para que ele nao feche ao retirar o hover do botão.
$('.menu-header').hover(function () {
    $('#administrativoCollapse').toggleClass('in');
});

A: Você pode usar o seguinte código para que quando clicar, além de você setar a classe para deixar ele aberto, você remove o evento de hover.
$('.menu-header').click(function () {
    $('#administrativoCollapse').toggleClass('in');
    $('#menu-header').off('hover');
});


text:
Q: Grub2 is not being installed within installation of Ubuntun 14.04.3 and Win 10 set before hope you can help a beginner. I recently upgraded Windows 7 to Windows 10.
After that I downloaded Ubuntu 14.04.3 and successfully installed it;
For that I made several partitions;
One for Windows 10 with around 400gb ntfs,then 3 partitions of ext 4, one root partition where I installed Ubuntu with around 150gb, one /home with also 150gb, one /boot with 1gb; I also set a partition vor swap of 10gb and a fat32 20gb file system called /commonfiles to have a partition I can use for both, Windows 10 and Ubuntu.
However, the installation ended successfully but unfortunately, grub2 wasn't installed and Windows 10 normally started...
Does anyone have an idea how to get grub2 with entries for both, Win 10 and Ubuntu 14.04.3?
I'm unfortunately a bloody beginner and I don't rech the terminal of Ubuntu because I see no way in starting Ubuntu;
I would be extremely happy if someone can help...
Thanks a lot! :)

A: Look , if you installed Ubuntu using UEFI boot configuration then you can easily change the boot config to start Ubuntu from your BIOS configuration menu :
set the first EFI boot priority to :
Ubuntu boot manager
Save & Exit
then u can boot up you Ubuntu
and when you're done and have access to your terminal you can install grub using this command :
sudo grub-install /dev/sdX  # Example: sudo grub-install /dev/sda

and don't forget to update grub
sudo update-grub

Source :
Ubuntu Official help content
the above didn't work out you can try to fix boot using your installation disk/usb after booting into your installation media to "Try Ubuntu before installing" you can use  :
Boot-Repair
installation :
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair

Source:
Ofiicial Ubuntu Boot-Repair
at last if none of the above works you can use a software :

EasyBCD

for Windows ..
you can modify windows' boot manager very easily and you can add ubuntu to it but you'll get to your ubuntu using Windows' boot manager not ubuntu's grub .


text:
Q: ERROR: syntax error at or near "SELECT" I am really new to postgres. The question looks very simple but I just cant see where I got wrong.
I a table created as follows:
  CREATE TABLE IF NOT EXISTS t(
        tn VARCHAR(30) NOT NULL,
        PRIMARY KEY(tn)
    );

I want to insert an instance if the instance does not exist. Here is my code:
INSERT INTO t (tn)
VALUES
(SELECT 'q' WHERE NOT EXISTS (SELECT * FROM t WHERE tn = 'q')) ;

And the psql console keeps giving me the error
ERROR:  syntax error at or near "SELECT"

I have checked every piece of code individually, for instance both
SELECT 'q' WHERE NOT EXISTS (SELECT * FROM t WHERE tn = 'q');

and
INSERT INTO t (tn) VALUES ('p');

run without error. But error occurs when I put them together.
Does anyone know where I got wrong..?

A: Lose VALUES and the brackets...
INSERT INTO t (tn)
SELECT 'q' WHERE NOT EXISTS (SELECT * FROM t WHERE tn = 'q');