text:
Q: Issue. Jackson in Spring not throws any exceptions I have a code like:
public class BigDecimalDeserializer extends JsonDeserializer<BigDecimal> {
    private static final Pattern PATTERN = Pattern
        .compile("^([1-9]+[0-9]*)((\\.)[0-9]+)?$");
    private static final String MESSAGE = "must be a number in format (99 or 99.99)";
    private static final String EMPTY_STRING = "";

    @Override
    public BigDecimal deserialize(JsonParser parser, DeserializationContext context)
                  throws IOException, JsonProcessingException
    {
        BigDecimal result = null;
        JsonNode node = parser.getCodec().readTree(parser);
        String text = node.asText();

        if (text != null && !text.equals(EMPTY_STRING)) {
            Matcher matcher = PATTERN.matcher(text);

            if (matcher.matches()) {
                result = new BigDecimal(text);
            } else {
                throw new ApplicationException(MESSAGE);
            }
        }
        return result;
    }
}

Nothing happens when this method throws ApplicationException or other type of exception.
Where this exception catches? And why there is no stacktraces in the console?
p.s. im trying to handle this exception in the @ControllerAdvice class (@ExceptionHandler(ApplicationException.class) method)..but nothing happens.
MessageConverter config:
public void configureMessageConverters(
        List<HttpMessageConverter<?>> converters) {
    final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
    final ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    converter.setObjectMapper(objectMapper);
    converters.add(converter);
    super.configureMessageConverters(converters);
}

ContollerAdvice:
@ExceptionHandler(ApplicationException.class)
protected ResponseEntity<Object> handleWrongRequest(
        RuntimeException exception, WebRequest request) {
    ApplicationException applicationException = (ApplicationException) exception;

    Error error = new Error();
    error.setField(EMPTY);
    error.setMessage(applicationException.getRootMessage());

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_JSON);

    return handleExceptionInternal(exception, error, headers,
            HttpStatus.FORBIDDEN, request);
}

Where Spring handles Jackson exceptions?


text:
Q: VBScript macro in QlikView: PasteSpecial method randomly fails I'm using a QlikView macro written in VBScript to export some pivot tables' data into some Excel templates. However it seems the PasteSpecial method that I use, fails from time to time.
Now, my question is, is there anything wrong with my code or should I handle the case the method fails during runtime?
QlikView Macro code posted below:
    sub ExcelTable1TemplateUse
    set XLApp = CreateObject("Excel.Application")
    XLApp.Visible = True
    set XLDoc = XLApp.Workbooks.Open("C:\Users\BSS\Documents\Alfaintes\20171204 - Report prioritari\Reports\Tabel 1\Table1_Template_SingleUser.xlsx")
    XLDoc.Sheets(1).Select
    XLDoc.Sheets(1).Range("A1").Select
    ActiveDocument.GetSheetObject("CH128").CopyTableToClipboard true
    XLDoc.Sheets(1).PasteSpecial -4163
    end sub

A: What happens when it fails?
And I think you can just
ActiveDocument.GetSheetObject("CH128").CopyTableToClipboard true
XLDoc.Sheets(1).Range.Cells("A1").PasteSpecial -4163

redpajama_set_name: RedPajamaStackExchange


text:
Q: Open a default browser window using c# and Process.Start I am trying to open a web page using the default browser when someone hits an API endpoint.
I have this working on my local test machine:
    [HttpGet("Http/{classId}")]
    public void OpenWebLink(Guid classId)
    {
        string target = "http://astrolab.meeting.trl.edu/class/details.aspx?classId=" + classId;
        System.Diagnostics.Process.Start("C:\\Program Files\\Mozilla Firefox\\firefox.exe", target);
    }

But when I publish to a server that has IIS, it can't find firefox.exe
The problem is, I had to put the full path to firefox just to get it to work on my machine. If I didn't include the path like that I'd get this error:
System.Diagnostics.Process.Start Win32Exception: 'The system cannot find the file specified.'

I also tried this:
    [HttpGet("Http")]
    public void OpenWebLink(Guid classId)
    {
        try
        {

            var ps = new ProcessStartInfo("http://astrolab.meeting.trl.edu/class/details.aspx?classId=" + classId;)
            {
                Verb = "open"
            };
        Process.Start(ps);
        }
        catch (Win32Exception w32Ex)
        {
            throw w32Ex;
        }
    }

But it still fails when I hit the endpoint on the IIS server with this:
System.ComponentModel.Win32Exception (2): The system cannot find the file specified.

Is there a way to set it up so that it will find the default browser on any machine?
Thanks!

A: It's as if dotnet developers are unaware of other operating systems besides Windows...
@Blindy's answer only works on Windows, but nowhere did they indicate this. And even if @SkyeBoniwell's question mentions IIS which implies Windows, neither the title of the question, nor the body, nor the tags explicitly mention Windows. As such, keeping in mind stackoverflow answers are meant to be used by everyone and not only the OP of a question, a correct answer to this thread should theoretically be os-agnostic. In practice, it should take into account as many operating systems as possible, i.e. at the very least the main three ones.
Here is a solution that works for 99% of end-user systems:
    public static void OpenBrowser(string url)
    {
        if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
        {
        Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
        }
        else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
        {
            Process.Start("xdg-open", url);
        }
        else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
        {
            Process.Start("open", url);
        }
        else
        {
            // throw
        }
    }

taken from here

A: Either use ShellExecute to launch your url (the more correct way), or pipe it through explorer (the lazier, less portable way).
Process.Start(new()
{
    UseShellExecute = true,
    FileName = "http://google.ca",
});

Process.Start("explorer.exe", "http://google.ca");


text:
Q: Decimal T-SQL to Decimal C# Is it possible to get a potential problem with conversion of a T-SQL decimal(30,8) to decimal in C#?

A: You can't represent all possible values of decimal(30,8) with the System.Decimal type of .NET.
decimal(30,8) has 30 significant digits, System.Decimal has 28-29 according to the documentation.
For example 1234567890123456789012.12345678 is a valid value for decimal(30,8), but writing 1234567890123456789012.12345678m in C# returns 1234567890123456789012.1234568, rounded and missing a digit.


text:
Q: Match series of (non-nested) balanced parentheses at end of string How can I match one or more parenthetical expressions appearing at the end of string?
Input:
'hello (i) (m:foo)'

Desired output:
['i', 'm:foo']

Intended for a python script. Paren marks cannot appear inside of each other (no nesting), and the parenthetical expressions may be separated by whitespace.
It's harder than it might seem at first glance, at least so it seems to me.

A: paren_pattern = re.compile(r"\(([^()]*)\)(?=(?:\s*\([^()]*\))*\s*$)")

def getParens(s):
  return paren_pattern.findall(s)

or even shorter:
getParens = re.compile(r"\(([^()]*)\)(?=(?:\s*\([^()]*\))*\s*$)").findall

explaination:
\(                     # opening paren
([^()]*)               # content, captured into group 1
\)                     # closing paren
(?=                    # look ahead for...
  (?:\s*\([^()]*\))*   #   a series of parens, separated by whitespace
  \s*                  #   possibly more whitespace after
  $                    #   end of string
)                      # end of look ahead

A: You don't need to use regex:
def splitter(input):
    return [ s.rstrip(" \t)") for s in input.split("(") ][1:]
print splitter('hello (i) (m:foo)')

Note: this solution only works if your input is already known to be valid. See MizardX's solution that will work on any input.


text:
Q: Tell a function to wait until the user presses a button with Qt I have created a project and a basic app where there is a ui that pops up for users to enter data and then the data is uploaded to a firebase database. When I attempt to run the app the ui appears and i can enter in the data like in this image:

However, the app is uploading to the data base as soon as it opes and so the database entry is all zeros. How can I make the app upload to the database and close after pressing submit. I am very new to c++ so any help would be appreciated :).
Here is my main.cpp:
#include "checkinapp.h"
#include "databasehandler.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    checkinapp w;
    w.show();
    DatabaseHandler dbhandler;
    return a.exec();
}

here is my checkinapp.h:
#ifndef CHECKINAPP_H
#define CHECKINAPP_H

#include <iostream>

#include <QMainWindow>
#include <QFile>
#include <QFileDialog>
#include <QTextStream>
#include <QMessageBox>
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>

QT_BEGIN_NAMESPACE
namespace Ui { class checkinapp; }
QT_END_NAMESPACE

class checkinapp : public QMainWindow
{
    Q_OBJECT

public:
    checkinapp(QWidget *parent = nullptr);
    ~checkinapp();

private slots:

    void on_happy_valueChanged(int value);

    void on_hungry_valueChanged(int value);

    void on_sleep_valueChanged(int value);

    void on_stress_valueChanged(int value);

    void on_male_toggled(bool checked);

    void on_female_toggled(bool checked);

    void on_other_toggled(bool checked);

    void on_help_toggled(bool checked);

    void on_pushButton_clicked();

private:
    Ui::checkinapp *ui;
};

#endif  // CHECKINAPP_H

checkinapp.cpp:
#include "checkinapp.h"
#include "ui_checkinapp.h"
#include "databasehandler.h"
#include "global_objects.hpp"
#include <QNetworkRequest>
#include <QDebug>
#include <QJsonDocument>
#include <QVariantMap>
#include <iostream>

using namespace std;

checkinapp::checkinapp(QWidget *parent)
    : QMainWindow(parent),
    ui(new Ui::checkinapp)
{
    ui->setupUi(this);
}
checkinapp::~checkinapp()
{
    if(help == 1)
    {
        //delete ui;
    }
    if(help == 1)
    {
        cout << "help";
    }
}

void checkinapp::on_happy_valueChanged(int value)
{
    happy = value;
}

void checkinapp::on_hungry_valueChanged(int value)
{
    hungry = value;
}

void checkinapp::on_sleep_valueChanged(int value)
{
    tired = value;
}

void checkinapp::on_stress_valueChanged(int value)
{
    stressed = value;
}

void checkinapp::on_male_toggled(bool checked)
{
    if(checked == true)
    {
        gender = 0;
    }
}

void checkinapp::on_female_toggled(bool checked)
{
    if(checked == true)
    {
        gender = 1;
    }
}

void checkinapp::on_other_toggled(bool checked)
{
    if(checked == true)
    {
        gender = 2;
    }
}

void checkinapp::on_help_toggled(bool checked)
{
    if(checked == true)
    {
        help = 1;
    }
}

void checkinapp::on_pushButton_clicked()
{
    submitted = true;
        if(submitted==true)
        {
            cout <<submitted;
        }
    //delete ui;
}

databasehandler.h:
#ifndef DATABASEHANDLER_H
#define DATABASEHANDLER_H
#include <checkinapp.h>
#include <QObject>
#include <QWidget>
#include <QNetworkAccessManager>
#include <QNetworkReply>

class DatabaseHandler : public QObject
{
    Q_OBJECT
public:
    explicit DatabaseHandler(QObject *parent = nullptr);
    ~DatabaseHandler();

public slots:
    void networkReplyReadyRead();

signals:

private:
    QNetworkAccessManager * m_networkManager;
    QNetworkReply * m_networkReply;

};

#endif // DATABASEHANDLER_H

databasehandler.cpp:
#include "checkinapp.h"
#include "databasehandler.h"
#include "global_objects.hpp"
#include <QNetworkRequest>
#include <QDebug>
#include <QJsonDocument>
#include <QVariantMap>
#include <iostream>

DatabaseHandler::DatabaseHandler(QObject *parent) : QObject(parent)
{
    m_networkManager = new QNetworkAccessManager ( this );
    QVariantMap newUser;
    newUser[ "Stress" ] = QString::number(stressed);
    newUser[ "Sleep" ] = QString::number(tired);
    newUser[ "Hungry" ] = QString::number(hungry);
    newUser[ "Happy" ] = QString::number(happy);
    newUser[ "Grade" ] = QString::number(grade);
    newUser[ "Date" ] = "1/10/21";
    newUser[ "Gender" ] = QString::number(gender);
    newUser[ "Aid" ] = QString::number(help);
    QJsonDocument jsonDoc = QJsonDocument::fromVariant( newUser );
    QNetworkRequest newUserRequest( QUrl( "url/User.json"));
    newUserRequest.setHeader( QNetworkRequest::ContentTypeHeader, QString( "application/json" ));
    m_networkManager->post( newUserRequest, jsonDoc.toJson() );
}
DatabaseHandler::~DatabaseHandler()
{
    m_networkManager->deleteLater();
}
void DatabaseHandler::networkReplyReadyRead()
{
    //qDebug() << m_networkReply->readAll();
}

A: To do that, according to your code, you should not handle you database connection in your main() function, but in a specific manager to open or close depending on your needs.
So following your code, you have some ideas here:

*

*Remove DatabaseHandler dbhandler; from main() and create it in your checkinapp class, adding new methods to post values into the database using the values set in the GUI.

*Keep the line DatabaseHandler dbhandler; but then you need to pass the object to the checkinapp class. Same than before, you will need new methods to populate the database.

Apart from that, I think you don't need to post in the DatabaseHandler constructor at the beginning:
m_networkManager->post( newUserRequest, jsonDoc.toJson() );


text:
Q: Why can't you store the minimum value of int64 into a uint64? In theory an int64 fits in a uint64, of course their numeric values will be different due to the first bit being reserved for the sign on int64, however why can't I do this conversion? it seems valid to me
import (
    "fmt"
    "math"
)

func main() {
    var randomNum uint64 = math.MinInt64
    fmt.Println(randomNum)
}

yields error
constant -9223372036854775808 overflows uint64

Here math.MinInt64 is -9223372036854775808, technically a number that fits in 63 bits plus sign.
I'm mainly looking into this since I want to convert 8 bytes back into a int64 with proper sign, but so far I only have seen functions that return uint64
binary.LittleEndian.Uint64(bytesArrays[0:8])

A: An int64 fits does fit in a uint64, but that's not what the code in the question does.  The code assigns the constant math.MinInt64 to the uint64 variable randomNum. The compiler reports an error because the constant is not representable by a uint64.
Assign to a variable first so that the rules for constants do not apply:
x := int64(math.MinInt64)
var randomNum = uint64(x)
fmt.Println(randomNum)

A: The reason why this "conversion" doesn't work, is because there is no conversion in your program. Assignment does not implicitly perform conversion (except for interface types).
See the assignability rules that govern assignment of constant values:

A value x is assignable to a variable of type T ("x is assignable to T") if one of the following conditions applies:

*

*x's type is identical to T.

*...

*x is an untyped constant representable by a value of type T.

In this case, math.MinInt64 is an untyped constant, but it is not representable by value of type uint64, because it is defined as so:

uint64      the set of all unsigned 64-bit integers (0 to 18446744073709551615)

Conversion between negative 64 bit integers and unsigned 64 bit integers is possible, but you need a genuine conversion for that. Yet still, you can't convert the constant value directly, because of a familiar rule:

A constant value x can be converted to type T if x is representable by a value of T.

So, the correct way is to first assign the number to a non-constant value:
x := int64(math.MinInt64)
y := uint64(x)
fmt.Println(y)

Playground link

A: Who says you can't?  Okay, the compiler says that, sort of.  But the compiler means that you can't put the value -9223372036854775808 into a uint64 variable, which is true; you need to put the bit pattern that, as an int64, represents -9223372036854775808, but representing the value it would be seen as a uint64 into the uint64:
var randomNum uint64 = math.MinInt64 + math.MaxUint64 + 1

which works fine—or of course do what GastroHealth showed.

I'm mainly looking into this since I want to convert [8] bytes back into a int64 with proper sign, but so far I only have seen functions that return uint64 (such as binary.LittleEndian.Uint64).

We do the obvious:
signed := int64(v ^ 0x8000000000000000 - 0x8000000000000000)

(Well, it's obvious once you've seen it a few times.)
See a complete example here (I used big-endian, I like it better for human use).  Note that you can just do signed := int64(v) here; the flip-and-subtract trick is good as an expression where you don't already have a variable.


text:
Q: How to store messages in /mosquitto/data MQTT mosquitto? I am running Docker in AWS ECS and inside the docker container in ECS instance i am running eclipse-mosquitto
I need to store the messages in /mosquitto/data
What i tried
docker exec -it [container name] sh navigated to /mosquitto/config/mosquitto.conf
Modified the mosquitto.conf file and added these lines :
persistence true
persistence_location /mosquitto/data/
listener 1883
listener 9001
protocol websockets

NOTE
I have mounted EFS on /mosquitto so i expect the configuration file to persist and i expect it to use that configuration file next time the container restarts
What i expect
Whenever i am publishing/subscribing to a topic it should store the relevant data under mosquitto/data

A: First
Logging into a running container and editing the config file won't change the running brokers behaviour.
You would normally need to restart the container (which will revert the changes to the config file)
You can mount your own config file into the container at start time with the following command line option (described on the docker hub page)
$ docker run -it -p 1883:1883 -p 9001:9001 -v mosquitto.conf:/mosquitto/config/mosquitto.conf eclipse-mosquitto

Secondly
mosquitto will not store all messages in the persistence file, that is not what it's for. The file is only used to store QOS 1 or 2 messages that are in flight and retained messages. These messages are normally kept in memory, but are written to the file at regular intervals or at broker shutdown so they can be restored when the broker restarts. Also the format of the persistence file is a custom binary format, it's not something you can easily read.


text:
Q: SQL command isn't working     db.rawQuery("UPDATE listelement SET fkrid = (SELECT rid FROM room WHERE roomname = '" + roomFromEditText + "')", null);

This command is not working. The SQL Statement seem to be correct (I tried it in an SQL Browser)

A: Use execSQL() and not rawQuery() for raw SQL queries that don't return data.
rawQuery() just compiles the SQL but does not run it. execSQL() both compiles and runs it.


text:
Q: JavaScript Object Id Do JavaScript objects/variables have some sort of unique identifier? Like Ruby has object_id. I don't mean the DOM id attribute, but rather some sort of memory address of some kind.

A: If you want to lookup/associate an object with a unique identifier without modifying the underlying object, you can use a WeakMap:
// Note that object must be an object or array,
// NOT a primitive value like string, number, etc.
var objIdMap=new WeakMap, objectCount = 0;
function objectId(object){
  if (!objIdMap.has(object)) objIdMap.set(object,++objectCount);
  return objIdMap.get(object);
}

var o1={}, o2={}, o3={a:1}, o4={a:1};
console.log( objectId(o1) ) // 1
console.log( objectId(o2) ) // 2
console.log( objectId(o1) ) // 1
console.log( objectId(o3) ) // 3
console.log( objectId(o4) ) // 4
console.log( objectId(o3) ) // 3

Using a WeakMap instead of Map ensures that the objects can still be garbage-collected.

A: No, objects don't have a built in identifier, though you can add one by modifying the object prototype.  Here's an example of how you might do that:
(function() {
    var id = 0;

    function generateId() { return id++; };

    Object.prototype.id = function() {
        var newId = generateId();

        this.id = function() { return newId; };

        return newId;
    };
})();

That said, in general modifying the object prototype is considered very bad practice.  I would instead recommend that you manually assign an id to objects as needed or use a touch function as others have suggested.

A: I've just come across this, and thought I'd add my thoughts. As others have suggested, I'd recommend manually adding IDs, but if you really want something close to what you've described, you could use this:
var objectId = (function () {
    var allObjects = [];

    var f = function(obj) {
        if (allObjects.indexOf(obj) === -1) {
            allObjects.push(obj);
        }
        return allObjects.indexOf(obj);
    }
    f.clear = function() {
      allObjects = [];
    };
    return f;
})();

You can get any object's ID by calling objectId(obj). Then if you want the id to be a property of the object, you can either extend the prototype:
Object.prototype.id = function () {
    return objectId(this);
}

or you can manually add an ID to each object by adding a similar function as a method.
The major caveat is that this will prevent the garbage collector from destroying objects when they drop out of scope... they will never drop out of the scope of the allObjects array, so you might find memory leaks are an issue. If your set on using this method, you should do so for debugging purpose only. When needed, you can do objectId.clear() to clear the allObjects and let the GC do its job (but from that point the object ids will all be reset).

A: Actually, you don't need to modify the object prototype. The following should work to 'obtain' unique ids for any object, efficiently enough.
var __next_objid=1;
function objectId(obj) {
    if (obj==null) return null;
    if (obj.__obj_id==null) obj.__obj_id=__next_objid++;
    return obj.__obj_id;
}

A:

const log = console.log;

function* generateId() {
  for(let i = 0; ; ++i) {
    yield i;
  }
}

const idGenerator = generateId();

const ObjectWithId = new Proxy(Object, {
  construct(target, args) {
    const instance = Reflect.construct(target, args);
    instance['id'] = idGenerator.next().value;
    return instance;
  }
})

const myObject = new ObjectWithId({
  name: '@@NativeObject'
});

log(myObject.id);


text:
Q: How to update and remove Pkexec executable I came to know that most linux distros(including Ubuntu) have a vulnerability due to PKEXEC. The advice that is given to be safe is to either update the polkit or remove the Pkexec executable.
My questions are:

*

*How can i update to the latest version of polkit so that i won't have the vulnerability.

*How can i remove the executable completely so that no one can use that old executable to take advantage of the said vulnerability.
I am using Ubuntu 18.04 and when i get the following output when i run the command locate pkexec:
/snap/core18/2284/usr/share/polkit-1/actions/org.dpkg.pkexec.update-alternatives.policy
/snap/core18/2344/usr/share/polkit-1/actions/org.dpkg.pkexec.update-alternatives.policy
/snap/core20/1376/usr/share/polkit-1/actions/org.dpkg.pkexec.update-alternatives.policy
/snap/core20/1405/usr/share/polkit-1/actions/org.dpkg.pkexec.update-alternatives.policy
/usr/bin/pkexec
/usr/share/man/man1/pkexec.1.gz
/usr/share/polkit-1/actions/org.dpkg.pkexec.update-alternatives.policy

A: As you can check at Ubuntu Security - CVE-2021-4034, the bug has already been patched by the maintainers.
To upgrade to the patched version (that's 0.105-20ubuntu0.18.04.6 in the case of Ubuntu "Bionic"), you don't need to do anything more than apply your system's regular security updates.
You can check if you are already running the patched version using apt:
$ apt policy policykit-1
policykit-1:
  Installed: 0.105-20ubuntu0.18.04.6
  Candidate: 0.105-20ubuntu0.18.04.6
  Version table:
 *** 0.105-20ubuntu0.18.04.6 500
        500 http://ca.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
        100 /var/lib/dpkg/status
     0.105-20 500
        500 http://ca.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

or with dpkg:
$ dpkg -l policykit-1
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                      Version                   Architecture              Description
+++-=========================================-=========================-=========================-=======================================================================================
ii  policykit-1                               0.105-20ubuntu0.18.04.6   amd64                     framework for managing administrative policies and privileges

(policykit-1 being the package that provides the pkexec binary, as you can confirm using dpkg -S /usr/bin/pkexec).
You can view the patch report in the package's changelog:
$ apt changelog policykit-1
policykit-1 (0.105-20ubuntu0.18.04.6) bionic-security; urgency=medium

  * SECURITY UPDATE: Local Privilege Escalation in pkexec
    - debian/patches/CVE-2021-4034.patch: properly handle command-line
      arguments in src/programs/pkcheck.c, src/programs/pkexec.c.
    - CVE-2021-4034

 -- Marc Deslauriers <marc.deslauriers@ubuntu.com>  Wed, 12 Jan 2022 07:34:00 -0500


text:
Q: Select multiple tables using Linq to SQL I'm trying to bind columns from two different tables in to gridview using Linq To Sql
Here's the bind:
var q = (from o in mail.tblmails
    join c in mail.tblstaffs on o.staffId equals c.id
    select new { o, c });
    return View(q);
and here is where I'm calling the bind in my View.
.Columns(columns =>
       {
       columns.Bound(o => o.dateAdded).Format("{0:MM/dd/yyyy}").Width(80);
       columns.Bound(o => o.companyId);
       //columns.Bound(c => c.staffId);
       columns.Bound(o => o.subject);
       columns.Bound(o => o.dateArchived);

   })

I'm getting an error
Exception Details: System.InvalidOperationException: The model item passed into the dictionary is of type 'System.Data.Linq.DataQuery1[<>f__AnonymousType06[System.Nullable1[System.DateTime],System.Nullable1[System.Int32],System.String,System.Nullable1[System.DateTime],System.String,System.Int32]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[ffs.Models.tblmail]'.
I have a feeling that the issue may have something to do with the line
< % Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage>"%>
but I'm not sure what to do to fix it.
I'm using the telerik grid extension.
Any help would be great, thanks.

A: What you are doing now (and doing wrong also) is sending the query data directly to the view. This is considered bad practice. Although possible to acces the resulting anonymous type, this method will cause to do your data acces during the view instead of in the controller.
What I recommend is you make a model (class) to represent the data and return a list of those entities (your model) to the view using:
<% Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<List<yourCreatedModelClass>>"%>

Watch the part where you tell the view you are handing it a list of your objects rather than just a clean view.
Some related problem and solution is discussed here

A: I think the problem (looking at your error message) lies in the fact that you are trying to pass an anonymous type around while the view is expecting an IEnumerable<tblmail>.
What you want to do is create a data structure like:
public class Model
{
   public tblmails Mails { get; set; }
   public tblstaff Staff { get; set; }
}

Then in your linq query you would put o into Model.Mails, and then put c into Model.Staff.  You then pass your IEnumerable<Model> result into your view, and hook your view up so it is expecting IEnumerable<Model> as the model.


text:
Q: Does the Nintendo 3Ds System Transfer delete the data on the target system? I want to do a system transfer, but I have different Nintendo IDs for my two systems and I've downloaded games on each of them.
I have quite a few questions because I'm confused with the info on the internet and on the actual systems during transfer:

*

*Will the data on the target system be deleted?

*If not, will the games from the source system be combined with the games on the target system? (Will I be able to play my source-system games, as well as target-system games, on my target system?); and what happens if I have the same game on both?

*If the games on the target system will be deleted but re-downloadable, does that mean my saves are gone? Is there anyway to keep the saves of my target-system games?
Thanks! :D

A: Yes, the data on the target system will be deleted, according to Nintendo Support "you cannot perform a system transfer if the target system has a Nintendo Network ID linked. You must format the target system to remove the Nintendo Network ID link prior to transferring content."
All I know is that only digital downloaded games are tied to the NNID, so if you erase the previous NNID on the target and overwrite it with another NNID you cannot play those games anymore. But I don't know if NNID is stored on the SD card or on the console itself.
Everything you purchased with your source NNID will be available for redownload on the target system after the transfer. What you had on the target before the format will be lost, because it's tied to the original NNID.
Remember that you can have only one console tied to a specific NNID.
I suggest you to look on Nintendo Support for further info.
See also What You Need to Know Before Performing a New Nintendo 3DS XL System Transfer.


text:
Q: How to use systemd for starting endless log generating commands I'm using some Apache projects like Apache Kafka and Apache Zookeeper. The difference between two is that when I issue Apache Kafka command on the terminal,kafka-server-start.sh $KAFKA_HOME/config/server.conf it generates logs and did not give back the control of the command line (the new line that I can issue some other command). But issuing the zookeeper service after some line logging, it gives back the terminal command to me.
Now I created services for Kafka and Zookeeper to start at the boot time automatically. The following is the template for *.service files:
[Unit]
Description=Zookeeper Daemon
Wants=syslog.target

[Service]
Type=forking
WorkingDirectory=/home/zookeeper
User=zookeeper
ExecStart=/opt/zookeeper/bin/zkServer.sh start
TimeoutSec=30

[Install]
WantedBy=multi-user.target

The .service file for both Kafka and Zookeeper have the same structure.
Starting Zookeeper service at the booting time is ok but the problem is when the command for starting Kafka service is issued, as Kafka run command structure does not back the command to the user, the systemd consider it as unsuccessful start and after a timeout, label it as a failed or inactive service! Does systemd have a solution for running such commands as a service?
Update1: using ExecStart="/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties &" it errors:
kafka.service - Kafka Daemon

Loaded: loaded (/etc/systemd/system/kafka.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2017-12-16 14:20:00 IRST; 3h 29min left
  Process: 925 ExecStart=/opt/kafka/bin/kafka-server-start.sh /opt/kafka/config/server.properties & (code=exited, status=203/EXEC)

Dec 16 14:19:58 kafka1 systemd[1]: Starting Kafka Daemon...
Dec 16 14:20:00 kafka1 systemd[1]: kafka.service: Control process exited, code=exited status=203
Dec 16 14:20:00 kafka1 systemd[1]: Failed to start Kafka Daemon.
Dec 16 14:20:00 kafka1 systemd[1]: kafka.service: Unit entered failed state.
Dec 16 14:20:00 kafka1 systemd[1]: kafka.service: Failed with result 'exit-code'

.
Update2: The sudo journalctl -xe output is:
    -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit rc-local.service has failed.
--
-- The result is failed.
Dec 16 14:20:02 kafka1 systemd[1]: rc-local.service: Unit entered failed state.
Dec 16 14:20:02 kafka1 systemd[1]: rc-local.service: Failed with result 'exit-code'.
Dec 16 14:20:02 kafka1 named[1116]: reading built-in trusted keys from file '/etc/bind/bind.keys'
Dec 16 14:20:02 kafka1 named[1116]: initializing GeoIP Country (IPv4) (type 1) DB
Dec 16 14:20:02 kafka1 iscsid[1180]: iSCSI logger with pid=1186 started!
Dec 16 14:20:02 kafka1 systemd[1]: iscsid.service: Failed to read PID from file /run/iscsid.pid: Invalid argument
Dec 16 14:20:02 kafka1 systemd[1]: Started iSCSI initiator daemon (iscsid).
-- Subject: Unit iscsid.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit iscsid.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Starting Login to default iSCSI targets...
-- Subject: Unit open-iscsi.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit open-iscsi.service has begun starting up.
Dec 16 14:20:02 kafka1 named[1116]: GEO-106FREE 20160408 Bu
Dec 16 14:20:02 kafka1 named[1116]: initializing GeoIP Country (IPv6) (type 12) DB
Dec 16 14:20:02 kafka1 named[1116]: GEO-106FREE 20160408 Bu
Dec 16 14:20:02 kafka1 named[1116]: GeoIP City (IPv4) (type 2) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP City (IPv4) (type 6) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP City (IPv6) (type 30) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP City (IPv6) (type 31) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP Region (type 3) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP Region (type 7) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP ISP (type 4) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP Org (type 5) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP AS (type 9) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP Domain (type 11) DB not available
Dec 16 14:20:02 kafka1 named[1116]: GeoIP NetSpeed (type 10) DB not available
Dec 16 14:20:02 kafka1 named[1116]: using default UDP/IPv4 port range: [32768, 60999]
Dec 16 14:20:02 kafka1 named[1116]: using default UDP/IPv6 port range: [32768, 60999]
Dec 16 14:20:02 kafka1 named[1116]: listening on IPv6 interfaces, port 53
Dec 16 14:20:02 kafka1 named[1116]: listening on IPv4 interface lo, 127.0.0.1#53
Dec 16 14:20:02 kafka1 named[1116]: listening on IPv4 interface enp0s17, 192.168.1.201#53
Dec 16 14:20:02 kafka1 named[1116]: generating session key for dynamic DNS
Dec 16 14:20:02 kafka1 named[1116]: sizing zone task pool based on 5 zones
Dec 16 14:20:02 kafka1 iscsiadm[1193]: iscsiadm: No records found
Dec 16 14:20:02 kafka1 named[1116]: using built-in root key for view _default
Dec 16 14:20:02 kafka1 named[1116]: set up managed keys zone for view _default, file 'managed-keys.bind'
Dec 16 14:20:02 kafka1 named[1116]: automatic empty zone: 10.IN-ADDR.ARPA
Dec 16 14:20:02 kafka1 systemd[1]: Started Login to default iSCSI targets.
-- Subject: Unit open-iscsi.service has finished start-up
-- Defined-By: systemd

Dec 16 14:20:02 kafka1 named[1116]: configuring command channel from '/etc/bind/rndc.key'
Dec 16 14:20:02 kafka1 named[1116]: command channel listening on 127.0.0.1#953
Dec 16 14:20:02 kafka1 named[1116]: configuring command channel from '/etc/bind/rndc.key'
Dec 16 14:20:02 kafka1 named[1116]: couldn't add command channel ::1#953: address not available
Dec 16 14:20:02 kafka1 systemd[1]: Started LSB: Set the CPU Frequency Scaling governor to "ondemand".
-- Subject: Unit ondemand.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit ondemand.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Started Permit User Sessions.
-- Subject: Unit systemd-user-sessions.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-user-sessions.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Starting Hold until boot process finishes up...
-- Subject: Unit plymouth-quit-wait.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit plymouth-quit-wait.service has begun starting up.
Dec 16 14:20:02 kafka1 systemd[1]: Starting Terminate Plymouth Boot Screen...
-- Subject: Unit plymouth-quit.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit plymouth-quit.service has begun starting up.
Dec 16 14:20:02 kafka1 systemd[1]: Started Hold until boot process finishes up.
-- Subject: Unit plymouth-quit-wait.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit plymouth-quit-wait.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 apport[1205]:  * Starting automatic crash report generation: apport
Dec 16 14:20:02 kafka1 systemd[1]: Started Getty on tty1.
-- Subject: Unit getty@tty1.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit getty@tty1.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Reached target Login Prompts.
-- Subject: Unit getty.target has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit getty.target has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Starting Set console scheme...
-- Subject: Unit setvtrgb.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit setvtrgb.service has begun starting up.
Dec 16 14:20:02 kafka1 systemd[1]: Started Terminate Plymouth Boot Screen.
-- Subject: Unit plymouth-quit.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit plymouth-quit.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 named[1116]: managed-keys-zone: loaded serial 66
Dec 16 14:20:02 kafka1 irqbalance[1209]:  * Starting SMP IRQ Balancer: irqbalance
Dec 16 14:20:02 kafka1 named[1116]: zone 0.in-addr.arpa/IN: loaded serial 1
Dec 16 14:20:02 kafka1 named[1116]: zone 255.in-addr.arpa/IN: loaded serial 1
Dec 16 14:20:02 kafka1 named[1116]: zone 127.in-addr.arpa/IN: loaded serial 1
Dec 16 14:20:02 kafka1 systemd[1]: Started LSB: VMware Tools thinprint.
-- Subject: Unit vmware-tools-thinprint.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit vmware-tools-thinprint.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 named[1116]: zone localhost/IN: loaded serial 2
Dec 16 14:20:02 kafka1 named[1116]: all zones loaded
Dec 16 14:20:02 kafka1 named[1116]: running
Dec 16 14:20:02 kafka1 systemd[1]: Started Set console scheme.
-- Subject: Unit setvtrgb.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit setvtrgb.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 apport[1205]:    ...done.
Dec 16 14:20:02 kafka1 systemd[1]: Started LSB: automatic crash report generation.
-- Subject: Unit apport.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit apport.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Started LXD - container startup/shutdown.
-- Subject: Unit lxd-containers.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit lxd-containers.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 irqbalance[1209]:    ...done.
Dec 16 14:20:02 kafka1 systemd[1]: Started LSB: daemon to balance interrupts for SMP systems.
-- Subject: Unit irqbalance.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit irqbalance.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 ntp[1204]:  * Starting NTP server ntpd
Dec 16 14:20:02 kafka1 ntpd[1272]: ntpd 4.2.8p4@1.3265-o Thu Sep  7 20:43:09 UTC 2017 (1): Starting
Dec 16 14:20:02 kafka1 ntpd[1272]: Command line: /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 111:117
Dec 16 14:20:02 kafka1 ntp[1204]:    ...done.
Dec 16 14:20:02 kafka1 systemd[1]: Started LSB: Start NTP daemon.
-- Subject: Unit ntp.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit ntp.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Reached target Multi-User System.
-- Subject: Unit multi-user.target has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit multi-user.target has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Reached target Graphical Interface.
-- Subject: Unit graphical.target has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit graphical.target has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Starting Update UTMP about System Runlevel Changes...
-- Subject: Unit systemd-update-utmp-runlevel.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-update-utmp-runlevel.service has begun starting up.
Dec 16 14:20:02 kafka1 systemd[1]: Started Update UTMP about System Runlevel Changes.
-- Subject: Unit systemd-update-utmp-runlevel.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit systemd-update-utmp-runlevel.service has finished starting up.
--
-- The start-up result is done.
Dec 16 14:20:02 kafka1 systemd[1]: Startup finished in 14.613s (kernel) + 9.707s (userspace) = 24.321s.
-- Subject: System start-up is now complete
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- All system services necessary queued for starting at boot have been
-- successfully started. Note that this does not mean that the machine is
-- now idle as services might still be busy with completing start-up.
--
-- Kernel start-up required 14613810 microseconds.
--
-- Initial RAM disk start-up required INITRD_USEC microseconds.
--
-- Userspace start-up required 9707956 microseconds.
Dec 16 14:20:02 kafka1 ntpd[1275]: proto: precision = 0.089 usec (-23)
Dec 16 14:20:02 kafka1 ntpd[1275]: Listen and drop on 0 v6wildcard [::]:123
Dec 16 14:20:02 kafka1 ntpd[1275]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Dec 16 14:20:02 kafka1 ntpd[1275]: Listen normally on 2 lo 127.0.0.1:123
Dec 16 14:20:02 kafka1 ntpd[1275]: Listen normally on 3 enp0s17 192.168.1.201:123
Dec 16 14:20:02 kafka1 ntpd[1275]: Listening on routing socket on fd #20 for interface updates
Dec 16 14:20:02 kafka1 /usr/lib/snapd/snapd[1028]: daemon.go:250: DEBUG: init done in 1.128521ms
Dec 16 14:20:02 kafka1 /usr/lib/snapd/snapd[1028]: daemon.go:251: started snapd/2.25 (series 16; classic) ubuntu/16.04 (amd64) linux/4.4.0-87-generic.
Dec 16 14:20:02 kafka1 snapd[1028]: 2017/12/16 14:20:02.886275 daemon.go:251: started snapd/2.25 (series 16; classic) ubuntu/16.04 (amd64) linux/4.4.0-87-generic.
Dec 16 14:20:02 kafka1 /usr/lib/snapd/snapd[1028]: snapmgr.go:496: DEBUG: Next refresh scheduled for 2017-12-16 20:27:09.921506057 +0330 IRST.
Dec 16 14:20:03 kafka1 iscsid[1186]: iSCSI daemon with pid=1187 started!
Dec 16 14:20:03 kafka1 ntpd[1275]: Soliciting pool server 194.225.50.25
Dec 16 14:20:04 kafka1 ntpd[1275]: Soliciting pool server 5.144.132.2
Dec 16 14:20:04 kafka1 ntpd[1275]: Soliciting pool server 5.144.132.2
Dec 16 14:20:05 kafka1 ntpd[1275]: Soliciting pool server 82.99.215.101
Dec 16 14:20:05 kafka1 ntpd[1275]: Soliciting pool server 5.79.108.34
Dec 16 14:20:06 kafka1 ntpd[1275]: Soliciting pool server 95.46.198.21
Dec 16 14:20:06 kafka1 ntpd[1275]: Soliciting pool server 82.99.215.102
Dec 16 14:20:06 kafka1 ntpd[1275]: Soliciting pool server 212.51.144.44
Dec 16 14:20:07 kafka1 ntpd[1275]: Soliciting pool server 72.5.72.15
Dec 16 14:20:07 kafka1 ntpd[1275]: Soliciting pool server 131.155.140.129
Dec 16 14:20:08 kafka1 ntpd[1275]: Soliciting pool server 195.78.244.50
Dec 16 14:20:08 kafka1 ntpd[1275]: Soliciting pool server 213.136.0.252
Dec 16 14:20:09 kafka1 ntpd[1275]: Soliciting pool server 195.141.190.190
Dec 16 14:20:09 kafka1 ntpd[1275]: Soliciting pool server 2a02:c205:2009:8290::1
Dec 16 14:20:09 kafka1 ntpd[1275]: Soliciting pool server 91.189.91.157
Dec 16 14:20:10 kafka1 ntpd[1275]: Soliciting pool server 91.189.94.4
Dec 16 10:50:12 kafka1 systemd[1]: Time has been changed
-- Subject: Time change
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- The system clock has been changed to REALTIME microseconds after January 1st, 1970.
Dec 16 10:50:13 kafka1 ntpd[1275]: Soliciting pool server 194.225.150.25
Dec 16 10:50:13 kafka1 ntpd[1275]: receive: Unexpected origin timestamp from 131.155.140.129
Dec 16 10:50:13 kafka1 ntpd[1275]: Soliciting pool server 91.189.89.198
Dec 16 10:50:31 kafka1 sshd[1670]: Accepted password for kafka from 192.168.1.110 port 38698 ssh2
Dec 16 10:50:31 kafka1 sshd[1670]: pam_unix(sshd:session): session opened for user kafka by (uid=0)
Dec 16 10:50:31 kafka1 systemd[1]: Created slice User Slice of kafka.
-- Subject: Unit user-1001.slice has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit user-1001.slice has finished starting up.
--
-- The start-up result is done.
Dec 16 10:50:31 kafka1 systemd[1]: Starting User Manager for UID 1001...
-- Subject: Unit user@1001.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit user@1001.service has begun starting up.
Dec 16 10:50:31 kafka1 systemd[1673]: pam_unix(systemd-user:session): session opened for user kafka by (uid=0)
Dec 16 10:50:31 kafka1 systemd-logind[936]: New session 1 of user kafka.
-- Subject: A new session 1 has been created for user kafka
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/multiseat
--
-- A new session with the ID 1 has been created for the user kafka.
--
-- The leading process of the session is 1670.
Dec 16 10:50:31 kafka1 systemd[1]: Started Session 1 of user kafka.
-- Subject: Unit session-1.scope has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit session-1.scope has finished starting up.
--
-- The start-up result is done.
Dec 16 10:50:31 kafka1 systemd[1673]: Reached target Paths.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
Dec 16 10:50:31 kafka1 systemd[1673]: Reached target Timers.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
Dec 16 10:50:31 kafka1 systemd[1673]: Reached target Sockets.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
Dec 16 10:50:31 kafka1 systemd[1673]: Reached target Basic System.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
Dec 16 10:50:31 kafka1 systemd[1673]: Reached target Default.
-- Subject: Unit UNIT has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit UNIT has finished starting up.
--
-- The start-up result is done.
Dec 16 10:50:31 kafka1 systemd[1673]: Startup finished in 47ms.
-- Subject: System start-up is now complete
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- All system services necessary queued for starting at boot have been
-- successfully started. Note that this does not mean that the machine is
-- now idle as services might still be busy with completing start-up.
--
-- Kernel start-up required KERNEL_USEC microseconds.
--
-- Initial RAM disk start-up required INITRD_USEC microseconds.
--
-- Userspace start-up required 47460 microseconds.
Dec 16 10:50:31 kafka1 systemd[1]: Started User Manager for UID 1001.
-- Subject: Unit user@1001.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit user@1001.service has finished starting up.
--
-- The start-up result is done.
Dec 16 10:50:37 kafka1 sudo[1763]:    kafka : TTY=pts/0 ; PWD=/home/kafka ; USER=root ; COMMAND=/bin/systemctl status kafka.service
Dec 16 10:50:37 kafka1 sudo[1763]: pam_unix(sudo:session): session opened for user root by kafka(uid=0)
Dec 16 10:50:37 kafka1 sudo[1763]: pam_unix(sudo:session): session closed for user root
Dec 16 10:59:18 kafka1 ntpd[1275]: 131.155.140.129 local addr 192.168.1.201 -> <null>
Dec 16 10:59:38 kafka1 ntpd[1275]: 5.79.108.34 local addr 192.168.1.201 -> <null>
Dec 16 10:59:54 kafka1 ntpd[1275]: 82.99.215.101 local addr 192.168.1.201 -> <null>
Dec 16 11:00:05 kafka1 ntpd[1275]: 91.189.91.157 local addr 192.168.1.201 -> <null>
Dec 16 11:00:24 kafka1 ntpd[1275]: 195.78.244.50 local addr 192.168.1.201 -> <null>
Dec 16 11:02:59 kafka1 sudo[2160]:    kafka : TTY=pts/0 ; PWD=/home/kafka ; USER=root ; COMMAND=/bin/journalctl -xe
Dec 16 11:02:59 kafka1 sudo[2160]: pam_unix(sudo:session): session opened for user root by kafka(uid=0)


text:
Q: facebook post to wall with big picture I want to post to facebook wall by my app
but something confuse me
this is my post

and i hope the picture can as big as below one

here is my code
NSDictionary *params = @{
                             @"message":@"www.apple.com.tw this is message",
                             @"link":@"www.yahoo.com.tw",
                             @"caption":@"link_caption",
                             @"description":@"dff",
                             @"name":@"erh",
                             @"picture":@"http://cdn.wall88.com/51a4f786c959d55670.jpg"

                             };

    FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]
                                  initWithGraphPath:@"me/feed"
                                  parameters:params
                                  HTTPMethod:@"post"];

    [request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection,
                                          id result,
                                          NSError *error){

        if (!error)
        {
            NSLog(@"sdg");
        }
    }];

and if i delete@"link":@"www.yahoo.com.tw"
the picture is what i want
but the link is car picture's link

car picture's size is 1920*1080
is i missing something?
can i control the picture size?
thanks in advance
======anser edit=====
image size 1200 * 630 is useful
but at beginning you post
facebook seem to need some time to detect image size,so it appear as a square image
press F5 more times, it will become big image

A: Follow the suggestions from Facebook for image sizes:

Use images that are at least 1200 x 630 pixels for the best display on
high resolution devices. At the minimum, you should use images that
are 600 x 315 pixels to display link page posts with larger images.
You should use a 1.91:1 image ratio, such as 600 x 314 px.

Source: https://developers.facebook.com/docs/sharing/best-practices#images
...that´s all you can do, Facebook decides about how it will look like, depending on many factors - for example, how many users liked stuff on that domain (i guess).


text:
Q: C++: Getting the range between two months/years In class, we're doing an assignment to get the range between two dates using months and years as input.
My process code is as follows:
    int totalMonths1 = (year * MONTHS_IN_YEAR) + month;
    int totalMonths2 = (year2 * MONTHS_IN_YEAR) + month2;
    int range;

    if(totalMonths1 > totalMonths2)
    {
        range = totalMonths1 - totalMonths2;
    }

    if(totalMonths1 < totalMonths2)
    {
        range = totalMonths2 - totalMonths1;
    }

With const int MONTHS_IN_YEAR = 12.
This tells me the difference between the two dates, but not the range. If I add 1 to the result, it's the correct range according to my professor's example program, but I'd like to know if there's a better way to get the range instead of doing "difference + 1".

A: No. It doesnt get any simpler/better than a - b + 1. Unfortunately, anything else is over-complicating the solution and unnecessary.


text:
Q: insert script tag Uncaught SyntaxError: Unexpected identifier when I try to run the following code, I get the error:
Uncaught SyntaxError: Unexpected identifier

Why?

var script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML="var time = setInterval(flower, 100); var flower01=document.getElementById("flowerContainerDiv"); function flower(){if(flower01.parentNode!==null) flower01.parentNode.removeChild(flower01);}";
var head = document.getElementsByTagName("head");
head[0].appendChild(script);

A: if you are trying to execute javascript why not do that directly in place of doing that by inserting it in script tag, because if this code is going to execute then you already in javascript tag:
var time = setInterval(flower, 100);
var flower01=document.getElementById("flowerContainerDiv");
function flower(){
  if(flower01.parentNode!==null)
    flower01.parentNode.removeChild(flower01);
}

otherwise if you still want to do it the cleaner way to can place this code in a function and call, as having script code as string is not readable:
function dosomestaff(){
  var time = setInterval(flower, 100);
  var flower01=document.getElementById("flowerContainerDiv");
  function flower(){
    if(flower01.parentNode!==null)
      flower01.parentNode.removeChild(flower01);
  }
}

var script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML="dosomestaff()";
var head = document.getElementsByTagName("head");
head[0].appendChild(script);

and if you still want to make your code work just change
"flowerContainerDiv"    to    'flowerContainerDiv'

A: this might help.
1.sometimes the browser doesn't like you putting the script tag in the head
2.you don't have to declare the type you can leave it out


text:
Q: What does "learned mythology" mean?
Academics in the humanities played an active part by conceiving a real
mythology of Sweden's grand prehistoric past. According to the multi-talented Uppsala professor
Olaus Rudbeck, Scandinavia, with
Sweden at its centre, had actually been Atlantis, Plato's ideal
society, which made Sweden the origin of the whole of European
civilisation. Rudbeck generously apportioned this honour equally to
the western and eastern halves of the kingdom. Likewise, Daniel
Juslenius, at Åbo Akademi, repeated in his dissertation Aboa vetus et
nova (Åbo Old and New) in 1700 a story fabricated in the sixteenth
century that his town had been founded immediately after the Flood by
Noah's son Magog Of course, the question is how many people had the
opportunity to acquaint themselves with these learned mythologies.
(bolds by me)
A history of Finland by Henrik Meinander

I have two questions:

*

*What does it mean to conceive a real mythology of Sweden's past? Does it mean that the academics fabricated a mythology based on Sweden's actual history?

*What is a learned mythology? According to Cambridge dictionary, one of the meanings of the word "learned" is: Learned behaviour has been copied from others. Does this refer to the meaning in the first question? That the mythologies are fictive?

A: (1) Prehistoric means of the time before history was written down. The academics fabricated a mythology linking prehistoric Sweden to European myths such as that of Atlantis.
(2) This is Cambridge's first definition of learned, pronounced as two syllables. The mythologies were made up by academics (learned men) and ordinary folk may not have known about them.

A: "Mythology" means a collection of fictional or semi-fictional stories, usually involving heroes and/or the supernatural. and often describing a people's past.
In this case, by a "real mythology", I think the writer means, not a set of stories that are true, but rather, a set of stories that really meet the definition of mythology. That is, he is emphasizing that they are not true, but fictional. They are not a "true history" but a "real mythology". They are "really a mythology".
"Learned" means facts or behavior that one has acquired from someone else or has developed over time. In this case, by "learned mythology" he means that the stories have been invented by one group and then passed on to others.


text:
Q: Calculating Center (GPS Point) and Radius (km) of n GPS points I'm new to GPS and position mapping but i have a background in programing and some of the math related to it.
I've been tasked with writing a small golang program that takes n GPS points (DMS) and returns a GPS point and Radius that makes a circle that contains all n GPS points.
if n <= 1, Not Valid.
if n = 2, The GPS point returned will be the midway point and the radius will the distance divided by 2.
if n >= 3, The GPS point and Radius that makes a circle that contains all n GPS points.

*

*Calculate the Centroid of a polygon of n GPS points, returns center GPS point in (DMS) format.

*Calculate the distance from the above centroid to each coordinate from the n set using Pythagoras. The biggest value will be the radius of the circle.
This is as far as my thought process goes. Is there any GPS specific math I need to find points in (DMS)? Are there golang packages that could help with this type of math? Can someone give me an example of this with n >= 3 How can I drop pins and a radius to check the results, google maps?


text:
Q: How to find the records with same key value assigned to multiple values in MongoDB I have data like the following,

*

*Student | Subject

*A  |            Language

*A  |          Math

*B   |      Science

*A     |    Arts

*C      |   Biology

*B        | History

and so on...
I want to fetch the students who has same name but enrolled in two different subjects Language & Math only.
I tried to use the query:
$group:{
    _id:"$student",
    sub:"{$addToSet:"$subject"}
},
$match:{
     sub:{$in:["Language","Math"]}
}

But I am getting no documents to preview in MongoDB Compass. I am working in a VM machine, Compass is able to group only biology, history, science, arts only but not able to group language and math. I wanted to get A as my output.
Thanks in loads.
The collection data and the expected output:
{ Student:"A", Subject:"Language" },
{ Student:"A", Subject:"Math" },
{ Student:"B", Subject:"Science" },
{ Student:"A", Subject:"Arts" },
{ Student:"C", Subject:"Biology" },
{ Student:"B", Subject:"History" }

I am looking to get A as my output.

A: You are almost there, just need some tweak to your aggregation pipeline:
const pipeline = [
  {
    $group:
    {
      _id: '$Student', // Group students by name
      subjects: {
        $addToSet: '$Subject', // Push all the subjects they take uniquely into an array
      },
    },
  },
  {
    // Filter for students who only offer Language and Mathematics
    $match: { subjects: { $all: ['Language', 'Math'], $size: 2 } },
  },
];

db.students.aggregate(pipeline);

That should give an output array like this:
[
  { "_id" : studentName1 , "subjects" : [ "Language", "Math" ] },
  { "_id" : studentName2 , "subjects" : [ "Language", "Math" ] },
  ....
]

A: You have to use an Aggregation operator, $setIsSubset. The $in (aggregation) operator is used to check an array for one value only. I think you are thinking of $in (query operator)..
The Query:
db.student_subjects.aggregate( [
{ $group: {
        _id: "$student",
        studentSubjects: { $addToSet: "$subject" }
   }
},
{ $project: {
       subjectMatches: { $setIsSubset: [ [ "Language", "Math" ], "$studentSubjects" ] }
   }
},
{ $match: {
       subjectMatches: true
   }
},
{ $project: {
       matched_student: "$_id", _id: 0
   }
}
] )

The Result:
{ "matched_student" : "A" }

NOTES:
If you replace [ "Language", "Math" ] with [ "History" ], you will get the result: { "matched_student" : "B" }.
You can also try and see other set operators (aggregation), like the $allElementsTrue. Use the best one that suits your application.

[ EDIT ADD ]
Sample data for student_subjects collection:
{ "_id" : 1, "student" : "A", "subject" : "Language" }
{ "_id" : 2, "student" : "A", "subject" : "Math" }
{ "_id" : 3, "student" : "B", "subject" : "Science" }
{ "_id" : 4, "student" : "A", "subject" : "Arts" }
{ "_id" : 5, "student" : "C", "subject" : "Biology" }
{ "_id" : 6, "student" : "B", "subject" : "History" }

The Result After Each Stage:
1st Stage: $group
{ "_id" : "C", "studentSubjects" : [ "Biology" ] }
{ "_id" : "B", "studentSubjects" : [ "History", "Science" ] }
{ "_id" : "A", "studentSubjects" : [ "Arts", "Math", "Language" ] }

2nd Stage: $project
{ "_id" : "C", "subjectMatches" : false }
{ "_id" : "B", "subjectMatches" : false }
{ "_id" : "A", "subjectMatches" : true }

3rd Stage: $match
{ "_id" : "A", "subjectMatches" : true }

4th Stage: $project
{ "matched_student" : "A" }


text:
Q: "Debug assertion failed" error there is debug assertion failed error. Can someone get to the probem.

Debug Assertion Failed !
Program:..
  File:fclose.c
  Line:47
Expression:(stream!=Null)

I am debugging the code in visual studio.
Here is the Part of the code:
int __cdecl fclose (
        FILE *stream
        )
{
        int result = EOF;

        _VALIDATE_RETURN((stream != NULL), EINVAL, EOF);

        /* If stream is a string, simply clear flag and return EOF */
        if (stream->_flag & _IOSTRG)
                stream->_flag = 0;  /* IS THIS REALLY NEEDED ??? */

        /* Stream is a real file. */
        else {
                _lock_str(stream);
                __try {
                        result = _fclose_nolock(stream);
                }
                __finally {
                        _unlock_str(stream);
                }
        }

        return(result);
}

A: Check the callers of fclose(). Don't feed a NULL FILE* to it.


text:
Q: Using json_decode to retrieve ajax-sent javascript array for email I'm trying to email the contents of a JS array by encoding using JSON.stringify and then decoding in the PHP which should then be sent via email. I get a success alert that the data is sent to the PHP okay, but the email doesn't come through. Can anybody spot anything glaringly obvious I'm missing/got wrong, please?
Array has been populated via .push function and I can output that fine in the HTML, so I know it's populated.
Using ajax to encode my data string:
dataString = myArray;

var jsonString = JSON.stringify(dataString);

 $.ajax({
    type: "POST",
    url: "script.php",
    data: {data : jsonString},
    cache: false,

    success: function(){
       alert("Success");
    }
});

Then in the PHP:
<?php
$data = json_decode(stripslashes($_POST['data']));

$to = "my@email.com";
$header = "Content-Type: text/html\r\nReply-To";
$subject = "This is my Subject Line";

$body =
    @"
    The data is: $data
    ";

    if(mail($to, $subject, $body, $header)) {
        die("true");
        } else {
            die("There was an error sending the email.");
        }
?>

The email doesn't come through at all, and I don't get any error messages at all. Can anybody help, please? Thanks!

A: First, you can't convert $data array to string directly.
You have to use print_r($data, true) to insert contents of the array into a string

A: Has you got a mailserver in the PHP machine?
mail() returns true if the mail is accepted to delivery, but this doesn't mean it's sent at all.

A: Probably you don't have a mail server.
What you can do quickly is, go to this link,
http://www.toolheap.com/test-mail-server-tool/
Download the tool. follow the steps to run it.
Then change your code to this to see things that you can do,
<?php
$data = json_decode(stripslashes($_POST['data']));

$to = "abc@gmail.com";
$header = "Content-Type: text/html\r\nReply-To";
$subject = "This is my Subject Line";

$body =
@"
The data is:
".print_r($data, true) ;

if(mail($to, $subject, $body, $header)) {
    die("true");
    } else {
        die("There was an error sending the email.");
    }
?>

I think you will get the value but how you will use it that's your choice.
Cheers.


text:
Q: How event driven systems work? This question bugs me. How event handling systems works?
what i understand is that there is must be a loop that waits for a message or something then activates a portion of a code. I know it is most likely a wrong idea but i need to understand how it works (abstractly)?
if there are diagrams that can explain it that would be good !

A: If you are asking about events in C# suppose that they are just implementation of
Publisher/Subscriber or Observer patterns.
http://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern
http://en.wikipedia.org/wiki/Observer_pattern
In short, there is no waiting, subscriber just gives to publisher a code (via delegate) to invoke when publisher fires an event.


text:
Q: Find $[\mathbb{Q}({5}^{1/4}):\mathbb{Q}]$ and the minimal polynomial of a over Q. I have tried doing this by splitting fields and then using the tower law but I have not had any luck. Any help is much appreciated.
Question:
Find $[\mathbb{Q}({5}^{1/4}):\mathbb{Q}]$ and the minimal polynomial of a over $\mathbb{Q}$.

A: $5^{1/4}$ satisfies $x^4-5$ which is irreducible over $\mathbb{Q}$ by Eisenstein's criterion. So it is the minimal polynomial of $5^{1/4}$ and $[\mathbb{Q}(5^{1/4}):\mathbb{Q}]=\deg{x^4-5}=4$. So the degree of the extension is $4$.


text:
Q: Scala 3 match type reduction Let's say I want to represent a vector using a matched type like this:
type V[I <: Int, N] = I match
  case 2 => (N, N)
  case 3 => (N, N, N)
  case 4 => (N, N, N, N)

so now I can declare my vectors using tuples:
  val v2: V[2, Int] = (2, 2)
  val v3: V[3, Int] = (3, 3, 3)
  val v4: V[4, Int] = (4, 4, 4, 4)

and then I can define a tuple-matrix and a tuple-square-matrix:
type Mx[L <: Int, C <: Int, N] = V[L, V[C, N]]
type Mxq[T <: Int, N] = Mx[T, T, N]
type M3I = Mxq[3, Int]

everything is fine until now:
  //Compiles
  val m3: M3I = (
    (1, 0, 0),
    (0, 1, 0),
    (0, 0, 1)
  )

  //Doesn't compile
  val m3Err: M3I = (
    (1, 0, 0, 1),
    (0, 1, 0),
    (0, 0, 1)
  )

finally I define extension methods to manipulate the matrices
 extension[L <: Int, C <: Int, N] (essa: Mx[L, C, N])

    @implicitNotFound(msg = "Não é possível multiplicar as matrizes pois ${C} != ${LB}")
    def *[LB <: Int, CB <: Int](outra: Mx[LB, CB, N])(using ev: C =:= LB) = ???

but when I try to use it with m1 * m2 (which are both 3x3 matrices) i get this compiler error:
value * is not a member of (TestesKoinos.V[(3 : Int), Int], TestesKoinos.V[(3 : Int), Int],
  TestesKoinos.V[(3 : Int), Int]
).
An extension method was tried, but could not be fully constructed:

    TestesKoinos.*[L, C, N](m1)[LB, CB]    failed with

        Found:    (TestesKoinos.m1 : (TestesKoinos.V[(3 : Int), Int],
          TestesKoinos.V[(3 : Int), Int]
        , TestesKoinos.V[(3 : Int), Int]))
        Required: TestesKoinos.Mx[L, C, N]

        where:    C is a type variable with constraint <: Int
                  L is a type variable with constraint <: Int
                  N is a type variable

        Note: a match type could not be fully reduced:

          trying to reduce  TestesKoinos.Mx[L, C, N]
          trying to reduce  TestesKoinos.V[L, TestesKoinos.V[C, N]]
          failed since selector  L
          does not match  case (2 : Int) => (TestesKoinos.V[C, N], TestesKoinos.V[C, N])
          and cannot be shown to be disjoint from it either.
          Therefore, reduction cannot advance to the remaining cases

            case (3 : Int) => (TestesKoinos.V[C, N], TestesKoinos.V[C, N], TestesKoinos.V[C, N])
            case (4 : Int) => (TestesKoinos.V[C, N], TestesKoinos.V[C, N], TestesKoinos.V[C, N],
          TestesKoinos.V[C, N]
        )
  m1 * m2

What is wrong with my code/logic here?


text:
Q: VBA cannot get element and input data Here is the website that I want the data to be inputed: website Under"From City/Airport"
And i found the following HTML elements for that inputbox:
<input name="frm1" class="frm1 col-sm-12 ui-autocomplete-input" autocomplete="off">
Below is my VBA code:
Sub Data_Scrap()

    Dim IE As SHDocVw.InternetExplorer, HTMLDoc As MSHTML.HTMLDocument, HTMLInput As MSHTML.IHTMLElementCollection, x As MSHTML.IHTMLElement
    Set IE = New SHDocVw.InternetExplorer

    IE.Visible = True
    IE.navigate "https://www.icao.int/environmental-protection/Carbonoffset/Pages/default.aspx"

    'Wait until the website is loaded
    Do While IE.Busy
        Application.Wait DateAdd("s", 1, Now)
    Loop

    Set HTMLDoc = IE.document

    Set HTMLInput = HTMLDoc.getElementsByTagName("input")

    For Each x In HTMLInput
        If x.getAttribute("name") = "frm1" Then
            x.innerText = "hkg"
            Exit For
        End If
    Next
End Sub

I also tried something simpler like HTMLDoc.getElementsByTagName("frm1")(0).value = "hkg" but it comes out with error:

Object variable or With block variable not set


text:
Q: Update iOS App Store What's New while in review? Simple question – can we update the "What's New" text for an update while the app is being reviewed, or after it has been approved but before releasing it?

A: As of April 2018, it's no longer possible to change the "What's new" text after the app version changes its status to In Review, Pending Developer Release or Ready for Sale. You have to upload a new build and go through App Review again to change the text.
Nevertheless you can change "What's new" text before that, even while it's waiting for review.
Source: 9to5Mac

A: So, it turns out you can edit it whenever you like, even after the app has gone live, apparently. We apparently had a release with a typo in the update notes a while back and could pop in and fix it after a user tweeted about it.

A: You cannot update the What's New text, or the icon, or the screenshots after the app has entered the review process.  That is part of what Apple reviews, so they do not want developers changing the application meta data after they have reviewed it, because there were many app developers that would put screenshots from other, better apps after the review was done.
You can however, update that information while it is in the "Waiting for Review" status.


text:
Q: View pdfs stored in assets folder from listview click in fragment I have created a ListView in which I would like each item to open a certain .pdf file located in assets/PDFS folder located within my Android App. The following code does not throw any errors, but does not open the file either. Can someone share an idea for the solution?
Note that I am using Fragment
public class FreshFragment extends Fragment implements OnItemClickListener {

    ListView lv;
    String[] titles;

    public FreshFragment() {

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View V = inflater.inflate(R.layout.fragment_fresh, container, false);

        lv = (ListView)V.findViewById(android.R.id.list);
        lv.setOnItemClickListener(this);

        return V;
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        switch (position) {
        case 0:
            File pdfFile = new File("res/assets/peedee.pdf");
            Uri path = Uri.fromFile(pdfFile);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(path, "application/pdf");
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            break;

        }
    }
}

A: You can't open a file in your assets in another app.  You need to write it to disk somewhere both apps can read it first, such as external storage.


text:
Q: Excel VBA copy row automatically I need help to create an automatic method to copy a row to a specific sheet.
I have a Tab (Sales) with a WEB api query importing data in this sheet every 5 min. I have a row within the Sales sheet with a name range identifying each item. The row has 100 different names and there are 100 sheets created with same names within the workbook.
I want to copy the entire row for each item and copy it to the sheet with the same name of the item.
This is to fire off the copy sub:
'Copy Sales data Every 10 Min
Sub test()
    'Application.OnTime Now + TimeValue("00:10:00"), "my_Procedure…"
End Sub

I have seen many methods on how to copy the row automatically, but I need help in copy row and use the item name and paste to other sheet with same name.

A: Without further information here is an outline of what i described in the comments. Here the list of named ranges starts at cell J3 in NamesSheet. In the image, i have shown it in the same sheet (SourceSheet for simplicity). The list is read into an array and that array is looped to select the appropriate sheet to set the values in.
Rather than copy and paste it sets the target row (the next available row), in the sheet accessed by the array index, equal to the source row (copyRow). A With statement is used to avoid selecting the target sheet (more efficient).
No error handling added for missing sheets at present.
I haven't assumed there will be a list of 100 named ranges in the sheet, otherwise you could have sized the array from the start.
Named ranges in ColA of Sales tab:

List of named ranges in Names sheet (abbreviated)

Option Explicit

Private Sub myProc()

Dim wb As Workbook
Dim wsSource As Worksheet
Dim wsNames As Worksheet

Set wb = ThisWorkbook
Set wsSource = wb.Worksheets("Sales")
Set wsNames = wb.Worksheets("Names")

Dim namesArr()
namesArr = wsNames.Range("J3:J" & wsNames.Cells(wsNames.Rows.Count, "J").End(xlUp).Row).Value

If UBound(namesArr, 1) <> wsSource.Range("ITEMName").Rows.Count Then
    MsgBox "There are not a matching number of named ranges listed in Names sheet."
    Exit Sub
End If

Dim i As Long
Dim currLastRow As Long
'Any optimization code could actually go in outer calling sub but consider
'some such as the following

Application.ScreenUpdating = False
Dim copyRow As Range

For i = LBound(namesArr, 1) To UBound(namesArr, 1)

   With wb.Worksheets(namesArr(i, 1))

     Set copyRow = wsSource.Range(namesArr(i, 1)).EntireRow

     If IsEmpty(.Range("A1")) Then   'First row in sheet is available

         .Rows(1).Value = copyRow.Value2

     Else

         currLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

         .Rows(currLastRow + 1).Value = copyRow.Value2

     End If

   End With

Next i

Application.ScreenUpdating = True

End Sub

Version 2:
Looping Named Ranges in Sales sheet (assumes only 101 Named Ranges in the sheet, tested with workbook scope, and that you will ignore 1 of these which is called ITEMName, no list required in a different sheet. Approach adapted from @user1274820.
Option Explicit

Private Sub myProc2()

    Dim wb As Workbook
    Dim wsSource As Worksheet

    Set wb = ThisWorkbook
    Set wsSource = wb.Worksheets("Sales")

    Dim currLastRow As Long
    'Any optimization code could actually go in outer calling sub but consider
    'some such as the following

    Application.ScreenUpdating = False

    Dim copyRow As Range
    Dim nm As Variant

    For Each nm In ThisWorkbook.Names

        If nm.RefersToRange.Parent.Name = "Sales" And nm.Name <> "ITEMName" Then

            With wb.Worksheets(nm.Name)

                Set copyRow = wsSource.Range(nm.Name).EntireRow

                If IsEmpty(.Range("A1")) Then    'First row in sheet is available

                    .Rows(1).Value = copyRow.Value2

                Else

                    currLastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

                    .Rows(currLastRow + 1).Value = copyRow.Value2

                End If

            End With

        End If

    Next nm

    Application.ScreenUpdating = True

End Sub


text:
Q: Object id is missing in Django framework when posted from AngularJS MongoDB I am posting the following object
{
    skillName : "Professional Skills"
    _id : {$oid: "5adf23946ab671bf6cb36aff"}
    }

to the DjangoService given below:
@csrf_exempt
@api_view(['GET','POST'])
def saveSubjectView(request):  #this service will add & update Subject

    if request.method == 'POST':
        try:
            stream = StringIO(request.body)
            subject = JSONParser().parse(stream)
            print("The subejct is ")
            pp.pprint(subject)
            serializedsubject = json.loads(json_util.dumps(subject))
            print("serializedsubject")
            pp.pprint(serializedsubject)

The output that I am getting is
'skillType': {   u'_id': {   }, u'skillName': u'Professional Skills'}

The ObjectId posted from the front end (AngularJS) is not printed in the service. I know that I can fix it by removing the $oid while posting from the AngularJS application. But I would like to know why this is not happening. I have searched the documents and I couldn't get a proper reply. May be the keywords I used are wrong. Keywords used are : "JSON serialisation of ObjectId", "$oid json serialization using Django".
The complete object I am posting to the Django service is given below:

A: Exactly. $oid or anything prefixed with $ is an internal format and reserved, so you cannot post field names. The convention is from MongoDB Extended JSON where such prefixes are used to identify the BSON Type for proper conversion, and used as a serializable transport since these "types" are not supported in basic JSON.
So the solution is to actually use the bson.json_util to "deserialize" the JSON string right from the start:
from bson import json_util

# serializedsubject = json.loads(json_util.dumps(subject))
serializedsubject = json_util.loads(request.body)     # correct usage

Or more succinctly self contained:
input = '{ "skillName" : "Professional Skills" ,"_id" : { "$oid": "5adf23946ab671bf6cb36aff"} }'
json_util.loads(input)

Returns
{u'skillName': u'Professional Skills', u'_id': ObjectId('5adf23946ab671bf6cb36aff')}

This correctly casts objects from any keys notated with the Extended JSON Syntax to their correct BSON Type, as also supported in the driver functions. And naturally the driver will then convert back to BSON when sending to MongoDB.
If for some reason your request.body contains anything other than a "string" which is valid for input to the function, then it is up to your code to convert it to that point. But there should be no need to "parse to JSON" and then "stringify" again just to input to the function.

NOTE: If you have not already done so within your JavaScript client side of the application, there is also the bson package available. This would allow where such Extended JSON is "received" from the server the translation into the BSON Types as JavaScript Objects, and of course then the serialization of such objects back into the Extended JSON Format.
This would in fact be recommended where "type" information needs to be maintained with the data transmitted and kept between client and server.


text:
Q: Which Analysis books did you learn from and how many years/textbooks did it take to become a master? It seems that nearly every graduate program in the U.S. requires an extensive education in Analysis clearly demonstrating its importance not only as a subfield itself, but as a foundation for other areas of abstract mathematics.
I am interested in doing research in Analysis as a graduate student. I am curious how long it takes a student to get to the level of serious research in the subject.
As subjective as this question is, I am curious to know from which texts some of you learned Analysis i.e. from Rudin (the family), Royden, Pugh, Bartle, Tao, Torchinsky, etc.
How many classes did it take to be near or at the level of research in the area? Which texts helped you get there?
Also, do you know of any summer programs in Analysis at your institution undergraduates can enroll in?
Thanks in advance!

A: In my undergrad, I took two one-semester courses following Royden's Real Analysis. I liked this book because Royden (generally) has a sufficient amount of detail. I found it a good grounding in the fundamentals of measure theory and metric spaces.
After this, I took a course in Fourier analysis that used many textbooks (among which my favourite was Katznelson's An Introduction to Harmonic Analysis) and a course in functional analysis that used Macluer's Elementary Functional Analysis (an introductory text but very well presented - I imagine very appropriate for self-study).
It was during this time (the last year of my undergrad) that my advisor lent me her copy of Rudin's Real and Complex Analysis. This changed my outlook on analysis. Rudin writes in a way that I find simultaneously enlightening and challenging. The overall effect is stimulating. I feel like this book was important in training as an analyst and still exerts an influence on the way I think.
I found that these texts were sufficient for me to acquire strong foundations. In fact, these four texts are among those that can be found at my desk for quick access. For getting to research-level analysis, my experience is that each area has its own set of knowledge and techniques at people's fingertips. Reading specialised textbooks and well written papers in a particular area is, in my opinion, the best way to approach research. An advisor or other specialist can be a great source of suggestions to find these things.
For undergraduate summer programmes, definitely speak to people in your department (repeating @Thomas, above).

A: People will have different experiences of doing research.
Typically in a graduate program in the US one starts with taking general classes. After covering some basic classes (often in algebra, topology, and analysis (and maybe others)) you might start to take more specialized classes. At this point you might also start working with a specific professor on a project. It is really dependent on the project and you how "fast" you get to do actual research. Some professors will have students start almost immediately with smaller projects. Others will insist that you cover certain background before giving you a project to work on.
So, it is really difficult to say how long to "get to a serious level". My opinion is that it all is serious. Doing research now I often find my self consulting graduate (or even undergraduate) level textbooks. Often I have questions that might be answered in a graduate level class! In general I would say to not worry so much about whether the level is "serious".
As for books, I used both Rudin and Royden.
The best way to know about summer programs is to ask faculty in the math department. They often have an undergraduate advisor. You can also ask your current instructors if they know anything. At least you would probably need to seek our letters of recommendation from past instructors. You institution might even have funding for you. You can also look online for programs. I always get excited when a student approaches me about wanting to do a summer program!

A: In what follows I've restricted myself to those books I actually used at the time (nothing from after about 1991 or 1992), so this does not include anything that appeared afterwards.
I had a one-semester course out of Royden (covered most of the book --- it was a fairly fast-paced course), a one-semester course out of Taylor's General Theory of Functions and Integration (covered the middle third of the book, this being at a different university), and a two-semester course using Wheeden/Zygmund's Measure and Integral that was taught by Torchinsky (6 years before his 1988 book appeared, but much of what's in his book was included, in particular all the stuff on cardinal and ordinal numbers and order types). But these are introductory texts that Ph.D. qualifying exams are based on, and of course I and pretty much everyone else was also familiar with several other books, in my case probably the most significant were (in order of how much I studied the book) Measure Theory by Halmos, Real and Abstract Analysis by Hewitt/Stromberg, Measure Theory by Cohn, and Integration by McShane. Also, Real and Complex Analysis by Rudin (first third of the book) was often recommended, and many students used it for Ph.D. qualifying exam preparation, but for whatever reason I never looked at it all that much, and in fact it was only 4 or 5 years ago that I finally wound up getting a copy of Rudin's book (saw it at a used bookstore).
For what it's worth, a couple of books that I recall being recommended very often were (this being late 1970s to early 1980s) Functional Analysis by Riesz/Sz.-Nagy (first third of the book, the three chapters covering integration) and Linear Operators. Part I. General Theory by Dunford/Schwartz (also first third of the book, which is also the three chapters covering integration), but I never wound up looking at them very much. However, in looking at these two books right now, I believe the first third of Riesz/Sz.-Nagy would make for a good summer project if someone wants a refresher in classical analysis topics. But not Dunford/Schwartz, unless you really want to dig deep into set function machinery stuff. Another book (2 volumes, actually) that was often suggested is Theory of Functions of a Real Variable by Natanson, which incidentally I later wound up using often as a reference, but because everything is restricted to the real line the drawback is that you're not going to see any general measure theory.
What you should read AFTER the basic first year course material will depend hugely on what area of analysis you intend to work in. In my particular case, and this is a rather outlying area (but which I find fascinating), the books that I wound up making the most use of include Real Functions by Goffman, A Primer of Real Functions by Boas (1981 edition), A Second Course on Real Functions by van Rooij/Schikhof, Measure and Category by Oxtoby, The Geometry of Fractal Sets by Falconer, Fractal Geometry by Falconer, Differentiation of Real Functions by Bruckner (1978 edition), Real Functions by Thomson, and Theory of the Integral by Saks.

A: As far as textbooks are concerned, I learned Real Analysis mainly from Michael Spivak's Calculus. My contact with Walter Rudin's textbooks started only after graduation, but I also have a very high opinion about them.


text:
Q: Stackoverflow-like comments voting SQL query I'm developing a commenting system like Stackoverflow or Disqus has where people can comment and vote on the comments. I have three tables for this: USERS, COMMENTS, and VOTES.
I'm having trouble figure out how to write the query to count votes and returning whether or not a given user has voted. Each user can only vote once per comment and can't vote on their own comment. Also, the comments and votes aren't just on one topic. Each page has its own topic and so when doing a GET to SELECT comments and votes, the WHERE topic_id='X' needs to be reflected in the query too.
here's my tables' data, how my query looks so far, and what i hope to have it return:
USERS table
user_id user_name
 1         tim
 2         sue
 3         bill
 4         karen
 5         ed

COMMENTS table
comment_id topic_id    comment   commenter_id
 1            1       good job!         1
 2            2       nice work         2
 3            1       bad job :)        3

VOTES table
 vote_id    vote  comment_id  voter_id
  1          -1       1          5
  2           1       1          4
  3           1       3          1
  4          -1       2          5
  5           1       2          4

SELECT users.*, comments.*, count(vote as totals), sum(vote=1 as yes), sum(vote=-1 as no),
my_votes.vote as did_i_vote, users.* as IM_THE_USER
from comments
join votes
on comments.comment_id=votes.comment_id
join users
on comments.commenter_id=users.user_id
join votes as MY_votes
on MY_votes.voter_id=IM_THE_USER.user_id
where topic_id=1 and IM_THE_USER.user_id=1
group by comment_id

user_id user_name comment_id topic_id  comment   commenter_id  totals yes no did_i_vote
   1      tim          1        1      good job!     1           2     1   1    NULL
   3      bill         3        1      bad job:)     3           1     1   0      1

A: SQL Fiddle for playing
select u.user_id, u.user_name,
       c.comment_id, c.topic_id,
       sum(v.vote) as totals, sum(v.vote > 0) as yes, sum(v.vote < 0) as no,
       my_votes.vote as did_i_vote
from comments c
join users u on u.user_id = c.commenter_id
left join votes v on v.comment_id = c.comment_id
left join votes my_votes on my_votes.comment_id = c.comment_id
                            and my_votes.voter_id = 1
where c.topic_id = 1
group by c.comment_id, u.user_name, c.comment_id, c.topic_id, did_i_vote;

Update: fixed group by clause
update by OP (tim peterson): fixed count as totals and added comment itself to be returned by the query
final working SQLFiddle


text:
Q: How to create Authentication & Authorization based on user Id I'm quite new to ASP.NET MVC5. I tried to build a Booking application with Users and Admin. A User can register themselves, and book items, show their own booking information using their own profile (after login).
I want Users to be able to log in to their profile and create/read their own booking. They should only be authorized to their own profile after login. The Admin should have access to all of the controller.
I tried to find a tutorial on doing this but I can only restrict the access to a controller based on a role only (eg; Admin), but not by specific User with their own Id (eg; User1 can only access User1 information).
I appreciate any kind of response. Thank you very much.

A: This is a multi-tenant application, so you should read a bit about multitenancy. Also, this works quite nicely with the claims authorization, so you should read that too.
You can create a simple permission model, with 3 permissions (read, create, edit). Every user has one or more claims to the resources (resource can be an URL for its profile, or user id in the database). Each resource claim can have one or more permissions for the operations which user can execute on this resource.
This way you can give your users a full permissions (R,C,E) on his own profile entries. Also, user can give some permissions to other users (for example, he can give read permissions to everyone, or edit permissions to his friends). This makes user an 'administrator' of his own profile, and he can give some limited permissions to the other users.
You can group the permissions into roles, so when you give user a role, all the permissions (and claims) are automatically created for him.
For the controller actions, you can look for a ClaimsAuthorizeAttribute (there are a few on SO, like this one: MVC5 Claims version of the Authorize attribute). Also, there's a great library with a lot of helpers in the IdentityServer projects here: https://github.com/IdentityServer


text:
Q: Griffon Compilation error: cannot override firePropertyChange? Upgrading my 0.3.1 Griffon app into 0.9.4 found the following compilation error:
 [griffonc] Threading injection feature disabled.

 [griffonc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

 [griffonc] ..\sgmentia-client\griffon\app\models\com\nortia\sgmentia\client\maestros\MaestrosModel.groovy: -1: firePropertyChange(java.lang.String,java.lang.Object,java.lang.Object) in com.nortia.sgmentia.client.maestros.MaestrosModel cannot override firePropertyChange in com.nortia.sgmentia.client.maestros.MaestrosModelSupport; attempting to assign weaker access privileges; was public
 [griffonc]  @ line -1, column -1.
 [griffonc] 1 error
 Compilation error: Compilation Failed

There are no mention of  firePropertyChange in my code so I dont know how to go on.
The referred classes look like follows:
abstract class MaestrosModelSupport
...
class MaestrosModel extends MaestrosModelSupport

Ideas??

Update
I've followed the naming convention (every Model must end up with XXXModel) and now the project compiles.
However after some refactoring there is something new:
 [copy] Copying 1 file to C:\maestro\desarrollo\projects\interactionManager\sgmentia-client\staging
 ERROR [main]: [1] ApplicationDefaultExceptionHandler Se ha producido un error inesperado en la aplicaci¾n: Interfaces must have java.lang.Object as superclass in class file com/nortia/sgmentia/client/DocumentController

 java.lang.ClassFormatError: Interfaces must have java.lang.Object as superclass in class file com/nortia/sgmentia/client/DocumentController
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)

So what now?

A: This appears to be another instance of https://jira.codehaus.org/browse/GRIFFON-440
I wonder how are you setting up your codebase, for example, why are the models placed in sgmentia-client\griffon\app\modelsinstead of sgmentia-client\griffon-app\models.
You can have abstract model classes as bases classes for all models, that should be supported form the get go, as long as you follow the conventions
abstract class AbstractSupportModel { ... }
class MaestrosModel extends AbstractSupportModel { ... }

Both AbstractSupportModel and MaestrosModel are placed in sgmentia-client\griffon-app\models.


text:
Q: Filter ext files in object using node js / javascript I am filtering a file by uploading it. File which I am uploading is in form of object

*

*And object look like this

console.log(files);

{ file-1:
 [{ name: `test.jpg`,
    path: `home/work/test.jpg`,
    size: 456 } ]
  file-2:
 [{ name: `random.jpg`,
    path: `home/work/random.jpg`,
    size: 456 } ] }

so i tried to do like this
if(files.endsWith(".jpg"){
 console.log("yes");
}else{
 console.log("no");
}

Here I am getting this error  uncaughtException: files.endsWith is not a function

*

*Even I tried this too

if(files.name.endsWith(".jpg"){
 console.log("yes");
}else{
 console.log("no");
}

Here I am getting this error uncaughtException: Cannot read property 'endsWith' of undefined

A: var jpgFiles = [];

Object.keys(files).map(key => {
files[key].filter(file => {
    if (file.name.endsWith('.jpg')) {
        console.log('yes');
jpgFiles.push(file);
        return true;
    }else {
        console.log('no');
        return false;
        }})
});

A: files is an object. endsWith is a string method.
You need to access the file array and check the name property either by using the index:
files['file-1'][0].name.endsWith('jpg');

or, if there's more than one file in the array using some or every to check the names:
files['file-1'].every(f => f.namee.endsWith('jpg'));

files['file-1'].some(f => f.name.endsWith('jpg'));

If you want to check the values across multiple properties you can iterate over them:

const files = {
  'file-1': [{
    name: `test.jpg`,
    path: `home/work/test.jpg`,
    size: 456
  }],
  'file-2': [{
    name: `random.jpg`,
    path: `home/work/random.jpg`,
    size: 456
  }]
}

const result = Object.values(files).every(arr => {
  return arr[0].name.endsWith('jpg');
});

console.log(result);

Note, your output is still invalid.