text:
Q: Failure on Push to Docker Registry using 'mvn compile jib:build ' I'm trying to build and deploy my docker image to a private registry using Google JIB maven plugin. However, it fails with issues accessing the private registry.
I have installed Docker Desktop v19.03.1 on my Windows 10 machine. Next I'm trying to using Google JIB Maven plugin to build my Spring Boot application and then push the image built on the private registry.
I have added the CERT to 'example.registry.com' to the Windows trusted CERTS. I was able to verify this using the docker command to login to private registry as below :-
docker login example.registry.com
This command returns success for authentication which means the CERT I added was accepted.
And Following the logon to the private registry, I'm able to PULL and PUSH images using docker command line to 'example.registry.com' successfully .
Below is my POM.xml file.
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>jib-maven-plugin</artifactId>
    <version>1.5.1</version>
    <configuration>
        <to>
           <image>example.registry.com/inventory-service-docker:1.0</image>
            <auth>
               <username>plaintextusernameforRegistry</username>
               <password>plaintestpasswordforRegistry</password>
           </auth>
        </to>
        <from>
             <image>openjdk:8</image>
        </from>
        <container>
           <ports>
              <port>8089</port>
           </ports>
        </container>
        <allowInsecureRegistries>true</allowInsecureRegistries> <!-- this is commented on the first run.-->
    </configuration>
</plugin>

When I run 'mvn compile jib:build' command from the console from the directory with pom.xml file, it does start the processing, however fails at a later stage with below error :-
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.5.1:build (default-cli) on project inventory-service-docker: Build image failed, perhaps you should use a registry that supports HTTPS or set the configuration parameter 'allowInsecureRegistries': Failed to verify the server at https://example.registry.com/v2/inventory-service-docker/blobs/sha256:9cc2ad81d40d54dcae7fa5e8e17d9c34e8bba3b7c2cc7e26fb22734608bda32e because only secure connections are allowed.
When I run the same command after setting the configuration parameter 'allowInsecureRegistries' as suggested from above error, I get a different error as below :-
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:1.5.1:build (default-cli) on project inventory-service-docker: Build image failed: Failed to authenticate with registry example.registry.com/inventory-service-docker because: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
Looks like some config that I'm missing when using JIB that does not connect  to 'example.registry.com' securely.

A: (Before I start, please don't use Jib 1.5.x, as the those versions have a network performance issue.)
JVM doesn't make use of the Windows certificate stores. This doc says

One big problem of the JRE is that it completely ignores the Windows certificate stores. Instead of using the windows certificate store it uses its own implementation

One potential option for Windows I just found in another answer is to start Java with -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT. But I haven't verified myself if this works.
Another way is to add your certificates to the default Java certificate store (truststore) file (cacerts). It is often located under <JDK>/lib/sercurity/ or <JRE>/jre/lib/security/.
There are multiple ways to add certificates (e.g., using various GUI tools). For example,

*

*on the command line

keytool.exe -import -storepass "changeit" -keystore "C:\Program Files (x86)\Java\jre1.8.0_144\lib\security\cacerts" -alias certificate.cer -file "C:\certificate.cer" -noprompt

*

*using a GUI tool called KeyStore Explorer
Lastly, for those who want to get some more ideas for troubleshooting this kind of Java cert issues, check out this comment.


text:
Q: CSS Media Queries not activating at specified widths. Why not? I have a bar that spans across the page (100% width) with a child container inside of it that spans 80% of the parent container's width.
I have the following CSS media query that is supposed to increase the child container's width from 80% to 100%:
@media screen and (max-width: 900px), screen and (max-device-width: 900px){
    #imagebar .container{
        width: 100%;
    }
}

However, using the dimensions given to me by my chrome developer tools, the query is taking affect at a width of 990px. Not 900px. This is occurring with all my media queries; they are all activating 80-100px earlier than they should be. Anyone know what might be causing this?

A: This is formatted wrong.
 @media screen and (max-width: 900px), screen and (max-device-width: 900px){
    #imagebar{
        .container{
            width: 100%;
        }
    }
}

should be:
@media screen and (max-width: 900px), screen and (max-device-width: 900px){
#imagebar .container{
        width: 100%; }

If you want to call on an element inside another element, dont open both elements, just specify which element in which parent you want to edit or change.

A: You can try like this it will work for  you
/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
 @media only screen and (min-width: 480px) and (max-width: 767px) {
  your css  here

}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Mapbox raster image not working in mobile
In mobile view mapbox renders black image instead of raster image. I suspect this is because of the size of image(3.9 MB), also this is happening mostly on chrome browser for mobile. Please help me find the potential issue here?

A: This sounds as if you could be running into the No-Data issue, when rendering transparency.
The black background that appears is the part of the raster image that does not contain any data. Generally a raster image is a rectangular grid of pixels. When you are working with data that is not rectangular, there are pixels within the grid that don't contain any data. These pixels are expressed as NoData values and represent the absence of data. GeoTIFFs that are uploaded to Mapbox Studio are displayed as JPEG to save space and make maps load quickly. Since JPEG cannot display transparency, NoData values appear black.
Please see this documentation on how to resolve this:
https://docs.mapbox.com/help/troubleshooting/raster-transparency-issues/#why-black-backgrounds-appear


text:
Q: What is the best practice to define the routing logic in branch deep links? I was going through the reference documentation of Branch on Cocoapods under the callback it suggests that the routing logic be kept. Heres is what logic I need to implement, but I could not figure out anything apart from an if-else logic. I want to induce a key--> functionality logic instead, what is the way it should be done?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    Branch *branch = [Branch getInstance];
    [branch initSessionWithLaunchOptions:launchOptions isReferrable:YES andRegisterDeepLinkHandler:^(NSDictionary *params, NSError *error) {
        // route the user based on what's in params
        // currently implemented as if-else logic
       if ([params objectForKey:@"key1"]){
           /*Do something*/
       }
       else if ([params objectForKey:@"key2"]){
          /*Do something else*/
       }
    }];
    return YES;
}

A: A good way to do this, would be by passing a url with many components rather than individual keys.
For example the metadata you pass could be :
abc.com/val1/val2

rather than having separate values as key1,key2...
This way,you can parse the url to get the separate path components and branch your routing accordingly.
This will also let you have multiple routes and values, without adding a new key-value pair in the dashboard each time.
Hope this answers your question.


text:
Q: Is only "void" a non-referenceable type? #include <iostream>
using std::cout;
using std::endl;
using std::boolalpha;
using std::add_rvalue_reference_t;
using std::is_reference_v;

int main(void) {

    cout << boolalpha << is_reference_v<add_rvalue_reference_t<int>> << endl;    // true
    cout << boolalpha << is_reference_v<add_rvalue_reference_t<int &>> << endl;  // true
    cout << boolalpha << is_reference_v<add_rvalue_reference_t<int &&>> << endl; // true
    cout << boolalpha << is_reference_v<add_rvalue_reference_t<void>> << endl;   // false

    return 0;
}

I wonder if there are any other types besides void that are non referenceable?

A: std::add_rvalue_reference won't make reference type for function type with cv-qualifier or ref-qualifier too. e.g.
cout << boolalpha << is_reference_v<add_rvalue_reference_t<void() const>> << endl;   // false
cout << boolalpha << is_reference_v<add_rvalue_reference_t<void() volatile>> << endl;   // false
cout << boolalpha << is_reference_v<add_rvalue_reference_t<void() const volatile>> << endl;   // false
cout << boolalpha << is_reference_v<add_rvalue_reference_t<void() &>> << endl;   // false
cout << boolalpha << is_reference_v<add_rvalue_reference_t<void() &&>> << endl;   // false

LIVE


text:
Q: Regulate OpenVPN users' access to specific websites More specifically, I push the route for 5 websites to the clients via the server config. However, I would like to block CLIENTS's access to one of these websites on an ad-hoc basis. In order to achieve this I understand that I have to edit the SERVER's iptables (directly or via ufw).
Unfortunately, I cannot manage to find the right way to do it! The most promising rule I found is
-A FORWARD -m state --state NEW,ESTABLISHED,RELATED -d X.X.X.X -j REJECT

But that does not work. Maybe I am not putting the rule in the appropriate segment of ufw's before rules.
Also various rules of the OUTPUT chain seem worthless.
All other efforts (editing hosts, adding different rules in ufw, etc.) result in the server not being able to access the website, but with the clients unaffected by the rule!
To my surprise I cannot find a suggestion that works, although I thought that website access-control on a VPN would be a trivial issue.


text:
Q: Is there a contradiction between sensorEvent and sensorListener about x-axis? I found two example in these two source code, but sensorEvent.java said "When the device lies flat on a table and is pushed on its left side toward the right, the x acceleration value is positive." and sensorListener.java said "When the device is pushed on its left side toward the right, the x acceleration value is negative (the device applies a reaction force to the push toward the left)". You can scroll up to see what Definition of the coordinate system is and you can find they are same. So I'm confused.
Of cause I do an experiment that just push my phone left side toward the right, I see x-axis is rising.
So,is there a wrong in example or I miss something?
Here is sensorEvent.java and sensorListener.java

A: As far as I know, the statement in SensorEvent is correct - illustrated by your own experiment. SensorListener has been deprecated for quite some time already (at least two years - it has been replaced by SensorEventListener), so you should assume the non-deprecated statement to be correct.
My guess is that in the earlier days of Android, the acceleration values used to be mirrored, as the difference between one of the other examples mentioned in both of these classes is similar to what you're getting confused by:
Current (in SensorEvent):

When the device lies flat on a table, the acceleration value is +9.81,
  which correspond to the acceleration of the device (0 m/s^2) minus the
  force of gravity (-9.81 m/s^2).

Deprecated (in SensorListener):

When the device lies flat on a table, the acceleration value is
  -STANDARD_GRAVITY, which correspond to the force the device applies on the table in reaction to gravity.

-STANDARD_GRAVITY resolves to -(9.80665) = -9.80665, exactly the opposite of the positive value stated in SensorEvent.


text:
Q: Android Simple client app sending text to google cloud datastore ? example, hints I am new to this environment and trying to explore while doing this task.
Description: The client application should display a textbox of any kind, and a submit button of any kind.
Assumptions: The server should be written in Google Application Framework and deployed online in a Google Application Framework account.

A: All in all, this is not an easy task.
First read tutorials on all your basic technologies: AppEngine and Android. There are plenty around. You should know how to make a text box on Android and handle click events.
Then to post some data to AppEngine from Android you'll need:

*

*The hardest part - user authentication. Three options:

*

*Your own username/passwords. You need a signup/login pages on AppEngine and at least a login page on Android. You also need a email confirmation.

*OpenID. Easy to setup on AppEngine. Hard to do on Android: Webservice credentials - OpenID/Android AccountManager?

*OAuth. Easy on Appengine. Pretty easy on Android. Requires Google account on Android phone and access to it (app privileges - not all people like this).

*REST service on AppEngine. Use Resteasy. And GSON for JSON conversion.

*REST client on Android. Example, video. Also use GSON.


text:
Q: How to display form on c# at spcefic time? I have a c# app form. A form will appear that shows all task to do for the day. This form will appear a half-hour before task start. I want to display this form when the program closes.

A: I can't quite figure out the exact question, but it's clear that you want to be able to display a form at a specific time (I figured this out from the title :-) )
Anyway...there are multiple ways to accomplish this, and it depends on what you are hoping to achieve.
If, for instance, you are planning on the app running all the time, you could have app set up a timer to go off then the specific time occurs and process the timer event.
Or, if you don't plan on the app running all the time, using the Windows task scheduler to automatically start your app at the appropriate time,
If you can provide more information on exactly what you are trying to do, and what constraints you have (and ask Romoku asks...what have you tried, see this link for examples of how to formulate a better question.

A: You could implement a Windows service that displays a form at a certain time. This would have to be running all the time.
Or you schedule a task for your application before it closes.


text:
Q: Issue with cts:field-word-query I have created a field named 'publication-titles' in my MarkLogic database (say ABC) based on element XPath.
The following query works fine on QC with Content Source as database 'ABC' (in which field exists)
let $text := 'The Point'

let $query := cts:field-word-query("publication-titles", $text,
("punctuation-sensitive", "case-insensitive", "whitespace-sensitive"), 5.0)

return
  xdmp:invoke-function(function()
    {
      cts:search(/Publication, $query)[1]
    },
    <options xmlns="xdmp:eval">
      <database>{xdmp:database("ABC")}</database>
    </options>
  )

However, if I change the Content Source to any other database, I get the following error
[1.0-ml] XDMP-NOFIELD: cts:search(fn:collection()/Publication, cts:field-
word-query("publication-titles", "The Point", ("case-
insensitive","punctuation-sensitive","whitespace-sensitive","lang=en"), 5)) -
- Field not defined: publication-titles
Stack Trace
At line 8 column 8:
In function() as item()*()

6. xdmp:invoke-function(function()
7. {
8. cts:search(/Publication, $query)[1]
9. },
10. <options xmlns="xdmp:eval">

Can anyone help me understand what is going wrong here?

A: Certain query constructors have dependencies on the execution context. Field queries and range or geospatial queries have the most obvious dependency (does the index exist? what are its parameters?), but value and word queries also look at the configuration to determine whether they are position sensitive or enabled at all. When you put the constructor outside the invoke-function, it will be called in the outer configuration. Often this won't make a material difference, but in many cases it will, or it will make a subtle difference (e.g. failing to use positions when you should have). There is no way to make this work in the way you'd like, any more than we could make a call to xdmp:database() work in that context.
Things should work if you just perform the same call inside the function body (i.e. just put the same let/return in there). The bug is that this too doesn't work, because the constructors incorrectly think they can be optimized in a way that the outer context executes them in the optimization phase. I'll fix this under 50017.

A: (replaced answer)
It looks like you have hit an unfortunate bug that seems to apply to all cts:field-*-query query constructors, but not to any of the others (not thoroughly verified).
Inline functions have the difficulty that they carry along context from where they are invoked as well as their own, so that explains potential references to the wrong database. It can be tricky to apply to correct context. I have filed a bug report, so hopefully this gets resolved soon in one of the next patch releases.
In the meantime, it is best to enforce the query constructor to get re-evaluated in the inner context. You can do that by serializing the query to XML, and parsing it inside the inline function. That is fairly easy to do. Wrap the constructor with document { .. }/*, and to parse it you use cts:query($query):
let $text := 'The Point'

let $query := document{
  cts:field-word-query("publication-titles", $text,
("punctuation-sensitive", "case-insensitive", "whitespace-sensitive"), 5.0)
}/*

return
  xdmp:invoke-function(function()
    {
      cts:search(/Publication, cts:query($query))[1]
    },
    <options xmlns="xdmp:eval">
      <database>{xdmp:database("ABC")}</database>
    </options>
  )

There is a very small penalty for the serialize and parsing, but that is likely negligible compared to the actual search time.
HTH!


text:
Q: Moving displayed data from Qt table to sqlite3 db I am new to python but have been able to create a pyside qt gui and fill the various boxes and a table with data from my application.  Basically it gets a test file reference from one .csf file and test criteria from another .csv file and fills the qt GUI with the results of the test application.  One of my GUI action buttons is supposed to take the data from boxes and all rows in the table and input into an sqlite3 database named "testresults.db"  I can create the database table with the headers.  I want to get gui data from some of the boxes and all the table data for each row into the testresults database.  I have seen lots of examples of moving data FROM a .db to Gui but none coming the other way.  Below is the header info from my main application and also the GUI code.  Any suggestions would be appreciated.
from PySide.QtGui import *
from ui_files import pyExpMainWindow
import sys
import sqlite3
import csv
import time
import os

class Main(QMainWindow, pyExpMainWindow.Ui_MainWindow):
    dbPath =(os.getcwd() + "\TestData.db")
    dbConn = sqlite3.connect(dbPath)
    def __init__(self, parent=None, index=None):
        super(Main, self).__init__(parent)
        self.setupUi(self)

        self.dbCursor = self.dbConn.cursor()
        self.dbCursor.execute("""CREATE TABLE IF NOT EXISTS Main(id INTEGER PRIMARY KEY,
                                assypartno TEXT, userialno TEXT, bserialno TEXT, testfile TEXT, desc TEXT,
                                expectedvalue TEXT, actualvalue TEXT, lowlimit TEXT, highlimit TEXT,
                                 status TEXT, time TEXT, opername TEXT)""")
        self.dbConn.commit()    # creates table if file doesn't exist
        self.start.clicked.connect(self.Start_T)
        self.repeat.clicked.connect(self.Repeat_Test)
        self.record.clicked.connect(self.Record_R)
        self._print.clicked.connect(self.Print_Report)
        self.cancel.clicked.connect(self.Cancel_Testing)
        self.load_initial_settings()

        with open("testprogs.csv", "rb") as f:  # testprogs.csv is the list of testable assemblies
            reader = csv.reader(f)
            for row in reader:
                line = row[0]
                if line[0] == "#":
                    continue
                self.partno.addItem(row[1])

    def load_initial_settings(self):
        """Loads the initial settings for the application. Sets the mainTable column widths,"""
        self.dbCursor.execute("""SELECT * FROM Main""")
        allRows = []    #Specifies a blank table so table just fills with header info
        for row in allRows:
            inx = allRows.index(row)
            self.mainTable.insertRow(inx)
            self.mainTable.setItem(inx, 0, QTableWidgetItem(row[1]))
            self.mainTable.setItem(inx, 1, QTableWidgetItem(row[2]))
            self.mainTable.setItem(inx, 2, QTableWidgetItem(row[3]))
            self.mainTable.setItem(inx, 3, QTableWidgetItem(row[4]))
************************************************************

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file '.\experiment.ui'
#
# Created: Wed Jul 09 07:02:46 2014
#      by: pyside-uic 0.2.15 running on PySide 1.2.2
#
# WARNING! All changes made in this file will be lost!

from PySide import QtCore, QtGui

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(865, 738)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.start = QtGui.QPushButton(self.centralwidget)
        self.start.setGeometry(QtCore.QRect(170, 30, 75, 23))
        self.start.setObjectName("start")
        self.partno = QtGui.QComboBox(self.centralwidget)
        self.partno.setGeometry(QtCore.QRect(10, 30, 151, 22))
        self.partno.setEditable(True)
        self.partno.setObjectName("partno")
        self.repeat = QtGui.QPushButton(self.centralwidget)
        self.repeat.setGeometry(QtCore.QRect(270, 30, 75, 23))
        self.repeat.setObjectName("repeat")
        self.cancel = QtGui.QPushButton(self.centralwidget)
        self.cancel.setGeometry(QtCore.QRect(640, 80, 75, 23))
        self.cancel.setObjectName("cancel")
        self.record = QtGui.QPushButton(self.centralwidget)
        self.record.setGeometry(QtCore.QRect(360, 30, 75, 23))
        self.record.setObjectName("record")
        self._print = QtGui.QPushButton(self.centralwidget)
        self._print.setGeometry(QtCore.QRect(460, 80, 75, 23))
        self._print.setObjectName("_print")
        self.description = QtGui.QLabel(self.centralwidget)
        self.description.setGeometry(QtCore.QRect(10, 80, 151, 20))
        self.description.setAlignment(QtCore.Qt.AlignCenter)
        self.description.setObjectName("description")
        self._operator = QtGui.QLineEdit(self.centralwidget)
        self._operator.setGeometry(QtCore.QRect(160, 80, 113, 20))
        self._operator.setAlignment(QtCore.Qt.AlignCenter)
        self._operator.setObjectName("_operator")
        self.unit_serialno = QtGui.QLineEdit(self.centralwidget)
        self.unit_serialno.setGeometry(QtCore.QRect(310, 80, 113, 20))
        self.unit_serialno.setAlignment(QtCore.Qt.AlignCenter)
        self.unit_serialno.setObjectName("unit_serialno")
        self.testno = QtGui.QLineEdit(self.centralwidget)
        self.testno.setGeometry(QtCore.QRect(460, 30, 113, 20))
        self.testno.setAlignment(QtCore.Qt.AlignCenter)
        self.testno.setObjectName("testno")
        self.brd_serialno = QtGui.QLineEdit(self.centralwidget)
        self.brd_serialno.setGeometry(QtCore.QRect(310, 110, 113, 20))
        self.brd_serialno.setAlignment(QtCore.Qt.AlignCenter)
        self.brd_serialno.setObjectName("brd_serialno")
        self.mainTable = QtGui.QTableWidget(self.centralwidget)
        self.mainTable.setGeometry(QtCore.QRect(20, 150, 811, 541))
        self.mainTable.setObjectName("mainTable")
        self.mainTable.setColumnCount(5)
        self.mainTable.setRowCount(0)
        item = QtGui.QTableWidgetItem()
        self.mainTable.setHorizontalHeaderItem(0, item)
        item = QtGui.QTableWidgetItem()
        self.mainTable.setHorizontalHeaderItem(1, item)
        item = QtGui.QTableWidgetItem()
        self.mainTable.setHorizontalHeaderItem(2, item)
        item = QtGui.QTableWidgetItem()
        self.mainTable.setHorizontalHeaderItem(3, item)
        item = QtGui.QTableWidgetItem()
        self.mainTable.setHorizontalHeaderItem(4, item)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QObject.connect(self.partno, QtCore.SIGNAL("currentIndexChanged(int)"), MainWindow.update)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
        self.start.setText(QtGui.QApplication.translate("MainWindow", "Start", None, QtGui.QApplication.UnicodeUTF8))
        self.repeat.setText(QtGui.QApplication.translate("MainWindow", "Repeat Test", None, QtGui.QApplication.UnicodeUTF8))
        self.cancel.setText(QtGui.QApplication.translate("MainWindow", "Cancel", None, QtGui.QApplication.UnicodeUTF8))
        self.record.setText(QtGui.QApplication.translate("MainWindow", "Record", None, QtGui.QApplication.UnicodeUTF8))
        self._print.setText(QtGui.QApplication.translate("MainWindow", "Print Report", None, QtGui.QApplication.UnicodeUTF8))
        self.description.setText(QtGui.QApplication.translate("MainWindow", "Description", None, QtGui.QApplication.UnicodeUTF8))
        self._operator.setText(QtGui.QApplication.translate("MainWindow", "Operator Name", None, QtGui.QApplication.UnicodeUTF8))
        self.unit_serialno.setText(QtGui.QApplication.translate("MainWindow", "Unit Serial #", None, QtGui.QApplication.UnicodeUTF8))
        self.testno.setText(QtGui.QApplication.translate("MainWindow", "Test #", None, QtGui.QApplication.UnicodeUTF8))
        self.brd_serialno.setText(QtGui.QApplication.translate("MainWindow", "Board Serial #", None, QtGui.QApplication.UnicodeUTF8))
        self.mainTable.horizontalHeaderItem(0).setText(QtGui.QApplication.translate("MainWindow", "Test", None, QtGui.QApplication.UnicodeUTF8))
        self.mainTable.horizontalHeaderItem(1).setText(QtGui.QApplication.translate("MainWindow", "Description", None, QtGui.QApplication.UnicodeUTF8))
        self.mainTable.horizontalHeaderItem(2).setText(QtGui.QApplication.translate("MainWindow", "Expected", None, QtGui.QApplication.UnicodeUTF8))
        self.mainTable.horizontalHeaderItem(3).setText(QtGui.QApplication.translate("MainWindow", "Actual", None, QtGui.QApplication.UnicodeUTF8))
        self.mainTable.horizontalHeaderItem(4).setText(QtGui.QApplication.translate("MainWindow", "Pass/Fail", None, QtGui.QApplication.UnicodeUTF8))


text:
Q: Is there a way to write make_unique() in VS2012? Herb Sutter propose a simple implementation of make_unique() there: http://herbsutter.com/gotw/_102/
Here it is:
template<typename T, typename ...Args>
std::unique_ptr<T> make_unique( Args&& ...args )
{
    return std::unique_ptr<T>( new T( std::forward<Args>(args)... ) );
}

My problem is that variadic templates are not yet part of VS2012, so I can't use this code as is.
Is there a maintainable way to write this in VS2012 that wouldn't involve copy-pasting the same function with different args count?

A: Even though variadic templates are not part of VS2012, there are macros built into the header file <memory> that help simulate them.
See this very nice answer which shows how to implement make_unique<T> in just a few cryptic lines.  I confirmed that it works well:

#include <memory> // brings in TEMPLATE macros.
#define MAKE_UNIQUE(TEMPLATE_LIST, PADDING_LIST, LIST, COMMA, X1, X2, X3, X4)   \
  template<class T COMMA LIST(_CLASS_TYPE)>  \
  inline std::unique_ptr<T> make_unique(LIST(_TYPE_REFREF_ARG))  \
  {  \
      return std::unique_ptr<T>(new T(LIST(_FORWARD_ARG)));  \
  }
_VARIADIC_EXPAND_0X(MAKE_UNIQUE, , , , )
#undef MAKE_UNIQUE

A: You could use Boost.Preprocessor to generate the different parameter counts, but I really don't see the advantage of that. Simply do the grunt job once, stuff it in a header and be done. You're saving yourself compile time and have your make_unique.
Here's a copy-paste of my make_unique.h header that simulates variadic templates for up to 5 arguments.

Since OP seems to not like copy-paste work, here's the Boost.Preprocessor code to generate the above:
First, make a main header that includes the template header multiple times (Boost.Preprocessor iteration code blatantly stolen from this answer):
// make_unique.h
#include <memory>
#include <utility>
#include <boost/preprocessor.hpp>

#ifndef MAKE_UNIQUE_NUM_ARGS
// allow this to be changed to a higher number if needed,
// ten is a good default number
#define MAKE_UNIQUE_NUM_ARGS 10
#endif

#if MAKE_UNIQUE_NUM_ARGS < 0
// but don't be stupid with it
#error Invalid MAKE_UNIQUE_NUM_ARGS value.
#endif

/* optional, see above for premade version
// include premade functions, to avoid the costly iteration
#include "detail/blah_premade.hpp

// generate classes if needed
#if MAKE_UNIQUE_NUM_ARGS > MAKE_UNIQUE_NUM_PREMADE
*/
#define BOOST_PP_ITERATION_LIMITS (0, MAKE_UNIQUE_NUM_ARGS)
#define BOOST_PP_FILENAME_1 "make_unique_template.h"
#include BOOST_PP_ITERATE()
//#endif

And now make a template header that gets included again and again and expands differently depending on the value of MAKE_UNIQUE_NUM_ARGS:
// make_unique_template.h
// note: no include guard

#define N BOOST_PP_ITERATION()

#define MAKE_UNIQUE_TEMPLATE_PARMS \
  BOOST_PP_ENUM_PARAMS(N, typename A)

#define MAKE_UNIQUE_FUNCTION_PARM(J,I,D) \
  BOOST_PP_CAT(A,I)&& BOOST_PP_CAT(a,I)

#define MAKE_UNIQUE_FUNCTION_PARMS \
  BOOST_PP_ENUM(N, MAKE_UNIQUE_FUNCTION_PARM, BOOST_PP_EMPTY)

#define MAKE_UNIQUE_ARG(J,I,D) \
  std::forward<BOOST_PP_CAT(A,I)>(BOOST_PP_CAT(a,I))

#define MAKE_UNIQUE_ARGS \
  BOOST_PP_ENUM(N, MAKE_UNIQUE_ARG, BOOST_PP_EMPTY)

template<class T BOOST_PP_COMMA_IF(N) MAKE_UNIQUE_TEMPLATE_PARMS>
std::unique_ptr<T> make_unique(MAKE_UNIQUE_FUNCTION_PARMS){
  return std::unique_ptr<T>(new T(MAKE_UNIQUE_ARGS));
}

// clean up
#undef MAKE_UNIQUE_TEMPLATE_PARMS
#undef MAKE_UNIQUE_FUNCTION_PARM
#undef MAKE_UNIQUE_FUNCTION_PARMS
#undef MAKE_UNIQUE_ARG
#undef MAKE_UNIQUE_ARGS
#undef N

A: The only way to simulate functions  with variadic argument lists is by creating a suitable list of overloads. Whether this is done manually, using something like the Boost preprocessor library, or using a suitable generator all amounts to the same: real variadic argument lists cannot be simulated. Personally, I think the most maintainable version of simulating variadic argument lists is to use a compiler which supports them as preprocessor and have it generate code suitable to be compiled by compilers not, yet, up to support variadic templates.

A: I have extended Hugues's answer to handle creating unique pointers which wrap arrays  (basically merged it with the code in this paper) and obtained the following, which works fine in my VC2012 projects:
#include <memory>

template<class T> struct _Unique_if {
    typedef std::unique_ptr<T> _Single_object;
};

template<class T> struct _Unique_if<T[]> {
    typedef std::unique_ptr<T[]> _Unknown_bound;
};

template<class T, size_t N> struct _Unique_if<T[N]> {
    typedef void _Known_bound;
};

// Visual Studio 2012 - specific
#define _MAKE_UNIQUE(TEMPLATE_LIST, PADDING_LIST, LIST, COMMA, X1, X2, X3, X4)                                          \
template<class T COMMA LIST(_CLASS_TYPE)> inline typename _Unique_if<T>::_Single_object make_unique(LIST(_TYPE_REFREF_ARG))  \
{                                                                                \
    return std::unique_ptr<T>(new T(LIST(_FORWARD_ARG)));                                                                    \
}
_VARIADIC_EXPAND_0X(_MAKE_UNIQUE, , , , )
#undef _MAKE_UNIQUE

template<class T> inline typename _Unique_if<T>::_Unknown_bound make_unique(size_t n)
{
    typedef typename std::remove_extent<T>::type U;
    return std::unique_ptr<T>(new U[n]());
}

// Visual Studio 2012 - specific
#define _MAKE_UNIQUE(TEMPLATE_LIST, PADDING_LIST, LIST, COMMA, X1, X2, X3, X4)                                          \
template<class T COMMA LIST(_CLASS_TYPE)> typename _Unique_if<T>::_Known_bound make_unique(LIST(_TYPE_REFREF_ARG)) = delete;
_VARIADIC_EXPAND_0X(_MAKE_UNIQUE, , , , )
#undef _MAKE_UNIQUE

A: Just out of curiosity I have tried to make similar thing - I needed to support more arguments than 4 - for _VARIADIC_EXPAND_0X kind of solution - probably only 4 will be supported.
Here is MacroArg.h header file:
#pragma once

//
// Retrieve the type
//
//  ARGTYPE( (ArgType) argName )                         => ArgType
//
// https://stackoverflow.com/questions/41453/how-can-i-add-reflection-to-a-c-application
//
#define ARGTYPE(x) ARGTYPE_PASS2(ARGTYPE_PASS1 x,)
//
//      => ARGTYPE_PASS2(ARGTYPE_PASS1 (ArgType) argName,)
//
#define ARGTYPE_PASS1(...) (__VA_ARGS__),
//
//      => ARGTYPE_PASS2( (ArgType), argName,)
//
#define ARGTYPE_PASS2(...) ARGTYPE_PASS3((__VA_ARGS__))
//
//      => ARGTYPE_PASS2(( (ArgType), argName,))
//
#define ARGTYPE_PASS3(x)   ARGTYPE_PASS4 x
//
//      => ARGTYPE_PASS4 ( (ArgType), argName,)
//
#define ARGTYPE_PASS4(x, ...) REM x
//
//      => REM (ArgType)
//
#define REM(...) __VA_ARGS__
//
//      => ArgType
//

//
// This counts the number of args: (0 is also supported)
//
//
//  NARGS( (ArgType1) argName1, (ArgType2) argName2 )   => 2
//
#define NARGS(...) NARGS_PASS2(NARGS_PASS1(__VA_ARGS__))
//
//  => NARGS_PASS2(NARGS_PASS1( (ArgType1) argName1, (ArgType2) argName2 ) )
//
#define NARGS_PASS1(...) unused, __VA_ARGS__
//
//  => NARGS_PASS2( unused, (ArgType1) argName1, (ArgType2) argName2 )
//
#define NARGS_PASS2(...) NARGS_PASS4(NARGS_PASS3(__VA_ARGS__, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
//
//  => NARGS_PASS4(NARGS_PASS3( unused, (ArgType1) argName1, (ArgType2) argName2 ) , 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) )
//
#define NARGS_PASS3(_unused,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,VAL, ...) VAL
//
//  => NARGS_PASS4(2)
//
#define NARGS_PASS4(x) x
//
//  => 2
//

//
// Show the type without parenthesis
//
//  ARGPAIR( (ArgType1) argName1 )                         => ArgType1 argName1
//
#define ARGPAIR(x) REM x
//
//  => REM (ArgType1) argName1
//
//  => ArgType1 argName1
//

//
// Show the type without parenthesis
//
//  ARGPAIR( (ArgType1) argName1 )                         => ArgType1 && argName1
//
#define REFARGPAIR(x) REFREM x
//
//  => REFREM (ArgType1) argName1

#define REFREM(...) __VA_ARGS__ &&
//
//  => ArgType1 && argName1
//

//
// Strip off the type
//
//  ARGNAME( (ArgType1) argName1 )                      => argName1
//
#define ARGNAME(x) EAT x
//
//      => EAT (ArgType1) argName1
//
#define EAT(...)
//
//      => argName1
//

//
// This will call a macro on each argument passed in
//
//  DOFOREACH(typename ARGTYPE, (ArgType1) argName1, (ArgType1) argName2 )
//
#define DOFOREACH(macro, ...) DOFOREACH_PASS1(CAT(DOFOREACH_, NARGS(__VA_ARGS__)), (macro, __VA_ARGS__))
//
//          => DOFOREACH_PASS1(CAT(DOFOREACH_, NARGS( (ArgType1) argName1, (ArgType1) argName2 ) ), (typename ARGTYPE, (ArgType1) argName1, (ArgType1) argName2 ) ))
//          => DOFOREACH_PASS1(CAT(DOFOREACH_, 2), (typename ARGTYPE, (ArgType1) argName1, (ArgType1) argName2 ) ))
//
#define CAT(x, y) CAT_PASS1((x, y))
//
//          => DOFOREACH_PASS1(CAT_PASS1((DOFOREACH_, 2)), (typename ARGTYPE, (ArgType1) argName1, (ArgType1) argName2 ) ))
//
#define CAT_PASS1(x) PRIMITIVE_CAT x
//
//          => DOFOREACH_PASS1(PRIMITIVE_CAT (DOFOREACH_, 2), (typename ARGTYPE, (ArgType1) argName1, (ArgType1) argName2 ) ))
//
#define PRIMITIVE_CAT(x, y) x ## y
//
//          => DOFOREACH_PASS1( DOFOREACH_2 ), (typename ARGTYPE, (ArgType1) argName1, (ArgType1) argName2 ) ))
//
#define DOFOREACH_PASS1(m, x) m x
//
//          => DOFOREACH_2 (typename ARGTYPE, (ArgType1) argName1, (ArgType1) argName2 ) )
//
#define DOFOREACH_0(m)
#define DOFOREACH_1(m, x1) m(x1)
#define DOFOREACH_2(m, x1, x2) m(x1), m(x2)
//
//          => typename ARGTYPE( (ArgType1) argName1 ), typename ARGTYPE( (ArgType1) argName2 ) )
//          => typename ArgType1, typename ArgType1
//
#define DOFOREACH_3(m, x1, x2, x3) m(x1), m(x2), m(x3)
#define DOFOREACH_4(m, x1, x2, x3, x4) m(x1), m(x2), m(x3), m(x4)
#define DOFOREACH_5(m, x1, x2, x3, x4, x5) m(x1), m(x2), m(x3), m(x4), m(x5)
#define DOFOREACH_6(m, x1, x2, x3, x4, x5, x6) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6)
#define DOFOREACH_7(m, x1, x2, x3, x4, x5, x6, x7) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7)
#define DOFOREACH_8(m, x1, x2, x3, x4, x5, x6, x7, x8) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
#define DOFOREACH_9(m, x1, x2, x3, x4, x5, x6, x7, x8, x9) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9)
#define DOFOREACH_10(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10)
#define DOFOREACH_11(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11)
#define DOFOREACH_12(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11), m(x12)
#define DOFOREACH_13(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11), m(x12), m(x13)
#define DOFOREACH_14(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11), m(x12), m(x13), m(x14)
#define DOFOREACH_15(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11), m(x12), m(x13), m(x14), m(x15)

//
//  Same version as DOFOREACH, except this one meant to be used for appending list of arguments. If 0 arguments, then list is not appended, otherwise additional command is added in front.
//
#define DOFOREACH2(macro, ...) DOFOREACH_PASS1(CAT(DOFOREACH2_, NARGS(__VA_ARGS__)), (macro, __VA_ARGS__))

#define DOFOREACH2_0(m)
#define DOFOREACH2_1(m, x1) ,m(x1)
#define DOFOREACH2_2(m, x1, x2) ,m(x1), m(x2)
#define DOFOREACH2_3(m, x1, x2, x3) ,m(x1), m(x2), m(x3)
#define DOFOREACH2_4(m, x1, x2, x3, x4) ,m(x1), m(x2), m(x3), m(x4)
#define DOFOREACH2_5(m, x1, x2, x3, x4, x5) ,m(x1), m(x2), m(x3), m(x4), m(x5)
#define DOFOREACH2_6(m, x1, x2, x3, x4, x5, x6) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6)
#define DOFOREACH2_7(m, x1, x2, x3, x4, x5, x6, x7) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7)
#define DOFOREACH2_8(m, x1, x2, x3, x4, x5, x6, x7, x8) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8)
#define DOFOREACH2_9(m, x1, x2, x3, x4, x5, x6, x7, x8, x9) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9)
#define DOFOREACH2_10(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10)
#define DOFOREACH2_11(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11)
#define DOFOREACH2_12(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11), m(x12)
#define DOFOREACH2_13(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11), m(x12), m(x13)
#define DOFOREACH2_14(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11), m(x12), m(x13), m(x14)
#define DOFOREACH2_15(m, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15) ,m(x1), m(x2), m(x3), m(x4), m(x5), m(x6), m(x7), m(x8), m(x9), m(x10), m(x11), m(x12), m(x13), m(x14), m(x15)

//
//  ARGX(1)     =>      (Arg1) arg1
//
#define ARGX(index) (Arg##index) arg##index

//
//  Defines same function with different amount of arguments.
//
#define DEFINE_MULTIARG_FUNC(macro) \
    macro ( ARGX(1) ); \
    macro ( ARGX(1), ARGX(2) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11), ARGX(12) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11), ARGX(12), ARGX(13)  ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11), ARGX(12), ARGX(13), ARGX(14)  ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11), ARGX(12), ARGX(13), ARGX(14), ARGX(15)  ); \

//
//  Same as previous, except add support also of function with no arguments.
//  (template functions normally requires at least one template parameter (so you write template<> in front of function and won't get error), that's why separate define)
//
#define DEFINE_MULTIARG_FUNC2(macro) \
    macro ( ); \
    macro ( ARGX(1) ); \
    macro ( ARGX(1), ARGX(2) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11), ARGX(12) ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11), ARGX(12), ARGX(13)  ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11), ARGX(12), ARGX(13), ARGX(14)  ); \
    macro ( ARGX(1), ARGX(2), ARGX(3), ARGX(4), ARGX(5), ARGX(6), ARGX(7), ARGX(8), ARGX(9), ARGX(10), ARGX(11), ARGX(12), ARGX(13), ARGX(14), ARGX(15)  ); \

/*
    Here is simple example of usage of these macros:

    #define MKFUNC_make_unique(...) \
    template <class T  DOFOREACH2(typename ARGTYPE, __VA_ARGS__) > \
    std::unique_ptr<T> make_unique(  DOFOREACH(REFARGPAIR, __VA_ARGS__) ) \
    { \
        return std::unique_ptr<T>( new T( DOFOREACH(ARGNAME, __VA_ARGS__) ) ); \
    }

    DEFINE_MULTIARG_FUNC2(MKFUNC_make_unique);      //<--
    #undef MKFUNC_make_unique

    Debugger will stall in "<--" this line, so it makes sense to keep amount of line absolute minimal.
*/

Some of details on debugging macros can be found here (similar kind of problem being discussed)
How can I add reflection to a C++ application?

A: I know I am late to the party here, but I just came across this. I have been doing this with a one-liner macro (and is VS2012 compatible):
#define MAKE_UNIQUE(T, ...) std::unique_ptr<T>(new T(__VA_ARGS__))

Or less portable, but you can pass in empty params
#define MAKE_UNIQUE(T, ...) std::unique_ptr<T>(new T(##__VA_ARGS__))

Use like this:
// MAKE_UNIQUE takes the type followed by the arguments list ...
std::unique_ptr<MyClass> pPointer = MAKE_UNIQUE(MyClass, param_1, param_2, ..., param_n);


text:
Q: I want to remove whitespace in sentences import "strings"
formatted_text := strings.TrimSpace (unformatted_text)

I want to format the text obtained by scraping.
In this way, leading and trailing whitespace can be removed, but whitespace in sentences is not.
How can I easily remove white space?

A: Use strings.ReplaceAll
s = strings.ReplaceAll(s, " ", "")


text:
Q: accessing ERRORLEVEL from bash script I have an application that only works properly when called from a windows command prompt. Something to do with the input/output streams.
So I can call it from a bash script by passing it as an argument to cmd.
cmd /c "badapp"
This works fine - but occasionally badapp fails with network problems - and I get no feedback. Is there anyway to check the ERRORLEVEl from the bash script - or see the output from badapp on the terminal running the bash script?

A: Yes, $? is the variable that contains the error level.
Try echo $? for example.
An example from Cygwin bash (I'm guessing you are using Cygwin because you are using the Windows cmd in your example.)
susam@nifty /cygdrive/c/Documents and Settings/susam/Desktop
$ cmd /c "badapp"
'badapp' is not recognized as an internal or external command,
operable program or batch file.

susam@nifty/cygdrive/c/Documents and Settings/susam/Desktop
$ if [ $? -eq 0 ]
> then
>   echo "good"
> else
>   echo "bad"
> fi
bad


text:
Q: lexer error-handling PLY Python The t_error() function is used to handle lexing errors that occur when illegal characters are detected. My question is: How can I use this function to get more specific information on errors? Like error type, in which rule or section the error appears, etc.

A: In general, there is only very limited information available to the t_error() function. As input, it receives a token object where the value has been set to the remaining input text.   Analysis of that text is entirely up to you.   You can use the t.lexer.skip(n) function to have the lexer skip ahead by a certain number of characters and that's about it.
There is no notion of an "error type" other than the fact that there is an input character that does not match the regular expression of any known token.  Since the lexer is decoupled from the parser, there is no direct way to get any information about the state of the parsing engine or to find out what grammar rule is being parsed.  Even if you could get the state (which would simply be the underlying state number of the LALR state machine), interpretation of it would likely be very difficult since the parser could be in the intermediate stages of matching dozens of possible grammar rules looking for reduce actions.
My advice is as follows:  If you need additional information in the t_error() function, you should set up some kind of object that is shared between the lexer and parser components of your code.  You should explicitly make different parts of your compiler update that object as needed (e.g., it could be updated in specific grammar rules).
Just as aside, there are usually very few courses of action for a bad token.   Essentially, you're getting input text that doesn't any known part of the language alphabet (e.g., no known symbol).   As such, there's not even any kind of token value you can give to the parser.  Usually, the only course of action is to report the bad input, throw it out, and continue.
As a followup to Raymond's answer, I would also not advise modifying any attribute of the lexer object in t_error().

A: Ply includes an example ANSI-C style lexer in a file called cpp.py.  It has an example of how to extract some information out of t_error():
def t_error(t):
    t.type = t.value[0]
    t.value = t.value[0]
    t.lexer.skip(1)
    return t

In that function, you can also access the lexer's public attributes:

*

*lineno           -  Current line number

*lexpos           -  Current position in the input string

There are also some other attributes that aren't listed as public but may provide some useful diagnostics:

*

*lexstate - Current lexer state

*lexstatestack - Stack of lexer states

*lexstateinfo - State information

*lexerrorf - Error rule (if any)

A: There is indeed a way of managing errors in PLY, take a look at this very interesting resentation:
http://www.slideshare.net/dabeaz/writing-parsers-and-compilers-with-ply
and at chapter 6.8.1 of
http://www.dabeaz.com/ply/ply.html#ply_nn3


text:
Q: What is primitive divergence?
*

*As in the title, what is primitive divergence?
How is it distinguished from normal divergence?

*As a followup, what is a primitive divergent graph in a theory?
Some simple examples?


text:
Q: Get data when scrolling Recyclerview according to position
How to get the data when scrolling RecyclerView for the particular position? I have a list of items which will show the user about the upcoming events(dynamically). I need to fetch the event details when it is positioned at center, to change the position of marker. Sorry, I can't show the code. If you need more details please comment here.

A: You must fetch the location data inside your reyclerview adapter's onBindViewHolder.
public class Adapter extends RecyclerView.Adapter<Adapter.MyViewHolder> {
         private List<Wrapper> dashboardList; //
         public Adapter(List<Wrapper> dashboardList) {
                this.dashboardList = dashboardList;

            }

        @Override
            public void onBindViewHolder(MyViewHolder holder, int position) {

                Wrapper data = dashboardList.get(position);
                holder.tv_price.setText(data.getPrice());
                holder.tv_address.setText(data.getAddress());
                fetchLocation(data.getLocation());
        }
        public void fetchLocation(String location)
        {
        //Code for location search
        }


text:
Q: Meteor re-render template after a button is clicked I am working a webpage which will show the search result. After the "search" button was clicked, a search_array should be passed into the template dynamically. How could I dynamically refresh the template after clicking the button?
Here is my code:
search_post.html

  search by name

      <input name="SearchName" id="SearchName" type="text" value="" placeholder="enter the name" class="form-control"/>

<input type="submit" value="Search" class="btn btn-primary" />

   {{#if show}}
   {{#each getInfo}}
      {{> postItem}}
   {{/each}}
   {{/if}}

search_post.js

var search_array;
Template.postSearch.events({
  'click .btn': function() {
     search_array = Posts.find({person_name: document.getElementsByName('SearchName')[0].value});
     Session.set('show', true);
  }
});

Template.postSearch.helpers({
  getInfo: function() {
     return search_array
  },

  show: function(){
        return Session.get('show');
   }
});

A: Use a Session variable or ReactiveVar instead of a normal variable search_array. That way when you change it the template will automatically update.
Template.postSearch.events({
    'click .btn': function () {
        let searchName = document.getElementsByName('SearchName')[0].value;
        Session.set('searchArray', Posts.find({person_name: searchName}).fetch());
        Session.set('show', true);
    }
});

Template.postSearch.helpers({
    getInfo() {
        return Session.get('searchArray');
    }
});

You could also just store searchName in the Session/ReactiveVar and do the database query in getInfo, that way the template will automatically rerender if the database changes.


text:
Q: AudioPlayer duration not working (Wix Velo) I'm using Wix Velo to develop a site. I have an AudioPlayer that is connected to an external URL through a dataset.
export function dataset_ready() {
   let item = $w('#dataset').getCurrentItem()
   const audioPlayer = $w('#audioPlayer')
   audioPlayer.src = item.audioURL
}

This works fine, the url is correct and the audioPlayer is able to play from the url. The problem I'm having is that the audioPlayer's duration property is incorrect. I thought it might be because the audio hadn't loaded yet, but even when I try to read the duration during the audioPlayer's onProgress function.
export function audioPlayer_progress(event) {
    const audioPlayer = $w('#audioPlayer')
    console.log("current: " + $w('#audioPlayer').currentTime + ", duration: " + $w('#audioPlayer').duration)
}

This does not ever return the correct duration, but always returns the correct currentTime. In fact, it's always returning 64 (seconds) as the duration when in fact the audio is over 23 minutes.
What can I try next?


text:
Q: iOS:passing data between two UITableViewController using storyboards I'm working on iPad app using master-detail template were the master tableview is passing data to a second tableviewController:
Currently is what I have:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  {
    UITableViewController *secondTableView = [segue destinationViewController];
  }

My question is. Why when I try access a property in the secondTableView for example:
secondTableView.myString = @"goodBye";
I get this error:

Property "myString" not found on object of type
  "UTableViewController".

My question is how can I fix this or if is a way around this error.
I'll really appreciate your help

A: Try this:
    UITableViewController *secondTableView = (UITableViewController*)[segue destinationViewController];

And make sure myString should be declared as property.
Then you should try this
secondViewControllwer *secondView = (secondViewControllwer*)[[secondViewControllwer alloc]init];

And class name should start with capital latter.

A: You are accessing undefined property on UITableViewController, moreover you cannot declare custom property on standard UITableViewController, you can only inject methods using category. I am wondering if UITableViewController is what you intended for secondTableView type?


text:
Q: Entity framework update table based on the column type getting from function Hi all I am having a table data displayed in grid which is having nearly 15 columns, so on click of each td I will display a modal so that user can update and save the data. I am trying to write a common function so that it takes ColumnName and ColumnValue as parameters which will be called by MVC view
[HttpPost]
Public JsonResult UpDateData(string ColumnName, string ColumnValue, int id)
{
    var dbData = context.Table.Where(i=>i.Pid == id).FirstOrDefault();
    Table t = new Table();
    t = dbData;
    t.SomeColumnName = ColumnValue; // Here I need a generic way to handle so that it should match the passed columnname, so that if I edit and pass another value it should accept
}

A: Resolved by using reflection
[HttpPost]
Public JsonResult UpDateData(string ColumnName, string ColumnValue, int id)
{
    var dbData = context.Table.Where(i=>i.Pid == id).FirstOrDefault();

    var oType = dbData .GetType();
    var prop = oType.GetProperty(ColumnName);
    object convertedValue = Convert.ChangeType(ColumnValue,
    prop.PropertyType);
    prop.SetValue(dbData , convertedValue); //set the value
}


text:
Q: If $f_n\to f$ pointwise on $\mathbb{R}$ and each $f_n$ is bounded, then $f$ is bounded (counter-example) + question on uniform convergence proof
Let $f_n$ be a sequence of functions defined on $\mathbb{R}$ sucht that $f_n\to f$ pointwise on $\mathbb{R}$ as $n\to\infty$ and each $f_n$ is bounded. Is $f$ necessarily bounded? Prove of give a counter-example. I would like to know if the following example holds as a counter-example. In the end I have also a question on it's non-uniform convergence proof.

Suppose $f_n(x)=x$ if $x<n$ and $f_n(x)=n$ if $x\ge n$. $f_n$ converges pointwise to $f(x)=x$
. Moreover, each $f_n$ is bounded (by $n$) and $f(x)$ is unbounded.
Now I would like to know if my proof on not uniform convergence of $f_n$ is correct. To prove it, we have to satisfy the following: $\exists \epsilon>0 \ \forall N \ \exists n\ge N \ \exists x \in \mathbb{R}:|f_n(x)-f(x)|>\epsilon$
Choosing $x=2n>n$ and $\epsilon=\frac{1}{2}$ we have that $|f_n(x)-f(x)|=|n-2n|=n>\frac{1}{2}$. So, $f_n$ doesn't converge uniformly to $f(x)=x$ regardless how $n$ is big.

A: Those functions $f_n$ are not bounded. Yes, $n$ is an upper bound, but they have no lower bound. However, you can define$$f_n(x)=\begin{cases}n&\text{ if }x>n\\x&\text{ if }x\in[-n,n]\\-n&\text{ if }x<-n,\end{cases}$$and that will work.
And this sequence $(f_n)_{n\in\Bbb N}$ is not uniformly convergent to $f(x)=x$ because$$(\forall n\in\Bbb N):\bigl|f(n+1)-f_n(n+1)\bigr|=1.$$So, if you take $\varepsilon=1$, and if $N\in\Bbb N$, then $\bigl|f(N+1)-f_N(N+1)\bigr|\geqslant\varepsilon$.

A: *

*Take $f$ to be an unbounded function. Let $\chi_n$ be the characteristic function of the interval $[-n,n]$, $n$ being a positive integer. Define $f_n=\chi_n\cdot f$. This provides a counterexample to the statement.

*Your counterexample and its proof is right.


text:
Q: Ignoring a value in tuple comparison but still retrieving it I'm working with a set that contains tuples of the form (position, name) and need to check if a value already exists in the set for the name while ignoring the position.
Is there a way that I can use the in operator similar to value in my_set, ignoring the position variable in the tuple during comparison, but still retrieving it? Something similar to (_, value) in my_set or (*, value) in my_set), but those don't work, first one returning an incorrect value, and the second raising a SyntaxError.
Obviously I can use a loop or a generator comprehension like value in (tup[1] for tup in my_set), but that doesn't retrieve the position variable from that tuple, and I was curious if there was some form of one-liner comprehension that would do this.

A: You can do this in O(n) with the existing data structure (iterating the set), but for O(1) you'll have to change data structure. You will need to make a lookup:
from collections import defaultdict

positions = defaultdict(list)
for position, name in my_set:
    positions[name].append(position)

Now this is an O(1) operation:
name in positions

Retrieving all per name:
for pos in positions[name]:
    ...

If you want this to  keep in synch with my_set mutations, then you will need to add in hooks for updating positions at the same time as adds/deletes to my_set.  It might be better to rethink the underlying data structure entirely, for example, using a dict instead of a set in the first place.


text:
Q: Django filter all assigned foreing keys Hello I would like to ask how to filter all assigned ForeignKeys of the object. My models looks like:
class Person(models.Model):
    name =  models.CharField(max_length=250)

class VirtualProject(models.Model):
    project_name = models.CharField(max_length=250)
    owner = models.ForeignKey(Person)

class Hours(models.Model):
    hours = models.FloatField()
    assigned_virtual_project = ForeignKey(VirtualProject)
    date = models.DateField()

I am sending GET request with owner and dateRange parameters and I would like to filter all virtual projects assigned to the owner (this is no issue, I can get this) AND also get all hours objects assigned to the virtual projects and sum all hours in specified date range. How I can do that? For frontend I am using React, so I am using django rest framework.
What I got so far in views:
class GetDataView(viewsets.ModelViewSet):
    serializer_class = DataSerializer

    def get_queryset(self):
       owner = self.request.query_params.get('owner')
       dateRange = self.request.query_params.get('dateRange')

       queryset = VirtualProject.objects.filter(owner=owner)
       return queryset

EDIT:
Serializers.py:
class VirtualProjectSerializer(serializers.ModelSerializer):
         class Meta:
             model = VirtualProject
             fields = '__all__'

A: You can simply use a SerializerMethodField in your serializer, associated with a sum aggregate query.
from django.db.models import Sum
from models import Hours

class VirtualProjectSerializer(serializers.ModelSerializer):
         hours = serializers.SerializerMethodField()

         class Meta:
             model = VirtualProject
             fields = '__all__'

         def get_hours(self, obj):
             qs = Hours.objects.filter(assigned_virtual_project=obj).aggregate(Sum(hours))
             return qs

Note that this will be read-only, which I believe is what you want anyway.


text:
Q: Landing page timeout for LookupOrderedRows I have a landing page that updates set of records from a Data Extension.
I'm using LookupOrderedRows(), but my page timeouts after cetain time.
I tried LookupRows() and its working but it is updating only 2000 records. My records are in 100,000. So I'm limiting the rows by specifying Number of rows to return to 20,000. But its not working
%%[

   Var @rows, @rowCTSubscribers, @oldband, @newband
   set @oldband = "x"
   set @newband = "y"
   set @rows = LookupOrderedRows("My data extension",20000,"modified ASC","band",@oldband)
   set @rowCTSubscribers = rowCount(@rows)

  For @i = 1 to @rowCTSubscribers do
  Set @rowSubscribers = row(@rows,@i)

   set @emailaddress = field(@rowSubscribers, 'emailaddress')

   UpdateData("ent.transfer","1","emailaddress",@emailaddress,"band",@newband)

next @i

]%%

Rows effected - %%=v(@rowCTSubscribers)=%%
Update complete

A: Use SSJS API call to Retrieve DataExtensionObject (Data Extension Rows) meeting your criteria and wrap it with do/while statement. This will allow you to retrieve more than 2000 records. Example:


text:
Q: tableau, excel workbook, three worksheets, want data sources column in union I have a question on Tableau Desktop. I have an excel file with three tabs: Applications, Shared Drives, Sharepoint_Libraries. I would like to union all of these tables. I would like a column called Data Source with the below values. So from Applications excel file, I would like a Data Source column in the Union which says Applications. So from Shared Drives excel file, I would like a Data Source column in the Union which says Shared Drives. Lastly, from Sharepoint_Libraries excel file, I would like a Data Source column in the Union which says Sharepoint_Libraries. How can I do this in Tableau? Do I need to edit the source excel files and add the Data Source column in each file? Or, can I create a calculated field called Data Source and use a formula to populate this information?

Data Source

Applications

Shared Drives

Sharepoint_Libraries

A: Tableau has a "merged mismatched fields" option for this situation.
So..

*

*open Desktop

*connect to the Excel file

*drag over the Applications sheet

*drag over the Shared Drives sheet and position it just below Applications until you see the "union" box appear then release your mouse button

*repeat for Sharepoint Libraries

*in the preview window (below) you will see the three different fields.

*highlight the three fields that you want to merge

*right-click and choose Merge Mismatched Fields.

Then you can rename the field accordingly :)


text:
Q: C# String array I'm new to programming, I recently started a computer science degree and I'm struggling a bit with the code, I am currently learning c#.
I am trying to get a string in an array to cut down on the amount of code and make it easier to format it in the console.
my code is:
 string [] sInvite = new string[]
         {
            "*********************************************"

                               +sGuest+
                    "is invited to the wedding of:"
                    + sBride + " and " + sGroom +
                "On Saturday 17 July 2016 at 2:00pm",

            "*********************************************"
         };

This is how I output it
Console.WriteLine(sInvite);

and this is the actual output in the console, obviously not what I wanted
system.String[]

any ideas on how I can get this to work, or what I am doing wrong?

A: If you are using C# 6 then you can take the answer from Yacoub Massad and instead use string interpolation:
string sInvite = $@"
*********************************************

                   {sGuest}
        is invited to the wedding of:
        {sBride} and {sGroom}
    On Saturday 17 July 2016 at 2:00pm

*********************************************";

A: Use a verbatim string like this:
string sInvite = @"

*********************************************

                   " + sGuest + @"
        is invited to the wedding of:
        " + sBride + @" and " + sGroom + @"
    On Saturday 17 July 2016 at 2:00pm

*********************************************";

Console.WriteLine(sInvite);

A: You created a string array containing a single element. You might as well just store that string as a string and print it. One thing you could do, if you want to keep using an array, is string.Join() the array elements together with a separator like \n. Then print that resulting string.

A: You don't need a string array in this case. You could use a verbatim string, like this
 string sInvite =
     @"*********************************************"

                           +sGuest+
                "is invited to the wedding of:"
                + sBride + " and " + sGroom +
            "On Saturday 17 July 2016 at 2:00pm",

        "*********************************************";

The @ allows you to write a string in two or more lines.
If you insist in use array, you can do Console.WriteLine(String.Join(" ", sInvite));, it will convert your array in a string using the first as a separator for the array positions.

A: I went on different route than all the other answers here to make sure that your text was always centered. I guessed that you wanted that from the way you formatted your code. So here's my answer:
int width = 45;
string sGuest = "Nasreddine";
string sBride = "Jane";
string sGroom = "John";

Console.WriteLine(new String('*', width));
Console.WriteLine(Center(sGuest, width));
Console.WriteLine(Center("is invited to the wedding of:",width));
Console.WriteLine(Center(sBride + " and " + sGroom, width));
Console.WriteLine(Center("On Saturday 17 July 2016 at 2:00pm", width));
Console.WriteLine(new String('*', width));

And this is the function that makes sure that the text is centered:
public static string Center(string str, int length)
{
    if (string.IsNullOrWhiteSpace(str))
    {
        return new String(' ',length);
    }

    if (str.Length >= length)
    {
        return str;
    }

    var halfDiff = (length - str.Length)/2.0;
    return string.Format("{0}{1}", new String(' ', (int) Math.Floor(halfDiff)), str) ;
}

And here's a live demo

A: First thing first, you do not need an array to reduce the code. Secondly the answers given prior to this one are a new way of doing what you want to achieve i.e verbatim string. Here is the old fashioned way of doing it:
var string1 = String.Format(@"
*********************************************
                  {0}
        is invited to the wedding of:
             {1} and {2}
    On Saturday 17 July 2016 at 2:00pm

*********************************************",sGuest,sBride,sGroom);

Console.Writeline(string1);


text:
Q: Leaflet.js choropleth example - updating color based on separate data file This Leaflet.js choropleth example assigns polygon color based on the geoJSON file density values.
function getColor(d) {
    return d > 1000 ? '#800026' :
           d > 500  ? '#BD0026' :
           d > 200  ? '#E31A1C' :
           d > 100  ? '#FC4E2A' :
           d > 50   ? '#FD8D3C' :
           d > 20   ? '#FEB24C' :
           d > 10   ? '#FED976' :
                      '#FFEDA0';
}

This updates each polygon's color in function style(feature)
function style(feature) {
    return {
        fillColor: getColor(feature.properties.density),
        weight: 2,
        opacity: 1,
        color: 'white',
        dashArray: '3',
        fillOpacity: 0.7
    };
}

and this new style is added to the map
L.geoJson(statesData, {style: style}).addTo(map);

However in my situation, my equivalent of the example's statesData geoJSON file doesn't have the density value in it.
Instead I have the density values in a separate data file that I used to create new array. This array has state name values and density values
var my_array = [
    ['name': 'alabama', 'density': 59],
    ['name': 'alaska', 'density': 30],
    etc
]

The question is how to relate the name string values in both the geoJSON file and the separate data file so that I can get the associated density values  into function style(feature) to change polygon colors?
This is likely not necessarily a Leaflet.js question but could a general Javascript 'how to' question.
So far I can loop through my_array and create a new array with name and color values.
color_array = []
for(var i=0; i < my_array.length; i++) {
   color_array.push([my_array[i][0] + ', ' +  getColor(my_array[i][1])]);
}

To get new color_array
color_array = [
['alabama', '#FFEDA0'],
['alaska', '#FEB24C'],
etc
]

Now how can I use this new color_array with the function style(feature) so that the color is set correctly for each name ?
In SQL I would do a join on name and feed the name and related density value to the getColor function with output being the name, density and color.
How can that be done in javascript?

A: You can probably skip step of creating the color array up front unless you need to cache it for performance reasons.
Just do this:

var my_array = [{
  'name': 'alabama',
  'density': 59
}, {
  'name': 'alaska',
  'density': 30
}];

function getColor(density) {
  if (density > 30) return 'blue';
  return 'red';
}

function getStateColor(stateName) {
  var color;
  for (var i = 0; i < my_array.length; i++) {
    if (my_array[i].name === stateName) {
      color = getColor(my_array[i].density);
      break;
    }
  }
  return color;
}

alert("alabama = " + getStateColor('alabama'));

Then you can do this
function style(feature) {
    return {
        fillColor: getStateColor(feature.properties.stateName),
        weight: 2,
        opacity: 1,
        color: 'white',
        dashArray: '3',
        fillOpacity: 0.7
    };
}


text:
Q: Add data to XML element within bash script I have the following XML :
<remote host="${jboss.domain.master.address:127.0.0.1}"     port="${jboss.domain.master.port:9999}"  security-realm="ManagementRealm" />

I want to add a username=admin line into this block. Whats the best way of going about this. I have tried every sed combination and have been getting nowehere...

A: Recommend against it, but:
xml=$( sed 's# /># username="admin"&#' <<< "$xml" )

A: Don't use text processing tools to edit XML. Use an XML-aware tool. For example, in xsh, you can just
open file.xml ;
$host = {'${jboss.domain.master.address:127.0.0.1}'} ; # ${ is special in xsh.
$port = {'${jboss.domain.master.port:9999}'} ;
$realm = 'ManagementRealm' ;

$n = //remote[@host=$host][@port=$port][@security-realm=$realm] ;
if (count($n) != 1) throw 'Found 0 or too many nodes.' ;
set $n/@username 'admin' ;
save :b ;


text:
Q: bacula-dir failed at start I want to install/config a backup-server by useing Bacula.
I've installed and configured everything with the help of
Bacula Tutorial
Now I tried to start the bacular director (bacula-dir) but nothing happens.
In debug-mode (bacula-dir -d 200) I get the following output.
bacula-dir: dird.c:223-0 Debug level = 200
bacula-dir: jcr.c:140-0 read_last_jobs seek to 192
bacula-dir: jcr.c:147-0 Read num_items=0
bacula-dir: dir_plugins.c:160-0 Load dir plugins
bacula-dir: dir_plugins.c:162-0 No dir plugin dir!
bacula-dir: mysql.c:709-0 db_init_database first time
bacula-dir: mysql.c:177-0 mysql_init done
bacula-dir: mysql.c:202-0 mysql_real_connect done
bacula-dir: mysql.c:204-0 db_user=bacula db_name=bacula db_password=password
bacula-dir: mysql.c:227-0 opendb ref=1 connected=1 db=7fe692baa560
bacula-dir: sql_create.c:357-0 In create mediatype
bacula-dir: sql_create.c:361-0 selectmediatype: SELECT MediaTypeId,MediaType FROM MediaType WHERE MediaType='File'
bacula-dir: mysql.c:249-0 closedb ref=0 connected=1 db=7fe692baa560
bacula-dir: mysql.c:256-0 close db=7fe692baa560
bacula-dir: pythonlib.c:102-0 No script dir. prog=DirStartUp
bacula-dir: dird.c:364-0 Start UA server
bacula-dir: bnet_server.c:112-0 Addresses host[ipv4:193.175.220.151:9101]
bacula-dir: job.c:1334-0 wstorage=storage1
bacula-dir: job.c:1343-0 wstore=storage1 where=Job resource
bacula-dir: job.c:1034-0 JobId=0 created Job=*JobMonitor*.2017-07-25_12.49.35_01
bacula-dir: dird.c:377-0 wait for next job
bacula-dir: scheduler.c:104-0 Enter wait_for_next_job
bacula-dir: scheduler.c:273-0 enter find_runs()
bacula-dir: scheduler.c:286-0 now = 5977223f: h=12 m=6 md=24 wd=2 wom=3 woy=30
bacula-dir: scheduler.c:303-0 nh = 5977304f: h=13 m=6 md=24 wd=2 wom=3 woy=30
bacula-dir: scheduler.c:312-0 Got job: WebServ1-backup
bacula-dir: scheduler.c:355-0 run@7fe692b84938: run_now=0 run_nh=0
bacula-dir: scheduler.c:355-0 run@7fe692b84a08: run_now=0 run_nh=0
bacula-dir: scheduler.c:355-0 run@7fe692b84ad8: run_now=0 run_nh=0
bacula-dir: scheduler.c:374-0 Leave find_runs()

It seems like there is an endless loop because after a few seconds the last 5 lines are starting again.
Can anybody help and tell me what I've done wrong or where I can get more informations about the error?
The server is a centOS 7 64bit.
Sorry for the bad english.

A: Problem solved by reconfiguration the director.


text:
Q: React Redux Thunk trigger multiple actions on one call I have an action which in turn must affect many other areas of my app state. In this case, when the user selects a website from a dropdown list, it must update many other components. I'm currently doing it like so:
setSelectedWebsite (websiteId) {
    // The core reason for this component
    this.props.setSelectedWebsite(websiteId);

    // Fetch all associated accounts
    this.props.fetchAllAccounts(websiteId)

    // Several other "side effect" calls here...
}

In this interest of making one component serve one purpose, this feels like a bad practice.
What is the best practice for triggering multiple actions in one call from a component?

A: You could use redux-thunk.
Your component's method:
setSelectedWebsite(websiteId){
    this.props.handleSetSelectedWebsite(websiteId) // this is a thunk
}

Your Redux file with action creators / thunks:
// this function is a thunk

export const handleSetSelectedWebsite = (websiteId) => (dispatch) => {
    dispatch(setSelectedWebsite(websiteId))
    dispatch(fetchAllAccounts(websiteId))
}

// these function are action creators (or could be other thunks if you style them the same way as the thunk above)

const setSelectedWebsite = (websiteId) => {
    // your code
}

const fetchAllAccounts = (websiteId) => {
    // your code
}

A: For handling complex side effects in a redux application, I would recommend looking at using Redux Sagas. I have seen its usage grow in popularity on projects large and small, and for good reason.
With sagas, in the example you have provided, you can emit a single action from a function provided through mapDispatchToProps and let a saga take care of the rest. For example: (following example assumes flux standard actions)
//import redux connect, react, etc

class SiteSelector extends React.Component {

    render() {
        const id = this.props.id;

        return (
           <button onClick={ () => this.props.action(id)>Click Me</button>
        )
    }
}

const mapStateToProps = (state) => ({
    id: state.websiteId
})

const mapDispatchToProps = dispatch => ({
    action: (id) => dispatch(setSelectedWebsite(id))
})

export connect(mapStateToProps, mapDispatchToProps)(SiteSelector)

Now you can handle the action emitted from setSelectedWebsite in a saga like so:
//import all saga dependencies, etc

export function* selectSite(action) {
  const id = action.payload.id
  yield put(Actions.selectWebsite(id))
  const results = yield call(Api.fetchAllAccounts, id)
  yield //do something complex with results
  yield //do something else...
  yield //and keep going...
}

// Our watcher Saga: spawn a new selectSite task every time the action from setSelectedWebsite is dispatched
export function* watchForSiteSelection() {
  yield takeEvery('SITE_SELECTED_ACTION', selectSite)
}

For reference checkout the docs: Redux Sagas


text:
Q: Querying against a large object We have a "dirty" leads custom object.
It has around 1000 records.
We will be getting similar files which we will load into dirty leads object every once in a while.
Our lead object has around 800k records.
I would like to create a dedup process that checks whether the incoming records in the dirty lead custom objects already exist in Lead.
My problem here is how to design code for this process.
How am I supposed to store the 800k records in memory as I am sure I will hit the heap limit...then what's the best way to achieve this ?
Would appreciate any help on this

A: Don't read them all in memory, but do specific queries to see if one or more of the 800k record matches the 1000 dirty lead records.
The searching should be in the database, and less in code. What I would do is to make the Database search as specific as possible (not necessarily 100% specific, but the results should be duplicate candidates), and then for the results that you get back, loop over  them in code and do the 100% check.
For the database, the LIKE operator might come in useful. See https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select.htm and https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_conditionexpression.htm


text:
Q: Java Generics -- Assigning a list of subclass to a list of superclass I have a basic question regarding assignment of a list of subclass to a list of superclass.
So I have something like the following:
Class B extends A;

List <B> bList = new ArrayList<B>();
List <A> aList = bList;

Why does this last assignment fail? Sorry for the newbie question

A: When you declare a List of items of type A, only items of type A can be added or removed from the List. If you need to include subclasses of A, use the generic wildcard ? extends A to indicate so. Your code should therefore be:
List <? extends A> aList = bList;

A: List<B> is not List<A>:
Through example: let say you have class B1 extends A{} and class B2 extends A{}
then (if you would be able to do that:
List<B1> b1 = new AList<B1>();
List<A> a = b1;

List<B2> b2 = new AList<B2>();

by the hypothesis, you should be able to do
    a.add(new B2())
but this is wrong.
If you try the same thing but using arrays instead of lists, it will compile and throw exception in runtime.
We say that arrays are covariant and generics are invariant.
to make the code compile you have the wite it:
List<? extends A> a = b;

this says that a is a list of some subtype of A. _But you don know which one. Because of that you can't do a.put(X)

A: To explain this, let me substitute "B" with Integer and "A" with Number. This is just to make it a little easier to explain.
Class Integer extends Number;

List <Integer> iList = new ArrayList<Integer>();
List <Number> nList = iList // will fail

The reason this would fail is because nList can take any Number -- it can take Integer, it can take Double, or for that matter any subclass of Number. However, this is not true for iList. You cannot add a Double to iList because it accepts only Integer and its subclasses. Hope this helps explain it to you.

A: List<B> and List<A> are invariant type. What you need is covariant type. In this case, it is List<? extends A>.

A: Because generics are strict type safe.
You can have
List<? extends A> aList = bList;

It says aList can hold list of any type which is an A

A: Because List<B> does not extend List<A>. For example, Integer extends Number and so does Long. So List<Number> can contain both Integer and Long. So if you assign List<Integer> to List<Number> you will be able to add Long to your list of integers.
You can declare
List<? super B> superB;

And that would allow assignment to superB of any list that contains B and its super classes.
But it's not the same as in your case aList=bList.
or
List<? extends A> extendsA;

Examples
    List<? super Integer> superA;
    superA = new ArrayList<Number>();

    List<? extends Number> extendsNumber;
    extendsNumber = new ArrayList<Integer>();

A: While at first glance you might think that
Class B extends A;

List <B> bList = new ArrayList<B>();
List <A> aList = bList;

should work, the problem is obvious when you imagine actually using these lists:
A something = new A();
aList.add( something ); // Should work because aList is a list of A's

but aList was assigned to bList, so that should be the same as
bList.add( something ); // Here's the problem

bList.add() takes a B, but something is an A, and an A is not a B!
And that's why generics should be (and are) strict type safe.


text:
Q: Best way to retrieve the value of a SecureString I'm trying to build an automated tool that goes out and checks recent transactions on my checking account (spying on my wife's purchases lol). The tool posts my username and password over SSL and then scrapes the bank page contents for transactions. Everything is sent over SSL of course but in order to make it automated I need to store my bank username and password somewhere.
So I started down the rabbit hole of .NET strings, security, and SecureString. I made a form to input my username and password into a SecureString (character by character) making sure not to use ANY System.String's. Then I retrieve a char[] from the SecureString, get a byte[] from it, zero the char[], encrypt the byte[] using the DPAPI and a salt string built in code, convert the encrypted byte[] to a Base64 System.String, zero the byte[]'s, and save the crypto string to an application setting.
The question was, how to I get I get it back into POST data in a HttpWebRequest without making it a System.String. What I came up with was the following function (which also URL encodes the characters without making strings).
/// <summary>
/// Retrieves, (and then zero's,) a character array from the SecureString.
/// Then optionally URL encodes the characters and returns an encoded byte array.
/// Make sure to zero out the byte array when you're done with it.
/// </summary>
/// <param name="secure">The SecureString to be retrieved.</param>
/// <param name="encodingFormat">The encoding format used to retrieve the byte array. The default is UTF-8.</param>
/// <param name="urlEncode">If true will URL encode characters which are invalid for URL's.</param>
/// <returns></returns>
public static byte[] ToByteArray(this SecureString secure, System.Text.Encoding encodingFormat, bool urlEncode)
{
    if (secure == null) throw new ArgumentNullException("secure");

    if (encodingFormat == null)
        encodingFormat = System.Text.Encoding.UTF8;

    char[] chars = new char[secure.Length];
    byte[] bytesToReturn;

    // copy the SecureString data into an unmanaged char array and get a pointer to it
    IntPtr ptr = Marshal.SecureStringToCoTaskMemUnicode(secure);

    try
    {
        // copy the unmanaged char array into a managed char array
        Marshal.Copy(ptr, chars, 0, secure.Length);
    }
    finally
    {
        Marshal.ZeroFreeCoTaskMemUnicode(ptr);
    }

    if (false == urlEncode)
    {
        bytesToReturn = encodingFormat.GetBytes(chars);
    }
    else
    {
        List<int> unsafeUrlCharIntValues = new List<int>();
        unsafeUrlCharIntValues.AddRange(Enumerable.Range(32, 16)); //   32-47   Reserved Characters:    ' '!?#$%&'()*+,-./
        unsafeUrlCharIntValues.AddRange(Enumerable.Range(58, 7)); //    58-64   Reserved Characters:    :;<=>?@
        unsafeUrlCharIntValues.AddRange(Enumerable.Range(91, 6)); //    91-96   Reserved Characters:    [\]^_`
        unsafeUrlCharIntValues.AddRange(Enumerable.Range(123, 4)); //   123-126 Reserved Characters:    {|}~

        // Get a count of the unsafe URL characters to see if any processing is required and how many extra char's we'll need in the array.
        int unsafeCharCount = 0;
        for (int i = 0; i < chars.Length; i++)
            if (unsafeUrlCharIntValues.Contains((int)chars[i]))
                unsafeCharCount++;

        if (unsafeCharCount < 1)
        {
            bytesToReturn = encodingFormat.GetBytes(chars);
        }
        else
        {
            char[] encodedChars = EncodeChars(chars);
            bytesToReturn = encodingFormat.GetBytes(encodedChars);

            // zero out encoded chars for security
            for (int i = 0; i < encodedChars.Length; i++)
                encodedChars[i] = '\0';
        }
    }

    // zero out chars
    for (int i = 0; i < chars.Length; i++)
        chars[i] = '\0';

    return bytesToReturn;
}

I zero out the char[]'s after I'm done with them. I also make sure to zero out the returned byte[] after I've written them to the HttpWebRequest stream. Is this secure or will the GC make copies of the char[] and byte[] objects? Is this any better than using System.String's? I've read other posts saying to use unsafe code and do everything in unmanaged memory but I still need to get a byte[] to my HttpWebRequest in the end.


text:
Q: Live data observer getting called even after observer is remoevd I have an activity, which instantiates a fragment say B. Fragment B shows a list of users. which i fetch from DB as LiveData. I add an observer to the live data. whenever the onChanged gets called i remove the observer.
But still whenever the DB changes onChanged gets called again and again.
Here is the code for fragment class:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    initRecyclerViews()
    viewModel.liveResult = viewModel.getAllUsers()
    observeData()
}
fun observeData() {
        viewModel.liveResults?.observe(this@UserFragment, Observer(allUserAdapter::submitList))
        viewModel.liveResults?.observe(this@UserFragment, observer)
    }
val observer: Observer<PagedList<User>> = object : Observer<PagedList<User>> {
    override fun onChanged(t: PagedList<User>?) {
        dataChanged()
    }
}

fun dataChanged() {
    // do some work

    viewModel.liveResults?.removeObservers(this@UserFragment)
}

Below is the code for adapter class:
class AllUsersAdapter(
private val inflater: LayoutInflater) :
    PagedListAdapter<User, MyViewHolder>(diffCallback) {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AllUsersItemViewHolder {
    return MyViewHolder(
            inflater.inflate(R.layout.user_item, parent, false))
}

override fun onBindViewHolder(holder: AllUsersItemViewHolder, position: Int) {
    holder.setItem(getItem(position))
}

companion object {
    private val diffCallback = object : DiffUtil.ItemCallback<User>() {
        override fun areItemsTheSame(oldItem: User, newItem: User): Boolean {
            val ret = oldItem.phonenumber == newItem.phonenumber
            return ret
        }

        override fun areContentsTheSame(oldItem: User, newItem: User): Boolean {
            val ret = oldItem.phonenumber == newItem.phonenumber
            return ret
        }
    }
}

}
Here is the code for viewmodel:
    class MyViewModel : BaseViewModel() {
       lateinit var mUsersList: LiveData<PagedList<MaxwellUser>>

fun getAllUsers() {

    val factory = dao.getUsers()
            liveResults = LivePagedListBuilder(factory,
                    PagedList.Config.Builder()
                            .setPageSize(Constant.PAGE_SIZE)
                            .setEnablePlaceholders(true)
                            .build()).build()
    }
}

This is the Dao Query:
@Query(Select * from users)
abstract fun getUsers(): DataSource.Factory<Int, User>

users table has many fields like name , phonenumber , status , location etc.
i keep on updating the table from background .
I want my fragment to load the data once , and when i remove the observer, it should not get any updates of the db changes.
But the problem is first time , when i load the fragment , the data gets loaded in the list , dataChanged gets called. and observers get removed.
But again when Some DB change happens ,my users list keep on updating .

A: Why do you observe the list two times?
viewModel.liveResults?.observe(this@UserFragment, Observer(allUserAdapter::submitList))
viewModel.liveResults?.observe(this@UserFragment, observer)

You can submit your list to adapter in dataChanged method.


text:
Q: Is read latency increased due to a big SSTable? If after a long period of time, STCS produced a really big SSTable, and later on we received a read request for a partition key that only exists in that big SSTable (i.e. it's unique across all the SSTables for that table), would the read latency be increased because we're dealing with a big SSTable, or is the read latency NOT influenced by the size of a partition index?
On a side note, I suppose that having the help of the partition summary and then using the partition index with pointers for just one big SSTable is still better than seeking a lot of smaller SSTables.

A: First, there is a single instance of Partition Key Cache by Cassandra process and it is shared by all SSTables and all tables. Its size limit is defined in cassandra.yaml
# Default value is empty to make it "auto" (min(5% of Heap (in MB), 100MB)).
# Set to 0 to disable key cache.
key_cache_size_in_mb:

For the Index Summary that is used to perform binary search to find the nearest partition offset for scanning, normally we sample every 128 partition keys but for SSTables that have a lot of partition keys, this sampling can be increased to save memory.
CREATE TABLE music.example (
    id int PRIMARY KEY
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    ...
    AND max_index_interval = 2048
    AND min_index_interval = 128
    ...;

The total memory usage of Index Summary can be configured in cassandra.yaml
# A fixed memory pool size in MB for for SSTable index summaries. If left
# empty, this will default to 5% of the heap size. If the memory usage of
# all index summaries exceeds this limit, SSTables with low read rates will
# shrink their index summaries in order to meet this limit.  However, this
# is a best-effort process. In extreme conditions Cassandra may need to use
# more than this amount of memory.
index_summary_capacity_in_mb:

# How frequently index summaries should be resampled.  This is done
# periodically to redistribute memory from the fixed-size pool to sstables
# proportional their recent read rates.  Setting to -1 will disable this
# process, leaving existing index summaries at their current sampling level.
index_summary_resize_interval_in_minutes: 60

See CASSANDRA-6379
So to reply your question, the read performance for big SSTable:

*

*Can be fast if by chance you have a cache hit in Partition Key Cache

*Will be slower because the index interval will be increased for big SSTable (e.g. SSTable having a lot of distinct partition keys, it's not necessarily related to its size in absolute)

*Will be slower if your big SSTable is not frequently used, see CASSANDRA-5519


text:
Q: Newly added subpages with parent slug as a prefix are only showing 404 error I have 8 pages such as Home, About, Services, Web Design, etc., on my WordPress site and they all are working fine. However, I would like to have prefix slug 'services' on the slugs of Web Design, Digital Marketing, etc., and I updated these pages' parent page attribute to 'Services'.
Before updating, it was working fine and the url was https://example.com/web-design. After updating, I get the url that I want (https://example.com/services/web-design) but it redirects me to 404 Not Found page when I visit the exact url that is mentioned in permalink field.
I tried removing and updating .htaccess file both manually and from settings' Permalinks option but it doesn't work. When I tried setting the parent 'empty' on page attributes, the url gets to normal without services and it works fine.
Current permalink structure in settings is https://example.com/%postname%. The problem is It's only redirecting me to 404 page instead of the correct url when setting page parent attributes. I want the page to be available with the url that I set with services prefix like (https://example.com/services/web-design).

A: Found the bugs and solution!
When I reviewed all my custom post types and taxonomies on the website, found that one taxonomy has used services in it as rewrite => array('slug' => 'services). It works fine after renaming the slug to a different one.
If you face the same issue,

*

*Double-check if the slug is already used by the custom post types or taxonomies

*Change it to a different one if already used

*Click on 'Save Changes' on the Settings / Permalinks page without making any changes.

Then, it will start working properly.


text:
Q: QAbstractListModel.match() causes ASSERT failure in QList::operator[]: "index out of range" I'm searching for the Index of an item(if it's existent in the model) with QAbstractListModel.match().
QModelIndex childIndex = m_DataSourceModel.match(m_DataSourceModel.index(0,0),Qt::UserRole,QVariant::fromValue(messageID),1,Qt::MatchRecursive)[0];

When the item is not found, this error occures:
ASSERT failure in QList<T>::operator[]: "index out of range", file C:/Qt/5.10.0/mingw53_32/include/QtCore/qlist.h, line 549

The manual says: "The list that is returned may be empty." and afterwards the QModelIndex should be checked with QModelIndex.isValid()
So why is the program crashing when nothing matches before I can check the index?

A: As indicated by the docs match, you can return an empty list so before accessing you must verify that you have at least the necessary number of elements:
QModelIndexList indexes = m_DataSourceModel.match(m_DataSourceModel.index(0, 0),
                                                  Qt::UserRole,
                                                  QVariant::fromValue(messageID),
                                                  1,
                                                  Qt::MatchRecursive);
if(!indexes.empty()){
    QModelIndex childIndex = indexes.first();
    // or QModelIndex childIndex = indexes[0];
}


text:
Q: CSS - How do I position my 'a' element text in a Bootstrap navbar? I am trying to position my a element text inside of a Bootstrap navbar but, so far, I have achieved an a element with 15px padding on all sides and a height of 0.
I am trying to implement a 'tabs bar' where a new tab is created every time a user clicks on an option in a separate navbar, so the li and a elements for the tab are added dynamically using JQuery.
Here is the code:
HTML:
@* Navbar -- Tabs Bar *@

JQuery:
$(".btnSwitchView a").click(function () {
    var tabName = $(this).data("name");
    var newTab = "
" + tabName + "
";
    $(".tabbar-nav").append(newTab);
})

CSS:
.tabsBar {
    background-color: gray;
    margin-bottom: 2em;
    min-height: 30px !important;
}

.tabbar-nav {
    position: absolute;
    display: block;
    width: 100%;
    height: 100%;
    bottom: 0;
}

.tab {
    display: block;
    margin-right: .7em;
    width: 10%;
    height: 100%;
    background-color: #222222;
    text-align: center;
}

.tab a {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0px 0px;
    color: gray;
}

Here is a picture of the result:

I want the text to centered horizontally and vertically in the box, and the box to be sitting on the bottom of the bar.
Thanks in advance for any help!

A: Too much CSS code and actually those heights and widths properties are the problem, especially this line: min-height: 30px !important;, which gives the nav exactly a height of 30px, because your nav is empty.
Try this:
.tabsBar {
    background-color: gray;
    margin-bottom: 2em;
}

.tabbar-nav {
    position: absolute;
    display: block;
    bottom: 0;
}

.tab {
    margin-right: .7em;
    background-color: #222222;
    text-align: center;
}

.tab a {
    color: gray;
}

This is the result tested in chrome and firefox


text:
Q: How do you capture environmental or camera settings in Machine Learning CNN architectures? I've been looking at computer vision problems. The CNN works exclusively with the image, and other factors like camera settings (f stop, ISO, etc) or environmental factors aren't directly taken into account. I can imagine a scenario where lighting conditions would factor in how an object gets "seen" (in a mobile platform application, for example).
Is there a way to explicitly have those factors taken into account within the NN architecture, or are they just implied via the dataset images used? How do you feed it into the NN since the input is just an image? It wouldn't make sense to just add another row and populate that with parameters; I would imagine the convolution would scramble the effects.
An example: say you are looking for a cylinder. In one image, you would be looking for a rectangle like object since you are viewing the cylinder sideways. In another view, you would be looking for a circle because you are looking at the tip.

A: Thanks  for taking a look at my question. Looking further into it, I find that the type of problem is called "mixed data" ingestion and found a link to a tutorial here.