text:
Q: How do I assign to a variable in a for loop in C? Noob, working on an encryption problem, and I want to iterate through combinations in an array in C, i.e. aaa, aab, aac, aba, etc. and then pass each combination to a function (to check whether that combination is the correct code).
I can print what I want to console no problem, i.e. aa, ab, ba, bb, but can't get those values into my temp variable.
#include <stdio.h>

int main(void) {
    char *word = "ab";

    char * temp[3];
    //temp[2] = '\0';

    for (int i = 0; i < 2; i++){
        for (int j = 0; j < 2; j++){
            temp[0] = &word[i];
            temp[1] = &word[j];
            printf("%s\n", *temp);
            // printf("%c", word[i]);
            // printf("%c\n", word[j]);
            // pass_temp_to_function(temp);
        }
    }

    return 0;
}

I'm getting ab, ab, b, b, when I should be getting aa, ab, ba, bb (with my above code), and don't know why or how to correct it or otherwise find the answer, hence my Noobish question.

A: It looks as if you've carefully coded it to create zero warnings even though it is very wrong, with all sorts of array of strings, and pointers to characters being flown around.
You want to have a single string of 2 characters, for that an array of 3 characters is sufficient:
char temp[3];
temp[2] = '\0';

...
    temp[0] = word[i];
    temp[1] = word[j];

    puts(temp); // less typing but essentially the same as printf("%s\n", temp);

A: I would recommend that the original poster review chapter 5 of Kernighan and Ritchie.
/* main.c - This is a novice program. */
/* Copyright (C) 2019 Robin Miyagi https://www.linuxprogramming.ca/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef _GNU_SOURCE
# define _GNU_SOURCE
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <error.h>

/*
 * Declared global so that the linker can find it.....................
 */
int main (void);

/*
 * Implementation.....................................................
 */
int
main
(void)
{
  char temp[3];
  int i;
  int j;

  temp[2] = '\0';
  for (i = 0; i < 2; ++i)
    for (j = 0; j < 2; j++)
      {
        temp[0] = 'a' + i;
        temp[1] = 'a' + j;
        printf ("%s\n", temp);  /* temp ---> beginning of array of char. */
      }
  return EXIT_SUCCESS;
}

A: temp is a pointer to pointer to char. I don't know why your code is constructed the way it is, so I'm just going to assume there is a reason.
            // printf("%c", word[i]);
            // printf("%c\n", word[j]);

Yup these lines didn't work. A slight mistake. Easy fix:
            printf("%c", temp[i][0]);
            printf("%c\n", temp[j][0]);

We have to dereference the char* again to get back to the char. I could have written *(temp[i]) but temp[i][0] is easier to read.

A: With the above help, I was able to get my code working as follows:
#include <stdio.h>
#include <string.h>

int main(void) {

    char * word = "abc";

    char temp[3];
    temp[2] = '\0';

    for (int i = 0; i < strlen(word); i++){
        for (int j = 0; j < strlen(word); j++){
            temp[0] = word[i];
            temp[1] = word[j];
            puts(temp);
        }
    }
    printf("%s", temp);

    return 0;
}

// displays aa, ab, ac, ba, bb, bc, ca, cb, cc, cc (duplicate)


text:
Q: When 2 threads would be executed on a 1 physical CPU core with a multi-core CPU machine? Lets say there's a machine with 8-cores CPU.
I'm creating 2 posix threads using standard pthread_create(...) function.
As I know there's no any garanties these threads always would be executed by a 2 different physical cores, but practically in 90% they will run simultaneously (or in parallel). At least for my cases I seen that top command shows 2 cpu's are running ... thus around 160-180% CPU usage
The question is:
What could be the scenario when 2 threads within a single process are running only on 1 physical core ?

A: Two cases:
1) The other physical cores are busy doing other stuff, so only one core gets used by this process. The two threads run in alternation on that core.
2) The physical core supports executing more than one thread concurrently using hyperthreading or something similar. The other physical cores are busy doing other stuff, so the best the scheduler can do is run both threads in a single physical core.

redpajama_set_name: RedPajamaStackExchange


text:
Q: arrays must be of same length when creating a dataframe for boston housing prediction On writing this code, it generates error.  Why?
df=pd.DataFrame(boston).
The error it generates is ValueError: arrays must all be same length .

A: You need to provide the data of boston to get a confirmed answer.
It currently seems as if boston is an array of arrays. where the length of nested lists might not be the same. You may have to add padding to the lists.


text:
Q: Does regular expression \d match minus sign and/or decimal point? I'm look at some old PERL/CGI code to debug an issue and noticed a lot of uses of:
\d - Match non-digit character
\D - Match digit character

Most online docs mention that \d is the same as [0-9], which is what I've always thought of it as. But, I've also noticed Stackoverflow Questions that mention character set difference.
Does "\d" in regex mean a digit?
Does \d also match a minus sign and/or decimal point?
I'm off to do some testing.

A: I don't know how Perl determine whether to use Unicode or ASCII or locale by default (no flag, no use). Regardless, by declaring use re '/a'; (ASCII), or use re '/u'; (Unicode), or use re '/l'; (locale), you will clearly signify to the Perl interpreter (and human reader) which mode you want to use and avoid unexpected behaviour.
Due to the effect of modifiers, \d has at least 2 meanings:

*

*Under effect of /a flag (ASCII), \d will match digits from 0 to 9 (no more and no less).

*Under effect of /u flag (Unicode), \d will match any decimal digit in any language, and is equivalent to \p{Digit}reference. This effectively makes \d+ pretty useless and dangerous to use, since it allows a mix of digits in any languages.
Quote from description of /u flag

And, \d+ , may match strings of digits that are a mixture from different writing systems, creating a security issue. num() in Unicode::UCD can be used to sort this out. Or the /a modifier can be used to force \d to match just the ASCII 0 through 9.

\d will not match any sign or punctuation, since those characters does not belong to Nd (Number, decimal digit) General Category of Unicode.

A: The answer is no. It merely does a digit check. However, Unicode makes things a bit more complex.
If you want to make sure something is a number -- a decimal number -- ake a look at the Scalar::Util module. One of the functions it has is look_like_number. This can be used to see if the string you're looking at could be a number or not, and works better than trying to use a regular expression.
This module has been part of standard Perl for a while, so you should have it on your system.

A:
Does \d also match a minus sign and/or decimal point?

NO


text:
Q: Extracting Binary Data (a jpeg image) in the Request Body Sent to a Node.js Server Problem To Solve
Hello. I have been given an iPhone app that, as part of its functionality, sends a request to the server with a binary jpeg image in the request body. I have to find a way to read that binary data, send it to a client via socket.io, and log a copy of the image to the disk on the server.
First Try:
I have tried a few approaches with no luck. First I tried this:
var http = require('http');
var fs = require('fs');

http.createServer(function (req, res) {
console.log("Request In");
    var body = '';
    req.on('data', function (data) {
        body += data;
    });
    req.on('end', function () {
        fs.writeFile("./1.jpeg", body, function(err) {
        if(err) {
            console.log(err);
           } else {
            console.log("The file was saved!");
     }
});
    });
res.writeHead(200, {'Content-Type':'text/plain'});
res.end('Image Saved!');
}).listen(3000);
console.log('Server running at http://127.0.0.1:3000/');

This didn't work. I could not get an image that would open in Windows Photo Viewer. The Windows Photo Viewer gave me the error Windows Photo Viewer can't open this picture because either Photo Viewer doesn't support this file format, or you don't have the latest updates to Photo Viewer I'm sure I have the latest version. I next wondered if the request was getting messed up between the phone and the server.
Checking Request Fidelity
I installed Fiddler 2. I setup a reverse proxy, detailed here. I clicked on the request and then went to the hex view. I save the bytes after the header information by right-clicking selecting save bytes. I named the file test.jpg and it opened up in Windows Photo Viewer just fine.

I chose which bytes to save based on the different colors on the "header bytes" and the "body bytes"

Here is an example of the image I ended up getting from saving those bytes

Second Try:
Now that I know that the image is in the request and I know I can get to using fiddler, I searched stackoverflow and google to find how to capture the request body. I tried a bunch of solutions but none gave me an image that I could open.
//Express.js
var express = require('express');
var app = express();
var fs = require('fs');

app.configure(function(){
    app.use(express.bodyParser());
    app.use(function(req, res, next) {
        req.rawBody = '';
        // req.setEncoding('base64');
        req.setEncoding(null);
        req.on('data', function(chunk) {
            req.rawBody += chunk;
        });
        req.on('end', function() {
            next();
        });
    });
});

app.listen(3000);

app.get('*', function(req, res){
    res.writeHead(200);
    res.end('Hello World');
    console.log(req.rawBody);
});

app.put('*',  function(req, res){
    console.log("putted");
    res.writeHead(200);
    res.end('Hello World');
    fs.writeFile("./1.jpg", req.rawBody, function(err) {
        if(err) {
            console.log(err);
        } else {
            console.log("The file was saved!");
        }
    });
    console.log(req.headers);
    console.log(req.params);
    console.log(req.body);
});
console.log("running");

As I understand, the express bodyParser looks for json key-value pairs and because the request body is just a bunch of binary data, its return an empty array/object (not sure which). I wrote the custom middleware that adds a rawBody variable to the request object (req) at the suggestion of this answer on stackoverflow. A few articles said to use req.setEncoding('something') to let the Node.js know how that data is encoded. I tried null base64 hex and binary.
I have uploaded the saved request from Fiddler 2, if you would like to take a look. Fiddler 2 Request. Note: I wasn't sure what file extension to use so I didn't use any file extension.
I am currently stuck. I have tried all the solutions I could find on google and stackoverflow. Please ask for clarification if you need it. I tried to be as detailed as possible (sorry for the length). Thank you for taking the time to read this far!
Side Note/Extra
I don't know much about Node.js buffers work. I would like to be able to accept a "stream" of these images if possible. I don't know how a buffer might play into an answer but if it does please try to explain it, assuming I have little knowledge about buffers.
I also mentioned wanting to send the image to a browser over socket.io. If you would like to include this second set in your answer it would be greatly appreciated.
If you would like, please include information about how your solution would perform. (Heavy on CPU or mem or light on one, etc)

A: This should do it:
var http = require('http');
var fs = require('fs');

var app = http.createServer(function (req, res) {
  req.pipe(fs.createWriteStream(__dirname + req.url));

  res.writeHead(201);
  res.end();
});

app.listen(3000);

Verified with curl:
curl -H 'Content-Type: application/octet-stream' --data-binary @file.jpg localhost:3000/foo.jpg

If this doesn't work, I'd test it with curl to make sure it's not the client which is doing something weird.
When it comes to sending it over socket.io, I wouldn't do that, but send the URL instead. If that's not an option I guess you would have to base64 encode the data.


text:
Q: Apache 2.2 VirtualHosts URL not found I'm hoping you can help. I have an existing Apache 2.2 server which serves a website I maintain. I am attempting to add additional websites for a colleague. Having done so, I get the following when I attempt to access the URL:

Not Found The requested URL / was not found on this server.

Here's a summary of my httpd-vhosts.conf file. I have three new, roughly identical, hosts that aren't working. Only NDV and the default are working.
NameVirtualHost *:80

<VirtualHost anycast.ns.cs.boeing.com:80>
        ServerName anycast.ns.cs.boeing.com
        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/www/anycast"

        ScriptAlias /cgi-bin "/opt/www/anycast/cgi-bin/"
        ErrorLog "logs/grant_error_log"
        CustomLog "logs/grant_access_log" common
</VirtualHost>

<VirtualHost *:80>
        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/httpd/manual"
        ServerAlias ntpm-application-01.ns.cs.boeing.com
        ErrorLog "logs/error_log"
        CustomLog "logs/access_log" common
</VirtualHost>

<VirtualHost *:80>
        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/www/ndv/html"
        ServerName ndv.web.boeing.com
        ScriptAlias /cgi-bin/ "/opt/www/ndv/cgi-bin/"
        ErrorLog "logs/error_log"
        CustomLog "logs/access_log" common
</VirtualHost>

<Directory "/opt/www/ndv/html/" >
        Options Indexes FollowSymLinks Includes
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml
        Order allow,deny
        Allow from all
</Directory>

<Directory "/opt/www/anycast/html/" >
        Options Indexes FollowSymLinks Includes
        Order allow,deny
        Allow from all
</Directory>

Based on the config above, this is what the server is seeing.
$ sudo bin/apachectl -S

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server ntpm-application-01.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:30)
         port 80 namevhost ntpm-application-01.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:30)
         port 80 namevhost ndv.web.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:39)
         port 80 namevhost anycast.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:48)
         port 80 namevhost ntpget.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:60)
         port 80 namevhost dnsdig.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:70)
Syntax OK

A: You seem to mix configuration approaches:
NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

This is the example from the Apache Docs regarding name based VHosts.
I can see in your config VirtualHost without the * -> anycast.ns.cs.boeing.com:80
as well as VHosts without a server name like ServerAlias ntpm-application-01.ns.cs.boeing.com
which has an alias, but no name.
I would start to even out the configurations like in the example and then try if the apache is more happy with that.
In short: Make sure each of you entries have *:80 and a server name.
Edit: This config is not tested but might work for you
NameVirtualHost *:80

<VirtualHost *:80>
        ServerName anycast.ns.cs.boeing.com

        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/www/anycast/html"

        ScriptAlias /cgi-bin "/opt/www/anycast/cgi-bin/"
        ErrorLog "logs/grant_error_log"
        CustomLog "logs/grant_access_log" common

        <Directory "/opt/www/anycast/html/" >
            Options Indexes FollowSymLinks Includes
            Order allow,deny
            Allow from all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        ServerName ntpm-application-01.ns.cs.boeing.com

        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/httpd/manual"

        ErrorLog "logs/error_log"
        CustomLog "logs/access_log" common
</VirtualHost>

<VirtualHost *:80>
        ServerName ndv.web.boeing.com

        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/www/ndv/html"

        ScriptAlias /cgi-bin/ "/opt/www/ndv/cgi-bin/"
        ErrorLog "logs/error_log"
        CustomLog "logs/access_log" common

        <Directory "/opt/www/ndv/html/" >
            Options Indexes FollowSymLinks Includes
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml
            Order allow,deny
            Allow from all
        </Directory>
</VirtualHost>

A: My advise is to open and read all the logs that apache generates. That will give you a clue of where the problem lies. I read the log at "/private/var/log/apache2/error_log" in a mac and found my clue: DocumentRoot [/path/to/rootdir] does not exist.
I opened the vhost file and found out that instead of encapsulating the root directory in double quotes I had used other characters that seemed like double quotes. I replaced them by the real double quotes, restarted apache and then the error was gone.

A: What worked for me is uninstalling and upgrading (in my case Wampserver) the software that you're using.


text:
Q: How to access XAMPP server from a seperate computer? I have been unsuccessful in connecting to my XAMPP server from a remote pc. I have checked my httpd-xampp.conf file and there is no LocationMatch section to input the "Allow from All". Not sure if this part just doesn't exist with newer versions of XAMPP, or if it is located in a different file?

A: Check on log file for more details about get 403, is first step to start investigate if problem is dir/file permission or httpd.conf misconfiguration


text:
Q: How do I call a sliding up panel in Flutter? I am using https://pub.dev/packages/sliding_up_panel and I want to trigger the opening of a new panel once a button is pressed on my existing panel.
    @override
    Widget build(BuildContext context) {
      BorderRadiusGeometry radius = BorderRadius.only(
        topLeft: Radius.circular(24.0),
        topRight: Radius.circular(24.0),
      );

      return Scaffold(
        appBar: AppBar(
          title: Text("SlidingUpPanelExample"),
        ),
        body: SlidingUpPanel(
          panel: Center(
            child: RaisedButton(
                  child: Text('Show new panel'),
                  onPressed: () {

                    **///want to add code
here to trigger the callback of the new panel.**

                  },
             ),
          ),

          collapsed: Container(
            decoration: BoxDecoration(
              color: Colors.blueGrey,
              borderRadius: radius
            ),
            child: Center(
              child: Text(
                "This is the collapsed Widget",
                style: TextStyle(color: Colors.white),
              ),
            ),
          ),

          body: Center(
            child: Text("This is the Widget behind the sliding panel"),
          ),

          borderRadius: radius,
        ),
      );
    }

This dependency has the capability to call an open() method with the help of a controller but I am unable to understand how to call a new sliding up panel with it (and obviously closing the existing one).
This is the code for the open() operation:
PanelController _pc = new PanelController();
...
  RaisedButton(
          child: Text("Open"),
          onPressed: () => _pc.open(),
        ),

A: You can copy paste run full code below
You can use Column and wrap these two SlidingUpPanel with Visibility and set maintainState, maintainAnimation to true
Working demo show switch between SlidingUpPanel 1 and 2
code snippet
body: Column(
        mainAxisAlignment: MainAxisAlignment.end,
        children: <Widget>[
          Visibility(
            maintainState: true,
            maintainAnimation: true,
            visible: _visible,
            child: SlidingUpPanel(
              controller: _pc1,
              panel: Center(
                child: RaisedButton(
                  child: Text('Show new panel 2'),
                  onPressed: () {
                    _pc1.close();
                    _visible = false;
                    setState(() {});
                    _pc2.open();
                  },

working demo

full code
import 'package:flutter/material.dart';
import 'package:sliding_up_panel/sliding_up_panel.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  PanelController _pc1 = new PanelController();
  PanelController _pc2 = new PanelController();
  bool _visible = true;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    BorderRadiusGeometry radius = BorderRadius.only(
      topLeft: Radius.circular(24.0),
      topRight: Radius.circular(24.0),
    );

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.end,
        children: <Widget>[
          Visibility(
            maintainState: true,
            maintainAnimation: true,
            visible: _visible,
            child: SlidingUpPanel(
              controller: _pc1,
              panel: Center(
                child: RaisedButton(
                  child: Text('Show new panel 2'),
                  onPressed: () {
                    _pc1.close();
                    _visible = false;
                    setState(() {});
                    _pc2.open();
                  },
                ),
              ),
              collapsed: Container(
                decoration:
                    BoxDecoration(color: Colors.blueGrey, borderRadius: radius),
                child: Center(
                  child: Text(
                    "Panel 1",
                    style: TextStyle(color: Colors.orange),
                  ),
                ),
              ),
              body: Center(
                  child: Text(
                      "Panel 1 This is the Widget behind the sliding panel")),
              borderRadius: radius,
            ),
          ),
          Visibility(
            maintainState: true,
            maintainAnimation: true,
            visible: !_visible,
            child: SlidingUpPanel(
              controller: _pc2,
              panel: Center(
                child: RaisedButton(
                  child: Text('Show new panel 1'),
                  onPressed: () {
                    _pc2.close();
                    _visible = true;
                    setState(() {});
                    _pc1.open();
                  },
                ),
              ),
              collapsed: Container(
                decoration:
                    BoxDecoration(color: Colors.blueGrey, borderRadius: radius),
                child: Center(
                  child: Text(
                    "Panel 2 ",
                    style: TextStyle(color: Colors.red),
                  ),
                ),
              ),
              body: Center(
                child:
                    Text("Panel 2 This is the Widget behind the sliding panel"),
              ),
              borderRadius: radius,
            ),
          ),
        ],
      ),
    );
  }
}


text:
Q: get all the values in Sql table using foreach I need to get all the Ids' from the table "StaffSectionInCharge", it has only two columns StaffId and SectionId, I have values of StaffId and StudentId.....the problem is I can't get the records directly to this table.....am using entity framework and the design of this table is
[EdmRelationshipNavigationPropertyAttribute("Model", "StaffSectionInCharge", "Section")]
    public EntityCollection<Section> Sections
    {
        get
        {
            return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Section>("Model.StaffSectionInCharge", "Section");
        }
        set
        {
            if ((value != null))
            {
                ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Section>("Model.StaffSectionInCharge", "Section", value);
            }
        }
    }

I can access this table through staff table like
Staff staff = buDataEntities.Staffs.First(s => s.StaffId == StaffId);
Section section = buDataEntities.Sections.First(s => s.SectionId == SectionId);

staff.Sections.Add(section);
buDataEntities.savechanges();

like this I can add the records to this StaffSectionInCharge table....
here I want to get all the StaffIds for the corresponding SectionId
I tried getting like
DataAccess.Staff staffs = new DataAccess.Staff();

foreach (int staff in staffs.Sections.Select(s=>s.SectionId))
            {

            }

but its not working, can anyone help me here

A: var staffIds = buDataEntities.Staffs
    .Where(st => st.Sections.Any(se => se.SectionId == SectionId))
    .Select(st => st.StaffId)
    .ToList();

or
var staffIds = buDataEntities.Sections
    .Where(se => se.SectionId == SectionId)
    .SelectMany(se => se.Staffs.Select(st => st.StaffId))
    .Distinct()
    .ToList();

Both options should work. If SectionId is the primary key of Section you can smplify the second code to:
var staffIds = buDataEntities.Sections
    .Where(se => se.SectionId == SectionId)
    .Select(se => se.Staffs.Select(st => st.StaffId))
    .SingleOrDefault();


text:
Q: side effects of encoding c style strings in base 64 My application normally logs binary messages to a file. It encodes the binary message in base64 and stores some string based metadata with each message to make it searchable.
Now, we would like to log messages which are plain C style strings. Is there any side effect/gotchas if the c-style strings can be base 64 encoded?


text:
Q: SVN, SSL certificate negotiation failed. However we don't use SSL certificate on our SVN Server Can you tell me please, at my workplace we don't use SSL certificates for SVN, however while running RUby on Rails command that checks SVN ( = Churn) still expects it and gives back the  following error:

SSL negotiation failed: SSL error code -1/1/336032856
  (https://137.172.75.98)

A: Can you change the protocol from https: to http: in the RoR command? That might fix it.


text:
Q: Can you use a PS3 controller as a gamepad/joystick in Windows? I'd like to know if it's possible to connect a PS3 controller to a Windows 7 personal computer so it could be used like any other gamepad.

A: *

*First you will need to download the driver from here
(MotioninJoy). Unzip the file and run the installation software.

*Now when you plug in your PS3 controller you will see a icon in the
system tray showing that Windows is installing drivers for your
controller. At this point the controller will be recognized, but you
won't be able to use it correctly (it needs to have a button profile loaded in MotionInJoy).

*Now open the DS3 tool, and press the "Load Driver" button. Windows
will warn you that the publisher is unknown, just ignore the message
and move on installing the driver. Now your PS3 will be ready for
use after you see a message SUCCESS: Install Completed. And that's
it actually. For more information check here (How-To-Geek)

A: If you're looking to get the PlayStation controller form factor, but aren't wedded specifically to a PS3 controller (which seems plausible since you mention not having bought one yet), consider instead purchasing an original PlayStation controller, along with a PSX-to-USB adapter such as this one -- odds are it'll be cheaper to buy both of those than a single PS3 controller (the linked Amazon page lists both the adapter and a PS2 Dual Shock controller for $26), and you'll get the same form factor without needing to worry about fighting with drivers, since the adapter presents the controller to the PC as a bog-standard USB HID device for which the drivers will be already present.


text:
Q: Binding boolean DependencyProperty to a button's Visibility property in Generic.xaml I have a class called CarSystemWindow that descends from Window, and it has a CanPinWindow boolean dependency property:
public class CarSystemWindow : Window {

    public static readonly DependencyProperty CanPinWindowProperty =
        DependencyProperty.Register( "CanPinWindow", typeof( bool ), typeof( CarSystemWindow ),
                 new FrameworkPropertyMetadata( false, FrameworkPropertyMetadataOptions.AffectsArrange ) );

    public bool CanPinWindow {
        get { return (bool) GetValue( CanPinWindowProperty ); }
        set { SetValue( CanPinWindowProperty, value ); }
    }

    . . .
}

In Generic.xaml, I have defined the default style for the CarSystemWindow class:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:CarSystem.CustomControls"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    xmlns:Telerik_Windows_Controls_Chromes="clr-namespace:Telerik.Windows.Controls.Chromes;assembly=Telerik.Windows.Controls">

    <BooleanToVisibilityConverter x:Key="BoolToVisbility" />

    <Style TargetType="{x:Type local:CarSystemWindow}">
        <Setter Property="WindowState" Value="Maximized" />
        <Setter Property="WindowStyle" Value="None" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:CarSystemWindow}">
                    <Viewbox Name="LayoutRoot"  Stretch="Uniform">
                        <StackPanel>
                            <Grid Background="#FF3C4B66" Height="50" Name="PART_Title">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="50" />
                                    <ColumnDefinition Width="50" />
                                    <ColumnDefinition Width="50" />
                                </Grid.ColumnDefinitions>
                                <Label Content="{TemplateBinding Title}"
                                       FontSize="32"
                                       Foreground="White"
                                       Grid.Column="0"
                                       HorizontalAlignment="Left"
                                       Name="PART_TitleLabel" />
                                <Button Grid.Column="1"
                                        Margin="5"
                                        Name="PART_PushpinButton"
                                        Visibility="{Binding CanPinWindow, Converter={StaticResource BoolToVisbility}, RelativeSource={RelativeSource Self}}">
                                    <Image Name="PART_PushpinImage" Source="/CarSystem;component/Resources/Unpinned.png" />
                                </Button>
                                <Button Grid.Column="2"
                                        Margin="5"
                                        Name="PART_MinimizeButton">
                                    <Image Name="PART_MinimizeButtonImage" Source="/CarSystem;component/Resources/Minimize.png" />
                                </Button>
                                <Button Grid.Column="3"
                                        Margin="5"
                                        Name="PART_CloseButton">
                                    <Image Name="PART_CloseButtonImage" Source="/CarSystem;component/Resources/Close.png" />
                                </Button>
                            </Grid>

                            <Rectangle Fill="#FFE61E0F" Height="4" Name="PART_TitleBar" />

                            <Grid Background="#FF3C4B66" Height="25" Name="PART_SubTitle">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Label Content="{TemplateBinding DeviceType}"
                                       FontSize="22"
                                       Foreground="White"
                                       Grid.Column="0"
                                       HorizontalContentAlignment="Right"
                                       Margin="5"
                                       MinWidth="75"
                                       Name="PART_DeviceTypeLabel" />
                                <Label Content="{TemplateBinding DeviceName}"
                                       FontSize="22"
                                       Foreground="White"
                                       Grid.Column="1"
                                       HorizontalContentAlignment="Left"
                                       Margin="5"
                                       MinWidth="250"
                                       Name="PART_DeviceNameLabel" />
                                <Rectangle Fill="White" Grid.Column="2" Name="PART_SubTitleRight" />
                            </Grid>

                            <Rectangle Fill="#FF3C4B66" Height="4" Name="PART_TitleBottom" />

                            <ContentPresenter Name="PART_ClientArea" />

                        </StackPanel>
                    </Viewbox>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    . . .

</ResourceDictionary>

The binding for the PART_PushpinButton Button's Visibiility property isn't working.  The button is always visible, even though the property defaults to false.  What am I doing wrong?
Tony

A: I think the RelativeSource should be TemplatedParent, not Self. Or am I missing some part of your code?
<Button Grid.Column="1"
    Margin="5"
    Name="PART_PushpinButton"
    Visibility="{Binding CanPinWindow, Converter= {StaticResource BoolToVisbility}, RelativeSource={RelativeSource TemplatedParent}}">


text:
Q: Error using generic return type (incompatible types: cannot be converted to T) public class Main{
    private MyQueue queue = null;
    private MyStack stack = null;
    private MyList list = null;

    public static void main(String args[]){
        Main m = new Main();
        m.run();
    }

    public void run(){
        // only one data structure is not null.
        // for example, let's suppose that it's queue
        this.queue = new MyQueue();

        int intToAdd = 6;   // I want to add this number
        this.selectStruct().insert(intToAdd);       // I want to invoke the "insert" method of the current data structure in use
    }

    private <T> T selectStruct(){       // this should check with data structure is in use (so which of them is not null) and then return the reference
        if (this.queue!=null){
            return this.queue;
        }
        if (this.stack!=null){
            return this.stack;
        }
        if (this.list!=null){
            return this.list;
        }
    }
}

I want to use this method called selectStruct to select the current data structure in use and return the reference. And from this reference then call insert that invokes the correct insert method of the correct class.
The problem is that I have several errors. I have never used generics, so I'm a bit confused.
$ javac Main.java
Main.java:22: error: incompatible types: MyQueue cannot be converted to T
                        return this.queue;
                                   ^
  where T is a type-variable:
    T extends Object declared in method <T>selectStruct()
Main.java:25: error: incompatible types: MyStack cannot be converted to T
                        return this.stack;
                                   ^
  where T is a type-variable:
    T extends Object declared in method <T>selectStruct()
Main.java:28: error: incompatible types: MyList cannot be converted to T
                        return this.list;
                                   ^
  where T is a type-variable:
    T extends Object declared in method <T>selectStruct()
Main.java:17: error: cannot find symbol
                this.selectStruct().insert(intToAdd);
                                   ^
  symbol:   method insert(int)
  location: class Object
4 errors

A: Let MyQueue, MyStack, and MyList implement the same interface containing the methods you want all your data structures to implement, e.g:
public interface IDataStructure {
    void insert(int intToAdd);
}

Your classes should then look like this:
public class MyQueue implements IDataStructure{

    @Override
    public void insert(int intToAdd) {
        // TODO
    }

}

public class MyStack implements IDataStructure{

    @Override
    public void insert(int intToAdd) {
        // TODO
    }

}

public class MyList implements IDataStructure{

    @Override
    public void insert(int intToAdd) {
        // TODO
    }

}

Finally, you can modify your selectStruct() method to return an IDataStructure:
private IDataStructure selectStruct() {
    if (this.queue != null) {
        return this.queue;
    }
    if (this.stack != null) {
        return this.stack;
    }
    if (this.list != null) {
        return this.list;
    }
    return null;
}

A: When you declare a method with a type parameter T (like private <T> T selectStruct()), you are saying that the user of this method can choose any type they want to use this method.
So in the body of selectStruct, you don't know which type the caller will use, and of course you can not return any specific type. That's why your every return clause like return this.queue; will produce an error.


text:
Q: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError spring-data-jpa 2.2.4 I recently migrated my spring code from 1.5.14.BUILD-SNAPSHOT to 2.2.4.RELEASE. At the beginning the code was working fine. I was able to work with the REST APIs and access the data. But suddenly I started to face the given error:-
Caused by: java.lang.IncompatibleClassChangeError
    at org.springframework.data.jpa.util.JpaMetamodel.lambda$isSingleIdAttribute$4(JpaMetamodel.java:94) ~[spring-data-jpa-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.jpa.util.JpaMetamodel$$Lambda$764/796118439.test(Unknown Source) ~[?:?]
    at java.util.Optional.filter(Unknown Source) ~[?:1.8.0_25]
    at org.springframework.data.jpa.util.JpaMetamodel.isSingleIdAttribute(JpaMetamodel.java:94) ~[spring-data-jpa-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.jpa.mapping.JpaPersistentPropertyImpl.lambda$new$2(JpaPersistentPropertyImpl.java:110) ~[spring-data-jpa-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.jpa.mapping.JpaPersistentPropertyImpl$$Lambda$754/307155209.get(Unknown Source) ~[?:?]
    at org.springframework.data.util.Lazy.getNullable(Lazy.java:212) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.util.Lazy.get(Lazy.java:94) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.jpa.mapping.JpaPersistentPropertyImpl.isIdProperty(JpaPersistentPropertyImpl.java:141) ~[spring-data-jpa-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.jpa.mapping.JpaPersistentEntityImpl.returnPropertyIfBetterIdPropertyCandidateOrNull(JpaPersistentEntityImpl.java:72) ~[spring-data-jpa-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.jpa.mapping.JpaPersistentEntityImpl.returnPropertyIfBetterIdPropertyCandidateOrNull(JpaPersistentEntityImpl.java:39) ~[spring-data-jpa-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.model.BasicPersistentEntity.addPersistentProperty(BasicPersistentEntity.java:218) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:538) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:506) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:705) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:374) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator$$Lambda$760/1221032697.accept(Unknown Source) ~[?:?]
    at java.util.Collections$SingletonSet.forEach(Unknown Source) ~[?:1.8.0_25]
    at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.createAndRegisterProperty(AbstractMappingContext.java:548) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.context.AbstractMappingContext$PersistentPropertyCreator.doWith(AbstractMappingContext.java:506) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:705) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:374) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:248) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:191) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:85) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$4(RepositoryFactoryBeanSupport.java:295) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport$$Lambda$700/409934976.accept(Unknown Source) ~[?:?]
    at java.util.Optional.ifPresent(Unknown Source) ~[?:1.8.0_25]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:295) ~[spring-data-commons-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:121) ~[spring-data-jpa-2.2.4.RELEASE.jar:2.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$162/768783366.getObject(Unknown Source) ~[?:?]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$162/768783366.getObject(Unknown Source) ~[?:?]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:116) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$162/768783366.getObject(Unknown Source) ~[?:?]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1287) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1207) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640) ~[spring-beans-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    ... 25 more

When I tried deleting the repository then the error started pointing another repository. When I reimported my project, the error did persist. Following is my POM code:-
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.4.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>3.17</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-envers</artifactId>
    </dependency>
    <dependency>
        <groupId>net.sf.json-lib</groupId>
        <artifactId>json-lib</artifactId>
        <version>2.4</version>
        <classifier>jdk15</classifier>
        <exclusions>
            <exclusion>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.springframework.security.oauth</groupId>
        <artifactId>spring-security-oauth2</artifactId>
        <version>2.3.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-jwt</artifactId>
        <version>1.0.9.RELEASE</version>
    </dependency>

    <!-- JSON-simple Plugin -->

    <!-- https://mvnrepository.com/artifact/org.modelmapper/modelmapper -->
    <dependency>
        <groupId>org.modelmapper</groupId>
        <artifactId>modelmapper</artifactId>
        <version>2.0.0</version>
    </dependency>

    <dependency>
        <groupId>org.sonarsource.scanner.maven</groupId>
        <artifactId>sonar-maven-plugin</artifactId>
        <version>3.6.0.1398</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

    <dependency>
        <groupId>de.codecentric</groupId>
        <artifactId>spring-boot-admin-starter-client</artifactId>
        <version>2.2.3</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.6.0.1398</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <testFailureIgnore>true</testFailureIgnore>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

I'm confused as why this happened. First day it worked fine and suddenly poof! The error. I tried deleting the JAR spring-data-jpa-2.2.4 and reimporting it. Still no luck. Please any help would be appreciated.
Edit:-
I referred this link but it didn't help -
Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class

A: I found the solution to my question. The problem was with my JDK version. I was using JDK v1.8.0_25 and I guess Spring 2.3.0 had some issues with that version. I recently updated the JDK version to 1.15.0.1 and code started working fine. I did not face the error as many times I executed the run command to execute my project.


text:
Q: Error in fetching repositories for ubuntu upgrade from 18.04 LTS to 20.04 LTS using do-release-upgrade I tried to update my Ubuntu 18.04 to 20.04 using the command sudo do-release-upgrade -d on my command line and it worked fine for a while, where it downloaded some repositories. After a while, it showed the following error:
Fetching
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libxml-libxml-perl amd64 2.0134+dfsg-1build1 [320 kB]
Err http://archive.ubuntu.com/ubuntu focal/main amd64 libxml-libxml-perl amd64 2.0134+dfsg-1build1
  Hash Sum mismatch
Hashes of expected file:
 - SHA256:02d4e0d785142836422d6ad32c7db158008bdc2b2975fd971e55476645b2ccb8
 - SHA1:18b39e848e301bb2f8ccc36c602426fd73ca9d64 [weak]
 - MD5Sum:8af41e9004d000b38f5b7e3f54117a61 [weak]
 - Filesize:319596 [weak]
Hashes of received file:
 - SHA256:df3a205735aa739038c3cc258ad97b45b50db29ad0efea9d03a6a6702f8cafda
 - SHA1:055d12a01dc616d56258cf3fb0f6e8d2af693d12 [weak]
 - MD5Sum:1e9b487c5b050c7818cdf9bdb65c95dc [weak]
 - Filesize:319596 [weak]
Last modification reported: Fri, 18 Oct 2019 21:47:31 +0000

Fetched 320 kB in 0s (0 B/s)
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libxml-libxml-perl amd64 2.0134+dfsg-1build1 [320 kB]
Err http://archive.ubuntu.com/ubuntu focal/main amd64 libxml-libxml-perl amd64 2.0134+dfsg-1build1
  Hash Sum mismatch
Hashes of expected file:
 - SHA256:02d4e0d785142836422d6ad32c7db158008bdc2b2975fd971e55476645b2ccb8
 - SHA1:18b39e848e301bb2f8ccc36c602426fd73ca9d64 [weak]
 - MD5Sum:8af41e9004d000b38f5b7e3f54117a61 [weak]
 - Filesize:319596 [weak]
Hashes of received file:
 - SHA256:df3a205735aa739038c3cc258ad97b45b50db29ad0efea9d03a6a6702f8cafda
 - SHA1:055d12a01dc616d56258cf3fb0f6e8d2af693d12 [weak]
 - MD5Sum:1e9b487c5b050c7818cdf9bdb65c95dc [weak]
 - Filesize:319596 [weak]
Last modification reported: Fri, 18 Oct 2019 21:47:31 +0000

Fetched 320 kB in 0s (0 B/s)
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libxml-libxml-perl amd64 2.0134+dfsg-1build1 [320 kB]
Err http://archive.ubuntu.com/ubuntu focal/main amd64 libxml-libxml-perl amd64 2.0134+dfsg-1build1
  Hash Sum mismatch
Hashes of expected file:
 - SHA256:02d4e0d785142836422d6ad32c7db158008bdc2b2975fd971e55476645b2ccb8
 - SHA1:18b39e848e301bb2f8ccc36c602426fd73ca9d64 [weak]
 - MD5Sum:8af41e9004d000b38f5b7e3f54117a61 [weak]
 - Filesize:319596 [weak]
Hashes of received file:
 - SHA256:df3a205735aa739038c3cc258ad97b45b50db29ad0efea9d03a6a6702f8cafda
 - SHA1:055d12a01dc616d56258cf3fb0f6e8d2af693d12 [weak]
 - MD5Sum:1e9b487c5b050c7818cdf9bdb65c95dc [weak]
 - Filesize:319596 [weak]
Last modification reported: Fri, 18 Oct 2019 21:47:31 +0000

Fetched 320 kB in 0s (0 B/s)

Could not download the upgrades

The upgrade has aborted. Please check your Internet connection or
installation media and try again. All files downloaded so far have
been kept.

Failed to fetch
http://archive.ubuntu.com/ubuntu/pool/main/libx/libxml-libxml-perl/libxml-libxml-perl_2.0134+dfsg-1build1_amd64.deb
Hash Sum mismatch
Hashes of expected file:
-
SHA256:02d4e0d785142836422d6ad32c7db158008bdc2b2975fd971e55476645b2ccb8
- SHA1:18b39e848e301bb2f8ccc36c602426fd73ca9d64 [weak]
- MD5Sum:8af41e9004d000b38f5b7e3f54117a61 [weak]
- Filesize:319596 [weak]
Hashes of received file:
-
SHA256:df3a205735aa739038c3cc258ad97b45b50db29ad0efea9d03a6a6702f8cafda
- SHA1:055d12a01dc616d56258cf3fb0f6e8d2af693d12 [weak]
- MD5Sum:1e9b487c5b050c7818cdf9bdb65c95dc [weak]
- Filesize:319596 [weak]
Last modification reported: Fri, 18 Oct 2019 21:47:31 +0000

Restoring original system state

Aborting
Reading package lists... Done
Building dependency tree
Reading state information... Done

I tried the whole process of sudo do-release-upgrade -d again and it showed the same error. How to overcome this error to upgrade my Ubuntu 18.04 to 20.04?
Please help!


text:
Q: What's wrong with this JSON object? What's wrong with this?
{ 'z': 'hello' }

Looks like a valid JavaScript dictionary to me, but both Python JSON and http://pro.jsonlint.com/ are telling me
Parse error on line 1:
{    'z': 'hello'}
-----^
Expecting 'STRING', '}'

What am I doing wrong?

A: Strings must be delimited by double quotes in JSON: http://www.json.org/
They can be single quoted in Python and JavaScript, but JSON is a very small subset of JavaScript.


text:
Q: what does "Vanilla experiences" mean? it is clear that "Vanilla" means that component that we add to our food , and no one don't know the meaning of "experiences" but i can't got it in this context , and i thi,k that it is a slang or idiomatic expression , could you help getting the meaning of it :
"
right there in front of them now without
commenting on whether these people were
already very socially awkward in the
first place I thought it was very
interesting how even with vanilla
experiences one could be so used to
reducing themselves to a voyeur that
they come to prefer that rather than the
real deal  "

A: Vanilla is an odd word.
Vanilla is an orchid that grows in Mexico. The tincture (extract in alcohol) of its seed pods has a delicious aroma and flavor.
Its most common use is flavoring ice-cream, so much so that vanilla ice-cream is not just the most popular variety, but effectively the default variety: when it comes to ice-cream (and similar products like frozen yogurt) whenever the variety is left unstated, it is assumed to be vanilla.
As a result, vanilla came to mean the default variety of anything, and eventually, the boring, unadventurous, predictable variety of anything.
If an automobile is "vanilla", it is a sedan with the base-model engine, and some common color like red or black.  If a person is "vanilla", he is largely conventional and conformist.  The word is often applied to sexual preferences; the opposite being "kinky" or "deviant".
"Vanilla experiences" are whatever the conventional experiences would be in a particular pursuit.


text:
Q: ¿Cómo leer los datos que se encuentran entre dos líneas que empiezan con una palabra clave? Tengo un código para extraer información de un archivo de salida de un programa llamado Gaussian. Tengo la siguiente sección del output:
Vibrational temperatures:   300 500 600 100 630
        (Kelvin)            425 689 900 325 456
                            654 897 562 148 635
                            456 888 999 789 456
Zero-point correction=      0.8998

Necesito sacar los valores numéricos de las temperaturas vibracionales iniciando de los que están en la misma línea que las palabras claves "vibrational temperatures" y terminando antes de la línea con la palabra clave de "zero-point correction". Mi código sólo me entrega la primera línea donde está la palabra "vibrational..." y no me entrega los demás valores. He intentado varias cosas pero no queda.
Agradezco de antemano cualquier sugerencia.

A: Sólo tienes que iterar las lineas del fichero y comprobar la primera palabra de cada linea para ver si coincide con Vibrational, (Kelvin) o Zero-point.
Según la estructura del fichero que has mostrado, algo así debería funcionar:
def temperatures(path):
    f = open(path, "r")
    temps = []
    for line in f:
        words = line.split()
        # Insertar elementos excepto "Vibrational temperatures"
        if words[0] == "Vibrational":
            temps += words[2:]
        # Insertar elementos excepto "(Kelvin)"
        elif words[0] == "(Kelvin)":
            temps += words[1:]
        # Convertir las subcadenas a enteros y devolver
        elif words[0] == "Zero-point":
            return map(int, temps)
        # Insertar todos los elementos
        else:
            temps += words


text:
Q: Error: Set property > System.Windows.Data.MultiBinding.Converter' threw an exception I have spent few hours to double check what's the error cause but I have no idea..
The error is

A first chance exception of type
  'System.Windows.Markup.XamlParseException' occurred in
  PresentationFramework.dll
Additional information: 'Set property
  'System.Windows.Data.MultiBinding.Converter' threw an exception.' Line
  number '363' and line position '86'.

XAML
<Grid Margin="1"
      DockPanel.Dock="Top">
  <Canvas x:Name="MinimapGrid"
          LayoutUpdated="MinimapGrid_LayoutUpdated">
    <Canvas.Resources>
      <local:OverlayRectangleRegionConverter x:Key="OverlayRectangleRegionConverter" />
    </Canvas.Resources>
    <Canvas.Background>
      <VisualBrush>
        <VisualBrush.Visual>
          <ItemsControl x:Name="itemsControl"
                        ItemsSource="{Binding Wells, IsAsync=True}">
            <ItemsControl.ItemsPanel>
              <ItemsPanelTemplate>
                <UniformGrid Rows="{Binding Rows, FallbackValue=16}"
                             Columns="{Binding Columns, FallbackValue=24}" />
              </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
              <DataTemplate>
                <Rectangle Fill="{Binding Name, Converter={StaticResource WellTypeColorConverter}}"
                           Height="10"
                           Width="10"
                           Stroke="Black" />
              </DataTemplate>
            </ItemsControl.ItemTemplate>
          </ItemsControl>
        </VisualBrush.Visual>
      </VisualBrush>
    </Canvas.Background>
    <Image x:Name="image"
           Height="410"
           Width="592"
           Source="Desert.jpg"
           Stretch="UniformToFill" />
    <Rectangle Fill="#FD9D5C5C"
               Canvas.Left="0"
               Canvas.Top="0"
               Width="{Binding ActualWidth, ElementName=image}"
               Height="{Binding ActualHeight, ElementName=image}"
               x:Name="rect">
      <Rectangle.OpacityMask>
        <DrawingBrush Stretch="None">
          <DrawingBrush.Drawing>
            <GeometryDrawing Brush="#99ffffff">
              <GeometryDrawing.Geometry>
                <CombinedGeometry GeometryCombineMode="Exclude">
                  <CombinedGeometry.Geometry1>
                    <RectangleGeometry>
                      <RectangleGeometry.Rect>
                        <MultiBinding Converter="{StaticResource OverlayRectangleRegionConverter}">
                          <Binding Path="(Canvas.Left)"
                                   ElementName="image" />
                          <Binding Path="(Canvas.Top)"
                                   ElementName="image" />
                          <Binding Path="Width"
                                   ElementName="rect" />
                          <Binding Path="Height"
                                   ElementName="rect" />
                        </MultiBinding>
                      </RectangleGeometry.Rect>
                    </RectangleGeometry>
                  </CombinedGeometry.Geometry1>
                  <CombinedGeometry.Geometry2>
                    <RectangleGeometry>
                      <RectangleGeometry.Rect>
                        <MultiBinding Converter="{StaticResource OverlayRectangleRegionConverter}">
                          <Binding Path="(Canvas.Left)"
                                   ElementName="PART_ZoomThumb" />
                          <Binding Path="(Canvas.Top)"
                                   ElementName="PART_ZoomThumb" />
                          <Binding Path="Width"
                                   ElementName="PART_ZoomThumb" />
                          <Binding Path="Height"
                                   ElementName="PART_ZoomThumb" />
                        </MultiBinding>
                      </RectangleGeometry.Rect>
                    </RectangleGeometry>
                  </CombinedGeometry.Geometry2>
                </CombinedGeometry>
              </GeometryDrawing.Geometry>
            </GeometryDrawing>
          </DrawingBrush.Drawing>
        </DrawingBrush>
      </Rectangle.OpacityMask>
    </Rectangle>
    <Thumb x:Name="PART_ZoomThumb"
           Canvas.Left="0"
           Canvas.Top="0"
           DragCompleted="PART_ZoomThumb_DragCompleted"
           DragDelta="PART_ZoomThumb_DragDelta"
           Cursor="SizeAll">
      <Thumb.Style>
        <Style TargetType="Thumb">
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="Thumb">
                <Rectangle StrokeThickness="3"
                           Stroke="Red"
                           Fill="Transparent" />
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
      </Thumb.Style>
    </Thumb>
  </Canvas>
</Grid>

OverlayRectangleRegionConverter.cs
public class OverlayRectangleRegionConverter : MarkupExtension, IMultiValueConverter
{
    public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
    {
        if (values == null || values.Length != 4) return new Rect(0, 0, 0, 0);
        for (var i = 0; i < values.Length; i++)
            if (double.IsNaN((double)values[i]))
                values[i] = 0.0;
        return new Rect((double)values[0], (double)values[1], (double)values[2], (double)values[3]);
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    {
        throw new NotImplementedException();
    }

    public override object ProvideValue(IServiceProvider serviceProvider)
    {
        return new RectConverter();
    }
}


text:
Q: control + s, return false but still call another function $(document).keydown(function (e) {
    if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
        function_which_does_a_lot_including_ajax_calls();
        return false;
    }
});

I'm trying to call a method on control+S, and, the call to function_which_does_a_lot_including_ajax_calls() stops the code from reaching the "return false" in time, which means that the browser prompts the default "Do you want to save this website" window.
If I change it to simply:
$(document).keydown(function (e) {
    if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
        // function_which_does_a_lot_including_ajax_calls();
        return false;
    }
});

... the return false is triggered, and nothing happens (no default prompt).
Is there a way I can do a lot of stuff, but still return false so that the browser does not do its default behavior?  Thanks!

A: Use e.preventDefault() to prevents browser's default behaviour (similar to return false).
Example:
$(document).keydown(function (e) {
    if (condition_says_NO_to_default) {
        e.preventDefault();
        .... //Rest of code

Update: Alternative method. The code below maintains the scope, this  and event object reference, while the return false statement is processed first:
$(document).keydown(function (e) {
    var $this = this; //Save reference for later
    setTimeout(function(){
        (function(event){
            //Your code here
        }).call($this, e);
    }, 1); // An extremely low timeout.
    return false;
});

A: I'm not sure I understand the behaviour you described but you can try something like:
$(document).keydown(function (e) {
    if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
        setTimeout(function_which_does_a_lot_including_ajax_calls, 100);
        return false;
    }
});


text:
Q: How to change the color of a button while it is pressed I want to change the color of a button while it is pressed, pause for a short time and then change the color back to the original color.
I can't seem to figure out how to do this (tried various forms of DynamicModule and Dynamic, but no luck). This is what I tried so far:
Manipulate[
  DynamicModule[{simulationFlag, bgnd = Automatic},
    simulationFlag = newSimulation;
    Pause[0.5];
    Dynamic[bgnd = Automatic; {simulationFlag}]],
  {{newSimulation, 0.02}, ControlType -> None},
  Row[{
    Button["New Simulation", Dynamic[newSimulation = newSimulation+1; {bgnd=Yellow}],
      Background -> Dynamic[bgnd]]}]
]

A: Explanation in detail what this code does:

*

*Since the Button[..., Background -> color] has a rather ugly look, I use a Panel with colored background as the label of the button, this causes the button-in-a-button look.

*When simply clicked (pressed and released immediately), nothing special happes, the button (and Panel) only changes appearance for the short time the button is pressed, then reverts back to normal.

*However, when the button is pressed but not released, the behaviour is different: with the first registered event of "MouseDown", a timed task is started that evaluates delay seconds later and reverts the color of the Panel back to normal no matter whether the button is released or not, but still leaves the Button look pressed.

*Releasing the button immediately removes any existing timed tasks.

So this code is a proof of principle that events can happen even while a button is in the iteraction phase. This might not be exactly what OP asked for but is my interpretation of the question.
delay = 2; (* time to stay blue when pressed *)
col = None; (* default color *)
down = False; (* default button state *)
EventHandler[Button[Dynamic@Panel[
     If[down, "Pushed", "Push!"], Background -> col, ImageMargins -> 5],
     Appearance -> Dynamic@If[down, "Pressed", "Normal"]],
 {
  "MouseDown" :> (
    down = True;
    RemoveScheduledTask /@ ScheduledTasks[]; (* to prevent multiple click-overlaps *)
    col = Hue[.6, 1, 1, .2];
    task = RunScheduledTask[col = None; RemoveScheduledTask@task, {delay}]),
  "MouseUp" :> (down = False; Quiet@RemoveScheduledTask@task; col = None)
  }, PassEventsDown -> True
 ]

A: For some unknown reason, @István's answer doesn't work here, so I rolled my own:
DynamicModule[{c = Yellow},
              Dynamic@Button["Press", Print["Pressed"];
                             c = Red;
                             RunScheduledTask[c = Yellow;
                                     RemoveScheduledTask[$ScheduledTask], {0}, AbsoluteTime[] + 3],
                             Background -> c]]

A: Here are a couple of ways.  One uses UpdateInterval.  The second uses Clock.  The Clock method continually uses some CPU to update the front end all the while the alternate color (Yellow) is displayed.  The first method makes only one update.  In this way it is more efficient.
In both cases, when the button is pressed, the background color is replaced by a dynamic object that updates itself and persists only while the alternate color is displayed.  The dynamic object is then destroyed after the interval has elasped and the color is replaced with the default color (Red, by my choice).
UpdateInterval method:
DynamicModule[{bgnd = Red, timer = Null, switch},
 Button["go",
  bgnd = Yellow;
  switch = 0;
  timer = Hold @ Refresh[If[switch < 1, switch++, timer = Null; bgnd = Red],
     UpdateInterval -> 2, TrackedSymbols :> {}],
  Background -> Dynamic[ReleaseHold @ timer; bgnd]
  ]
 ]

Clock method:
DynamicModule[{bgnd = Red, clicktime = 0, duration = 2},
 Button["go",
   clicktime = Clock[Infinity];
   bgnd = Hold @ If[Clock[Infinity] < clicktime + duration, Green, bgnd = Red],
   Background -> Dynamic[ReleaseHold @ bgnd]
   ]
 ]

With respect to the code added in an edit, which seems possibly to be seeking a different sort of behavior  -- that is, not for a certain amount of time, but while the Manipulate updates -- here is a simplified version that works:
Manipulate[
 Pause[0.5];
 bgnd = Automatic;
 newSimulation,
 {{newSimulation, 0.02}, ControlType -> None},
 {{bgnd, Automatic}, ControlType -> None},
 Button["New Simulation", newSimulation = newSimulation + 1;
  bgnd = Yellow, Background -> Dynamic[bgnd]]]


text:
Q: C pthread mutex: Expected expression before `{' I am using the pthread library to create two threads. I am using two queues to communicate the data between the two threads (producer-consumer) and hence want to have a mutex to sync the push-pops in the queue by the threads.
But I get a compile error as follows:
$ gcc simple-tun.c simple-tun -lpthread
simple-tun.c: In function 'new_queue':
simple-tun.c:920:13: error: expected expression before '{' token

The the function where I get the error is:
908 struct queue * new_queue () {
909
910     struct queue * q;
911     q = (struct queue *) malloc (sizeof(struct queue));
912
913     if (q == NULL)
914         return NULL;
915
916
917     q->head = NULL;
918     q->tail = NULL;
919     q->is_empty = 1;
920     q->mutex = PTHREAD_MUTEX_INITIALIZER;
921
922     return q;
923 }

structure queue is:
    struct queue {
 80     struct node * head;
 81     struct node * tail;
 82     int is_empty;
 83     pthread_mutex_t mutex;
 84 };

If I comment out line 920, the linker starts giving 'multiple declaration errors'
$ gcc simple-tun.c simple-tun -lpthread
simple-tun: In function `settun':
(.text+0x2b7): multiple definition of `settun'
/tmp/cc5Ms4xP.o:simple-tun.c:(.text+0x1cb): first defined here
simple-tun: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o:(.fini+0x0): first defined here
simple-tun: In function `mktun':
(.text+0x1e2): multiple definition of `mktun'
/tmp/cc5Ms4xP.o:simple-tun.c:(.text+0xf6): first defined here
simple-tun: In function `net_connect':
(.text+0xe27): multiple definition of `net_connect'
/tmp/cc5Ms4xP.o:simple-tun.c:(.text+0x1115): first defined here
simple-tun: In function `data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.data+0x0): first defined here
simple-tun: In function `client_connect':
(.text+0xe95): multiple definition of `client_connect'
/tmp/cc5Ms4xP.o:simple-tun.c:(.text+0x1183): first defined here
simple-tun: In function `data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtbegin.o:(.data+0x0): first defined here
simple-tun:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4+0x0): first defined here
simple-tun: In function `server_connect':
(.text+0xfa2): multiple definition of `server_connect'
/tmp/cc5Ms4xP.o:simple-tun.c:(.text+0x1290): first defined here
simple-tun: In function `print_usage':
(.text+0xe05): multiple definition of `print_usage'
/tmp/cc5Ms4xP.o:simple-tun.c:(.text+0x10f3): first defined here
simple-tun: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../x86_64-linux-gnu/crti.o:(.init+0x0): first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.7/crtend.o:(.tm_clone_table+0x0): multiple definition of `__TMC_END__'
simple-tun:(.data+0x10): first defined here
/usr/bin/ld: error in simple-tun(.eh_frame); no .eh_frame_hdr table will be created.
collect2: error: ld returned 1 exit status

I was not able to find a solution in my searches. Is there something fundamentally wrong with my code? Can someone help me spot what I am doing wrong?
Please let me know if I need to post more snippets or more outputs.

A: PTHREAD_MUTEX_INITIALIZER is exactly that, an initializer to use in declarations:
pthread_mutex_t foo = PTHREAD_MUTEX_INITIALIZER;

if you have a pthread_mutex_t that was created elsewhere - such as by malloc - initialize it with pthread_mutex_init:
pthread_mutex_init(&q->mutex, NULL);

from the SUSV2 documentation for pthread_mutex_init:

In cases where default mutex attributes are appropriate, the macro PTHREAD_MUTEX_INITIALIZER can be used to initialise mutexes that are statically allocated. The effect is equivalent to dynamic initialisation by a call to pthread_mutex_init() with parameter attr specified as NULL, except that no error checks are performed.

A: *

*You can't use PTHREAD_MUTEX_INITIALIZER like that - it has to be used as an initializer, not in a regular assignment expression.  You have two choices to fix it - either call pthread_mutex_init(), or add a typecast to use PTHREAD_MUTEX_INITIALIZER as a compound literal.  Your choice of:
pthread_mutex_init(&q->mutex, NULL);

or:
q->mutex = (pthread_mutex_t)PTHREAD_MUTEX_INITIALIZER;

*Your linker error problem is due to this command line:
gcc simple-tun.c simple-tun -lpthread

You're missing a -o, so you're trying to link the program with itself.  That's bad news.  What you probably want is:
gcc simple-tun.c -o simple-tun -lpthread

And really, you should add some warning flags in there, too.


text:
Q: How can I forbid mouse click links in web browser of my WPF application? I developed a WPF application, in my application I added a webbrowser control, and then I want forbidden mouse click the links in web browser. I have tried like this:
<WebBrowser x:Name="show_web" Canvas.Top="64" Width="900" Height="488" Visibility="Visible" IsEnabled="False" />

but it does not work.  I need a good solution.


text:
Q: `react-map-gl` ERROR Module not found error [MAPBOX] Failed to compile
./node_modules/@math.gl/web-mercator/dist/esm/web-mercator-viewport.js
Module not found: Can't resolve 'gl-matrix/mat4' in 'D:\Projects\react-app\frontend\node_modules\@math.gl\web-mercator\dist\esm'+

I get this on the development status, I tried repeatedly to install and uninstall npm i react-map-gl. I also tried to create a new app but facing same error.

A: The issue is basically one of the dependencies of react-map-gl which is called gl-matrix has upgraded to version 3.4.0 from 3.3.0. Probably because it is a minor upgrade some of its dependant libraries
    ├─┬ mapbox-gl@1.13.1
│ └── gl-matrix@3.3.0
├─┬ react-map-gl@5.3.17
│ └─┬ viewport-mercator-project@7.0.4
│   └─┬ @math.gl/web-mercator@3.5.5
│     └── gl-matrix@3.3.0  deduped
└─┬ viewport-mercator-project@6.2.3
  └── gl-matrix@3.3.0

automatically tried to fetch latest minor version. I'm trying force-resolutions with npm both on docker as well.
You can check which version your packages are using with
- npm ls gl-matrix

then try
- npm install --unsafe-perm to force resolutions if necessary.

A: I had the same issue and in the end had to add gl-matrix as an explicit dependency:
npm install gl-matrix

A:

Installation
Using react-map-gl requires react >= 16.3.

npm install --save react-map-gl mapbox-gl


text:
Q: On a Mac, how do you start TextEdit or TextMate from a shell? (bash) I tried and the only way seemed like typing in
/Applications/TextEdit.app/Contents/MacOS/TextEdit

in a bash shell.  But even when I close the application, it is not considered an exit. I need to go to the app icon on the dock and click "Quit" so that it will exit.
Any other way to invoke and exit it?  thanks.

A: I'd read the MacRumours guide for open, namely running open -e file.txt to open the file with TextEdit, and (if you have set TextWrangler as the default for .txt files) open -t file.txt to open it with TextWrangler (or whatever you have set the default program to). If you're looking to set the default for a file type, see this question.

A: open your .bash_profile using for example:
nano ~/.bash_profile

at the end of the file paste the following:
# TextMate
o(){
open $1 -a textmate.app
}

reload your profile:
source ~/.bash_profile

usage:
o myfile.txt

A: You can use mate [file] to open it from the shell.
This does require that you link this, but it's fairly easy and I believe it might already be an option in the preferences. Just checked, go to "Help" -> "Terminal Usage" in the menubar.
You can also use mate . (note the .) to open the entire current folder as a project in TextMate.

A: For TextMate, just type 'mate filename' in shell. Directory name works too.


text:
Q: iOS How To Convert NSDictionary To URL QueryString In Simplest Way How can I convert NSDictionary To URL QueryString in iOs ?
for example :
NSDictionary *params = @{@"a":@1, @"b":@2}
NSString queryString = convert(params); // a=1&b=2


text:
Q: How to derive total number of items from a pagination endpoint? I have an endpoint that returns a list of objects -- let's say that it's called /getDogs. The API provider exposes some basic pagination options (namely offset and size), but there's no way to get the total number of dogs.
I could do something like:
(pseudocode)
PAGE_SIZE
curPage = 0
while (items left in list)
  dogs = fetch('/getDogs', { offset: currentOffset, size: PAGE_SIZE })
  if dogs.length < PAGE_SIZE
    // we've found the last page
    return curPage * PAGE_SIZE + (PAGE_SIZE - dogs.length) // or something like this
  else
    curPage++
    currentOffset += PAGE_SIZE

This seems inefficient, which is a concern because the API is heavily rate-limited.
How can I efficiently derive the total number of objects using only the offset and size?
Note: I'm trying to get the total number of objects so that I'll be able to A) display the number of total pages and let the user navigate to it, and B) reverse the display order of the items (the endpoint returns the items in an illogical order -- least-recently updated *first*)


text:
Q: Meteor.js MongoDB access? I am new to Mongo and Meteor.
I have installed Meteor on Mac OSX 10.8, and I have created a new Meteor app using a collection called 'Fillup'.
I am going through some tutorials about Mongo, and I am trying to learn the shell commands, but none of them are working.
I want to use Mongo command line to view and manipulate the collection I have going in my Meteor app.
I installed Mongo seperately after Meteor, and I think Meteor might me using a different 'copy' of Mongo, because now when I try 'mongo' I get :
$ mongo
MongoDB shell version: 2.4.5
connecting to: test
Sun Jul 28 14:25:33.055 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed

Whether Meteor is running or not, and Meteor works fine.

A: Try running mongod first and then mongo.

To start MongoDB using all defaults, issue the following command at the system shell:
mongod

This is for vanilla MongoDB though, you might be using a Meteor-specific flavor like someone else mentioned.
http://docs.mongodb.org/manual/tutorial/manage-mongodb-processes/

A: Meteor is using different binaries of Mongo to keep the compatible version.
If you want to test your Mongo shell commands or just play with it on the same version as Meteor, create a Meteor app and keep it running:
meteor create testapp
cd testapp
meteor

And in different shell (or tab) run
meteor mongo

The reason why it didn't work in your case: you didn't start the MongoDB server command mongod. But when you run your Mongo app locally, it will run mongod with the correct set of flags and separate database file.


text:
Q: How do I cast an empty GeometryCollection to an empty typed geometry in PostGIS As a workaround to an obscure issue, I need to do exactly the opposite as describe here in order to harmonize my data set: How to convert a "Polygon" to a "GeometryCollection" type in PostGIS but with the tiny difference that my geometry collections are actually empty (ST_IsEmpty() returns true). (they are the result of an actual 3D intersection which sometimes gives empty geometry collections... I need to figure out why.)
So, to make it clear: how do I cast -- if possible -- an empty ST_GeometryCollection object to en empty typed geometry, i.e. either a point, line or polygon (or their corresponding multi parts, which should only be a matter of applying ST_Multi() on their single part versions)?
My final problem is this error message because I'm using a CTE to INSERT field in an existing table:
Geometry type (LineString) does not match column type (MultiLineString)

Version info:
PostgreSQL 14.1 (Debian 14.1-1.pgdg110+1) on x86_64-pc-linux-gnu,
    compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit

POSTGIS="3.1.4 ded6c34"
    [EXTENSION]
        PGSQL="140"
        GEOS="3.9.0-CAPI-1.16.2"
        SFCGAL="1.3.8"
        PROJ="7.2.1"
        LIBXML="2.9.10"
        LIBJSON="0.15"
        LIBPROTOBUF="1.3.3"
        WAGYU="0.5.0 (Internal)"
        TOPOLOGY


text:
Q: Using a delegate to populate a listbox Ive been playing around with delegates trying to learn and I ran into one small problem Im hoping you can help me with.
class myClass
{
   OtherClass otherClass = new OtherClass(); // Needs Parameter
   otherClass.SendSomeText(myString);
}

class OtherClass
{
   public delegate void TextToBox(string s);

   TextToBox textToBox;

   public OtherClass(TextToBox ttb)  // ***Problem***
   {
       textToBox = ttb;
   }

   public void SendSomeText(string foo)
   {
       textToBox(foo);
   }
}

the form:
public partial class MainForm : Form
   {
   OtherClass otherClass;

   public MainForm()
   {
       InitializeComponent();
       otherClass = new OtherClass(this.TextToBox);
   }

   public void TextToBox(string aString)
   {
       listBox1.Items.Add(aString);
   }

}

Obviously this doesnt compile because the OtherClass constructor is looking for TextToBox as a parameter.   How would you recommend getting around the issue so I can get an object from myClass into the textbox in the form?

A: You can change the OtherClass to something like
class OtherClass
{
    public delegate void TextToBox(string s);

    TextToBox textToBox;

    public OtherClass()
    {
    }
    public OtherClass(TextToBox ttb)  // ***Problem***
    {
        textToBox = ttb;
    }

    public void SendSomeText(string foo)
    {
        if (textToBox != null)
            textToBox(foo);
    }
}

But I am not quite sure what you wish to achive with
class myClass
{
   OtherClass otherClass = new OtherClass(); // Needs Parameter
   otherClass.SendSomeText(myString);
}


text:
Q: The provisioning profile iOS team is expiring soon (free account) The first time I deployed an app to an iPhone I got this warning. When you Google for answers it seems like I should go to https://developer.apple.com/account/ios/certificate and refresh my provisioning profile. However, I can't access that page and just gets redirected to https://developer.apple.com/account/#/welcome.
I REALLY hate to have this warning and it seems that there is no way to remove it. Does anyone know hot to fix this for free accounts (just logging in with Apple ID)?

A: Unfortunately, Apple doesn't allow management of apps, certs or bundle ids without a paid account. However, a correctly-functioning, free account should let Xcode auto-create provisioning profiles which expire in about a week.  And because  they timeout so soon, this causes Xcode to nag you with a warning in order to support Apple (e.g., spending more money) to pay for the privilege of usable development, which is reasonable. Just ignore it or spend $99 USD if you feel it necessary to silence this, deploy apps you wrote for longer than 1 week, deploy apps to other people's devices and perhaps publish a great app which can make you some $ too.


text:
Q: How to place Icons Inside a Data Gird (Material UI)? How describe it in Typescript? This is my Data Gird
import * as React from 'react'
import { DataGrid, GridColDef } from '@material-ui/data-grid'
import { ProductService } from '../services/ProductServices'

const columns: GridColDef[] = [
  { field: 'id', headerName: 'Id', type: 'number', width: 70 },
  { field: 'name', headerName: 'Nome', width: 200 },
  { field: 'description', headerName: 'Descrição', width: 400 },
  { field: 'price', headerName: 'Preço', type: 'number', width: 130 },
  { field: 'quantity', headerName: 'Quantidade', type: 'number', width: 130 },
  { field: 'situation', headerName: 'situação', type: 'number', width: 130 }
]

some code here geting the rows...

export const ProductBox: React.FC = () => {
  return (
    <div style={{ height: 400, width: '100%', marginTop: 75 }}>
      <DataGrid rows={rows} columns={columns} pageSize={5} checkboxSelection />
    </div>
  )
}

And this is my row Interface:
interface IProduct {
  id: number
  name: string
  price: number
  description: string
  quantity: number
  situation: string
}

How to place a field with icon? And how to say that my icon is an icon for typescript?

A: I solved my own problem! Found the answer here:
https://material-ui.com/pt/components/data-grid/columns/


text:
Q: AVCaptureSession audio doesn't work for long videos I'm using AVCaptureSession to record a video with audio. Everything seems to work properly for short videos, but for some reason, if I record a video that is longer than about 12 seconds, the audio doesn't work.

A: Updating videoFileOutput.movieFragmentInterval = kCMTimeInvalid solved this for me.
However, I accidentally set the movieFragmentInterval after calling startRecordingToOutputFileURL. An agonizing hour later I realized my mistake. For newbies like me, note this obvious sequence.
videoFileOutput.movieFragmentInterval = kCMTimeInvalid
videoFileOutput.startRecordingToOutputFileURL(filePath, recordingDelegate: recordingDelegate)

A: kCMTimeInvalid is now deprecated. This is how to assign it now:
videoFileOutput?.movieFragmentInterval = CMTime.invalid

A: Edit (because this answer is still getting upvotes): This answer works to mitigate the problem but the likely root cause for the issue is addressed in @jfeldman's answer.

I found the solution as an answer to a completely different question.
The issue is the movieFragmentInterval property in AVCaptureMovieFileOutput.
The documentation for this property explains what these fragments are:

A QuickTime movie is comprised of media samples and a sample table
identifying their location in the file. A movie file without a sample
table is unreadable.
In a processed file, the sample table typically appears at the
beginning of the file. It may also appear at the end of the file, in
which case the header contains a pointer to the sample table at the
end. When a new movie file is being recorded, it is not possible to
write the sample table since the size of the file is not yet known.
Instead, the table is must be written when recording is complete. If
no other action is taken, this means that if the recording does not
complete successfully (for example, in the event of a crash), the file
data is unusable (because there is no sample table). By periodically
inserting "movie fragments" into the movie file, the sample table can
be built up incrementally. This means that if the file is not written
completely, the movie file is still usable (up to the point where the
last fragment was written).

It also says:

The default is 10 seconds. Set to kCMTimeInvalid to disable movie
fragment writing (not typically recommended).

So for some reason my recording is getting messed up whenever a fragment is written. I just added the line movieFileOutput.movieFragmentInterval = kCMTimeInvalid; (where movieFileOutput is the AVCaptureMovieFileOutput I've added to the AVCaptureSession) to disable fragment writing, and the audio now works.

A: We also experienced this issue. Basically disabling movie fragment writing will work but it doesn't actually explain the issue. Most likely you are recording to an output file using a file extension that does not support this feature, like mp4. If you pass an output file with the extension mov you should have no issues using movie fragment writing and the output file will have audio.


text:
Q: What is the probability of a four occurring in 300 dice rolls? If I rolled a die 300 times and recorded each outcome, what is the chance of rolling at least one four?
I know that the answer will be very close to $1$, but I don't know if there is a formula for finding that exact value.
If I did this with two dice, then $P(4)=\frac{11}{36}$, which I only know how to work out if I draw a two-way table.
Any help is appreciated, thanks!

A: Hint: What is the probability of NOT rolling a single 4?

A: The easiest way to look at this is first to compute the probability that none of the outcomes is a $4$. So for each roll there would then be five possibilities out of six and for two goes this would be $\left(\frac 56\right)^2$ and the probability of at least one $4$ would be $1-\left(\frac 56\right)^2= 1 - \frac {25}{36} = \frac {11}{36}$.
Now apply this thinking to your main case.

A: Ask the complement question:

What is the probability that a 4 will not occur?

That, of course, is $\left(\frac56\right)^{300}$. So the probability of rolling at least one 4 is
$$1-\left(\frac56\right)^{300}=1-1.76046×10^{-24}$$
It really is so close to 1 that I had to resort to just writing the difference out – the raw probability cannot be distinguished from 1 in 64-bit floating point.


text:
Q: How to add rainbow gradient to an Image in android I want to add Transparent Rainbow or Spectrum Gradient to Bitmap.
In photoshop it is very easy. Now I want to do it programmatically. I have gone through a lot of research. But gradient has only one starting color and one ending. How could I add the rainbow color(multiple color) Gradient in Android.
Or is there a way to add that effect to bitmap in Android? Like given

A: for this you can use a translucent image with the desired gradient and put it on top of your image view in a FrameLayout. then capture bitmap of the view.

once you get your layout ready use this answer to capture bitmap from it

try this to convert a view (framelayout) into a bitmap:
public Bitmap viewToBitmap(View view) {
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    view.draw(canvas);
    return bitmap;
}


text:
Q: How do conjugation rules apply for vectors in complex spaces? So I have (1,0,0),(1,2,0),(1,2,3) Inner product is defined to be $x_1$ * conjugate of $x_2$ + $y_1$ *conjugate of $y_2$ +$z_1$ *conjugate of $z_2$
Is the inner product of (1,0,0)(1,2,0), 1*1 or 1*-1?
Also I have the complex vector space with span ((1,1,0,0),(1,1,1+i,1+i),(1 + i,1+i,i,i),(1,1,1,1)). I know that they are LI since the only combination that gives the zero vector is having 0's in front of all vectors. Since it has 4 vectors, I thought it would have dimension 4. The answer is 2, is that because we are looking over the complex vector spaces and therefore the 1st and 4th vectors do not count?