text:
Q: 502 Bad Gateway nginx, I have one dominion for two distinct apps (FLASK and DJANGO). I'm using one index page to distribute routes I think this erros happens, because of proxy_pass is incorrect, if someone has any idea please tell me thanks

NGINX FILE

proxy_cache_path /var/nginx/cache/project
keys_zone=djangoproject_cache:60m;

gzip on;
gzip_proxied any;
gzip_types text/plain text/xml text/css application/javascript application/x-javascript;
gzip_vary on;
gzip_disable msie6;

upstream appserver {
        server unix:/home/dir/projects/djangoproject/gunicorn.sock fail_timeout=0;
}

server {
    listen 80;
    listen [::]:80 default_server;
    return 301 https://$host$request_uri;
}

server {

    listen 443;
    server_name www.subdominion.dominion www.subdominion.dominion;
    add_header X-Frame-Options "SAMEORIGIN";

    ssl_certificate    certificate.crt;
    ssl_certificate_key        certificate.key;

    ssl on;
    server_tokens off;

    root /var/www/html/;
    index index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }

    location /djangoproject{

      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      # Fix the "It appears that your reverse proxy set up is broken" error.
      rewrite ^/djangoproject(.*) /$1 break;
      proxy_pass          http://unix:/home/sftpserver/projects/podaexpress/gunicorn.sock; -- I think the error is here
      try_files $uri @proxy_to_appserver;
      access_log /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log;
      sendfile_max_chunk 1024k;
      root /home/dir/projects/djangoproject/static;
      proxy_read_timeout  90;
    }

    location /flaskproject{
      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      # Fix the "It appears that your reverse proxy set up is broken" error.
      rewrite ^/flaskproject(.*) /$1 break;

      proxy_pass          http://unix:/home/dir/projects/flaskproject/gunicorn.sock;

      proxy_read_timeout  90;

    }

    location @proxy_to_appserver {
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE_ADDR $remote_addr;
        proxy_redirect off;
                proxy_pass http://appserver;
    }
}

using this nginx file I got one page manager index.html, in this page has two buttons with href link for my dominion/djangoproject or dominion/flaskproject , everything is correct until here, but when I click in button whose link directs for another project has one error http 502, but gunicorn file is correct

gunicorn file from djangoproject

#!/bin/bash

NAME="djangoproject"                                              # Name of the application (*)
DJANGODIR=/home/dir/projects/djangoproject/                # Django project directory (*)
SOCKFILE=/home/dir/projects/djangoproject/gunicorn.sock    # we will communicate using this unix socket (*)
USER=root                                                       # the user to run as (*)
GROUP=root                                                      # the group to run as (*)
NUM_WORKERS=15                                                  # how many worker processes should Gunicorn spawn (*)
DJANGO_SETTINGS_MODULE=project.qasettings                      # which settings file should Django use (*)
DJANGO_WSGI_MODULE=project.wsgi                                  # WSGI module name (*)

echo "------------- INICIANDO $NAME gunicorn -------------"

# Activate the virtual environment
cd $DJANGODIR
source /home/dir/projects/djangoproject/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH

# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR

# Start your Django Unicorn Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec /home/dir/projects/djangoproject/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $NUM_WORKERS \
  --user $USER \
  --bind=unix:$SOCKFILE \
  --daemon

in both links I get the correct url example https://subdominion.dominion.com.br/djangoprojects or https://subdominion.dominion.com.br/flaskproject


text:
Q: Python: timeformat with timezone from helm I'm trying to parse a timestamp that was generated from helm helm list command.
Now the timestamp format is something like this:
2021-08-24 13:19:18.683572 +0800 +0800
How can I parse it using python?
Thanks in advance

A: When with string trimming:
    def _convert_time_to_iso_format(date_helm_format: str) -> datetime:
        """The helm time output format: 2021-08-24 13:19:18.683572 +0300 +0300
        Need to convert to iso format: 2021-08-24 13:19:18.683

        Args:
            date_helm_format (str): 2021-08-24 13:19:18.683572 +0300 +0300
        """
        (date, hour, tz, _) = date_helm_format.split(" ")
        hour = hour[0:-3] # remove nano-seconds, Python don't know how to handle it
        updated_date = date + " " + hour + " " + tz
        updated_date = datetime.strptime(updated_date, "%Y-%m-%d %H:%M:%S.%f %z")
        updated_date = updated_date - updated_date.utcoffset()
        return updated_date

redpajama_set_name: RedPajamaStackExchange


text:
Q: Plotting: R: Legend positioning (units) + font I have the following
xaxis <- seq(0,1,by=0.01)
aij <- sqrt(1 - (1-xaxis)**1.02)
bij <- 1 - (1 - xaxis)**1.50
cij<-aij-bij
pdf("MyPdf.pdf",family="Times New Roman")
par(mfrow=c(1, 1), mar=c(5, 5, 4, 10))
plot(xaxis,aij,type="l", col="black",lty=1, xlab="Size ratio", ylab="Value of function")
lines(xaxis,bij,type="l",col="black",lty=2)
par(new=TRUE)
plot(xaxis,cij,,type="l",col="black",lty=4,xaxt="n",yaxt="n",xlab="",ylab="")
grid(nx = 10, ny = 10)
axis(4)
mtext("Difference", side=4,line=3)
legend(x='bottomright',col=c("black","black"), lty=c(1,2,3), legend=c("aij","bij","Difference"),inset=c(-0.25,0))
dev.off()

I am not able to understand the following:

*

*How to specify the coordinates for the legend (for example instead of bottomright I wish to have a personally chosen position) - What are the units for the coordinate system and what is its orientation?

*How to position the text properly?

*Is it possible to have BOLD, TIMES font in this plot for all the objects?

A: This illustrates how to move the legend to a particular location in the coordinate system of the plot, with "user-coordinates". See ?par for how to provide the proper value to 'text.font' in the ?legend function. My pdf-device has only a "Times" font, so I cannot show you how to use the named font you describe. You can see the valid names of the currently available pdf fonts with:
names(pdfFonts())

pdf("MyPdf.pdf", family="Times")
par(mfrow=c(1, 1), mar=c(5, 5, 4, 10))
plot(xaxis,aij,type="l", col="black",lty=1, xlab="Size ratio", ylab="Value of function")
lines(xaxis,bij,type="l",col="black",lty=2)
par(new=TRUE)
plot(xaxis,cij,,type="l",col="black",lty=4,xaxt="n",yaxt="n",xlab="",ylab="")
grid(nx = 10, ny = 10)
axis(4)
mtext("Difference", side=4,line=3)
legend(x=0.2,y=0.02, col=c("black","black"), lty=c(1,2,3), legend=c("aij","bij","Difference"), text.font=2 )
dev.off()


text:
Q: Read doubles that extend in multiple lines of txt file My requirement is to read a double array from a text file. It might seem trivial by apparently i'm having an error with the delimiters.
Example:

4
0.000000000000000, 0.000000000000000, 1.000000000000000, 1.000000000000000

where 4 is the length of the double array and the values below separated by commas and space.
Scanner es =  new Scanner(filename);
int numberofValues = es.readInt();
double[] Vector = new double[numberofValues];
for (int k = 0; k < numberofKnotValues; k++)
{
    knotValueVector[k] = es.nextDouble();
}

So up to 15 double values can fit in one text line and I encounter no problem. But if the vector I am supposed to read has more values then the values are split in two or more lines like so:

0.000000000000000, 0.000000000000000, 0.000000000000000, 0.125000000000000, 0.250000000000000, 0.375000000000000, 0.500000000000000, 0.625000000000000, 0.750000000000000, 0.875000000000000, 1.000000000000000, 1.000000000000000, 1.000000000000000

The problem is after I read the last double of the line and a comma remains at the end. When I try to read the next double the an error occurs that it is not a double but space.
So far the delimiter (" , *" ) seem to be enough for reading the doubles of line, but I can't find one that fits for multiple lines despite the fact that I tried some like

",s*\n"
",s*\r"

but they do not seem to work. So some help will be appreciated!!

A: Since there's no comma between the first number (4) and the rest, but there's always whitespace, set delimiter to:
",?\\s+"

UPDATE
The pattern I gave seems to work fine, regardless of how many numbers are given per line, and whether a line ends with a comma or not:
String input = "13\r\n" +
               "\r\n" +
               "0.000000000000000, 0.000000000000000, 0.000000000000000, 0.125000000000000,\r\n" +
               "0.250000000000000, 0.375000000000000, 0.500000000000000, 0.625000000000000\r\n" +
               "0.750000000000000, 0.875000000000000, 1.000000000000000, 1.000000000000000,\r\n" +
               "1.000000000000000";
Scanner in = new Scanner(input);
in.useDelimiter(",?\\s+");
int count = in.nextInt();
double[] values = new double[count];
for (int i = 0; i < count; i++)
    values[i] = in.nextDouble();
System.out.println(Arrays.toString(values));

Output
[0.0, 0.0, 0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0, 1.0, 1.0]


text:
Q: SQLite how to convert BLOB byte to INT with built-in functions? i have an sqlite database that contains a column with BLOB data.
these BLOB data are 4 byte width. i want to split the 4 bytes appart and convert each part to an integer value to calculate with it.
i found out, that i can use SUBSTR(val, start, length) to take the BLOB value appart. the result is still of type BLOB.
but how can i convert the BLOB/byte to an integer value?
is there a built-in function that can convert byte BLOB values to an integer?
or is there a way to convert a hex-string-value into an integer value, so i could play with HEX(val) or QUOTE(val)
CREATE TEMP TABLE IF NOT EXISTS test AS SELECT x'cafe1a7e' AS val;
SELECT (val)
    , TYPEOF(val)
    , HEX(val)
    , QUOTE(val)
    , TYPEOF(HEX(val))
    , TYPEOF(QUOTE(val))
    , CAST(val AS INT)
    , CAST(HEX(val) AS INT)
    , CAST(QUOTE(val) AS INT)
    , SUBSTR(val, 1, 1)
    , TYPEOF(SUBSTR(val, 1, 1))
    , HEX(SUBSTR(val, 1, 1))
    , HEX(SUBSTR(val, 2, 1))
    , HEX(SUBSTR(val, 3, 2))
    , val + val
    , SUBSTR(val, 1, 1) + 1
    , CAST(SUBSTR(val, 1, 1) AS INT)
    FROM test;
DROP TABLE test;

A: There is no built in function that I know of, so this is how I do it - if you know how many bytes you want to convert:
--creates table h2i with numbers 0 to 255 in hex and int
CREATE TEMP TABLE bits (bit INTEGER PRIMARY KEY);INSERT INTO bits VALUES (0);INSERT INTO bits VALUES (1);
CREATE TEMP TABLE h2i (h TEXT, i INT);
INSERT INTO h2i (h, i) SELECT printf('%02X',num),num FROM (SELECT b7.bit * 128 + b6.bit * 64 + b5.bit * 32 + b4.bit * 16 + b3.bit * 8 + b2.bit * 4 + b1.bit * 2 + b0.bit AS num FROM bits b7, bits b6, bits b5,bits b4, bits b3, bits b2, bits b1, bits b0) as nums;

SELECT
HEX(SUBSTR(val, 1, 1)),h2i0.i
,HEX(SUBSTR(val, 2, 1)),h2i1.i
,HEX(SUBSTR(val, 3, 2)),h2i2.i*256+h2i3.i
,HEX(SUBSTR(val, 1, 4)),h2i0.i*16777216+h2i1.i*65536+h2i2.i*256+h2i3.i
FROM test
JOIN h2i h2i0 ON h2i0.h=HEX(SUBSTR(val, 1, 1))
JOIN h2i h2i1 ON h2i1.h=HEX(SUBSTR(val, 2, 1))
JOIN h2i h2i2 ON h2i2.h=HEX(SUBSTR(val, 3, 1))
JOIN h2i h2i3 ON h2i3.h=HEX(SUBSTR(val, 4, 1))
;

A: @rayzinnz, thank you for the hint.
in the meantime i gave up.
i puzzled together a kind of a solution, but i never got it work to set the initial x'cafe1a7e' value from outside the WITH RECURSIVE construction.
WITH RECURSIVE fx(val_hex, val_int, iter) AS (
    VALUES(HEX(x'cafe1a7e'), 0, 0)
    UNION ALL
    SELECT
        SUBSTR(val_hex, 1, LENGTH(val_hex) - 1),
        val_int + (
        CASE SUBSTR(val_hex, -1)
            WHEN '0' THEN 0
            WHEN '1' THEN 1
            WHEN '2' THEN 2
            WHEN '3' THEN 3
            WHEN '4' THEN 4
            WHEN '5' THEN 5
            WHEN '6' THEN 6
            WHEN '7' THEN 7
            WHEN '8' THEN 8
            WHEN '9' THEN 9
            WHEN 'A' THEN 10
            WHEN 'B' THEN 11
            WHEN 'C' THEN 12
            WHEN 'D' THEN 13
            WHEN 'E' THEN 14
            WHEN 'F' THEN 15
            ELSE 0
        END << (iter * 4)
        ),
        iter + 1
    FROM fx
    WHERE val_hex != ''
    LIMIT 9
    )
--SELECT * FROM fx
SELECT val_int FROM fx WHERE val_hex == ''
;

the BLOB value there is hardcoded.
maybe you find a way.

A: You can convert one hex digit at a time using instr:
SELECT hex(b), n, printf("%04X", n)
  FROM (SELECT b,
        (instr("123456789ABCDEF", substr(hex(b), -1, 1)) << 0) |
        (instr("123456789ABCDEF", substr(hex(b), -2, 1)) << 4) |
        (instr("123456789ABCDEF", substr(hex(b), -3, 1)) << 8) |
        (instr("123456789ABCDEF", substr(hex(b), -4, 1)) << 12) |
        (instr("123456789ABCDEF", substr(hex(b), -5, 1)) << 16) |
        (instr("123456789ABCDEF", substr(hex(b), -6, 1)) << 20) |
        (instr("123456789ABCDEF", substr(hex(b), -7, 1)) << 24) |
        (instr("123456789ABCDEF", substr(hex(b), -8, 1)) << 28) AS n
    FROM (SELECT randomblob(4) AS b))

Example output:
D91F8E91|3642723985|D91F8E91

(Simplification of idea from [1].)


text:
Q: Aframe how to reset default scale after loading the GLTF model I am trying to make an app which adds models from Google poly in GLTF format.
I had the issue of some models being extremely large when added on the scene which I solved by computing their size with bounding box max and min values and setting the scale amount.
Now after adding the objects to the scene when I open the inspector and drag to scale objects, even with a small amount of drag the objects becomes very large.
If there is any way to reset the scale value of loaded objects so that default value can be the value which I computed and this can also solve the drag to scale issue.
Note: The computed scale factor for some elements goes to 0.00001 for x, y, z.

A: Use the three.js API within A-Frame components to compute a bounding box of the model, then scale it down to the size you prefer. Example:
AFRAME.registerComponent('autoscale', {
  schema: {type: 'number', default: 1},
  init: function () {
    this.scale();
    this.el.addEventListener('object3dset', () => this.scale());
  },
  scale: function () {
    const el = this.el;
    const span = this.data;
    const mesh = el.getObject3D('mesh');

    if (!mesh) return;

    // Compute bounds.
    const bbox = new THREE.Box3().setFromObject(mesh);

    // Normalize scale.
    const scale = span / bbox.getSize().length();
    mesh.scale.set(scale, scale, scale);

    // Recenter.
    const offset = bbox.getCenter().multiplyScalar(scale);
    mesh.position.sub(offset);
  }
});

HTML:
<a-entity autoscale="2" gltf-model="stereo.gltf"></a-entity>

The code above will fit your model to a ~2m box, and re-center it. For more information see THREE.Object3D documentation.
three.js r89, A-Frame 0.8.0.


text:
Q: Store Symmetric-key on a remote server in android My app needs a Symmetric encryption key to store game data so the user or anyone else cant modify that. From my research I found that there is no where to save this key safely on device other than hosting my own https server. I want to avoid hosting a costly https server just for this purpose. My question, is there a service/server to store my key that can only be accessed/read by my app.  What I mean by service is third party (e.g google) service provider which enable this process.

A: If you want to go for the difficult and likely overcomplicated route, you could try using Diffie-Hellman to establish a shared secret key between each client and the server.


text:
Q: Using Auto Layout to have UILabel and UITextField next to each other I am trying to position a UILabel instance label next to a UITextField instance textfield like done in the iOS Settings dialogs. I'm using Auto Layout and constraints with the help of Florian Kuglers FLKAutoLayout extensions (https://github.com/dkduck/FLKAutoLayout).

When I set only a leading constraint for the label and a space constraint between label and textfield, the label and textfield widths are adjusted to their content. (bottom picture)
But when I set also a trailing constraint for the textfield, only textfields width is adjusted to its content, but label is stretched. (top picture)
I want to behave the opposite around, so that the textfield will be stretched and the label is adjusted to its content. Why does iOS decide to stretch the label instead of the textfield?
[self addSubview:self.label];
[self addSubview:self.textField];

[self.label alignLeadingEdgeWithView:self predicate:@"10"];
[self.textField constrainLeadingSpaceToView:self.label predicate:@"10"];

// difference between top and bottom pciture
// [self.textField alignTrailingEdgeWithView:self predicate:@"-25"];

A:
EDITED: So after the comment of Rahul I played with width and priorities. Adding the following width constraint lead into the somewhat wrong direction, because of entering some very long value, the label was resized too small.
[self.label constrainWidth:@"0@1"];

So I finally read up on "Compression Resistance and Content Hugging" (http://www.objc.io/issue-3/advanced-auto-layout-toolbox.html) and the solution is to set the Horizontal Content Hugging priority of the label to a higher value.
[self.label setContentHuggingPriority:500 forAxis:UILayoutConstraintAxisHorizontal];

Then even entering big values will let the label stay as width as its content!
Solution is not adding a width constraint with priority, but to set Compression Resistance and Content Hugging properties for the intrinsic content size of the UIViews.

A: Following constraints which I set in the storyboard works exactly how you want.

*

*Horizontal space constraint between label and superview.(default)

*Horizontal space constraint between textfield and superview. (default)

*Horizontal space constraint between textfield and label.


text:
Q: To get values from particular dynamic textbox In the below code i have a dynamic textbox and javascript function.I want to get value from particular text box by spiliting the value by $ .But my actual result i can get the value from particular dynamic textbox and different textbox by spilting the value by $ .Pls help me to get value from particular dynamic textbox.
Asp.net
<asp:TextBox ID="txtField" runat="server" width="200Px"></asp:TextBox>

JS:
 str = "";
 $('input[type=text]').each(function () {
    str += $(this).val() + "$";
 });
 if (str != "")
    str = str.substring(0, str.length - 1);
    alert(str);

A: Just an idea:
When you create dynamic textfields, give define them with a specific class say dyn:
 str = "";
 $('input[type=text] .dyn').each(function () {
    str += $(this).val() + "$";
 });
 //your furthur codes


text:
Q: How to track mobile devices around beacon I saw a video about a Pi 0 that has been coded to track the amount of people that are in a location at a certain time to report the data to an app that tell's people if the area is busy. This does not require for the tracked devices to be connected to a wifi.
How would one go by that? Are there specific node modules?
Thank you in advance

A: The RPi Zero is able to discovery nearby Bluetooth devices if those devices are advertising there presence.
The command line tool bluetoothctl allows you to scan for devices to test this.
To do this with code, BlueZ has a set of APIs which are documented at:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/adapter-api.txt
There is an example of how to discovery with the API using Python at:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/test-discovery
The BlueZ API uses D-Bus so can be used with any language that has D-Bus bindings.
https://www.freedesktop.org/wiki/Software/DBusBindings/


text:
Q: XSLT XML to HTML Crosstab table I am trying to make a crosstab tables from the XML file from ToDoList (http://www.abstractspoon.com/tdl_resources.html)  Here is an example XML file:
<?xml version="1.0" encoding="utf-16" ?>
<TODOLIST PROJECTNAME="Projects">
    <TASK TITLE="proj1" ID="1" NUMPERSON="1" PERSON="Chris" NUMTAGS="1" TAG="Caro" CALCTIMEESTIMATE="36"/>
    <TASK TITLE="proj2" ID="2" NUMPERSON="1" PERSON="Chris" NUMTAGS="1" TAG="Nat" CALCTIMEESTIMATE="8" />
    <TASK TITLE="proj4" ID="4" NUMPERSON="1" PERSON="Chris" NUMTAGS="1" TAG="Caro" CALCTIMEESTIMATE="36" />
    <TASK TITLE="proj5" ID="5" NUMPERSON="1" PERSON="Sahb" NUMTAGS="1" TAG="Nat" CALCTIMEESTIMATE="128" />
    <TASK TITLE="proj32" ID="32" NUMPERSON="2" PERSON="Seb" PERSON1="Chris" NUMTAGS="1" TAG="Nat" CALCTIMEESTIMATE="0.90" />
</TODOLIST>

Each task is an element and all the info are attributes.  I want to make a table like this with the tags as the top row and the persons as the first column.

        Caro
        Nat

        Chris
        72
        8

        Sahb
        128
        0

        Seb, Chris
        0
        9

As you can see the same person can have many projects and I want to add up the CALCTIMEESTIMATE for each person based on the tag(s).  I can get the first row with
<xsl:key name="dtag" match="/TODOLIST/TASK/@TAG" use="." />
<xsl:for-each select="TASK/@TAG[generate-id() = generate-id(key('dtag', .)[1])]">

      <xsl:value-of select="."/>

</xsl:for-each>

But the sum function does not give the desired results. What I'm I missing? Is there an easy way to do the sum based on two attributes?  ToDoList uses XSLT 1.0, that's why I couldn't use distinct-values.
Here is the full XSLT, I've tried alot of different thing, Here I was trying to get it working just for Chris but it would not add up his 2 projects.
<xsl:template match="TODOLIST">
<xsl:text disable-output-escaping="yes"><!DOCTYPE html></xsl:text>

<title>Projects..</title>

Projects..

<xsl:for-each select="TASK/@TAG[generate-id() = generate-id(key('dtag', .)[1])]">

      <xsl:value-of select="."/>

</xsl:for-each>

<xsl:apply-templates select="TASK/@PERSON[generate-id() = generate-id(key('dperson', .)[1])]" />

</xsl:template>

<xsl:template match="TASK/@PERSON">

          <xsl:value-of select="."/>

        <xsl:apply-templates select="/TODOLIST/TASK/@TAG[generate-id() = generate-id(key('dtag', .)[1])]" />

</xsl:template>

<xsl:template match="/TODOLIST/TASK/@TAG">

        <xsl:value-of select="sum(../@CALCTIMEESTIMATE[../@PERSON = 'Chris'])" />

</xsl:template>

A: To get your sum to work, you need to know both the current person and the current tag.
In your current template that matches TASK/@PERSON, you should pass the current value of the attribute to the next template
<xsl:apply-templates
   select="/TODOLIST/TASK/@TAG[generate-id() = generate-id(key('dtag', .)[1])]">
     <xsl:with-param name="PERSON" select="." />
</xsl:apply-templates>

Then, in your template that matches @TAG, you could access the 'dperson' key in the SUM, so you sum all tasks for that person, and for the current tag, like so:
<xsl:template match="/TODOLIST/TASK/@TAG">
  <xsl:param name="PERSON" />

    <xsl:value-of
      select="sum(key('dperson', $PERSON)[../@TAG = current()]/../@CALCTIMEESTIMATE)"/>

</xsl:template>


text:
Q: A question in combinatorics Given a sequence of $0$s and $1$s think of it as blocks of $0$s and $1$s. Like $0001101001$ is a sequence of blocks $000$,$11$,$0$,$1$,$00$,$1$

*

*How may ways can one pick $t$ bits from a $0/1$ sequence such that no two of the bits are consecutive and each is from a separate block?

*How many ways can one pick $t$ bits from a $0/1$ sequence such that each is from a separate block but no two of them are from consecutive blocks?

If there are $B$ blocks in the string then $^{B}C_t$ gives the number of ways you can pick $t$ bits such that each is from a separate block - this is because once the $t$ blocks are chosen it doesn't matter which of its elements is picked.

A: Let $r$ be the number of bits and $s$ be the number of blocks.
To answer your second question, you can use the stars and bars technique outlined in this question. You have $s$ blocks and you want to distinguish $t$ or them, so go through your blocks in order, and when you pick one, you disqualify the next one. So $t-1$ blocks end up being disqualified, and the number of ways to distinguish $t$ of your blocks is $\binom{s-t+1}{t}$.
For the first question, I don't think it has a nice closed answer because it depends on the length of each block. If each block only has one entry, then it's the same as the other question, but with multiple entries in each block, it depends on whether or not you choose the last bit in the block...


text:
Q: JSF, Mojarra, Myfaces, Tomahawk, Primefaces: summary I know there are a lot of answer about these things, but I'm trying to clear my mind about jsf, mojarra, myfaces, primefaces.
Can you please confirm this summary?
JSF is the standard JAVA (by Oracle).
Mojarra (by Oracle) and Myfaces (by Apache) are two implementations of the standard JSF.
Myfaces Tomahawk is a component library as the same as PrimeFaces.
My configuration includes Java 1.8, Eclipse Luna, Apache Tomcat 8, Maven. I'm building a project with PrimeFaces.
So since Tomcat is not a Java EE Application Server, it does not include by itself an implementation of JSF, and I should add it explicitly.
On Eclipse I can include a JSF implementation using maven:
<dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.8-02</version>
    </dependency>

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.8-02</version>
    </dependency>

or Eclipse Project Facets:

the results will be exactly the same? Or I need to import both Mojarra and jsf-core, jsf-impl ?
Thank you!!

A: For Maven project with Eclipse, it is better to add JSF implementation in your POM file rather than using Eclipse provided JARs.
Myfaces, Primefaces and Richfaces are all JSF component libraries / frameworks but having not exactly the same features and the stability level also differs.
Other points you mentioned are correct.


text:
Q: $f'(x)=0$ implies $f$ constant, although finite or countable exceptions I am reading a text and I do not know why this follows:

I $f$ is a continuous function and $f'(x)=0$ for every $x \in \mathbb{R}$ except for a finite set $E$ or a countable set $E$, then $f$ must be constant.

Does anybody know an example for such an function?

A: The problem here is a common one in that the formulation of the result can be at odds with everyday usage of the language.
The only examples of such $f$ are in fact constant functions, which have $f'(x)= 0$ for all $x$.
What does

[...] $f'(x)=0$ for every $x \in \mathbb{R}$ except for a finite set $E$ or a countable set $E$, [...]

mean to say precisely?
It means to say that there is a set $E$ that is finite or countable such that $f'(x)= 0$ for all $x \notin E$.
Note that:

*

*$E$ can be empty.

*It is not uncommon that the author does not insist that $f'(x) \neq 0$ for $x \in E$.

Informally, the result says if for continous $f$ you know $f'(x) = 0$ for all $x$ except possibly some few exceptions, then you can conclude that $f$ is constant (and after that you'd know in fact $f'(x) = 0$ for all $x$).
In particular, this result tells you that there cannot be any interesting examples: by the very result every example has to be constant!


text:
Q: how to left align tootip text in bootstrap--4 The text in the tooltip in bootstrap 4 is center-aligned.
How do you left-align it?
And how do you justify it?
Looking for CSS approach.

          <button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ipse Epicurus fortasse redderet, ut Sextus Peducaeus, Sex. Si quae forte-possumus. Iam id ipsum absurdum, maximum malum neglegi. Traditur, inquit, ab Epicuro ratio neglegendi doloris. Deinde dolorem quem maximum?">
            Tooltip
          </button>

https://www.bootply.com/RBrnkGUv7o

A: Use the data-html attibute to customize the text. Use text-left or text-justify to align it...
https://www.bootply.com/TRrXmm3ROD
<button type="button" class="btn btn-secondary"
       data-toggle="tooltip"
       data-html="true"
       data-placement="top" title="
tooltip text here
">
       Tooltip
</button>


text:
Q: What is the Python equivalent of a jagged array? After years of using Excel and learning VBA, I am now trying to learn Python.  Here's the scenario:
I asked 7 summer camp counselors which activities they would like to be in charge of.  Each student had a random number of responses, and there is no upper limit on the number of activities chosen.  However, each activity is unique, and once "claimed" by a student it cannot claimed by any other counselor.  The results were:
Adam: archery, canoeing
Bob: frisbee, golf, painting, trampoline
Carol: tennis, dance, skating
Denise: cycling
Eddie: horseback, fencing, soccer
Fiona: painting
George: basketball, football

I'm most familiar with VB (I am an old guy) and in the past I would have stored the above info in a jagged array.  But since I'm new to Python, I am confused as to how to do this.  I think a list of lists would work for me and here is my code.  Let's say I have a list of counselors, and separate lists for each counselors' activities.  How do I merge them or put them in one data structure?  What am I doing wrong below?  Thank you.
counselors = []
counselors = ['Adam','Bob','Carol','Denise','Eddie','Fiona','George']

#create a list of Carol's activities
activities = []
activities = ['tennis','dance','skating']

counselors[2].append[(activities)]

A: A jagged array in Python is pretty much a list of lists as you mentioned.
I would use a dictionary to store the counselors activity information, where the key is the name of the counselor, and the value is the list of activities the counselor will be in charge of e.g.
counselors_activities = {"Adam": ["archery", "canoeing"],
                      "Bob": ["frisbee", "golf", "painting", "trampoline"],
                      "Carol": ["tennis", "dance", "skating"],
                      "Denise": ["cycling"],
                      "Eddie": ["horseback", "fencing", "soccer"],
                      "Fiona": ["painting"],
                      "George": ["basketball", "football"]}

And access each counselor in the dictionary as such:
counselors_activites["Adam"] # when printed will display the result => ['archery', 'canoeing']

In regards to the question, I would store the list of activities available in a list, and anytime an activity is chosen, remove it from the list and add it to the counselor in the dictionary as such:
list_of_available_activities.remove("archery")
counselors_activities["Adam"].append("archery")

And if a counselor no longer was in charge of the activity, remove it from them and add it back to the list of available activities.
Update: I have provided a more fully fledged solution below based on your requirements from your comments.
Text file, activites.txt:
Adam: archery, canoeing
Bob: frisbee, golf, painting, trampoline
Carol: tennis, dance, skating
Denise: cycling
Eddie: horseback, fencing, soccer
Fiona: painting
George: basketball, football

Code:
#Set of activities available for counselors to choose from

set_of_activities = {"archery",
                  "canoeing",
                  "frisbee",
                  "golf",
                  "painting",
                  "trampoline",
                  "tennis",
                  "dance",
                  "skating",
                  "cycling",
                  "horseback",
                  "fencing",
                  "soccer",
                  "painting",
                  "basketball",
                  "football"}

with open('activities.txt', 'r') as f:
    for line in f:

        # Iterate over the file and pull out the counselor's names
        # and insert their activities into a list

        counselor_and_activities = line.split(':')
        counselor = counselor_and_activities[0]
        activities = counselor_and_activities[1].strip().split(', ')

    # Iterate over the list of activities chosen by the counselor and
    # see if that activity is free to choose from and if the activity
    # is free to choose, remove it from the set of available activities
    # and if it is not free remove it from the counselor's activity list

    for activity in activities:
        if activity in set_of_activities:
            set_of_activities.remove(activity)
        else:
            activities.remove(activity)

    # Insert the counselor and their chosen activities into the dictionary

    counselors_activities[counselor] = activities

# print(counselors_activities)

I have made one assumption with this new example, which is that you will already have a set of activities that can be chosen from already available:
I made the text file the same format of the counselors and their activities listed in the question, but the logic can be applied to other methods of storage.
As a side note and a correction from my second example previously, I have used a set to represent the list of activities instead of a list in this example. This set will only be used to verify that no counselor will be in charge of an activity that has already been assigned to someone else; i.e., removing an activity from the set will be faster than removing an activity from the list in worst case.
The counselors can be inserted into the dictionary from the notepad file without having to insert them into a list.
When the dictionary is printed it will yield the result:
{"Adam": ["archery", "canoeing"],
 "Bob": ["frisbee", "golf", "painting", "trampoline"],
 "Carol": ["tennis", "dance", "skating"],
 "Denise": ["cycling"],
 "Eddie": ["horseback", "fencing", "soccer"],
 "Fiona": [], # Empty activity list as the painting activity was already chosen by Bob
 "George": ["basketball", "football"]}


text:
Q: Magento - Accessing values from an Mage_Catalog_Model_Resource_Product_Collection object I am new to magento and php and I am trying to retrieve values from an object.
$_productCollection=$this->getLoadedProductCollection();

When I do a print_r() I am getting something like below
Mage_Catalog_Model_Resource_Product_Collection Object
(
    [_flatEnabled:protected] => Array
        (
            [1] =>
        )

    [_productWebsiteTable:protected] => sn_catalog_product_website
    [_productCategoryTable:protected] => sn_catalog_category_product
    [_addUrlRewrite:protected] => 1
    [_urlRewriteCategory:protected] => 3
    [_addMinimalPrice:protected] =>
    [_addFinalPrice:protected] =>
    [_allIdsCache:protected] =>
    [_addTaxPercents:protected] => 1
    [_productLimitationFilters:protected] => Array
        (
            [category_id] => 3
            [category_is_anchor] => 1
            [store_id] => 1
            [use_price_index] => 1
            [customer_group_id] => 0
            [website_id] => 1
            [visibility] => Array
                (
                    [0] => 2
                    [1] => 4
                )

        )
)

And I need to get the category ID in this.
Can someone please help me

A: Trying to get the category from a product list is the long way around as a product list is part of a category. I assume you are doing this on category pages (otherwise you are dealing with more than one category, such as on a search page) in which case you can retrieve it more directly;
$category = Mage::registry('current_category');
$categoryId = $category->getId();

// to find out what other info is stored, temporarily use this
print_r($category->debug());

A: you are dealing with collection that is a massive containing multiple collection items (objects) so to get data out of there you need to iterate over this first
$_productCollection=$this->getLoadedProductCollection();

foreach($_productCollection as $product){

//display data that object contains
//print_r($product->getData());

//display category id's that product is associated with
//print_r($product->getCategoryIds());

}


text:
Q: How loader Maps DLL in to Process Address Space I am curious to know How the Loader Maps DLL in to Process Address Space. How loader does that magic. Example is highly appreciated.
Thanks in advance.

A: Okay, I'm assuming the Windows side of things here. What happens when you load a PE file is that the loader (contained in NTDLL) will do the following:

*

*Locate each of the DLLs using the DLL search semantics (system and patch-level specific), well-known DLLs are kind of exempt from this

*Map the file into memory (MMF), where pages are copy-on-write (CoW)

*Traverse the import directory and for each import start (recursively) at point 1.

*Resolve relocations, which most of the time is only a very limited number of entities, since the code itself is position-independent code (PIC)

*(IIRC) patch the EAT from RVA (relative virtual address) to VA (virtual address within current process memory space)

*Patch the IAT (import address table) to reference the imports with their actual address within the process memory space

*For a DLL call DLLMain() for an EXE create a thread whose start address is at the entry point of the PE file (this is also oversimplified, because the actual start address is inside kernel32.dll for Win32 processes)

Now when you compile code it depends on the linker how the external function is referenced. Some linkers create stubs so that - in theory - trying to check the function address against NULL will always say it's not NULL. It's a quirk you have to be aware of if and when your linker is affected. Others reference the IAT entry directly in which case an unreferenced function (think delay-loaded DLLs) address can be NULL and the SEH handler will then invoke the delay-load helper and (attempt to) resolve the function address, before resuming execution at the point it failed.
There is a lot of red tape involved in the above process which I oversimplified.
The gist for what you wanted to know is that the mapping into the process happens as an MMF, though you can artificially mimic the behavior with heap space. However, if you remember the point about CoW, that's the crux in the idea of DLLs. Actually the same copy of (most of) the pages of the DLL will be shared among the processes that load a particula DLL. The pages which are not shared are the ones that we wrote to, for example when resolving relocations and similar things. In this case each process has a - now modified - copy of the original page.
And a word of warning concerning EXE packers on DLL. They defeat exactly this CoW mechanism I described in that they allocate space for the unpacked contents of the DLL on the heap of the process into which the DLL is loaded. So while the actual file contents are still mapped as MMF and shared, the unpacked contents occupy the same amount of memory for each process loading the DLL instead of sharing that.

A: What level of detail are you looking for? On the basic level, all dynamic linkers work pretty much the same way:

*

*Dynamic libraries are compiled to relocatable code (using relative jumps instead of absolute, for example).

*The linker finds an appropriately-sized empty space in the memory map of the application, and reads the DLL's code and any static data into that space.

*The dynamic library contains a table of offsets to the start of each exported function,  and calls to the DLL's functions in the client program are patched at load-time with a new destination address, based on where the library was loaded.

*Most dynamic linker systems have some system for setting a preferred base address for a particular library. If a library is loaded at its preferred address, then the relocation in steps 2 and 3 can be skipped.

A: If you are really interested you should read the book Linkers and Loaders.

A: Assuming this is in Windows (DLL hints at that), you might want to read Microsoft's Run-Time Dynamic Linking documentation page. It doesn't specify in detail how the DLL is mapped into the address space; I guess you're not supposed to need to know that.


text:
Q: Did I translate the very short C code correctly into assembler? I'm currently learning assembly x86 and I have made a little task for myself.
The C code:
if (a == 4711) { a = a + 2 } else
               { a = a - 2 }

Assembler Code (eax is a register, cmp is compare, jne is jump if not equal and jmp is jump if equal):
         mov eax, a
         cmp eax, 4711
         jmp equal
equal:   add eax, 2
         jne unequal
unequal: sub eax, 2

I think a little more efficient than that would be:
         mov eax, a
         cmp eax, 4711
         jne unequal
         add eax, 2
unequal: sub eax, 2

Edit:
         mov eax, a
         cmp eax, 4711
         jne unequal
equal:   add eax, 2
         jmp continue
unequal: sub eax, 2
continue: ...

Did I translate it correctly?

A: Nope.
In the first case, your jne unequal does nothing since control would go there anyway. You need to jump to after that.
In your second case, if the comparison is true, you both add and subtract 2, doing nothing.
You also don't store the result back where the original value was, you just leave it in eax.

A: Your edit is correct except for one thing.
mov    eax, a

moves the address of "a" into eax, not the contents/value

This short snippet is done with NASM on Ubuntu 16.04 elf64

            section .text
    global _start
_start
        mov     eax, a

        cmp     eax, 4711
        jnz     unequal
        add     eax, 2
        jmp     Done

    unequal:
        sub     eax, 2

Done:   mov [a], eax

        section .rodata
a   dd  180308

It disassembles to;
00400080  B89C004000        mov eax,0x40009c

00400085  3D67120000        cmp eax,0x1267
0040008A  7505              jnz 0x400091
0040008C  83C002            add eax,byte +0x2
0040008F  EB03              jmp short 0x400094
00400091  83E802            sub eax,byte +0x2

00400094  8904259C004000    mov [0x40009c],eax

Variable "a" lives here
0040009C  54C00200

Note that @ 4000080 the address of a is moved into EAX, but @ Done (400091), whatever is in EAX is moved into that address. Notice too, the value @ "a" is stored in reverse order (little endian. Usually in code you'd see it as 0x2c054

A: Let's get back to your first code:
         mov eax, a
         cmp eax, 4711
         jmp equal
equal:   add eax, 2
         jne unequal
unequal: sub eax, 2

Let's pretend the first instruction load eax with "a" (it actually would in TASM/MASM, but rather stick to explicit and accurate [a], it's easier to read the source and works also in NASM).
Second instruction is cmp, which does subtract 4711 from eax, throws the result away (not storing it anywhere), and only flag register is affected. If "a" was 4711, then result of subtraction is zero, so ZF=1 then. Otherwise ZF=0. (for other flags affected by CMP see some documentation).
So on line 3 the eax still contains value from "a", and flag register contains result of cmp eax,4711. And you do jmp. This is unconditional jump, happening no matter what, so you directly continue to instruction at "equal" address, which is add eax,2. => You add 2 to "a" in every case.
Also the add itself affects flags, so for "a" == -2 the ZF=1, otherwise ZF=0!
Then comes the first conditional jump, branching the code, based on current flag register content. The jne is abbreviation of "jump not equal", and "equal" in this context means set zero flag (ZF=1).
So when "a" was -2, ZF is 1 ("is equal") ahead of jne, thus jne will NOT jump to the "unequal" address, but will continue to the next instruction (which is actually at "unequal" address anyway, so the jne is meaningless).
For "a" different from -2 the ZF will be 0 ("is not equal"), so jne will execute the jump on the provided label, continuing with instruction at address "unequal".

So you have to navigate the CPU away from instructions you don't want to execute.
    xor eax,eax   ; sets eax to 0, and ZF=1
    jz  label_1   ; ZF is 1, so jump is executed, CPU goes to "label_1"
    inc eax       ; this instruction is then skipped and not executed
label_1:
    ; eax being still 0, and ZF being still set ON
    ; whatever instruction is here, CPU will execute it after the "jz"

Slightly modified example to show the case when condition is false
    xor eax,eax   ; sets eax to 0, and CF=0, ZF=1, ...
    jc  label_1   ; CF is 0, so "jump carry" is NOT executed
    inc eax       ; this instruction is executed after "jc"
label_1:
    ; here eax is 1
    ; CF is still 0 (not affected by INC)
    ; but ZF is 0 (affected by INC)

Summary: you should have pretty good idea what instructions affect what flags, and in what way. When unsure, keep CMP + Jcc pair together (to not affect flag results from cmp accidentally). Jcc stands for any "conditional jump" instruction. When the condition is met, the jump to provided label is executed. Otherwise the Jcc instruction is ignored, and execution does continue with instruction right after it.

BTW, I personally would write that C code:
if (a == 4711) { a = a + 2 } else
               { a = a - 2 }

as:
    cmp [a],DWORD 4711
    mov eax,2
    je a_is_4711
    neg eax  ; -2 for non 4711 value
a_is_4711:
    add [a],eax


text: Q: How to check if there was document made in mongoDB? So I made an social network application with MERN stack and I want to make sure that user can only post once a day. So I would need validation for that. How do I make that user can post only one post from 00:00 to 23:59 the same day. Meaning he can post on 4th July in 23:59 and 5th July 00:01.


text:
Q: Equation of motion of a gas's center of mass due to heating So here's a pretty basic question that I don't know how to solve within standard thermodynamics.
Let's say I have a container with a gas in it. I transfer heat, $Q$, to the gas from the bottom of the container. Let us assume the local equilibrium hypothesis is true for such a system. We know that, since hot air is lighter, the lighter air will move up, causing the center of mass to move to the bottom.
Let the center of mass undergo a displacement, $\vec s_{CM}$. Is there a way to find the equation of motion for the velocity $\vec v_{CM}$ of the center of mass of the gas? (Assume any required parameters such as density $\rho$, etc.)

A: The natural convection problem you are envisioning can be solved for the time- and spatial variations of the temperature, the velocity, and  density using the basic spatially differentiated transport equations (Navier-Stokes equations {with typically a linearized buoyancy term} in conjunction with the continuity {mass balance} equation and the differential energy balance equation {first law of thermodynamics}).
For approaches to setting this up, see Transport Phenomena by Bird, Stewart, and Lightfoot.  Depending on the specific geometry, an analytic solution is usually not possible, and one would have to resort to a numerical solution, typically involving computational fluid dynamics (CFD).

A: Let's consider a simpler problem: we'll heat the gas from the top of the container, and remove the heat from the bottom.  That way we can possibly avoid the complications of convection.
The exponential atmosphere with linear temperature lapse has the steady-state pressure profile
$$
P(z) = P_0 \left(
\frac{T_0}{T(z)}
\right)^{ Mg / R L}
$$
where $M$ is the molar mass of the gas, $g$ is the local gravitational acceleration, $R = N_A k$ is the ideal gas constant, and $L = dT/dz$ is the temperature lapse rate.
To find the height of the center of mass, you would compute the density from the ideal gas equation, then integrate over the density distribution in the usual way:
$$
z_\text{c.o.m.} = \frac{\int dz\,\rho(z) z}{\int dz\,\rho(z)}
$$
(though you'll want to be less sloppy about linear versus volume densities than I've been.) The density result is (from the same link)
$$
\rho(z) = \rho_0 \left(
\frac{T_0}{T_0 + Lz}
\right)^{\left(
1 + \frac{Mg}{RL}
\right)}
$$
which is clearly related the pressure result, since $T(z) = T_0 + Lz$ is the mathematical statement of the linear temperature lapse. This reduces to the more familiar
$$
\rho(z) \underset{L\to0}\longrightarrow \rho_0 \exp \left({-Mg z}/{R T_0}\right)
$$
in the constant-temperature limit.  You have said you're not interested in containers where the gravitational scale height matters, so you might take the more naïve approximation that $\lim_{L\to0}\rho(z) = \rho_0$, and the center of mass for a constant-temperature cylinder is just in the middle.
If you were to introduce heat-at-the-top and cool-at-the-bottom to your system slowly, so that the linear temperature lapse were a good approximation the entire time, you could compute
$$
\frac{d}{dt} z_\text{c.o.m.}
= \frac{dz_\text{c.o.m.}}{dL}  \frac{dL}{dt}
$$
But if you're neglecting convection, the heat is going to diffuse through the tube in a nonlinear, Newton-cooling, exponential sort of way, so there's no point in that algebra unless you just think it's fun. Better is to take the arguments that went into this setup and turn them into a computational model, where heat diffuses between adjacent slices based on the thermal conductivity of the gas, and mass flows between segments because of the pressure differences.  You might consider a model with constant-mass slices which grow and shrink, rather than a model with constant-height slices with mass exchange.
If you are not neglecting convection, you still have to do all of this work, but in three dimensions.


text:
Q: Windows Authentication pop-up When I try to use Windows auth, the pop-up tells me: X website required login for Y domain.
How can I hide the website name? And only show "You are required to login  first" text on that pop-up?
I cant' seem to figure it out.

A: You can't change the popup for security reasons. That dialog is provided by the web browser.

A: For security reasons, this is guaranteed to be impossible.
Otherwise, malicious websites in <iframe>s will steal your credentials by masquerading as a legitimate site.


text:
Q: Where does this road lead to? I am new in a new city and I am not familiar with this city. Sometimes I want to ask a friend or just a stranger for the correct direction. Usually I would ask "where does this road lead to" when I was wondering the destination of a road or what is another road connect with this road.
So is "Where does this road lead to?" a right way to ask?

A: The phrasing is not incorrect, but I think as a query for directions it's a little vague. The person you're asking does not know what you're after -- are you trying to get to a specific location, or asking if this street/road goes to a general area, or just trying to get some general information on where it goes without a specific goal of your own in mind?
So you could say "Can I get to X by going on this road?", or "Will this road get me to X?" (or "...lead me to X?").
As to street or road (as brought up in a comment), in the US we tend to regard a 'street' as a paved roadway that is in a city or town, could be a "downtown area" with lots of streets and buildings, or could be a suburban area with lots of residence driveways on the street. 'Road' usually means a paved roadway that is going to continue for a longer distance. But this isn't a strong distinction, the terms are used pretty much interchangably and will certainly both be understood.


text:
Q: Custom button block doesn't work I am a beginner in creating Gutenberg blocks. I want to create a custom block for a button. It should have an input field inside for the button text and the user should be able to choose between two button styles and the target URL in the InspectorControls area. But somehow my code doesn't work. The editor refreshes when I am inside of the input field and I am not able to access InspectorControls. Here is my code:
const InspectorControls = wp.editor.InspectorControls;
const PanelBody = wp.components.PanelBody;
const PanelRow = wp.components.PanelRow;
const RadioControl = wp.components.RadioControl;
const TextControl = wp.components.TextControl;

wp.blocks.registerBlockType('test-blocks/primary-button', {
    title: 'Primary Button',
    icon: 'button',
    category: 'test',
    attributes: {
        buttonText: {
            type: 'string'
        },
        buttonLink: {
            type: 'string'
        },
        buttonStyle: {
            type: 'string',
            default: "btn btn-primary"
        }
    },
    edit: function (props) {
        "use strict";

        function updateText(event) {
            props.setAttributes({
                buttonText: event.target.value
            });
        }

        function updateLink(event) {
            props.setAttributes({
                buttonLink: event.target.value
            });
        }

        function updateStyle(event) {
            props.setAttributes({
                buttonStyle: event.target.value
            });
        }
        return wp.element.createElement(
            "div",
            null,
            wp.element.createElement(
                "a", {
                    type: "button",
                    href: "",
                    class: props.attributes.buttonStyle
                },
                wp.element.createElement("input", {
                    type: "text",
                    value: props.attributes.buttonText,
                    onChange: updateText
                })
            ),
            wp.element.createElement(
                InspectorControls,
                null,
                wp.element.createElement(
                    PanelBody, {
                        title: "Button Settings",
                        initialOpen: true
                    },
                    wp.element.createElement(
                        PanelRow,
                        null,
                        wp.element.createElement(RadioControl, {
                            label: "Button Style",
                            value: props.attributes.buttonStyle,
                            options: [{
                                    label: "Primary",
                                    value: "btn btn-primary"
                                },
                                {
                                    label: "Secondary",
                                    value: "btn btn-secondary"
                                }
                            ],
                            onChange: updateStyle
                        })
                    ),
                    wp.element.createElement(
                        PanelRow,
                        null,
                        wp.element.createElement(TextControl, {
                            label: "Target URL",
                            value: props.attributes.buttonLink,
                            onChange: updateLink
                        })
                    )
                )
            )
        );

    },
    save: function (props) {
        "use strict";
        return wp.element.createElement("a", {
            type: "button",
            href: props.attributes.buttonLink,
            class: props.attributes.buttonStyle
        }, props.attributes.buttonText);
    }
});

A: I'd recommend looking at how the existing Button component works to get a sense of how Gutenberg does things. Specifically it uses a <RichText/> component (instead of a native <input>) which allows you to specify the tag name while also supporting user input.
Generally I'd advice against using <input> elements whenever possible. WordPress makes available a ton of components that can dramatically simplify your work.
For block styles, you may want to look at the styles attribute you can add to a block's definition. It will automatically create the UI necessary for a user to switch styles and output CSS classes to the block for styling. It may not match exactly what you have (e.g. btn btn-primary), but it will line up with the "proper" way of doing things in Gutenberg (e.g. is-style-primary).


text:
Q: Prevent "Flicker" of Images in ExtJS Grid on Grid Update/Refresh I'm displaying images in an ExtJS grid by using column renderers that return HTML  tags. The issue is that the images "flicker" (i.e., vanish and re-appear) each time the grid is updated. Is there a way to prevent this? Here's a simplified example of what I'm doing:
Ext.create('Ext.grid.Panel', {
  title: 'My Grid',
  store: myStore
  columns: [
    {
      header: 'Image',
      dataIndex: 'imgUrl',
      renderer: function(imgUrl, meta, record) {

        // Add a mouse-over / tooltip that shows the name
        meta.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(record.getName()) + '"';

        return '<img src="' + imgUrl + '">';
      }
    }
  ]
});

A: I found that using a CSS background-image instead of an <img> tag fixes the problem (only tested with Chrome). Example:
Ext.create('Ext.grid.Panel', {
  title: 'My Grid',
  store: myStore
  columns: [
    {
      header: 'Image',
      dataIndex: 'imgUrl',

      width: 16, // The width of the background-image

      renderer: function(imgUrl, meta, record) {

        // Add a mouse-over / tooltip that shows the name
        meta.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(record.getName()) + '"';

        meta.tdAttr += 'style="background-image: url(\'' + imgUrl + '\'); background-repeat: no-repeat;"';
      }
    }
  ]
});


text:
Q: Access SQLite db from MMF I'm using System.Data.SQLite lib to access my SQLite database. I want to load the db file to memory and use MMF (Memory Mapped Files) to access the database.
Is this possible using the default SQLite library?
edit:
Alternatives on how I can have an in-memory database are welcome.

A: no...
You can:

*

*create an in-memory DB instance (specify in connection string Data Source=:memory:) and load the contents from the DB file into that instance... when you change contents of the in-memory instance your DB file won't get updated... you could later on save the in-memory instance content into a DB file... one way to do this

*use a RAM disk and copy the db file into that RAM disk...

*modify the source code of the library to support MMF


text:
Q: Adicionando buttons no canto superior direito da div Estou utilizando bootstrap, HTML e CSS em um layout responsivo e queria adicionar dois buttons no canto superior direito da DIV

Como consigo realizar isso? independente do que tem dentro da div?
por exemplo

ou

div {
  background: gray;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

A: Se você esta a usar bootstrap pode utilizar a classe pull-right tal como o colega @hugocsl mencionou.
Segue exemplo:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />

    <button class="btn btn-default" type="submit">

    </button>
    <button class="btn btn-default" type="submit">

    </button>

Veja a documentação das classes flutuantes do Bootstrap

A:

        X
        Menu


text:
Q: Keep visitors from accessing wp-admin login page I'm running a site with Wordpress and would like to keep my visitors from accessing the admin login page by simply going to "domain.com/wp-admin". I've looked into allowing specific IPs, but I'm always working at in different locations on different networks, so any static solutions are out of the question.
I'm thinking about just putting in a couple of redirects, but I'm not entirely sure that would be the best, most secure solution.
*Note: I've looked into a couple of plugins, but they only limit what users can do once in the admin panel. I'd like to stop visitors and hackers from getting in altogether.

A: A better option is to put the restrictions at the Apache level, so that WP is not involved at all in the access decisions. A regular HTTP password might be suitable, e.g.
<Location /wp-admin/>
   Require valid-user
   AuthType Basic
   etc...
</Location>

and you could combine this with a Satisfy directive so that the places you KNOW you're logging in from are explicitly allowed in via IP matching, and leave the password prompt for "everything else".


text:
Q: How to add add third party plugin in angular2 i am new to angularJS2, i want to add datetime picker in one of my forms. so i followed this site for the creation of the datetime picker control. I ran this command

npm install ng2-date-time-picker --save

and i am able to even import the file like this
import { DateTimePickerModule } from 'ng2-date-time-picker';

but when i run the appliaction, i get an error like this

This is the order, how i have linked the file in index.html
<base href="/">
    <title>Policy Intialization</title>
    <meta charset="utf-8" />
    <link href="../../Content/bootstrap.css" rel="stylesheet" />
    <!-- Polyfills for older browsers -->
    <script src="https://unpkg.com/core-js/client/shim.min.js"></script>
    <script src="https://unpkg.com/zone.js@0.7.4?main=browser"></script>
    <script src="https://unpkg.com/systemjs@0.19.39/dist/system.src.js"></script>
    <script src="https://cdn.rawgit.com/angular/angular.io/b3c65a9/public/docs/_examples/_boilerplate/systemjs.config.web.js"></script>
    <script src="systemjs.config.js"></script>
    <script>
        System.import('app').catch(function (err) { console.error(err); });
    </script>

being an .net MVC developer, I am very confused on which path to follow to include a third party plugin. anyone help would be appreciated.
UPDATE 1
This is the plunkr for refrence


text:
Q: different json structure returned for the same call depending on endpoint I created a ticket with SoftLayer support and for some reason they suggested I post here , so here it is. I am using the python client to call the API method list_vlans().
This call returns a different json structure depending on the Softlayer location I am in which cant be correct. (This breaks all of my automation) Specifically when I am on a virtual server in Dallas, I am getting back a response structure that is completely different that when I am in DC or Frankfurt for example.
This makes no sense and I am using the same very simple code defined here:
http://softlayer-api-python-client.readthedocs.org/en/latest/api/managers/network/


text:
Q: Ajax multiple checkboxes displaying dynamic content I am trying to display different content on a webpage which is request by a user via checkboxes.
I have a php sidebar displaying multiple checkboxes.
<label><input id="<?php echo $side_oq['Sidebar_Content']; ?>" type="checkbox"><?php echo $side_oq['Sidebar_Content']; ?></label>

As I am not that familiar with JQuery and Ajax, I did some digging and made a single request work.
Ajax
$(document).ready(function(){
$('#A1').change(function() {
    if($(this).is(':checked')) {
        var check = $(this).attr("id");
         $('.home_textbox_1').load("sideRead.php", {postcheck: check})
    }else{
        $('.home_textbox_1').load("sideRead.php", {postcheck: NULL})
    }
});
});

$(document).ready(function(){
$('#A2').change(function() {
    if($(this).is(':checked')) {
        var check = $(this).attr("id");
         $('.home_textbox_1').load("sideRead.php", {postcheck: check})
    }else{
        //$('.home_textbox_1').load("sideRead.php", {postcheck: 0})
    }
});
});

PHP
//sideRead.php
$side_content_sql="SELECT *
                       FROM Sidebar
                        WHERE Sidebar_Level='".$_POST['postcheck']."'";
$side_content_query = mysqli_query($dbconnect, $side_content_sql);
$side_content_oq = mysqli_fetch_assoc($side_content_query);

*

*Problem

If I uncheck the box nothing happens (as I have not implemented it) but I don't really have an idea how its done.
//edit
If I try to put "NULL" in #A1 nothing changes.
If I pass the else-statement from #A2 the sql-query will be empty and I can catch that and display nothing but there will also be a fatal error

*Problem

If I use the posted ajax code twice and change  $('#A1').change(function(){   to  $('#A2').change(function(){  #A2 "overwrites" #A1 but if both are checked I want to display both
//edit 2
I changed the Ajax code to:
$(document).ready(function(){
$('.sideRead_Level').each(function() {
    $(this).change(function() {
        if($(this).is(':checked')) {
            var check = $(this).attr("id");
             $('.home_textbox_1').load("sideRead.php", {postcheck: check});
        }else{
            $('.home_textbox_1').load("sideRead.php", {postcheck: null});
        }
    });
});
});

Now it is working for every checkbox but the content is still not kept if I mark multiple.
Secondly, the deselection still makes some problems.

*

*If I deselect a checkbox I get a Type Error : document.getElementById(...) is null

*Handling the else-statement is still not working. I get a sql-query like
"FROM Sidebar WHERE Sidebar_Level=''" which results in a "Recoverable fatal error"

If I try to catch the else-statement in php, such as:
if(!is_null($_POST['postcheck']){//do sql}
else{//print nothing}

the complete php script doesn't work anymore.

A: This solution is still not working perfectly concerning what I want to achieve, however, it might help other beginners to get a better understanding of using checkboxes with php, ajax and jquery.
At this point, special thanks to Taplar for your help.
The current toggle menu
$(document).ready(function(){
$('input.sideButton').change(function() {
    var checked = [];
    $("input[name='sideShow']").each(function() {
        $(this).change(function() {
            $("input[name='sideShow']:checked").each(function (){
                checked.push($(this).val());
                $('.home_textbox').load("example.php", {postcheck: checked});
            });
            checked = [];
        });
    });
});
});

In my code there are still some further problems which I guess result from other things, however, if I check the textboxes the array pushed to php looks most of the time like (example):

*

*Array ( [0] => A1 )

*Array ( [0] => A1 [1 ] => A2 [2] => B1 )

The deselection also works most of the time (sometimes random stuff happens, though) except if only one element is selected, eg Array ( [0] => A1 ). The array then never changes into an empty array.
I hope someone can use this or might have further thoughts concerning the topic.


text:
Q: Is there a way to have a template do specific things based on if parameter is a template type and value? I would like to have a helper function or a templated struct do different things if passed a function pointer or a functor, but if I understand the template system correctly, this is not possible, since one is a type and the other is not.
Am I correct on that?  I'd like to keep my API the same if possible, passing it either a functor or function pointer but not incur the cost of storing a pointer if not needed.  E.g.:
template <typename T, void(*fn)(T)>
struct X1
{
  T m_t;

  X(T t) : m_t(t) {}
  void invoke() { fn(m_t); }
};

template <typename T, typename F>
struct X2
{
  T m_t;
  F m_f;

  X(T t, F f) : m_t(t), m_f(f) {}
  void invoke() { m_f(m_t); }
};

So in that case, I'd either like to have these structs sharing the same name, or have helper functions instantiate the appropriate struct with either a functor or a function pointer placed at the same parameter position with the same decorations around the function/functor.
Something like:
void fn(int) {}
auto functor = [](int){};
int h = 3;

auto x1 = make_X(h, fn);
auto x2 = make_X(h, functor);

Where make_X() is the link that I'm looking for.  Ideas?

A: The single responsibility principle says that the optimization around function pointers being stateless, and the rest of your code, should be handled separately.
So, create a stateless functor that calls fn in one part of your code:
template<class Sig, Sig* fn>
auto stateless() {
  return [](auto&&...args)->decltype(auto){
    return fn(decltype(args)(args)...);
  };
}

this is C++14.  In C++11, you just have to write the equivalent of that lambda manually.1
empty base optimization helper makes storing empty instances of types cheap and somewhat easy:
template<class Tag, class T, class=void>
struct ebo {
  ebo( T tin ):t(std::forward<T>(tin)) {}
  T t;
  T& get( Tag ){ return t; }
  T const& get( Tag ) const { return t; }
  ebo(ebo&&)=default;
  ebo(ebo const&)=default;
  ebo&operator=(ebo&&)=default;
  ebo&operator=(ebo const&)=default;
  ebo()=default;
};
template<class Tag, class T>
struct ebo<Tag, T,
  std::enable_if_t<std::is_empty<T>{} && !std::is_final<T>{}>
>:
  T
{
  ebo( T tin ):T(std::forward<T>(tin)) {}
  T& get( Tag ){ return *this; }
  T const& get( Tag ) const { return *this; }
  ebo(ebo&&)=default;
  ebo(ebo const&)=default;
  ebo&operator=(ebo&&)=default;
  ebo&operator=(ebo const&)=default;
  ebo()=default;
};

And implement X with the above:
struct F_tag {};
template <typename T, typename F>
struct X:ebo<F_tag, F>
{
  X(T tin, F fin):
    ebo<F_tag,F>(std::forward<F>(fin)),
    m_t(std::forward<T>(tin))
 {}

  T m_t;
  void invoke() { this->get(F_tag{})(m_t); }
};
template<class T, class F>
X<T,F> make_X( T t, F f ) {
  return {std::forward<T>(t),std::forward<F>(f)};
}

At point of use, this looks like:
void fn(int) {}
auto functor = [](int){};
int h = 3;

auto x1 = make_X(h, stateless<void(int),&fn>());
auto x2 = make_X(h, functor);

zero bytes are used to store either the fn(int) or functor.
I take by value: adding forwarding references is left as an exercise.

1 C++11 version of stateless:
template<class Sig, Sig* fn>
struct stateless_t {
  template<class...Ts>
  auto operator()(Ts&&...ts)const
  -> decltype( fn(std::declval<Ts>()...) )
  { return fn(std::forward<Ts>(ts)...); }
};
template<class Sig, Sig* fn>
stateless_t<Sig, fn> stateless() { return {}; }


text:
Q: ScrollViewer.IsHorizontalRailEnabled="False" or ScrollViewer.IsHorizontalRailEnabled="True" has no effect I am learning xaml and I am at Gridview. I have noticed that when I type in:
<GridView x:Name="Grid1" Grid.Row="1" SelectionMode="None"  Padding="120,0,0,0" RenderTransformOrigin="0.5,0.5" d:LayoutRounding="Auto"
              ScrollViewer.IsHorizontalRailEnabled="False">

or
<GridView x:Name="Grid1" Grid.Row="1" SelectionMode="None"  Padding="120,0,0,0" RenderTransformOrigin="0.5,0.5" d:LayoutRounding="Auto"
              ScrollViewer.IsHorizontalRailEnabled="True">

There is no difference when I run the app. I would like to know if "ScrollViewer.IsHorizontalRailEnabled" really does anything, or am I doing something wrong. Also same for "ScrollViewer.IsVerticalRailEnabled"
I have been to MSDN, the explanation there doesn't help. Thanks.

A: To enable horizontal scroll, you need to do this
<GridView x:Name="Grid1" Grid.Row="1" SelectionMode="None"  Padding="120,0,0,0" RenderTransformOrigin="0.5,0.5" d:LayoutRounding="Auto">
<ScrollViewer HorizontalScrollBarVisibility="Auto" HorizontalScrollMode="Enabled">

<!-- Inside XAML code here -->

</ScrollViewer>
</GridView>

To enable vertical scroll, you need to do this
<GridView x:Name="Grid1" Grid.Row="1" SelectionMode="None"  Padding="120,0,0,0" RenderTransformOrigin="0.5,0.5" d:LayoutRounding="Auto">
<ScrollViewer VerticalScrollBarVisibility="Auto" VerticalScrollMode="Enabled">

<!-- Inside XAML code here -->

</ScrollViewer>
</GridView>

Hope this helps!


text:
Q: Putting margins between Buttons I want to put margins/spacing between each of these four Buttons. I am struggling a bit with the css. The following code does not give me space between each Button. Does anyone know what I need to change?
practice.html

    <input type="button" id="button0" style="color:black; width:100px; height: 50px" />
    <input type="button" id="button1" style="color:black; width:100px; height: 50px"  />
    <input type="button" id="button2" style="color:black; width:100px; height: 50px"  />
    <input type="button" id="button3" style="color:black; width:100px; height: 50px" />

practice.css
.button{
    margin: 20px;
}

A: .button is responsible for class. You should write
button {margin: 20px;}

Thats all :). Remember that button should have display: block or display: inline-block, so the element can render margin property properly.

Example of different CSS selectors:
button {} // <button>
.buttonclass {} // <button class="buttonclass">
#buttonid {} // <button id="buttonid">

A: add class="button" for each button:
<input class="button" type="button" id="button0" style="color:black; width:100px; height: 50px" />

A: .button is a class selector and you have no classes set. button as a selector won't work with the given HTML as the element is input. The correct css would be
input[type="button"]
{
    margin:20px;
}

input[type="button"] {
  color: black;
  width: 100px;
  height: 50px;
  margin: 20px;
}

  <input type="button" id="button0" />

  <input type="button" id="button1" />
  <input type="button" id="button2" />

  <input type="button" id="button3" />

From your comments it sounds like there is another style being applied from somewhere. You may need to make a more specific selector.
Try
div input[type="button"]
{
    margin:20px;
}

Also use Chrome Developer tools or Firebug for Firefox to inspect the buttons to see what styes are being applied to your buttons. Don't forget to flush your cache as well (ctr +f5) as CSS is cached by the browser.
More info on getting started with CSS Selectors


text:
Q: Distinct in sails js and mongodb Model.distinct("Age").done(function(err, ward) {
  if(err)
    return next(err);
  if(!ward)
    return next();
  res.json(ward);
});

After executing this code, it gives the following error:
TypeError: Object [object Object] has no method 'distinct'

But distinct works in robomongo. How can I rectify the error?

A: Currently Walterline (the ORM of sails) dont support distinct()-function.
But you can use the native()-function to get direct access to the native mongo driver:
Modelname.native(function(err,coll){
  coll.distinct("Age", function(err,result){
     res.json(result);
  });
});

See: https://sailsjs.com/documentation/reference/Models/Model-Methods/native.html

A: What you probably need is the ability for the SailsJS ORM (Waterlin) to give you back the native MongoDB collection: http://beta.sailsjs.org/#/documentation/reference/Models/Model-Methods/native.html
Once you've got it you will be able to call native MongoDB queries.
By design, Waterline is meant to be used with several databases while keeping the same code. And currently there is no "disctinct" feature.


text:
Q: Angular + Rails app hang up whole browser when trying to fetch subpage I'm writing application using Angular and Rails. I have fallback in my ApplicationController:
class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :intercept_html_requests

  private

  def intercept_html_requests
    render('pages/index') if request.format == Mime::HTML
  end
end

And router like:
betly.config(function($routeProvider, $locationProvider) {
  $locationProvider.html5Mode(true);

  $routeProvider.when('/', {
    templateUrl: 'assets/tournaments.html',
    controller: 'tournamentController'
  }).when('/aaa', {
    templateUrl: 'assets/tournaments.html',
    controller: 'tournamentController'
  }).when('/matches/:matchId',{
    templateUrl: 'assets/matchDetails.html',
    controller: 'matchController'
  }).otherwise({
    redirectTo:'/'
  });
});

views/layouts/application.html.erb:
<!DOCTYPE html>
<html lang="en" ng-app>
  <head>
    <meta charset='utf-8' />
    <title>BetLy</title>
    <%= stylesheet_link_tag    "application", media: "all" %>
    <%= csrf_meta_tags %>
  </head>
  <body>
    <%= yield %>
    <%= javascript_include_tag "application" %>
  </body>
</html>

And when I'm trying to go to /matches/10 the browser infinitely download assets. Why and how to fix that?

A: Problem was in routes file. When you are trying to catch all routes in your Rails app then you shouldn't add / in route, so it should look like:
match '*any', to: 'controller#method'

instead of
match '/*any', to: 'controller#method'


text:
Q: Mobile Firefox development directly on my (rooted) Android instead of having to repack and reinstall the fennec APK for every little edit? For mobile Firefox development, how can I hack the core javascript directly on my (rooted) Android so I can get instant results instead of having to repack and reinstall the fennec APK for every little edit ?
The problem is that all the files are locked up in the /data/app/org.mozilla.fennec/base.apk, and within that there is another archive (/asses/omni.ja) which can be unzipped to give the javascript. Reconstructing the apk file on device after editing the zip file inside it has proved unworkable, as although the apk file can be unzipped, it does not work when simply zipped back up again.
The goal is just to try things out and learn the workings of Firefox on device and on the go.

A: Android install the app to a directory in /data/app/[package name]
You should be able to find the directory for this browser using the package name.
Then you can edit the javascript files in that folder but you might have to restart the app.


text:
Q: Xcode 12.4 build successful but getting NSCocoaErrorDomain Code: 257 You don't have permission I'm trying to build my react native project using the xcode. Project gets build successfully but its not running on the simulator or on the device.
Whenever i'm trying to build the app i get the below error:
Details

The file "myapp" couldn't be opened because you don't have permission to view it.
Domain: NSCocoaErrorDomain
Code: 257
Failure Reason: You don't have permission.
Recovery Suggestion: To view or change permissions, select the item in the Finder and choose File > Get Info.
User Info: {
NSFilePath = "/Users/myuser/Library/Developer/Xcode/DerivedData/myapp-aylojruwzhsbrrbwomkiwefxqlxv/Build/Products/Debug-iphonesimulator/myapp.app";
}
The operation couldn't be completed. Permission denied
Domain: NSPOSIXErrorDomain
Code: 13
Failure Reason: Permission denied
System Information
macOS Version 10.15.7 (Build 19H512)
Xcode 12.4 (17801) (Build 12D4e)
I have tried to solve this by removing the DerivedData folder and even checking the permission of the folder. Currently all the files in this folder are set to my system user and staff and all the files have permission set to 755.
Also i tried changing the system privacy setting by giving full access to Xcode but still i'm facing the same issue.
Can anyone help me on this?

A: I had this issue as well. For me I had accidentally changed the Executable file property in info.plist rather than changing the Bundle display name property. Fixing this fixed the error for me.


text:
Q: JSON array is converting to a generic list, but not converting to a generic collection. Why? I am sending a Json Array from the client web application to asp.net webapi.
For example,
{
    "SurveyId":3423,
    "CreatorId":4235,
    "GlobalAppId":34,
    "AssociateList":[
        {"AssociateId":4234},
        {"AssociateId":43},
        {"AssociateId":23423},
        {"AssociateId":432}
    ],
    "IsModelDirty":false,
    "SaveMode":null
}

Here Associate List is a JSON Array,
Usually it will automatically serialize to a List<> object.
Using the below code ,i am posting the response to the WebApi
public IEnumerable<Associate> Post(ResponseStatus responseStatus)
{
   return this.responsestatusrepository.ResponseStatusCheck(responseStatus);
}

The ResponseStatus class is shown below.
public class ResponseStatus : AppBaseModel
{
        public int SurveyId { get; set; }
        public int CreatorId { get; set; }
        public int GlobalAppId { get; set; }
        public List<Associate> AssociateList { get; set; }
}

I have changed the List<> to Collection<> as a part of my code analysis correction.
ie, public Collection<Associate> AssociateList { get; set; }
But it is always getting a null value when we are using collection instead of List. Is there any specific reason for this?

A: Ok, I think I will have to answer this in an indirect way.
What you are passing on to the server is an array of objects (in JSON format), but once you start processing this in C# the array of objects is now treated as a single c# object. Inside this object, your model expects one of the fields to be a Collection of Associate.
Right, when I work with JSON data similar to whats mentioned in this case - I prefer to use Newtonsofts' JOject.
So here is how I made the C# object with the JSON data you provided:
Used your model:
public class ResponseStatus
{
    public int SurveyId { get; set; }
    public int CreatorId { get; set; }
    public int GlobalAppId { get; set; }
    public Collection<Associate> AssociateList { get; set; }
}

public class Associate
{
    public int AssociateId { get; set; }
}

Made a routine which takes string (the JSON data), and returns an object of type ResponseStatus:
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;

---------------------------------------------------------------------

public static ResponseStatus GetResponseStatusObject(string jsonData)
{
    JObject jObject = JObject.Parse(jsonData);
    return jObject.ToObject<ResponseStatus>();
}

Now when I call this method and pass on the exact same JSON data which you provided, I get this:

This might not directly solve your problem, but hopefully guide you in the right direction in understanding array/object serialization when working with JavaScript/C#.
Best of luck!


text:
Q: iOS: Why is the outlined location services icon still showing after stopping monitoring for regions? I am testing on an iPad 3rd gen on iOS 7.1 since I have no other iOS device for the moment.
The first time I run my app, it starts monitoring for several regions. The status bar and the Location Services settings page are showing the outlined location services icon (my app is the only one in the list that has the outlined icon). When I kill my app, the icon is still showing on both places since I do not stop monitoring the regions yet. Until then everything is fine.
My problem is when I run my app for a second time, I stop monitoring for all monitored regions, but the location services outlined icon does not disappear on the status bar and the Location Services settings page...
Here is my code called at the first run :
- (void) getLocationManagerInstance {
    if (!self.locationManager) {
        self.locationManager = [CLLocationManager new];
    }
    self.locationManager.delegate = self;
}

- (void) startLocationGathering {
    if(self.shouldUpdateGPSLocations) {
        [self.locationManager startMonitoringSignificantLocationChanges];
    }
}

- (void) startMonitoringBeaconRegions {
    if(self.rootRegion) {
        [self.locationManager startMonitoringForRegion:self.rootRegion];
    }
    if (self.beaconRegions && self.beaconRegions.count < 20) {
        [self.beaconRegions enumerateObjectsUsingBlock:^(CLBeaconRegion* region, NSUInteger idx, BOOL *stop) {
            [self.locationManager startMonitoringForRegion:region];
        }];
    }
}

- (void) startMonitoringCircularRegions {
    if (self.gpsRegions && self.gpsRegions.count) {
        [self.gpsRegions enumerateObjectsUsingBlock:^(CLCircularRegion* region, NSUInteger idx, BOOL *stop) {
            [self.locationManager startMonitoringForRegion:region];
        }];
    }
}

And my code called at the second run :
- (void) getLocationManagerInstance {
    if (!self.locationManager) {
        self.locationManager = [CLLocationManager new];
    }
    self.locationManager.delegate = self;
}
- (void) locationManagerCleanup {
    [AWRUtils dlog:@"locationManagerCleanup"];
    NSArray* monitoredRegions = [self.locationManager monitoredRegions].allObjects;
    for (CLRegion* r in monitoredRegions) {
        [self.locationManager stopMonitoringForRegion:r];
    }
    NSArray* rangedRegions = [self.locationManager rangedRegions].allObjects;
    for (CLBeaconRegion* r in rangedRegions) {
        [self.locationManager stopRangingBeaconsInRegion:r];
    }
    [self.locationManager stopUpdatingLocation];
    [self.locationManager stopMonitoringSignificantLocationChanges];
}

If I uninstall my app, the outlined location services icon disappear. But why is the icon not disappearing when I stop monitoring the monitored regions?

EDIT: After more testing, I found that the instance of the CLLocationManager that I have on the second run has no monitored regions ([self.locationManager monitoredRegions] returns nil)...

EDIT 2: I also found that if, on the second run, I start monitoring all the same regions that started monitoring on the first run AND THEN I stop monitoring them, the outlined location services icon disappear. Is this a normal behavior? I read nothing about that in all my internet researches...


text:
Q: on key-up text field to search database, then retrieve data on other text field Please help me! I want to live search (on key-up) by enter customer phone number then it will retrieve customer name and email from database.Here my example form
<html>
<head>
<script type="text/javascript">

      $(function(){
          $(".cust_phone").keyup(function() {
          var cust_name = $(this).val();
          var cust_email = $(this).val();
          var dataString = 'cust_phone='+cust_name+cust_email;
          if(cust_name!='' && cust_email!='') {
            $.ajax({
              type: "POST",
              url: "customer_info.php",
              data: dataString,
              cache: false,
              success: function(html) {
                var data = html.split['|'];
                var cust_phone = data[0];
                var cust_name = data[1];
                var cust_email = data[2];
                $("#cust_phone").val(cust_phone);
                $("#cust_name").val(cust_name);
                $("#cust_email").val(cust_email);
              }
            });
          }
          return false;
        });

</script>
</head>

<body>

  <input type="text" name="cust_phone" id="cust_phone">
  <input type="text" name="cust_name" id="cust_name">
  <input type="text" name="cust_email" id="cust_email">

</body>
</html>

This is first file (cutomer_form.php)
<?php

$cust_phone= $_POST['cust_phone'];

$query = mysql_query("SELECT DISTINCT cust_phone
  FROM rent WHERE cust_phone LIKE '$search'");

// $result = mysql_query("SELECT DISTINCT cust_phone
//   FROM rent WHERE cust_phone = '$search'");

$data = mysql_fetch_assoc($query);

$cust_name = $data['cust_name'];
$cust_phone = $data['cust_phone'];
$cust_email = $data['cust_email'];

echo $cust_phone .'|'. $cust_name.'|'.$cust_email;

?>

This is second file (customer_info.php)


text:
Q: Generating a combobox list based on a selection from another combobox C# (linked by Databases) I am creating a Booking system for a Univeristy project using C# and WPF. I have completed a great majority of the project and now have a fully working update, delete and create new button for customers, bookings and guests. I store all data about Customers, Bookings and Guests within their own respective classes and in turn they then get saved to a database through a Connection Superclass.
Everything was working however, I started to implement Foreign keys into my database as to link the data together (and it works) but now my project is starting to look a little bit messy...
When creating a new booking, you must also choose a CustomerID from a ComboBox (cmbCustomerList), this allows the CustomerID_FK to be added to the same instance of BookingID. If you wish to edit the booking then you must select not only the cmbCustomerList but also the cmbBookingsList, however, if you try to update a BookingID with a new CustomerID_FK it throws an error, it also makes the program look messy as the Bookings ComboBox will show every booking no matter what CustomerID you chose. Does anyone know any way to make it so that when a CustomerID is selected from cmbCustomerList, it also only displays the BookingID's that have the same CustomerID_FK within cmbBookingsList?
Here is a copy of my Bookings window, I won't include my Bookings class because it's a simple collection of Get/Set methods, the main work is done within the NewBookings window and the Connection Class
NewBookings.xaml.cs
//Refresh the items in cmbBookingsList
    public void BookingsRefresh()
    {
        cmbBookingsList.ItemsSource = con.RefreshBookingsList();
    }

//Refresh the items in cmbCustomerList
    public void CustomerRefresh()
    {
        cmbCustomerList.ItemsSource = con.RefreshCustomerList();
    }

Connections.cs
//show customer information in the list
    public List<CustomerClass> RefreshCustomerList()
    {
        List<CustomerClass> CustomerList = new List<CustomerClass>();

        try
        {
            command.CommandText = "SELECT * FROM Customers";
            command.CommandType = CommandType.Text;
            connection.Open();

            OleDbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                CustomerClass c = new CustomerClass();

                c.Customer_ID = Convert.ToInt16(reader["CustomerID"].ToString());
                c.Customer_FirstName = reader["FirstName"].ToString();
                c.Customer_Surname = reader["Surname"].ToString();
                c.Address_Line1 = reader["AddressLine1"].ToString();
                c.Address_Line2 = reader["AddressLine2"].ToString();
                c.City = reader["City"].ToString();
                c.Country = reader["Country"].ToString();

                CustomerList.Add(c);
            }
            return CustomerList;
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            if (connection != null)
            {
                connection.Close();
            }
        }
    }

public List<BookingsClass> RefreshBookingsList()
    {
        List<BookingsClass> BookingsList = new List<BookingsClass>();

        try
        {
            command.CommandText = "SELECT BookingID, CheckIn, CheckOut, Dinner, Breakfast, CarHire, Diet FROM Bookings";
            command.CommandType = CommandType.Text;
            connection.Open();

            OleDbDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                BookingsClass b = new BookingsClass();

                b.Booking_ID = Convert.ToInt16(reader["BookingID"].ToString());
                b.Arrival_Date = reader["CheckIn"].ToString();
                b.Departure_Date = reader["CheckOut"].ToString();
                b.Dinner = Convert.ToBoolean(reader["Dinner"]);
                b.Breakfast = Convert.ToBoolean(reader["Breakfast"]);
                b.CarHire = Convert.ToBoolean(reader["CarHire"]);
                b.DietaryReq = reader["Diet"].ToString();

                BookingsList.Add(b);
            }
            return BookingsList;
        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            if (connection != null)
            {
                connection.Close();
            }
        }
    }

I'm sorry if this question is a bit broad or a bit complicated. I would much rather you left a comment telling me it isn't a good question rather than down voting, that way I will improve it and make it easier to understand

A: I think the main issue you're having is that your trying to build a Winforms app in WPF
if you switch to an MVVM structure it becomes much easier
then you would have your Combos bound to a DataField on your ViewModel
the view model would then update itself as required and the bindings will automatically update your view
here is a quick and dirty example
XAML
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApplication1"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <local:BookingVM x:Key="vm"/>
    </Window.Resources>
    <StackPanel DataContext="{Binding Mode=OneWay, Source={StaticResource vm}}">
        <ComboBox ItemsSource="{Binding Types}" SelectedItem="{Binding Type}" DisplayMemberPath="Name"/>
        <ComboBox ItemsSource="{Binding Customers}" SelectedItem="{Binding Customer}" DisplayMemberPath="Name"/>
        <Button Command="{Binding Save, Mode=OneWay}">Save</Button>
    </StackPanel>
</Window>

Code (note using Prism and c# 6.0)
as i don't have your database to work with i'll create some example models that will do for demo purposes
public class CustomerModel
{
    public int ID { get; set; }
    public string Name { get; set; }
    public int[] BoodkingType { get; set; }
}
public class BoodkingTypeModel
{
    public int ID { get; set; }
    public string Name { get; set; }
}

public static class DummyDatabase
{
    public static IEnumerable<BoodkingTypeModel> BoodkingTypes { get; } = new BoodkingTypeModel[]
    {
        new BoodkingTypeModel { ID=1, Name="Type1"  },
        new BoodkingTypeModel { ID=2, Name="Type2"  },
        new BoodkingTypeModel { ID=3, Name="Type3"  },
        new BoodkingTypeModel { ID=4, Name="Type4"  },
    };
    public static IEnumerable<CustomerModel> Customers { get; } = new CustomerModel[]
    {
        new CustomerModel { ID=1, Name="Customer1" ,BoodkingType= new int[]{ 1,2,3,4 } },
        new CustomerModel { ID=1, Name="Customer2" ,BoodkingType= new int[]{ 1,2 } },
        new CustomerModel { ID=1, Name="Customer3" ,BoodkingType= new int[]{ 3,4 } },
        new CustomerModel { ID=1, Name="Customer4" ,BoodkingType= new int[]{ 1 } },
    };

}

now this is the clever part the VM, that actually does all the work
public class BookingVM : BindableBase
{
    public BookingVM()
    {
        //Command binding in this situation is better than EventHandling as it allows you to specify requirements as well as actions
        //in this case that you can't save unless Type and Customer have been set
        Save = new DelegateCommand(
            () => Console.WriteLine("Save Clicked"), //ExecuteAction
            () => Type != null && Customer!=null //CanExecute
            );
    }
    private BoodkingTypeModel _Type;

    public BoodkingTypeModel Type
    {
        get { return _Type; }
        //this is triggered both when you change the values in the View via binding, and when you set the values via code meaning that you have a single point of entry so you don't need to check every place you alter the calue to be sure that its updates the control, also this value can be bound to no controls or 500 it doesn't matter its all handled automatically plus everything is now type safe very hard to do with generic controls
        set
        {
            if(SetProperty(ref _Type, value))
            {
                Save.RaiseCanExecuteChanged();
                OnPropertyChanged(nameof(Customers));//instruct all bindings on customers to refresh
            }
        }
    }

    public IEnumerable<BoodkingTypeModel> Types
    {
        get { return DummyDatabase.BoodkingTypes; }
    }

    private CustomerModel _Customer;

    public CustomerModel Customer
    {
        get { return _Customer; }
        set
        {
            if (SetProperty(ref _Customer, value))//SetProperty changes the property if the value has change and raises the event that updates binding
            {
                Save.RaiseCanExecuteChanged();//refresh command state
            }
        }
    }

    public IEnumerable<CustomerModel> Customers
    {
        get
        {
            return from c in DummyDatabase.Customers
                   where Type == null || c.BoodkingType.Contains(Type.ID)
                   //the where clause is the link using the selected type to filter your customers
                   select c;
        }
    }
    public DelegateCommand Save { get;  }
}

the code in Prism, simplifies some of the more annoying tasks you have to do for every single class, so i highly recomend it however you could also write your own versions for very little effort
code for BindableBase can be seen here the actual code is only about a dozen lines


text:
Q: how to use Ajax success function store data in database?Django I want to get data(user) from dropdown by using Ajax success function. I want when clicking 'add member',it will show username under the button,and also the username will stay when refreshing the page.
{% block script %}
    var url = $( '#selection-button' ).attr( 'action' );
    $("#selection-button").on('click', function(e) {
        e.preventDefault();
        var value =$('#member_list').val();
        $.ajax({
            type:'POST',
            url: '{% url 'project:project_add_member' project_id=project_id %}',
            data: { user_id:value },
            success:function (result) {
                $("#res").append(value);
            },
            error:function (result) {
              alert('error');
              console.info(data);
            }
        });
    });

{%  endblock %}

A: Just a trick: Firstly, display the username as a result of an Ajax call like you did in a div area. Secondly, you actually have a tag for the username in this area , example: {{username}}.
At first it's always empty as there is no data in you db (nothing to show), but just after you fill the data, first it will bring the ajax result there, which is temporary but it will go on showing the same data upon your refresh as you always call it via the tag I wrote above.
You can get this {{username}} tag via your view. Hope you know how to call it from DB.