text:
Q: Error starting up angular server I have the following server.js file:
var express = require('express'),
    api     = require('./api'),
    app     = express();

app
    .use(express.static('./public'))
    .use('./api', api)
    .get('*', function (req, res) {
        res.sendfile('public/main.html');
    })
    .listen(3000);

and the server.js file is located in C:\Users\myName\Desktop\prodfixes\server.js and main.html is located in C:\Users\myName\Desktop\prodfixes\public\main.html
and going to http://localhost:3000/ doesn't throw an error on screen however on the command line (I am using nodemon server.js to run the server) I am getting the error: express deprecated res.sendfile: Use res.sendFile instead. So then I obviously changed res.sendfile to res.sendFile but then I get an error when i refresh the screen:

TypeError: path must be absolute or specify root to res.sendFile
   at ServerResponse.sendFile (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\response.js:394:11)
   at C:\Users\myName\Desktop\prodfixes\server.js:9:7
   at Layer.handle [as handle_request] (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\layer.js:95:5)
   at next (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\route.js:131:13)
   at Route.dispatch (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\route.js:112:3)
   at Layer.handle [as handle_request] (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\layer.js:95:5)
   at C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\index.js:277:22
   at param (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\index.js:349:14)
   at param (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\index.js:365:14)
   at Function.process_params (C:\Users\myName\Desktop\prodfixes\node_modules\express\lib\router\index.js:410:3)

Sorry I am new to angular and using servers so any help would be greatly appreciated. Thanks.

A: Using path.resolve should resolve this issue in a cross-platform compatible way:
var express = require('express'),
    path = require('path'),
    api = require('./api'),
    app = express();

app
    .use(express.static('./public'))
    .use('./api', api)
    .get('*', function (req, res) {
        res.sendFile(path.resolve('public/main.html'));
    })
    .listen(3000);

path.resolve will provide the absolute path to the file which will satisfy the requirements for the res.sendFile() function:

Unless the root option is set in the options object, path must be an
  absolute path of the file.

http://expressjs.com/api.html

A: I agree with S. Buda... definitely seems like you have the wrong path. The error specifies "TypeError: path must be absolute or specify root to res.sendFile at ServerResponse.sendFile" - try using the full path instead of the relative path. C:\Users\myName\Desktop\prodfixes\public\main.html instead of just public/main.html.


text:
Q: почему-то не работают стили для main работают стили для других классов, но для main не работает

.main{
    background-color: brown;
    height: 200px;
    width: 100%;
    z-index:1;
}
<!DOCTYPE html>

    <link rel="stylesheet" href="pages/index.css">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Domstroy</title>

в DevTools нашел возможную проблему,а именно вместо стиле написано Inherited from body

redpajama_set_name: RedPajamaStackExchange


text:
Q: paramiko object method exec_command doesn't execute shell script this is 3rd hour of me knowing the existence of something which is called paramiko.
my requirement: run a py script on windows that connects to remote linux server, executes a shell script there and take output of whatever shell script prints and return to python script and print it on python windows terminal.
I am able to connect through ssh. Opening channel and session both working.
Issue: SshObj.exec_command doesn't work for some commands or scripts.
However, I tried with normal "ls" command. same SshObj.exec_command call is working fine.
below is snippet:
>>> ssh = paramiko.SSHClient()
>>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> ssh.connect(IP,22,usname,pswd)
>>> stdin, stdout, stderr = ssh.exec_command('/home/scripts/a.sh')
>>> stdout.channel.recv_ready()
False
>>> stdout.channel.recv_ready()
False
>>> stdin, stdout, stderr = ssh.exec_command('/home/scripts/a.sh')
>>> stdin, stdout, stderr = ssh.exec_command('ls')
>>> stdout.channel.recv_ready()
True


text:
Q: OpenGL - Rotating a 2D Asteroids Ship So I've been googling this out the wazoo and going through all sorts of resources - texts, lectures, etc. - but I'm either missing something or just not grasping it correctly. For a class in OpenGL we need to design an Asteroids game, which seems like a simple enough concept, but I'm finding it very difficult to get the movement of my ship down right. I know that we need to translate our ship to the origin, perform the rotation, and translate it back to its appropriate position - the problem I'm facing is understanding the execution of it. The code I have for drawing a ship is this so far:
void
drawShip(Ship *s)
{
    glClear(GL_COLOR_BUFFER_BIT);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glPushMatrix();
    myTranslate2D(s->x, s->y);
    float x = s->x, y = s->y;
    myRotate2D(s->phi);
    glBegin(GL_LINE_LOOP);
    glVertex2f(s->x + s->dx, s->y + s->dy + 3);
    glVertex2f(s->x + s->dx-2, s->y + s->dy - 3);
    glVertex2f(s->x + s->dx, s->y + s->dy -1.5);
    glVertex2f(s->x + s->dx + 2, s->y + s->dy - 3);
    glEnd();
    myTranslate2D(s->x - x, s->y - y);
    glPopMatrix();
}

With rotation and motion determined by the following variables, which are correctly modified in a Keyboard function:
if (left == 1)
    {
        ship.phi -= 0.3;
    }
    if (right == 1)
    {
        ship.phi += 0.3;
    }
    if (up == 1)
    {
        ship.dx += -2.0*sin(ship.phi);
        ship.dy += 2.0*cos(ship.phi);
    }
    if (down == 1)
    {
        ship.dx += 2.0*sin(ship.phi);
        ship.dy += -2.0*cos(ship.phi);
    }
    drawShip(&ship);

Once I get the rotation down, I'm confident that I can get the rest of everything done. As it is, the above code will allow my object to either rotate on the origin or around it, but it will not rotate in place unless it is directly on the origin. The ship itself has been initialized to points of (0,0), (25, 25), and (50, 50), and for my purposes the origin of the screen (0,0) is the bottom left corner.
Can someone help me understand why my ship will not rotate in place, and only about the origin? I expect that it has something to do with how I'm performing my translations and rotation, but I'm at a loss as to what.

A: Your draw function seems wrong.
Your ship design shouldn't depend on it's position. What this means is that the coordinates of the vertices should always be the same. Then use GlTranslate and Rotate to get it into the right position. You also do a translate after you draw and before you pop the matrix. That doesn't do anything because matrix changes only apply to vertices defined after the matrix change.
The structure should be something like this:
// Make sure the origin is in the 0, 0  of your space.
GlPushMatrix();  // Save this setup
GlTranslate(ship.x, ship.y);  // Location of the ship.
GlRotate(ship.phi);  // Or whatever is the name of the angle of the ship.

DrawShip();  // Draws the sprite/wireframe/object you want.
GlPopMatrix();  // Return to the original setup.

A: Alright I actually figured it out with some poking. The problem was that I've been drawing the changes in velocity directly from the draw, instead of calculating the new position based on velocity and translating as such. Here's the fixed code:
    glClear(GL_COLOR_BUFFER_BIT);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glPushMatrix();
    float newX = s->x + s->dx, newY = s->y + s->dy;
    myTranslate2D(newX, newY);
    myRotate2D(s->phi);
    glBegin(GL_LINE_LOOP);
    glVertex2f(s->x, s->y + 3);
    glVertex2f(s->x - 2, s->y - 3);
    glVertex2f(s->x, s->y - 1.5);
    glVertex2f(s->x + 2, s->y - 3);
    glEnd();
    glPopMatrix();


text:
Q: ruby faye server with scala client I have a Faye server running with ruby, and now, I need to send notifications to a client in Scala, but scala can't handle Bayeux, only WebSockets.
Is there a way to change my connection type from Bayeux to using websockets?
Some conf. files I have
faye.ru
require 'faye'

Faye::WebSocket.load_adapter('thin')

bayeux = Faye::RackAdapter.new(:mount => '/faye', :timeout => 25)
run bayeux

sending notifications
 def broadcast(channel, data)
    message = {:channel => channel, :data => data, :ext => {:auth_token => FAYE_TOKEN}}
    uri = URI.parse("http://192.168.0.92:9292/faye")
    Net::HTTP.post_form(uri, :message => message.to_json)
  end

A: We migrate our scala app to ruby. Much better now :)


text:
Q: ADFS ADAL current user windows service I'm trying to authenticate a Windows Service (so non interactive) against an (ASP.net) Web API, using ADFS 3.0 and the current user's credentials.
Is this possible, and if so is the approach below correct?
When running as a console app I can successfully get (JWT) tokens using the AcquireTokenAsync overloads that display a login screen, which then automatically logins in as the current user and disappears without interaction. That obviously isn't appropriate for a Windows Service though (and throws an error about displaying UI in non interactive mode).
We get the following error in the ADFS servers Windows Log:
Encountered error during federation passive request.

Microsoft.IdentityServer.RequestFailedException: MSIS7065: There are no registered protocol handlers on path /adfs/oauth2/token to process the incoming request.
   at Microsoft.IdentityServer.Web.PassiveProtocolListener.OnGetContext(WrappedHttpListenerContext context)

This is from a POST to /adfs/oauth2/token HTTP/1.1:
resource=https%3A%2F%2Fadfs-server%2Fapi_name&client_id=983EB4F7-A4D1-4897-A2BD-5D6C268A5813&scope=opened

Which results in an HTML document saying an error has occurred.
Generated by the following code:
var authenticationContext = new AuthenticationContext("https://adfs-server/adfs", validateAuthority: false); //validate authority can only be true with Azure AD
var tokenResult = await authenticationContext.AcquireTokenAsync("https://adfs-server/api_name", "983EB4F7-A4D1-4897-A2BD-5D6C268A5813", new UserCredential()); //use current login -- this line fails
request.Headers.Add("Authorization", tokenResult.CreateAuthorizationHeader());

The versions we are using are:

*

*ADAL.net (Microsoft.IdentityModel.Clients.ActiveDirectory) 3.13.9

*ADFS 3.0 (Windows Server 2012 R2)

*.net Framework 4.6.2

*Windows 10 (Creators Update - 1703)

A: ADFS 3.0 only supports Authorisation Code Grant with web API as per this article.
Have a look at that and post any questions.


text:
Q: Insert or Update error due to Foreign Key CREATE TABLE `blog` (
  `id` int(11) NOT NULL,
  `userid` int(20) NOT NULL,
  `Heading` varchar(50) NOT NULL,
  `image` varchar(225) NOT NULL,
  `content` varchar(2000) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `carousel` (
  `id` int(11) NOT NULL,
  `userid` int(225) NOT NULL,
  `image` varchar(225) NOT NULL,
  `title` varchar(225) NOT NULL,
  `imageby` varchar(225) NOT NULL,
  `checked` tinyint(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE `user` (
  `id` int(11) NOT NULL,
  `fname` varchar(30) NOT NULL,
  `lname` varchar(30) NOT NULL,
  `emailid` varchar(30) NOT NULL,
  `password` varchar(50) NOT NULL,
  `comment` varchar(2000) NOT NULL,
  `reset_link_token` varchar(200) NOT NULL,
  `exp_date` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE `blog`
  ADD PRIMARY KEY (`id`),
  ADD KEY `userid` (`userid`);

ALTER TABLE `carousel`
  ADD PRIMARY KEY (`id`),
  ADD KEY `userid` (`userid`);

ALTER TABLE `user`
  ADD PRIMARY KEY (`id`) USING BTREE;

ALTER TABLE `blog`
  ADD CONSTRAINT `blog_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `user` (`id`),
  ADD CONSTRAINT `blog_ibfk_2` FOREIGN KEY (`userid`) REFERENCES `user` (`id`),
  ADD CONSTRAINT `blog_ibfk_3` FOREIGN KEY (`userid`) REFERENCES `user` (`id`);

ALTER TABLE `carousel`
  ADD CONSTRAINT `carousel_ibfk_1` FOREIGN KEY (`userid`) REFERENCES `user` (`id`);

My question now is that when i am updating or inserting the boolean value in the table 'carousel' and 'column', it is showing the error written below

Cannot add or update a child row: a foreign key constraint fails
(bloggin.carousel, CONSTRAINT carousel_ibfk_1 FOREIGN KEY
(userid) REFERENCES user (id))


text:
Q: How to change my total input value at the same time as my item input values change I am having trouble getting my grandTotal value to update at the same time as my item input values change. The grandTotal updates only when I add another item to the cart. How do I get my grandTotal  to update without adding an item? I've tried putting my grandTotal variable in the quantity change event block but the total only adds and not subtracts every time the qty changes. I've also tried switching the event listener to 'change' instead of 'click but still have the same problem.

     let grandTotal = 0;
  let addBtn;
  let subBtn;
  let cartElements;
  let parsed;
  for(let i = 0; i < cartElement.length; i++){
    cartElements = cartElement[i];
    quantities = qtyElement[i];
    prices = priceElement[i];
    addBtn = addBtns[i];
    subBtn = subBtns[i];
    parsed = parseFloat(prices.value);
    grandTotal += parsed;
  }
  cartElements.addEventListener('click', function(e) {
      let buttonClicked = e.target;
      if(buttonClicked.innerText === "+"){
        quantities.value++;
        prices.value = quantities.value * price;
      } if(buttonClicked.innerText === "-"){
        quantities.value--;
        prices.value = quantities.value * price;
      }
    });
  grandTotalInput.value = grandTotal;
 }
<form class="cart-form">

shopping cart

  </form>
<form id="totalContainer">

</form>

  <input name="grandTotalInput" id="grandTotalInput" type="number" disabled="">

A: You would need to update the grandtotal inside this function :

quantities.addEventListener('click', function(){
    let qty = parseFloat(quantities.value);
    prices.value = qty * price;
});


text:
Q: need help for eclipse mysql 5.1 connectivity i have downloaded MySQL Server 5.1 and MySQL Connector J.
I added jar file in java build.
opened the data source explorer and created a new MySQL connection profile.url is jdbc:mysql://localhost:3306/test. test is my database in mysql.
when i click on test connection i am getting this error:
java.sql.SQLException: Access denied for user 'swathi'@'localhost' (using password: YES)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:927)
    at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4689)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1304)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2486)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2519)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2304)
    at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:834)
    at com.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:346)
    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.createConnection(JDBCConnection.java:214)
    at org.eclipse.datatools.connectivity.DriverConnectionBase.internalCreateConnection(DriverConnectionBase.java:105)
    at org.eclipse.datatools.connectivity.DriverConnectionBase.open(DriverConnectionBase.java:54)
    at org.eclipse.datatools.connectivity.drivers.jdbc.JDBCConnection.open(JDBCConnection.java:73)
    at org.eclipse.datatools.enablement.internal.mysql.connection.JDBCMySQLConnectionFactory.createConnection(JDBCMySQLConnectionFactory.java:28)
    at org.eclipse.datatools.connectivity.internal.ConnectionFactoryProvider.createConnection(ConnectionFactoryProvider.java:83)
    at org.eclipse.datatools.connectivity.internal.ConnectionProfile.createConnection(ConnectionProfile.java:359)
    at org.eclipse.datatools.connectivity.ui.PingJob.createTestConnection(PingJob.java:76)
    at org.eclipse.datatools.connectivity.ui.PingJob.run(PingJob.java:59)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Please help

A: Are you sure the username and password provided are correct? Try Using the connection string:
jdbc:mysql://localhost:3306/test/?user=<your_username>&password=<your_password>

A: I have found answer to my question.It was a username password issue.I was using a wrong username.On mysql command line i wrote the query "select * from mysql.user" and i got to know about my username.When i put correct username in the connection profile i was able to establish the connection successfully.


text:
Q: GridView only shows first row i have a gridview to show images with button, but i have a problem, it only shows the first row, and i send it data for 3 rows..
This is my layout code:
<?xml version="1.0" encoding="utf-8"?><!-- To make screen scroll in vertical direction -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:bootstrapthumbnail="http://schemas.android.com/apk/res-auto"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    android:background="@drawable/fondodroid2"
    android:orientation="vertical">

    <!-- Main layout -->

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:id="@+id/scrollView">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#fefdff"
                android:layout_marginLeft="@dimen/login_activity_horizontal_margin"
                android:layout_marginRight="@dimen/login_activity_horizontal_margin"
                android:layout_marginTop="@dimen/login_activity_vertical_margin"
                android:padding="@dimen/login_activity_horizontal_margin"
                android:id="@+id/linearLayout">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:baselineAligned="true"
                    android:paddingTop="0dp"
                    android:paddingBottom="0dp"
                    android:layout_marginBottom="@dimen/login_activity_vertical_margin"
                    android:weightSum="1">

                    <ImageView
                        android:layout_width="@dimen/login_activity_logo"
                        android:layout_height="@dimen/login_activity_logo"
                        android:id="@+id/imageView"
                        android:src="@drawable/logo"
                        android:contentDescription="Icon GG"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentTop="true" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:text="@string/files"
                        android:id="@+id/textView"
                        android:textSize="@dimen/login_activity_text"
                        android:textColor="@android:color/black"
                        android:textStyle="bold"
                        android:layout_marginTop="10dp"
                        android:layout_alignParentTop="true"
                        android:layout_toRightOf="@+id/imageView"
                        android:layout_marginLeft="10dp" />

                </RelativeLayout>

                <RelativeLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center"
                    android:id="@+id/relativeLayout">

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="fill_parent"
                        android:layout_centerInParent="true"
                        android:background="#686868"
                        android:gravity="center">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textColor="@android:color/white"
                            android:text="@string/sign_string"
                            android:textSize="@dimen/login_activity_vertical_margin"
                            android:textStyle="bold" />
                    </LinearLayout>

                </RelativeLayout>

                <RelativeLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center">

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:gravity="center"
                        android:id="@+id/linearSign"
                        android:layout_centerInParent="true"
                        android:background="#cccccc"
                        android:visibility="gone">

                        <ImageView
                            android:id="@+id/sign_thumb"
                            android:layout_width="150dp"
                            android:layout_height="150dp"
                            android:layout_margin="3dp"></ImageView>

                        <LinearLayout
                            android:orientation="horizontal"
                            android:layout_width="150dp"
                            android:layout_height="wrap_content"
                            android:layout_below="@+id/sign_thumb"
                            android:layout_alignEnd="@+id/sign_thumb">

                            <Button
                                android:layout_width="match_parent"
                                android:layout_height="wrap_content"
                                android:text="Eliminar"
                                android:id="@+id/deleteButton"
                                android:background="#cc6b67"
                                android:textStyle="bold"
                                android:layout_marginBottom="8dp" />
                        </LinearLayout>

                    </LinearLayout>
                </RelativeLayout>

                <RelativeLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center"
                    android:id="@+id/relativeLayout2"
                    android:layout_marginTop="16dp">

                    <LinearLayout
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="fill_parent"
                        android:layout_centerInParent="true"
                        android:background="#686868"
                        android:gravity="center">

                        <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:textColor="@android:color/white"
                            android:text="@string/images"
                            android:textSize="@dimen/login_activity_vertical_margin"
                            android:textStyle="bold" />
                    </LinearLayout>
                </RelativeLayout>

                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:id="@+id/linearLayout2">

                    <GridView
                        android:layout_width="wrap_content"
                        android:layout_height="fill_parent"
                        android:id="@+id/gridImages"
                        android:numColumns="2"
                        android:layerType="hardware"
                        android:verticalSpacing="1dp"
                        android:horizontalSpacing="1dp" />
                </LinearLayout>

            </LinearLayout>

            <ImageView
                android:layout_width="@dimen/login_activity_logo_h"
                android:layout_height="@dimen/login_activity_logo_v"
                android:id="@+id/imageView2"
                android:src="@drawable/logo"
                android:layout_below="@+id/linearLayout"
                android:layout_alignRight="@+id/linearLayout"
                android:layout_marginTop="@dimen/login_activity_vertical_margin"
                android:layout_marginBottom="@dimen/login_activity_vertical_margin"
                android:contentDescription="@string/logo" />

        </RelativeLayout>
    </ScrollView>

</LinearLayout>

In the adapter i dont have any strangle, but if you need i copy it here..I try with fill_parent wrap_content etc but nothing works..
Edit: the adapter code:
public class GridAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Activity activity;
    private List<String> images = new ArrayList<String>();
    private OnDeleteItem mListener;

    public interface OnDeleteItem {
        public void onDeleteItemClick(String path);
    }

    public GridAdapter(Activity inyectActivity, List<String> listImages) {
        activity = inyectActivity;
        images = listImages;
        inflater = LayoutInflater.from(activity);
        mListener = (ReviewFilesActivity) activity;

    }

    public void notifyDataSetChanged(List<String> dataImages) {
        images = dataImages;
        super.notifyDataSetChanged();
    }

    public View getView(final int position, View convertView, ViewGroup parent) {
        GridViewHolder vHolder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.grid_view, null);
            vHolder = new GridViewHolder(convertView, mListener);
            vHolder.image.setImageBitmap(ImagesUtilities.decodeSampledBitmapFromResource(images.get(position), 400, 400));
            vHolder.path = images.get(position);
            vHolder.delete.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mListener.onDeleteItemClick(images.get(position));
                }
            });
        } else {
            vHolder = (GridViewHolder) convertView.getTag();
        }
        return convertView;
    }

    @Override
    public int getCount() {
        return images.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    static class GridViewHolder {

        public GridViewHolder(View view, OnDeleteItem listener) {
            ButterKnife.inject(this, view);
        }

        @InjectView(R.id.grid_item_image)
        ImageView image;
        @InjectView(R.id.deleteButton)
        Button delete;
        String path;

        public String getPath() {
            return path;
        }

    }
}

Edit2:
I did more simply the XML, but the rows dont show.
<?xml version="1.0" encoding="utf-8"?><!-- To make screen scroll in vertical direction -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fillViewport="true"
    android:background="@drawable/fondodroid2"
    android:orientation="vertical">

    <!-- Main layout -->

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:id="@+id/scrollView">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#fefdff"
                android:layout_marginLeft="@dimen/login_activity_horizontal_margin"
                android:layout_marginRight="@dimen/login_activity_horizontal_margin"
                android:layout_marginTop="@dimen/login_activity_vertical_margin"
                android:padding="@dimen/login_activity_horizontal_margin"
                android:id="@+id/linearLayout">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:baselineAligned="true"
                    android:paddingTop="0dp"
                    android:paddingBottom="0dp"
                    android:layout_marginBottom="@dimen/login_activity_vertical_margin"
                    android:weightSum="1">

                    <ImageView
                        android:layout_width="@dimen/login_activity_logo"
                        android:layout_height="@dimen/login_activity_logo"
                        android:id="@+id/imageView"
                        android:src="@drawable/logo"
                        android:contentDescription="Icon GG"
                        android:layout_alignParentLeft="true"
                        android:layout_alignParentTop="true" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textAppearance="?android:attr/textAppearanceLarge"
                        android:text="@string/files"
                        android:id="@+id/textView"
                        android:textSize="@dimen/login_activity_text"
                        android:textColor="@android:color/black"
                        android:textStyle="bold"
                        android:layout_marginTop="10dp"
                        android:layout_alignParentTop="true"
                        android:layout_toRightOf="@+id/imageView"
                        android:layout_marginLeft="10dp" />

                </RelativeLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:id="@+id/relativeLayout"
                    android:orientation="vertical">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:textColor="@android:color/white"
                        android:text="@string/sign_string"
                        android:textSize="@dimen/login_activity_vertical_margin"
                        android:textStyle="bold"
                        android:background="#686868"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentStart="true"
                        android:gravity="center"
                        android:id="@+id/textView3" />

                    <ImageView
                        android:id="@+id/sign_thumb"
                        android:layout_width="match_parent"
                        android:layout_height="100dp"
                        android:layout_centerHorizontal="true"
                        android:layout_alignParentEnd="false"
                        android:visibility="gone" />

                    <Button
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Eliminar"
                        android:id="@+id/deleteButton"
                        android:background="#cc6b67"
                        android:textStyle="bold"
                        android:layout_alignBottom="@+id/textView3"
                        android:layout_alignParentStart="true"
                        android:visibility="gone" />

                </LinearLayout>

                <RelativeLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_gravity="center"
                    android:id="@+id/relativeLayout2"
                    android:layout_marginTop="16dp">

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:textColor="@android:color/white"
                        android:text="@string/images"
                        android:textSize="@dimen/login_activity_vertical_margin"
                        android:textStyle="bold"
                        android:background="#686868"
                        android:layout_alignParentEnd="true"
                        android:layout_alignParentStart="true"
                        android:gravity="center"
                        android:id="@+id/textView2" />

                    <GridView
                        android:layout_width="match_parent"
                        android:layout_height="fill_parent"
                        android:id="@+id/gridImages"
                        android:numColumns="2"
                        android:verticalSpacing="1dp"
                        android:horizontalSpacing="1dp"
                        android:layout_alignParentLeft="false"
                        android:layout_marginLeft="0dp"
                        android:layout_below="@+id/textView2" />
                </RelativeLayout>

            </LinearLayout>

            <ImageView
                android:layout_width="@dimen/login_activity_logo_h"
                android:layout_height="@dimen/login_activity_logo_v"
                android:id="@+id/imageView2"
                android:src="@drawable/logo"
                android:layout_below="@+id/linearLayout"
                android:layout_alignRight="@+id/linearLayout"
                android:layout_marginTop="@dimen/login_activity_vertical_margin"
                android:layout_marginBottom="@dimen/login_activity_vertical_margin"
                android:contentDescription="@string/logo" />

        </RelativeLayout>
    </ScrollView>

</LinearLayout>

A: Here is some simplified example to achieve needed layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_icon" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/relativeLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <ImageView
            android:id="@+id/sign_thumb"
            android:layout_width="match_parent"
            android:layout_height="100dp"
            android:src="@drawable/ic_icon" />

        <Button
            android:id="@+id/deleteButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

    <GridView
        android:id="@+id/gridImages"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:numColumns="2" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/ic_icon" />

</LinearLayout>


text:
Q: How to set a full screen popup background in Swift I am a beginner in iOS development.
I  followed this tutorial https://github.com/nrlnishan/ViewPager-Swift to implement a viewPager in my application.
Then I followed https://github.com/nbyn/MWAPopup/blob/master/README.md to implement a popup in the first view of the popup.
But the popup background doesn't appear as full screen.
This screenshot may explain more my problem.

Please help me.

A: You are showing the popup on the wrong UIViewController. show method shows the popup inside the UIViewController that is passed in as a parameter.
Also when using someones else's GitHub code or library, always look for the number of the stars for the repository since the most quality solutions are recognized by the community, especially solutions to the popular problems like popups. Try something like this https://github.com/Orderella/PopupDialog


text:
Q: invalid character 'R' looking for beginning of value I am trying to hit a url
http://localhost:33250/api/v1/edit-order-request/?order_id=1231

, there I get this error :
invalid character 'R' looking for beginning of value

What am I doing wrong?
Edit :
http_client.go
func (c *HTTPClient) Call(url string, body interface{}, h http.Header, hc string, method string) (*response.BaseResponse, error) {
    outputChannel := make(chan *response.BaseResponse, 1)
    util.FilterHeaders(&h)
    errChannel := hystrix.Go(hc, func() error {
        var res *http.Response
        var err error
        switch method {

        case util.Post:
            rbyte, _ := json.Marshal(body)
            rreader := bytes.NewReader(rbyte)
            res, err = c.httpClient.Post(url, rreader, h)
        case util.Put:
            rbyte, _ := json.Marshal(body)
            rreader := bytes.NewReader(rbyte)
            res, err = c.httpClient.Put(url, rreader, h)
        case util.Patch:
            rbyte, _ := json.Marshal(body)
            rreader := bytes.NewReader(rbyte)
            res, err = c.httpClient.Patch(url, rreader, h)
        case util.Get:
            res, err = c.httpClient.Get(url, h)
            log.Info().Msgf("res %v",res)
        }
        if err != nil {
            log.Error().Err(err).Msgf(method+" api failed: %s", body)
            return err
        }
        defer res.Body.Close()
        var baseResponse response.BaseResponse
        d := json.NewDecoder(res.Body)
        d.UseNumber()
        err = d.Decode(&baseResponse)
        if err != nil {
            log.Error().Err(err).Msgf("Failed to decode the response for url %s", url)
            return err
        }
        baseResponse.HTTPStatusCode = res.StatusCode

        outputChannel <- &baseResponse
        return nil
    }, func(err error) error {
        return err
    })
    select {
    case res := <-outputChannel:
        log.Info().Msgf(method+" response for URL %s, BODY %s , HEADER %s, RESPONSE %s", url, util.ToJSON(body), util.ToJSON(h), util.ToJSON(res))
        return res, nil
    case err := <-errChannel:
        log.Info().Msgf("Error received on error channel for URL %s", url)
        return nil, err
    }
}

Stub :
var EditServiceGetConversationIdOmtTaskIdNonEmptyStub = &wiremock.Stub{
    Request: wiremock.Request{
        Method:     "GET",
        UrlPattern: "/api/v1/edit-order-request/"+"?order_id=1231",
    },
    Response: wiremock.Response{
        Status: 200,
        Body:   EditServiceGetConversationIdOmtTaskIdNonEmptyResponse,
    },
}

var EditServiceGetConversationIdOmtTaskIdNonEmptyResponse = "{\"statusCode\":0,\"statusMessage\":\"success\",\"data\":{\"order_id\":1231,\"edit_reason\":\"EDIT\",\"crm_conversation_id\":\"p-qwr-1234\",\"omt_task_id\":\"1231\"}}"

When in stub I use Url parameter , then this error is gone. Could someone explain me the reason for this  ?
Error Logs when using Url Pattern as parameter :
http_client.go:54 > res &{404 Not Found 404 HTTP/1.1 1 1 map[Content-Type:[text/plain] Server:[Jetty(9.4.20.v20190813)]] 0xc001fd5200 -1 [] true false map[] 0xc0003e6100 <nil>}
http_client.go:66 > Failed to decode the response for url http://localhost:33350/api/v1/edit-order-request/?order_id=1231 error="invalid character 'R' looking for beginning of value"
http_client.go:81 > Error received on error channel for URL http://localhost:33350/api/v1/edit-order-request/?order_id=1231

Success Logs in case of Url as Parameter :
http_client.go:54 > res &{200 OK 200 HTTP/1.1 1 1 map[Matched-Stub-Id:[901cbfb1-fc1a-40e8-9f00-fae29f54be3d] Server:[Jetty(9.4.20.v20190813)] Vary:[Accept-Encoding, User-Agent]] 0xc0020aa8a0 -1 [] true true map[] 0xc0020a0600 <nil>}
http_client.go:78 > GET response for URL http://localhost:33355/api/v1/edit-order-request/?order_id=1231, BODY null , HEADER {"Authorization":["Basic R0dZU1dJOjIwMTVTVyFHR1k="],"Content-Type":["application/json"]}, RESPONSE {"statusCode":0,"statusMessage":"success","data":{"crm_conversation_id":"p-qwr-1234","edit_reason":"EDIT","omt_task_id":"1231","order_id":1231},"httpStatusCode":200,"id":0,"code":"","message":""}


text:
Q: Mysql, partitioning not working on date range I'm trying to partition a table, this is its structure:
CREATE TABLE IF NOT EXISTS `actions` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `uuid` varchar(36) COLLATE utf8_unicode_ci DEFAULT NULL,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `username` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `event` varchar(16) COLLATE utf8_unicode_ci NOT NULL,
  `obj_id` int(11) unsigned NOT NULL,
  `inline` text COLLATE utf8_unicode_ci NOT NULL,
  `meta` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`,`date`),
  KEY `event` (`event`),
  KEY `obj_id` (`obj_id`),
  KEY `username` (`username`),
  KEY `date` (`date`),
  KEY `user_date` (`username`,`date`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
 PARTITION BY RANGE ( UNIX_TIMESTAMP(date))
(PARTITION actions_0 VALUES LESS THAN (1209592800) ENGINE = InnoDB, # 2008-05-01
 PARTITION actions_images_1 VALUES LESS THAN (1212271200) ENGINE = InnoDB, # 2008-06-01
 [...]
 PARTITION actions_67 VALUES LESS THAN (1388530800) ENGINE = InnoDB,
 PARTITION actions_68 VALUES LESS THAN MAXVALUE ENGINE = InnoDB)

now, it seems to be fine when I select for a specific date:
EXPLAIN PARTITIONS SELECT * FROM `actions` WHERE `date` = '2008-05-04 16:13:15' ;

+----+-------------+----------------+------------------
| id | select_type | table          | partitions
+----+-------------+----------------+------------------
|  1 | SIMPLE      | actions        | actions_1

but if I do this query:
EXPLAIN PARTITIONS SELECT * FROM `actions` WHERE `date` > '2008-05-04 16:13:15' AND `date` < '2008-05-05 16:13:15';

Mysql scans for all the actions_N tables, what am I doing wrong?
this is the first time I'm using partitions but I followed the manual and I can't find where I got wrong.
thanks!

A: well, it's a mysql bug
http://bugs.mysql.com/bug.php?id=28928

A: The use of partitioning columns employing date or time types other than DATE or DATETIME is not supported with RANGE COLUMNS.
DATE and DATETIME. Columns using other data types relating to dates or times are not supported as partitioning columns.


text:
Q: Can we enable "My Domains" within "Trialforce Source Org"? Is there any downside to Enabling "My Domains" within a "Trialforce Source Org"?
Now that My Domains is a necessary function to be enabled for Lightning Components, it is becoming more and more required to be setup in our Trialforce Org, but I am unable to find proper documentation that could answer my query. I'm confused how will it effect New Trials generated from the Trialforce Template from a Trialforce org which has a My Domains setup to "xyz" subdomain?
Because I've noticed that if I don't setup My Domains, then we don't see any Lightning Component of Lightning Component Tab in the Trialforce org (from the Managed Package we need to give Trials for).

A: New org created from your Trialforce will get a domain name like xyz-1234.
The system will add a random 4 digits number to make your domain unique.
Your customer can open a ticket to get it changed.


text: Q: speed calculation using RFID reader and arduino no I have 2 RFID readers and 1 Arduino UNO. RFID will have 2 positions START and END. when I pass my tag through START it should start calculating time and end until it reaches the END position. START position should stop scanning immediately as soon as it scans the End position it should be vice-versa. I need the code to do this stuff.


text:
Q: Debugging the init() method in a Java servlet From what I know about how a Tomcat server works, is that if you have a Java servlet in your web application, the init() method is called whenever the server starts up.
In that case, how can I debug the init() method? Putting a break point clearly doesn't work, and for some reason System.out.println statements also do not yield any output on my server console.
I have checked that the correct web app (.war) is deployed and it extracts correctly in the webapps folder of my Tomcat server.

A: It seems to me like your deployment descriptor servlet declaration doesn't have an load-on-startup value bigger than 0. If you have omitted that element, the Servlet will only be initialized when the container deems that it should handle a request. Until then, the init method is not called.
By providing the load-on-startup value, like so
 <servlet>
    <servlet-name>servlet</servlet-name>
    <servlet-class>com.example.YourServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

You are telling the container to initialize the Servlet right away, therefore invoking your init method on startup, rather than when the first request for that servlet arrives.

A: It is not correct, the init() method is not called when server startsup.
It is called only once and it is called during the FIRST CALL TO YOUR SERVLET to which the same init() method belongs.
As there is one init() for each Serlvet, init() for respective servlet is called when you call the servlet for first time. i.e After container loads the servlet and instantiates it then init() method is called.
Either do,

*

*Load on startup in web.xml for servlet

*Give call to serlvet(after first call you should see println statement in console)


text:
Q: Upload files using curl to remote api I am trying to upload the files users uploaded along with other post data to remote api using curl.  This what i have done so far
$_POST['certf'] = '@'.$_FILES['certf']['tmp_name'].';filename=' . $_FILES['certf']['name'];

$url = "example.com/app_handler.php?key=key";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, "Content-Type:multipart/form-data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
$result = curl_exec($ch);
curl_close($ch);
echo $result;

In the receiving side i have just printed the $_FILES but it is empty. all the tutorials i have found on internet saying that can accessed $_FILES and we can use it as normal file upload from there. What did i miss here?

A: Try to send file with CurlFile
$filePath= $_FILES['file1']['tmp_name'];
$fileType= $_FILES['file1']['type'];
$fileName= $_FILES['file1']['name'];
$post_data['certf'] = new \CurlFile($filePath, $fileType, $fileName);

$url = "example.com/app_handler.php?key=key";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, "Content-Type:multipart/form-data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = curl_exec($ch);
curl_close($ch);
echo $result;


text:
Q: Recovering control of a closed input descriptor process Doing some tests in scm (a scheme interpreter), I've intentionally closed the current-input-port (equivalent to the standard input file descriptor). Once the program work in REPL, the things got crazy, printing systematically a error message. My question is: how could I recover the control of process, that means, how could I reestablish the input file descriptor of such process?
Search for "changing file descriptor of a running process" or something similar, I couldn't find a helpful article.
Thanks in advance
System information: Debian 10.

A: You almost certainly can't, although this does slightly depend on how the language-level ports are mapped to the underlying OS-level I/O system.
If what you do is close the OS-level standard input then all is lost:

*

*the REPL tries to read from standard input, gets an error as it's closed;

*it tries to raise some error which will involve prompting the user for input ...

*... from standard input, which is closed, so it gets error;

*game over.

The only way to survive this is for one of two things to be true:

*

*either you've wrapped an error handler around the code which is already prepared to deal with this;

*or the implementation is smart enough to recognise that it's getting closed-port errors in its closed-port error handler and gives up in some smart way.

Basically once the OS level standard input is gone anything that needs to get input from it is doomed: you can't put it back without OS-level surgery on the process.
However it's possible that the implementation maps a single OS-level I/O stream to multiple language-level streams, and closing only one of these streams would leave the system with some other stream-of-last-resort to which it can still talk, and which still refers to the OS-level standard input.  Common Lisp is an example of a system which can (depending on configuration) do this.  It has, for instance, *standard-input* *error-output*, *query-io*, *terminal-io* and other streams, and it's very possible to be in a situation where, for instance, *standard-input* has been closed causing read errors, but *query-io* still points somewhere with a human on the end of it.
I don't know if scm does that.


text:
Q: How to prevent the multiple click on div in polymer? I have created a web application with Polymer where I implemented album functionality, when I click on the album multiple times the album products are repeated multiple times.
How can I fix this issue?

  <template is='dom-repeat' items='[[productAlbum.albumProdImages]]' as='productImage'>

  </template>

       + {{productAlbum.albumProdLength}}

Help me to fix this.


text:
Q: Miranda's book Lemma 1.3 pag. 58 How can I show that, given $X_A$ and $X_B$ two conics in $\mathbb{P}^{2}(\mathbb{C})$, the map $T: X_A \mapsto X_B$ is holomorphic, where $B=T^{t}AT$ is the symmetric matrix defining the equation of the conic $X_B$.

A: Hint: Since $T$ is non-singular, the map $T:\mathbb{P}^2\to\mathbb{P}^2$ is holomorphic. To see this, look at it in local coordinates. Then the restriction of a holomorphic map to a subvariety is also holomorphic.


text:
Q: Segmentation fault with pointer to pointer I have the following code:
int main(){
int j,rows,columns;
int i;
char **text;
char **final;

rows=45;
columns=7;

text=malloc(2*sizeof(char));

for(i=0;i<2;i++)
      text[i]=malloc(3*sizeof(char));

final=malloc(rows*sizeof(char));

for(i=0;i<rows;i++){
            final[i]=malloc(columns*sizeof(char));
                      }

for(i=0;i<2;i++)
 for(j=0;j<3;j++)
      text[i][j]='a';

for(i=0;i<rows;i++){
 printf("i %d\n",i);
          for(j=0;j<columns;j++){
        printf("j %d\n",j);
                   final[i][j]='a';
          }
}

printf("%s\n%s\n",final[0],text[0]);

}

When I run it everything is fine with "text" pointer, but not with "final" pointer. A segmentation fault message appears when I try to initialize "final" with 'a'. Specifically the message is appeared when i=14 and j=0.Could someone tell me why?

A: The lines
final=malloc(rows*sizeof(char));

and
text=malloc(2*sizeof(char));

allocate space for chars. You need pointers, though, since malloc returns a pointer, which does not fit into a char.
Replace them by
final=malloc(rows*sizeof(char*));

and
text=malloc(2*sizeof(char*));

Notes:

*

*If you didn't know: since sizeof(char) == 1 by standard definition, you can omit the multiplications with sizeof(char).


text:
Q: Bootstrap modal on form submit not displaying at correct point Requirement
I want to display a fixed message to the user whilst a file is being uploaded and attached to an email to discourage clicking back or refreshing the page or repeatedly clicking the submit button.
Background
I'm using bootstrap v3.3.7 and JQuery v3.3.1.
I thought a good way to tackle this requirement was to make use of the Bootstrap Modal plugin, especially when I realised you could fix the modal on screen using:
$("#modal-foo").modal({backdrop: 'static',keyboard: false});

I have the following modal:
@model Web.ViewModels.Site.Foo.FooViewModel

                     Uploading your file and submitting it for review

We're currently uploading and submitting your file for review.

This may take a few moments. Please do not hit the back button or try to refresh this page whilst this is happening.

I have the following form:
<form id="fooform" asp-action="fooaction" asp-controller="foocontroller" asp-route-fooid="@Model.FooId" method="post" enctype="multipart/form-data" class="form-horizontal">

I have the following button:
<input type="submit" value="Submit" class="btn btn-primary" />

And the following jquery:
//when dom loaded hooks
$.when($.ready).then(function () {
  $('#fooform').on('submit', function () {
     if ($(this).valid()) {
        //we've passed the unobtrusive validation so now present the message to the user
        $("#modal-foo").modal({
          backdrop: 'static',
          keyboard: false
        });
     }
   });
})

Issue
What I was hoping would happen is that the modal would appear once the unobtrusive validation has passed, and is displayed until the user is redirected to a thank you page.
What I'm finding happen is that the modal isn't appearing until later in the process.
For example, if I put some alerts in to see what's happening, using the code below, the modal doesn't appear until after 'here3'. It's as though the .modal is firing an instruction to browser to display the modal but it doesn't action it immediately.
//when dom loaded hooks
$.when($.ready).then(function () {
  $('#fooform').on('submit', function () {
     alert('here1');
     if ($(this).valid()) {
        //we've passed the unobtrusive validation so now present the message to the user
        alert('here2');
        $("#modal-foo").modal({
          backdrop: 'static',
          keyboard: false
        });
        alert('here3');
     }
   });
})

Alternative attempt to achieve requirement
I've tried using an anchor instead of a submit button but again, the modal doesn't appear until after 'here3':
Submit

Javascript function:
function showModal() {
  if ($('#fooform').valid()) {
    //we've passed the unobtrusive validation so now present the message to the user
    alert('here1');
    $("#modal-foo").modal({
      backdrop: 'static',
      keyboard: false
    });
    alert('here2');
    //can I somehow wrap the submit in a promise or delegate so that after the modal appears it does the submit?
    $('#fooform').submit();
    alert('here3');
  }
}

Question
How can I achieve my requirement? As per my comment in the Javascript function above, can I wrap the form submit in a promise or delegate or can I set something on the DOM to fire after the modal has displayed or is there an alternative to the Modal that I should look at?

A: The problem is while you click the submit button your page reloading
that's why you cannot see your modal
$.when($.ready).then(function () {

  $('#fooform').on('submit', function (e) {
       e.preventDefault();//added here
  //   if ($(this).valid()) {
        //we've passed the unobtrusive validation so now present the message to the user
        $("#modal-foo").modal({
          backdrop: 'static',
          keyboard: false
        });
   //  }
   });
})

see your above code i used 'e.preventDefault()' to block your submission on click
Now you can see your model
But your 'valid()' command will not work here, because form is prevented from
submitting, that's why i commented out that....
So change your code according to this.....
One method is using AJAX you can send data without page reload...
otherwise give a button to open model and put submit button on the model...
There is one more chance that model will not work...
while inserting scripts it must be in order that jquery must insert before other plugins,
insert,

above code first,
then try,
i am including the working full code below
<!DOCTYPE html>

  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">

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

@model Web.ViewModels.Site.Foo.FooViewModel

                     Uploading your file and submitting it for review

We're currently uploading and submitting your file for review.

This may take a few moments. Please do not hit the back button or try to refresh this page whilst this is happening.

<form id="fooform" asp-action="fooaction" asp-controller="foocontroller" asp-route-fooid="@Model.FooId" method="post" enctype="multipart/form-data" class="form-horizontal">

</form>
Submit

A: In the end I got this working by using the following. Hopefully, someone else may find this useful:
Same button and form
<input type="submit" value="Submit" class="btn btn-primary" />

<form id="fooform" asp-action="fooaction" asp-controller="foocontroller" asp-route-fooid="@Model.FooId" method="post" enctype="multipart/form-data" class="form-horizontal">

Modal
Note the additional data-backdrop and data-keyboard attributes on the 1st div
@model Web.ViewModels.Site.Foo.FooViewModel

                     Uploading your file and submitting it for review

We're currently uploading and submitting your file for review.

This may take a few moments. Please do not hit the back button or try to refresh this page whilst this is happening.

jQuery
I ended up taking the key elements from the modal plugin in the Bootstrap js file and the modal appeared at the point I expected it to whilst still giving me the modal display effects that I was looking for.
function showModal() {
    var $body = $("body");
    $body.addClass("modal-open");
    $(document.createElement('div'))
        .addClass('modal-backdrop fade in')
        .appendTo($body)
    var $modal = $("#modal-foo");
    $modal.show();
    $modal.scrollTop(0);
    $modal[0].offsetWidth;
    $modal.addClass('in');
}

//when dom loaded hooks
$.when($.ready).then(function () {
    $('#fooform').on('submit', function () {
        if ($(this).valid()) {
            showModal();
        }
    });
})


text:
Q: What happens when a software that is open source without any license is later licensed with gpl version 3? I want to use certain piece of software for my commercial project. The software that will be making use of is open source and I will modify the source code to suit my needs.
Say at a later date, the open source software is licensed under GPL version 3, what happens then? Am I allowed to use the original unlicensed version without any implications?

A:
The software that will be making use of is open source

No, it isn't. You said that it has no license. Then it isn't open source. If it has no license that grants you specific rights in addition to the rights given to you by copyright law (which are practically none), then it isn't open source. In particular, you are not allowed to copy it, modify it, distribute it, not even download it, etc. Depending on your jurisdiction, you may not even be allowed to run it since running involves copying from disk to RAM; most jurisdictions have thankfully moved away from this ridiculous interpretation, but there may still be some that haven't.

Am I allowed to use the original unlicensed version without any implications?

You never were allowed to use that version in the first place, and you still aren't allowed to use it now, since its (non-)license hasn't changed a bit.

A: The use of unlicensed source code is governed by copyright law, which is considerably more restrictive than most software licences. Essentially, a licence grants you rights to source code above what the default legal situation would be. It is often easier and more reliable to pick the later, GPL'd version and abide by the GPL, for which there is ample precedence and advice available, than to use code for which you technically have no rights whatsoever.


text:
Q: Doing operations with only Nth element of a list I want to multiply only every second number on a list(0-100) but I just can't get it to work.

A:
I want to change to list so: 1,2,3,4,5,6,7,8 becomes 1,4,3,8,5,16 etc.

Though I don't understand how you multiply 6 to end up with 16, I assume this is what you need:
new_list = []

for x in range(1,100):
  if x % 2 == 0: new_list.append(x*2)
  else: new_list.append(x)

print(new_list)

If the number is divisible by 2, you multiply it with 2 and append it to a new list. If not, you just append it without multiplying.
Running this program, you get the following output:
[1, 4, 3, 8, 5, 12, 7, 16, 9, 20, 11, 24, 13, 28, 15, 32, 17, 36, 19, 40, 21, 44, 23, 48, 25, 52, 27, 56, 29, 60, 31, 64, 33, 68, 35, 72, 37, 76, 39, 80, 41, 84, 43, 88, 45, 92, 47, 96, 49, 100, 51, 104, 53, 108, 55, 112, 57, 116, 59, 120, 61, 124, 63, 128, 65, 132, 67, 136, 69, 140, 71, 144, 73, 148, 75, 152, 77, 156, 79, 160, 81, 164, 83, 168, 85, 172, 87, 176, 89, 180, 91, 184, 93, 188, 95, 192, 97, 196, 99]

A: You can`t multiply with 0 , because the result will be always 0.
result=1
for i in range (1 , 10 ):
   if i%2==0:
     result*=i
print(result)

A: [x*10 for x in range(100) if x%2==0] # take vale to be multiply instead of 10, use x if you want to multiply with number it self

below code will only multiply even elements and keep other as it is.
def iterate_lis(get_list):
    ls = []
    for x in get_list:
        if x%2==0:
            ls.append(x*2)
        else:
            ls.append(x)
    print(ls)
    return ls

iterate_count = 5  # list will be iterate 5 times

for i in range(iterate_count):
    if i ==0:
        get_lis = iterate_lis(range(100))
    else:
        get_lis = iterate_lis(get_lis)

result for iterate_count=5 will be as follow:
>>>
[0, 1, 4, 3, 8, 5, 12, 7, 16, 9, 20, 11, 24, 13, 28, 15, 32, 17, 36, 19, 40, 21, 44, 23, 48, 25, 52, 27, 56, 29, 60, 31, 64, 33, 68, 35, 72, 37, 76, 39, 80, 41, 84, 43, 88, 45, 92, 47, 96, 49, 100, 51, 104, 53, 108, 55, 112, 57, 116, 59, 120, 61, 124, 63, 128, 65, 132, 67, 136, 69, 140, 71, 144, 73, 148, 75, 152, 77, 156, 79, 160, 81, 164, 83, 168, 85, 172, 87, 176, 89, 180, 91, 184, 93, 188, 95, 192, 97, 196, 99]
[0, 1, 8, 3, 16, 5, 24, 7, 32, 9, 40, 11, 48, 13, 56, 15, 64, 17, 72, 19, 80, 21, 88, 23, 96, 25, 104, 27, 112, 29, 120, 31, 128, 33, 136, 35, 144, 37, 152, 39, 160, 41, 168, 43, 176, 45, 184, 47, 192, 49, 200, 51, 208, 53, 216, 55, 224, 57, 232, 59, 240, 61, 248, 63, 256, 65, 264, 67, 272, 69, 280, 71, 288, 73, 296, 75, 304, 77, 312, 79, 320, 81, 328, 83, 336, 85, 344, 87, 352, 89, 360, 91, 368, 93, 376, 95, 384, 97, 392, 99]
[0, 1, 16, 3, 32, 5, 48, 7, 64, 9, 80, 11, 96, 13, 112, 15, 128, 17, 144, 19, 160, 21, 176, 23, 192, 25, 208, 27, 224, 29, 240, 31, 256, 33, 272, 35, 288, 37, 304, 39, 320, 41, 336, 43, 352, 45, 368, 47, 384, 49, 400, 51, 416, 53, 432, 55, 448, 57, 464, 59, 480, 61, 496, 63, 512, 65, 528, 67, 544, 69, 560, 71, 576, 73, 592, 75, 608, 77, 624, 79, 640, 81, 656, 83, 672, 85, 688, 87, 704, 89, 720, 91, 736, 93, 752, 95, 768, 97, 784, 99]
[0, 1, 32, 3, 64, 5, 96, 7, 128, 9, 160, 11, 192, 13, 224, 15, 256, 17, 288, 19, 320, 21, 352, 23, 384, 25, 416, 27, 448, 29, 480, 31, 512, 33, 544, 35, 576, 37, 608, 39, 640, 41, 672, 43, 704, 45, 736, 47, 768, 49, 800, 51, 832, 53, 864, 55, 896, 57, 928, 59, 960, 61, 992, 63, 1024, 65, 1056, 67, 1088, 69, 1120, 71, 1152, 73, 1184, 75, 1216, 77, 1248, 79, 1280, 81, 1312, 83, 1344, 85, 1376, 87, 1408, 89, 1440, 91, 1472, 93, 1504, 95, 1536, 97, 1568, 99]
[0, 1, 64, 3, 128, 5, 192, 7, 256, 9, 320, 11, 384, 13, 448, 15, 512, 17, 576, 19, 640, 21, 704, 23, 768, 25, 832, 27, 896, 29, 960, 31, 1024, 33, 1088, 35, 1152, 37, 1216, 39, 1280, 41, 1344, 43, 1408, 45, 1472, 47, 1536, 49, 1600, 51, 1664, 53, 1728, 55, 1792, 57, 1856, 59, 1920, 61, 1984, 63, 2048, 65, 2112, 67, 2176, 69, 2240, 71, 2304, 73, 2368, 75, 2432, 77, 2496, 79, 2560, 81, 2624, 83, 2688, 85, 2752, 87, 2816, 89, 2880, 91, 2944, 93, 3008, 95, 3072, 97, 3136, 99]

A: import numpy as np
l = range(100)
np.product(l[0::2])

This will give you every second element of your list and multiply all.

A: Use range() to generate the indexes of the entries you want to change...
numbers = [1, 2, 3, 4, 5, 6, 7, 8]

for i in range(1, len(numbers), 2):
    numbers[i] *= 2

will result in numbers containing the list
[1, 4, 3, 8, 5, 12, 7, 16]


text:
Q: ScrollTo method not woking in react native ScrollView component scrollTo() is not working in react native - ScrollView Component
I am trying to scroll to top of screen on tap of button which is in the bottom of the screen. Screen is scrollable and lots of contents and other component inside ScrollView Component.
Function to scroll to top

_scrollToTop = () => {
      this.sv.scrollTo({x: 0, y: 0, Animated: true})
}

Component inside render to call _scrollToTop function
<ScrollView ref={c => (this.sv = c)}>
.
.
.
.
   <Button onPress={this._scrollToTop}>
     <Icon name="arrow-up" } />
   </Button>

</ScrollView>

But when button is tapped, nothing happens.
Using following environment:
"react": "16.8.6",
"react-native": "0.60.5",


text:
Q: Get data from multidimensional array js I have a JS array, for example:
const array1 = [{"entrance":"20","a":"10"},{"entrance":"15","b":"25"}];

I want to get entrance values as a new array. Till today I'm using a for-loop to do it, like this:
var entrance = [];
for(i=0;i<array1.length;i++){
  entrance[i] = array1[i]["entrance"];
}

This works perfect, but I wonder if there is a prettier way to do this. Do you have any suggestions?

A: Use .map():

const array1 = [{"entrance":"20","a":"10"},{"entrance":"15","b":"25"}];
const entrance = array1.map((e) => e.entrance);

console.log(entrance);

A: You can try with map()

The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

const array1 = [{"entrance":"20","a":"10"},{"entrance":"15","b":"25"}];

var entrance = array1.map(i => i.entrance);
console.log(entrance);

A: Pretty way using map and destructuring:
const array1 = [{"entrance":"20","a":"10"},{"entrance":"15","b":"25"}];
const entrances = array1.map(({ entrance }) => entrance);

A: It has not been mentioned yet. You could use forEach:
const array1 = [{"entrance":"20","a":"10"},{"entrance":"15","b":"25"}];
const res = [];
array1.forEach((obj) => {res.push(obj.entrance)});
console.log(res);


text:
Q: 'Should' instance variables or properties ever share getter/setters Say I have a JavaScript object:
myObject = {
    oneArray: [],
    otherArray: [],

    setOneArray: function(){
        /*some code that sets the contents*/
    }

    setOtherArray: function(){
        /*again code that sets contents*/
    }
}

Now let's say that as it stands right now, the code of both 'setters' are identical. I'm duplicating effort and code, no two ways about it.  I could have written a single function for both and saved however-long in coding (or copying/pasting).  In the foreseeable future I've no reason to treat these any differently - so is this fundamentally a bad practice?
If context matters, both arrays are being pushed the same kind of data - strings - but from different parts of a JSON file.

A: I'm going to go ahead and say it: Yes, it's a bad practice to duplicate code. One of the first principles developers should learn is DRY. Having duplicate code just increases the chance for them to get out of sync.
What you could do is still have bother setters, but have them each only call another method that contains the same code. If that ever changes one day, then you can get rid of the common method and have your setters simply be different at that point.


text:
Q: Using LStrHandleArray in .NET I am trying to call a DLL (created with LabView) from .NET. I've succeeded for most of the methods, but one requires a string array as an input.
Labview supposedly uses C calling conventions when creating DLLs but the function prototype does not use a char pointer as I would expect but rather an LStrHandleArray:
void SetOutputUnits(LStrHandleArray *OutputUnits)

Does anyone know what reference I need to include to be able to use LStrHandleArray from within .NET?
Googling LStrHandleArray yields only 19 results, most of which are unanswered questions on other forums. I've added every National Instruments reference I can think of but I don't see LStrHandleArray and I can't find any documentation on it online.

A: The definition of the type is as follows:
/** @brief Long Pascal-style string types. */
typedef struct {
    int32   cnt;        /* number of bytes that follow */
    uChar   str[1];     /* cnt bytes */
} LStr, *LStrPtr, **LStrHandle;
typedef struct _LStrArray {
    int32 nElts;
    LStrHandle  str[1];
} LStrArray, **LStrArrayHandle;

Note that the use of 1 is the C technique to make an array type be allocated flat inline instead of in a separate pointer. The same declaration is used regardless of the length of the array or length of the string. You allocate enough memory accommodate the full size of the array/string... indexes deliberately go beyond the declared allocation size. It's something unheard of in managed languages, but this is the low-level structural declaration that the compiler uses.
To invoke from .NET code, you'll need to create a wrapper DLL that takes a flattened form of the data that you marshal across as a string or other marshallable data structure and then unflatten\construct in the C++ code. Both the array handle itself and the internal string handles have to be allocated with DSNewHandle() or DSNewHClr() from the extcode.h header file so that they're in the memory space that LabVIEW can manipulate.
This example shows invoking the DLL from another C DLL, but it has other helpful discussion.
PS: LabVIEW DOES use C calling conventions. That refers to the order of parameters on the stack and the fact that the data structures are all definable with PODs (plain old C data types). It does not imply anything about the data structures used in the interfaces.

A: This is an old post, but since there is no accepted answer...
LStrHandleArray is represented as a flattened 2-D array of char, with known dimension sizes.
You can use array of StringBuilder to send input to LStrHandleArray. This works because StringBuilder allocates memory for the string and keeps track of its capacity size, increasing as needed.
Just make sure charset is ANSI when importing your Labview DLL!
https://learn.microsoft.com/en-us/dotnet/api/system.text.stringbuilder?view=netcore-3.1


text:
Q: Can anyone get app-engine plugin working with Grails on mac os x? I have been trying for 4 days to get app-engine and grails working together on my mac to no avail. I am using  latest groovy/grails and appengine sdk versions. Im following the app-engine plugin step by step on the grails site..
http://grails.org/plugin/app-engine
Groovy Version: 1.7.1 JVM: 1.5.0_22
Grails 1.3.0.RC1
echo $APPENGINE_HOME reveals
/Users/markstim/appengine-java-sdk-1.3.2
 I perform the following steps
 1. grails create-app myapp
 2. cd myapp; grails list-plugins    reveals
hibernate           1.3.0.RC1        --  Hibernate for Grails
tomcat              1.3.0.RC1        --  Apache Tomcat plugin for Grails
 add the following line to Config.groovy
google.appengine.application="myapp"
 install the plugin for app-engine grails install-plugin app-engine and answer 'jpa' when asked (no errors yet)
installed plugins list now looks like
app-engine          0.8.9            --  Grails AppEngine plugin
gorm-jpa            0.7.1            --  GORM-JPA Plugin
 then grails run-app and get this error as the server is coming up...

[java] WARNING: Nested in org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'pluginManager' defined in ServletContext
resource [/WEB-INF/applicationContext.xml]:
Invocation of init method failed; nested exception is
org.codehaus.groovy.grails.exceptions.NewInstanceCreationException:
Could not create a new instance of class [GormJpaGrailsPlugin]!:
     [java] java.lang.NoClassDefFoundError: org.grails.jpa.JpaPluginSupport

then if i navigate to localhost:8080 I get
HTTP ERROR: 503
Problem accessing /myapp. Reason:
SERVICE_UNAVAILABLE
Powered by Jetty://

A: Localhost:8080 is your application.  You do not need to add 'myapp' to your path.

A: According to Will it play in app engine you have to use grails app-engine run

A: Agreed with tgd25 - you will need to remove /myapp that is why you are getting a 404.
Oddly enough, after having reached the same exception as you did with Grails 1.3RC1 on a Mac, I managed to get 'grails app-engine run' to startup with the DataNucleus enhancer and one (1) domain class just to test.
However, on a save, the webapp spews the following exception.  See accompanying JIRA:

 [java] 2010-04-17 21:48:05,675 [13387359@qtp-10769461-4] ERROR errors.GrailsExceptionResolver  - This operation requires a transaction yet it is not active
 [java] javax.persistence.TransactionRequiredException: This operation requires a transaction yet it is not active
 [java]     at org.datanucleus.jpa.EntityManagerImpl.assertIsActive(EntityManagerImpl.java:846)
 [java]     at org.datanucleus.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:545)
 [java]     at org.springframework.orm.jpa.JpaTemplate$8.doInJpa(JpaTemplate.java:290)
 [java]     at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:183)
 [java]     at org.springframework.orm.jpa.JpaTemplate.flush(JpaTemplate.java:288)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [java]     at java.lang.reflect.Method.invoke(Method.java:592)
 [java]     at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
 [java]     at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
 [java]     at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
 [java]     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
 [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
 [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:121)
 [java]     at org.grails.jpa.JpaPluginSupport$__clinit__closure3_closure7_closure14.doCall(JpaPluginSupport.groovy:471)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [java]     at java.lang.reflect.Method.invoke(Method.java:592)
 [java]     at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
 [java]     at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
 [java]     at org.codehaus.groovy.runtime.metaclass.ClosureMetaMethod.invoke(ClosureMetaMethod.java:80)
 [java]     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoMetaMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:307)
 [java]     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:63)
 [java]     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
 [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
 [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
 [java]     at pollster.BookController$_closure4.doCall(script12715407593811946448835.groovy:24)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [java]     at java.lang.reflect.Method.invoke(Method.java:592)
 [java]     at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
 [java]     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:225)
 [java]     at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:51)
 [java]     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:44)
 [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:143)
 [java]     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)
 [java]     at pollster.BookController$_closure4.doCall(script12715407593811946448835.groovy)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 [java]     at java.lang.reflect.Method.invoke(Method.java:592)
 [java]     at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:100)
 [java]     at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)
 [java]     at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
 [java]     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1058)
 [java]     at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:915)
 [java]     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)
 [java]     at groovy.lang.Closure.call(Closure.java:276)
 [java]     at groovy.lang.Closure.call(Closure.java:271)
 [java]     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleAction(SimpleGrailsControllerHelper.java:378)
 [java]     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.executeAction(SimpleGrailsControllerHelper.java:245)
 [java]     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleURI(SimpleGrailsControllerHelper.java:200)
 [java]     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsControllerHelper.handleURI(SimpleGrailsControllerHelper.java:137)
 [java]     at org.codehaus.groovy.grails.web.servlet.mvc.SimpleGrailsController.handleRequest(SimpleGrailsController.java:88)
 [java]     at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
 [java]     at org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.doDispatch(GrailsDispatcherServlet.java:256)
 [java]     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
 [java]     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
 [java]     at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:563)
 [java]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
 [java]     at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
 [java]     at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
 [java]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:70)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
 [java]     at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 [java]     at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 [java]     at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 [java]     at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
 [java]     at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
 [java]     at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:327)
 [java]     at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
 [java]     at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:283)
 [java]     at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:259)
 [java]     at org.codehaus.groovy.grails.web.util.WebUtils.forwardRequestForUrlMappingInfo(WebUtils.java:252)
 [java]     at org.codehaus.groovy.grails.web.mapping.filter.UrlMappingsFilter.doFilterInternal(UrlMappingsFilter.java:187)
 [java]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.obtainContent(GrailsPageFilter.java:245)
 [java]     at org.codehaus.groovy.grails.web.sitemesh.GrailsPageFilter.doFilter(GrailsPageFilter.java:136)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.codehaus.groovy.grails.web.servlet.filter.GrailsReloadServletFilter.doFilterInternal(GrailsReloadServletFilter.java:101)
 [java]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.codehaus.groovy.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:67)
 [java]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.codehaus.groovy.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:63)
 [java]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 [java]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 [java]     at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
 [java]     at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:51)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:122)
 [java]     at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
 [java]     at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
 [java]     at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
 [java]     at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
 [java]     at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
 [java]     at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
 [java]     at com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:70)
 [java]     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 [java]     at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:349)
 [java]     at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
 [java]     at org.mortbay.jetty.Server.handle(Server.java:326)
 [java]     at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
 [java]     at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:938)
 [java]     at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
 [java]     at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
 [java]     at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
 [java]     at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
 [java]     at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

A: I had to remove the tomcat plugin before mine worked. I think that's where the confusion comes in - tomcat serves the app at localhost:8080/appname whereas app engine plugin serves it off the root.
On my Mac with latest grails/appengine I couldn't get the current app-engine plugin [0.8.9] to work; I used the 0.8.8 version.
To run it, I just used "grails run-app".
Hope this helps.


text:
Q: Mongo query to sort results with maximum number of distinct attributes or keys? I need to write a MongoDB find query to fetch results from a collection and sort them on the basis of maximum attributes per row.
for example:
right now results are something like this:
[{
    column1 : "abc",
    column2 : "def",
},
{
    column1 : "abc",
},
{
    column1 : "abc",
    column2 : "def",
    column3 : "ghi"
}]

what query should return (in descending order of number of columns):
[{
    column1 : "abc",
    column2 : "def",
    column3 : "ghi"
},
{
    column1 : "abc",
    column2 : "def",
},
{
    column1 : "abc",
}]

Query is db..find({"column1": "abc"});

Is it possible to achieve through querying database?

A: not optimal, but you could call mapReduce to get ids by number of fields, and then query for those ids in ascending order, here's some code to start with (not tested!)
var map = function(doc) {
   emit(Object.keys(doc).length, doc._id);
}
var reduce = function(key, values) {
   return values;
}
coll.mapReduce(function() { map(this) }, reduce, function(err, results) {
   results.sort((a,b) => { return a._id > b._id });
   results.forEach(result => {
      console.log("now getting ids with " + result._id + " fields");
      var cursor = coll.find({ _id : { $in : result.value}});
      // do something with cursor.
   });
);

Another option would be to add a field to each doc "fields_count" which will hold the number of fields for that document, and you can use that field to query by.


text:
Q: yii2 seperate comma data in the gridview for each entry of the relation I have 3 tables and i have made relation to What table by using Field table. i want to show name row from What table in Gridview.but it shows me row of data seperated by comma. i want each data in different column. like sql query result with repeated field.
this is my tbon.php model:
public function getWhat()
    {
        return $this->hasMany(What::className(), ['idw' => 'idw'])
            ->viaTable('Field', ['id' => 'id']);
    }
public function getField()
    {
        return $this->hasMany(Field::className(), ['id' => 'id']);
    }

and in TbonSearch.php i have added these codes:
public $what;
public $field;

and
[['field','what'],'safe']

and in search method, i have added:
$query = Tbon::find()
           ->joinWith(['field'])
           ->joinWith(['what']);

and for sorting:
$dataProvider->sort->attributes['what'] = [
            'asc' => ['what.name' => SORT_ASC],
            'desc' => ['what.name' => SORT_DESC],

        ];

and add search filter:
->andFilterWhere(['like', 'what.name', $this->what]);

in index i have added this code and here is the problem, i think:
<?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'id',
            [
                'label'=>'Name',
                'attribute' => 'what',
                'value' => function ($data) {
                    $str = '';
                    foreach($data->what as $name) {
                        $str .= $name->name.',';
                    }
                    return $str;
                },
            ],

data is like this: a,b,c,d for field of name! but i want ID and a then in next row ID and b and etc.
any help will be appreciated!

A: I dont know your code and I dont get the meaning, but I can answer in general.
A GridView is used to view Data in a Grid. A row in a GridView represents a dataset and presenting data in the form of a table.
foreach($data->what as $name) {
                    $str .= $name->name.',';
                }

I assume you want to display the Name attribute from the relation what. You can simply achieve this with the tablename.columnname syntax.
<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        'id',
        [
            'label'=>'Name',
            'attribute' => 'what.name',
        ],

If you want to display the ID column additionally:
<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        'id',
        [
            'label'=>'Name',
            'attribute' => 'what',
            'value' => function ($data) {
                $str = '';
                foreach($data->what as $name) {
                    $str .= ' ';
                    $str .= $name->id.'';
                    $str .= $name->name.',';
                }
                return $str;
            },
        ],

To be more precise (in Terms of your Problem). We have a datamodel with a junction table like the following simple book database.

Example:
If you want to display the names of the authors on the standard CRUD generated index Gridview, you can do something like this:
<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $searchModel,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],

        'id',
        'book_name',
        [
            'label'=>'Author(s)',
            'value' => function ($dataProvider) {
                $str = '';
                foreach($dataProvider->authors as $name) {
                    $str .= ' ';
                    $str .= $name->id.' ';
                    $str .= $name->author_name.',';
                }
                return $str;
            },
        ],

        ['class' => 'yii\grid\ActionColumn'],
    ],
]); ?>

with the result:

In addition, you can edit the Detail View to display such an information in an extra Gridview. The result can look like this.

To achieve this you have to:

*

*add a data provider to your controller and pass the provider to the view

*add a gridview widget in your view and connect the data provider

*add a method to your model which crawls the data

view.php aka the view
use yii\grid\GridView;

// other code

<?= GridView::widget([
    'dataProvider' => $dataProvider,
        'columns' => [
        'id',
        [
            'attribute' => 'author.author_name',
            'header' => 'Author(s)',
        ],
    ],

]); ?>

BookController.php aka the controller
public function actionView($id)
{
    $dataProvider = Book::getAllAuthors($id);
    return $this->render('view', [
        'model' => $this->findModel($id),
        'dataProvider' => $dataProvider,
    ]);
}

Book.php aka the model
use \yii\data\ActiveDataProvider;

// other code

public static function getAllAuthors($id) {

    $query = BookAuthor::find()->where(['book_id' => $id]);
    $dataProvider = new ActiveDataProvider([
        'query' => $query,
    ]);

    return $dataProvider;

}


text:
Q: what does it mean when we use " group by 1" in an SQL Query I have come across a query where it is specified by
select concat(21*floor(diff/21), '-', 21*floor(diff/21) + 20) as `range`,     count(*) as
`number of users` from new_table group by 1 order by diff;

here what exactly does group by 1 mean?

A: Assuming you have a Select:
SELECT name FROM employee GROUP BY 1;

No matter what, it will always group by the first column given in the select.
In this case, the column 'name' is grouped.
So if we alternate the above statement to:
SELECT department FROM employee GROUP BY 1;

We now group the department, without having to change the '1' in the group by.
EDIT: (as requested by Stewart)
If we have the following Data in table 'employe':
-- name --
Walt
Walt
Brian
Barney

A simple select would deliver all rows above, whereas the 'group by 1' would result in one Walt-row:
output with group by:
-- name --
Walt
Brian
Barney

A: +1 to @FabianBigler for answering first, but I'll add this:
http://dev.mysql.com/doc/refman/5.6/en/select.html says:

Columns selected for output can be referred to in ORDER BY and GROUP BY clauses using column names, column aliases, or column positions. Column positions are integers and begin with 1.

For what it's worth, this is non-standard SQL, so don't expect it to work on other brands of SQL database.


text:
Q: Display Hover instead of Href for conditional check I have a very basic html requirement where on some parameter value, I need to hide the hyperlink on the text and show the hover on the text.
Below is my test html.How should I handle my Javascript where when accesscode =10, I should show only hover not href?
<!DOCTYPE html>

test Heading

Test screen.

 Learn More

A: If you want to create a tooltip that's displayed when you hover over the link, assign the title property.

var accessCode = 10;
var hideElem = document.getElementById("tagUrl");
if (accessCode == 10) {
  //should not display the link, instead show the hover.
  hideElem.href = '#';
  hideElem.title = 'Link is not active now';
}

test Heading

Test screen.

Learn More

A: First remove target="_blank" as well from the link and if you do not want user to redirect to top of the page. You can use javascript:void(0) inside href tag to avoid this
Try this:

var accessCode = 10;
var hideElem = document.getElementById("tagUrl");
if (accessCode == 10) {
  //should not display the link, instead show the hover.
  hideElem.href = 'javascript:void(0)';
  hideElem.removeAttribute('target');
  hideElem.title = 'Link is not active now';
}

test Heading

Test screen.

Learn More

A: Try to make a test with code below.

    <title>Disable Link using JavaScript</title>

test Heading

Test screen.

 Learn More