text:
Q: Release ad-hoc ed expired provisioning sorry for my bad english but i'm italian.
I have to release an app that will work on only a few devices. What should I do when the provisioning profile expires? Will the app continue to work or should I release it again with the updated profile?
thx all

A: No the app will not work after the mobileprovision expiration date. You need to renew your mobile provision, build again and sign the app with new certificate and resent to users the new mobile provision file and the new app.
Edit:
You can submit for an enterprise account an you will not have this issue again.

A: Not sure what you're really asking, but here is a quick answer with some points that might help you.
Ad hoc provisioning profiles last for 1 year. After a year the certificate is invalid and the application won't work any more. At this point you will have to create a new certificate (usually just renew the certificate will work) and re-release built against the new certificate. This will mean that anyone using the application this way will have to remove the app from their device and install the new package you send them.
When you release an application on the app store the certificate is permanent, you don't have to renew anything and apple will deal with it itself.

A: If you archived it, all you need to do is create a new .ipa (by selecting "Share" in the organizer) and sign it using the new profile.
If you didn't archive it you need to build it again and you'll need to reselect the code signing identities in the project settings.
Either way you need to send a new build or a re-signed archive to your testers, the new profile alone won't work.


text:
Q: Minified angular2 - Has anyone done this successfully yet? I'm building an angular2 app, and started working on my build/minification process.  I can successfully build and run my application in a dev mode, with individual JS files, which are unminified.  But when I build them into a single, concatenated file my application will not run.  All I get is a blank page, no errors on the console.  I've tried webpack, gulp, etc, all have the same result when running in the browser.
I'm curious if anybody has gotten this to work yet? Or has any suggestions?
One thing I notice in my compiled JS (from typescript) is that the bootstrap call is present, but never executed if I set a break point.
I'm compiling my TypeScript to es5 and System modules.  Angular2.beta12
Index.html
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- inject:css -->
    <link rel="stylesheet" href="resources/css/ncss.css">
    <link rel="stylesheet" href="css/App.css">
    <!-- endinject -->

    <!-- 1. Load libraries -->
    <!-- IE required polyfills, in this exact order -->
    <!-- inject:js -->
    <script src="libs/system-polyfills.js"></script>
    <script src="libs/angular2/bundles/angular2-polyfills.js"></script>
    <script src="libs/system.src.js"></script>
    <script src="libs/Rx.js"></script>
    <script src="libs/angular2/bundles/angular2.min.js"></script>
    <script src="libs/angular2/bundles/router.min.js"></script>
    <script src="libs/angular2/bundles/http.min.js"></script>
    <!-- endinject -->

    <!--<script src="app/app.min.js"></script>-->

    <!-- 2. Configure SystemJS -->
    <script>

        System.import('app/app.min.js')
                .then(null, console.error.bind(console));

    </script>

</head>

<!-- 3. Display the application -->

<body>
    <app-component></app-component>

</body>

TSConfig:
{
  "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "declaration": true,
    "suppressImplicitAnyIndexErrors": true,
    "outDir": "./dist/app",
    "outFile": "./dist/app/app.min.js"
  },
  "exclude": [
    "node_modules",
    "typings/browser",
    "typings/browser.d.ts",
    "dist/libs"
  ]
}

A: I think I have my answer. I was cherry-picking the files I needed when I built my dist directory. I ended up copying the entire angular2 and rxjs directories to make all files available to SystemJS, then it started working. Thanks all!

redpajama_set_name: RedPajamaStackExchange


text:
Q: Jupyter Notebook to HTML - Notebook JSON is invalid: ['outputPrepend'] I am trying to convert my Jupyter Notebook file (.ipynb) into an HTML file for easier reading. Every time I try to save the notebook I get a "Notebook validation failed" error:
Notebook validation failed: ['outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend'] has non-unique elements:
[
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend"
]

message when file is saved
When I try to download as .html using File > Download as, I get a further more detailed error but I still cannot make out what it means or what needs to be done to solve the problem and finally download as HTML:
nbconvert failed: ['outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend'] has non-unique elements

Failed validating 'uniqueItems' in code_cell['properties']['metadata']['properties']['tags']:

On instance['cells'][70]['metadata']['tags']:
['outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend']

message when trying to download as HTML
This is only happening on the specific notebook I am working on. I have tried to save and export other notebooks as HTML successfully.
Any help is appreciated. Thanks

A: I recently experienced this from using the VSCode Notebook editor. I solved it by opening the notebook in a regular text editor and deleting all the extra outputPrepend-items, leaving only a single one in each array.


text:
Q: Web Animations API - varying animation durations? I'm experimenting with the Web Animations API which currently works only in Webkit browsers. As one can imagine, the documentation is a bit sparse:

*

*Here's a blog post I found on it

*Here's the spec
I'm trying to do two things:

*

*Reverse the animation at a random point in time before the animation ends.

*Stagger the duration of the effects in the animation. For example, for a 3 second animation, the first portion of it should be 1.25s and the second portion should be 1.75s.

Here's a working example which uses the Web Animation API. My concern is that the 3 animations are spaced evenly among the 3 seconds. How can I space them out differently without instantiating multiple animationPlayer objects?

$('.box').click(function() {
  var animationPlayer = this.animate([{
    transform: 'translateX(0px)'
  }, {
    transform: 'translateX(600px)'
  }, {
    transform: 'translate(600px, 200px)'
  }], 3000);

  animationPlayer.onfinish = function(e) {
    console.log('complete!');
  }

  //  wiggle wiggle wiggle
  setTimeout(function() {
    animationPlayer.reverse();
    setTimeout(function() {
      animationPlayer.reverse();
    }, 250);
  }, 750);
});
.box {
  background-color: red;
  width: 200px;
  height: 200px;
  display: inline-block;
}

A: About your first question, looks like Chrome implementation still hasn't the reverse function. This is consistent with the documentation that you have linked. May be in Canary, but I haven't checked.
Correction: reading an update in your linked blog, looks like it has been added to Chrome. However, it isn't working for me ...
About your second question, specify an offset in your second keyframe
If the first transform must run for 1.25 s, for a total of 3 s, this is 1.25 / 3 = .416, so

$('.box').click(function() {
  var animationPlayer = this.animate([{
    transform: 'translateX(0px)'
  }, {
    transform: 'translateX(600px)', offset: 0.416
  }, {
    transform: 'translate(600px, 200px)'
  }], 3000);

  animationPlayer.onfinish = function(e) {
    console.log('complete!');
  }

  //  wiggle wiggle wiggle
  setTimeout(function() {
    animationPlayer.reverse();
    setTimeout(function() {
      animationPlayer.reverse();
    }, 250);
  }, 750);
});
.box {
  background-color: red;
  width: 200px;
  height: 200px;
  display: inline-block;
}


text:
Q: weblinks svg file not working once placed within webpage On my home page I am trying to insert an svg with clickable parts that link to other webpages. I made this svg with Illustrator and when I open it in a browser directly everything works the way it should. However, once I place this svg on my webpage, upon clicking it, it seems to open an image instead of opening the actual page it is linked to. If you rightclick and click on 'open in new tab'  or 'open in new window' it does open the link.
The svg is displayed on www.unfoldmyworld.com, it is the worldmap with the clickable images.
Here is a snippet of code from the svg regarding a clickable area:
<a xlink:href="http://www.unfoldmyworld.com/Africa" xlink:show="replace">
        <polygon id="Box-1" fill="#FFFFFF" opacity="0" points="366.938,336.958 461.559,
        336.946 461.583,409.583 481.003,409.56 480.979,449.266 441.263,449.266 441.28,
        431.596 366.938,431.58      "/>

In order to get the svg onto my wordpress elementor page I installed the plugin svg support. I already tried putting in xlink:show="new" and target="_blank" which did not do the trick. I have also tried putting the whole svg inline in an html code box, which resulted in the same issue. If anyone can tell me what I have to do to get these links to actually open the intended page in the current window (not in a new one), that would be greatly appreciated.

A: I managed to find a solution to this problem myself. It turns out that this issue is caused by Elementor. It automatically opens a lightbox when clicked on the link. To solve this issue the data-elementor-open-lightbox="no" attribute needs to be added to the link within the svg file.


text:
Q: SQL - Which query will be more efficient? -Assume sample records whats to show CompanyName ,CompanyID ,OrderID , Ordername ,Sum(Amount) .Except amount all columns are Varchar
CompanyName  | CompanyID  | OrderID    |  OrderName    |      Amount
CS           |    10      |  5567      |  Bonds        |      67000
CS           |    10      |  5567      |  Bonds        |      77000
CS           |    10      |  5566      |  Derivatives  |      90000
Barleys      |    20      |  5567      |  Bonds        |      90000
Barleys      |    20      |  5566      |  Derivatives  |      90000
T.D          |    30      |  5566      |  Derivatives  |      90000
T.D          |    30      |  5567      |  Bonds        |      60000

Which query will be efficient
Select CompanyName, CompanyID, OrderID, OrderName ,Sum(Amount)
from @Table
group by CompanyName, CompanyID, OrderID, OrderName;

Or:
Select  CompanyID, Max(CompanyName),OrderID, Max(OrderName) ,Sum(Amount)
from @Table
group by  CompanyID, OrderID;

Both Query gives the same result but what's to know which query is good in terms of performance wise if the table contains more than 7 million records. will the group by affect the performance  ?


text:
Q: preventing mongodb from accepting non-local connections I'm running MongoDB in an untrusted environment (everything on the machine running the single mongod instance is trusted, everything else is not). As a result, I only want things running locally to connect to the mongod instance. Is there a way to prevent MongoDB from accepting any remote connections, or even better, opening a port that others could attempt to connect to?
If the typical solution to this kind of problem is not MongoDB-specific (ie it relies on OS configuration), I am running on a *nix system.

A: From http://docs.mongodb.org/manual/reference/configuration-options/:

bind_ip
Default: All interfaces.
Set this option to configure the mongod or mongos process to bind to and listen for connections from applications on this address. You may attach mongod or mongos instances to any interface; however, if you attach the process to a publicly accessible interface, implement proper authentication or firewall restrictions to protect the integrity of your database.

Setting that to an address that's only internally accessible (or in extreme, only accessible by processes on that host, ex 127.0.0.1) will likely do what you want.


text:
Q: working with lists in c# - without using database - many to many i already looked at How to model a Many to many-relationship in code?
and I don't quite understand the answer.
also looked at C# Mapping Many To Many but don't want to use entity framework/database
I have Students, and Subjects
public class Subject : Student
    {
        public string SubjectName { get; set; }
        public string StudentClassNumber { get; set; }
    }

    public class Student
    {
        public string StudentName { get; set; }
        public string isjoined { get; set; }

    }

then to instanciate
List<Subject> subject = new List<Subject>();

and to add values/properties
subject2.Add(new Subject2() { SubjectName = "Math", StudentName = "Ben", isjoined = "yes", StudentClassNumber ="2" });
            subject2.Add(new Subject2() { SubjectName = "Math", StudentName2 = "Andrew", isjoined = "yes", StudentClassNumber = "4" });
            subject2.Add(new Subject2() { SubjectName = "Science", StudentName2 = "Andrew", isjoined = "no", StudentClassNumber = "5" });
            subject2.Add(new Subject2() { SubjectName = "Science", StudentName2 = "Ben", isjoined = "no", StudentClassNumber = "3" });

and now my issue, The "Andrew" or "Ben" that are in "Math" are the same (students) that are in "Science" , this is not a new Andrew and Ben
Id like to have a WriteLine that writes: Math - StudentName - StudentClassNumber - Is joined,
for both/all students
Ie Math :
Ben 2
Yes
Andrew 4 Yes
Science
Ben 3 No
Andrew 4 No
Here is an attempt using linq
class Students
    {
        public string StudentName { get; set; }

    }

    class Subject
    {
        public string Name { get; set; }
        public Students Occupier { get; set; }
    }

    class InnerJoin3
    {
        public static void DoJoin()
        {
            Students ben = new Students { StudentName = "Ben" };
            Students andrew = new Students { StudentName = "Andrew" };

            Subject math = new Subject { Name = "Math", Occupier = andrew };
            Subject science = new Subject { Name = "Science", Occupier = ben };

            // Create two lists.
            List<Students> people = new List<Students> { ben, andrew };
            List<Subject> subjects = new List<Subject> { math, science };

            // Create a collection of student-subject pairs. Each element in the collection
            // is an anonymous type containing both the student's name and their subject's name.
            var query = from student in people
                        join subject in subjects on student equals subject.Occupier
                        select new { OccupierName = student.StudentName, SubjectName = subject.Name };

            foreach (var ownerAndSubject in query)
            {
                Console.WriteLine($"\"{ownerAndSubject.SubjectName}\" is the subject of choice for {ownerAndSubject.OccupierName}");
            }
        }
    }

A: Well if it is like you said. You want the following result in your console Application:
Math: name, name
Science: name.. etc.

In your Main Class add the following:
static void Main(string[] args)
        {
            Students ben = new Students { StudentName = "Ben" };
            Students andrew = new Students { StudentName = "Andrew" };

            Subject mathAndrew = new Subject { Name = "Math", Students = andrew };
            Subject ScienceAndrew = new Subject { Name = "Science", Students = andrew };
            Subject scienceBen = new Subject { Name = "Science", Students = ben };

            List<Students> people = new List<Students> { ben, andrew };
            List<Subject> subjects = new List<Subject> { mathAndrew, ScienceAndrew, scienceBen };

            var query = from student in people
                        join subject in subjects on student equals subject.Students
                        select new SetQuery(student.StudentName, subject.Name);

            ScienceResult(query);
        }

And add this method:
note in order to create the ScienceResult Method we need a SetQuery class instance.
public static void ScienceResult(IEnumerable<SetQuery> query)
        {
            Console.Write("Science: ");
            foreach (var result in query)
            {
                if (result.Name == "Science")
                {
                    Console.Write(result.StudentName + " ");
                }
            }

            Console.WriteLine();

            Console.Write("Math: ");
            foreach (var result in query)
            {
                if (result.Name == "Math")
                {
                    Console.Write(result.StudentName + " ");
                }
            }

            Console.WriteLine();
        }

Set Query Class Instance with Dependency Injection
internal class SetQuery
    {
        public string StudentName;
        public string Name;

        public SetQuery(string studentName, string name)
        {
            this.StudentName = studentName;
            this.Name = name;
        }
    }

Result is:
Science: Ben Andrew
Math: Andrew

For best practice i would use a database to save your information and to GET your information from. Also the method ScienceResult is NOT DRY you would wanna change that. this is just for illustration purpose.
For more info About DRY check the following:
DRY (Don't Repeat Yourself) and if assignements

A: Not sure what you're looking for exactly, but best software practices be damned, here you go (assuming solution is called "stackoverflow61918396"):
Student.cs
using System.Collections.Generic;

namespace stackoverflow61918396
{
    class Student
    {
        public string Id { get; set; }

        public string Name { get; set; }

        public List<string> SubjectsEnrolledIn { get; set; }

        public Student()
        {
            SubjectsEnrolledIn = new List<string>();
        }
    }
}

Subject.cs
using System.Collections.Generic;

namespace stackoverflow61918396
{
    class Subject
    {
        public string Id { get; set; }

        public int ClassNumber { get; set; }

        public string Name { get; set; }

        public List<string> StudentsInSubject { get; set; }

        public Subject()
        {
            StudentsInSubject = new List<string>();
        }
    }
}

Manager.cs
using System;
using System.Collections.Generic;
using System.Linq;

namespace stackoverflow61918396
{
    class Manager
    {
        public static List<Student> Students { get; set; }

        public static List<Subject> Subjects { get; set; }

        public Manager()
        {
            Students = new List<Student>();
            Subjects = new List<Subject>();

            // Seed some students
            var ben = new Student() { Id = Guid.NewGuid().ToString(), Name = "Ben" };
            var andrew = new Student() { Id = Guid.NewGuid().ToString(), Name = "Andrew" };
            var amanda = new Student() { Id = Guid.NewGuid().ToString(), Name = "Amanda" };
            var greg = new Student() { Id = Guid.NewGuid().ToString(), Name = "Greg" };
            var peter = new Student() { Id = Guid.NewGuid().ToString(), Name = "Peter" };
            var jessica = new Student() { Id = Guid.NewGuid().ToString(), Name = "Jessica" };
            var james = new Student() { Id = Guid.NewGuid().ToString(), Name = "James" };
            var doug = new Student() { Id = Guid.NewGuid().ToString(), Name = "Doug" };
            var cory = new Student() { Id = Guid.NewGuid().ToString(), Name = "Cory" };
            var laura = new Student() { Id = Guid.NewGuid().ToString(), Name = "Laura" };
            Students.Add(ben);
            Students.Add(andrew);
            Students.Add(amanda);
            Students.Add(greg);
            Students.Add(peter);
            Students.Add(jessica);
            Students.Add(james);
            Students.Add(doug);
            Students.Add(cory);
            Students.Add(laura);

            // Seed a couple sections of math and science
            var math2 = new Subject() { Id = Guid.NewGuid().ToString(), Name = "Math", ClassNumber = 2 };
            var math4 = new Subject() { Id = Guid.NewGuid().ToString(), Name = "Math", ClassNumber = 4 };
            var science5 = new Subject() { Id = Guid.NewGuid().ToString(), Name = "Science", ClassNumber = 5 };
            var science3 = new Subject() { Id = Guid.NewGuid().ToString(), Name = "Science", ClassNumber = 3 };
            Subjects.Add(math2);
            Subjects.Add(math4);
            Subjects.Add(science5);
            Subjects.Add(science3);

            // Seed some enrollments
            Enroll(ben.Id, math2.Id);
            Enroll(andrew.Id, math2.Id);
            Enroll(andrew.Id, science5.Id);
            Enroll(amanda.Id, math2.Id);
            Enroll(peter.Id, math2.Id);
            Enroll(jessica.Id, math4.Id);
            Enroll(james.Id, math2.Id);
            Enroll(doug.Id, math4.Id);
            Enroll(doug.Id, science5.Id);
        }

        public Student AddStudent(string name)
        {
            var student = new Student() { Id = Guid.NewGuid().ToString(), Name = name };
            Students.Add(student);

            return student;
        }

        public Subject AddSubject(string name, int classNumber)
        {
            var subject = new Subject() { Id = Guid.NewGuid().ToString(), Name = name, ClassNumber = classNumber };
            Subjects.Add(subject);

            return subject;
        }

        public bool DeleteStudent(string id)
        {
            try
            {
                var student = Students.Where(s => s.Id == id).FirstOrDefault();

                if (student == null) return false;

                Students.Remove(student);

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public bool DeleteSubject(string id)
        {
            try
            {
                var subject = Subjects.Where(s => s.Id == id).FirstOrDefault();

                if (subject == null) return false;

                Subjects.Remove(subject);

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        public bool Disenroll(string studentId, string subjectId)
        {
            var student = Students.Where(s => s.Id == studentId).First();
            var subject = Subjects.Where(s => s.Id == subjectId).First();

            try
            {
                student.SubjectsEnrolledIn.Remove(subjectId);
                subject.StudentsInSubject.Remove(studentId);
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }

        public Student EditStudent(string id, string name)
        {
            var student = Students.Where(s => s.Id == id).FirstOrDefault();

            if (student == null) return null;

            student.Name = name;

            return student;
        }

        public Subject EditSubject(string id, string name, int classNumber)
        {
            var subject = Subjects.Where(s => s.Id == id).FirstOrDefault();

            if (subject == null) return null;

            subject.Name = name;
            subject.ClassNumber = classNumber;

            return subject;
        }

        public bool Enroll(string studentId, string subjectId)
        {
            var student = Students.Where(s => s.Id == studentId).First();
            var subject = Subjects.Where(s => s.Id == subjectId).First();

            try
            {
                student.SubjectsEnrolledIn.Add(subjectId);
                subject.StudentsInSubject.Add(studentId);
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }

        public Student GetStudent(string id)
        {
            return Students.Where(s => s.Id == id).FirstOrDefault();
        }

        public Subject GetSubject(string id)
        {
            return Subjects.Where(s => s.Id == id).FirstOrDefault();
        }

        public IEnumerable<IGrouping<string, Tuple<string, int, string>>> GetSubjectAllStudents(string id)
        {
            var tupleList = new List<Tuple<string, int, string>>();

            var subjectName = Subjects.Where(s => s.Id == id).FirstOrDefault()?.Name;
            var subjectList = Subjects.Where(s => s.Name == subjectName).ToList();

            if (subjectName == null) return null;

            foreach (Subject subject in subjectList)
            {
                foreach (Student student in Students)
                {
                    if (subject.StudentsInSubject.Contains(student.Id))
                    {
                        tupleList.Add(new Tuple<string, int, string>(student.Name, subject.ClassNumber, "yes"));
                    }
                    else
                    {
                        tupleList.Add(new Tuple<string, int, string>(student.Name, subject.ClassNumber, "no"));
                    }
                }
            }

            var sortedTupleList = tupleList.GroupBy(x => x.Item1);

            return sortedTupleList;
        }

        public List<Subject> GetSubjectAlternatives(string id)
        {
            var subjectName = Subjects.Where(s => s.Id == id).FirstOrDefault()?.Name;

            if (subjectName == null) return null;

            return Subjects.Where(s => s.Name == subjectName).ToList();
        }

        public List<Student> ListStudents()
        {
            return Students;
        }

        public List<Subject> ListSubjects()
        {
            return Subjects;
        }
    }
}

Program.cs
using System;
using System.Collections.Generic;

namespace stackoverflow61918396
{
    class Program
    {
        static bool Again { get; set; }
        static Manager Manager { get; set; }

        static void Main()
        {
            Again = true;
            Manager = new Manager();

            do
            {
                Console.WriteLine("Enter a command (type 'help' for options):");
                var selection = Console.ReadLine();
                Console.WriteLine("\n");

                CommandHandler(selection);
            } while (Again);
        }

        static void CommandHandler(string command)
        {
            switch (command)
            {
                case var s when s.Trim().ToLower() == "help":
                    Console.WriteLine("Commands:");
                    Console.WriteLine("'quit' - exits the program");
                    Console.WriteLine("'students' - lists all students");
                    Console.WriteLine("'subjects' - lists all subjects");
                    Console.WriteLine("'student [id]' - shows this student's record");
                    Console.WriteLine("'subject [id]' - shows this subject's record");
                    Console.WriteLine("'all students by subject [id]' - lists all students in this subject or not");
                    Console.WriteLine("'alternatives for subject [id]' - lists all class numbers of a subject");
                    Console.WriteLine("'new student [name]' - adds a new student");
                    Console.WriteLine("'new subject [name] [class number]' - adds a new subject");
                    Console.WriteLine("'edit student [id] [name]' - edits an existing student");
                    Console.WriteLine("'edit subject [id] [name] [class number]' - edits an existing subject");
                    Console.WriteLine("'delete student [id]' - deletes an existing student");
                    Console.WriteLine("'delete subject [id]' - deletes an existing subject");
                    Console.WriteLine("'enroll [student id] [subject id]' - enrolls a student into a subject");
                    Console.WriteLine("'disenroll [student id] [subject id]' - disenrolls a student from a subject");
                    Console.WriteLine("\n");
                    break;
                case var s when s.Trim().ToLower() == "quit":
                    Again = false;
                    break;
                case var s when s.Trim().ToLower() == "students":
                    try
                    {
                        List<Student> studentList = Manager.ListStudents();

                        if (studentList == null) throw new Exception();

                        Console.WriteLine("Students:");
                        foreach (Student student in studentList)
                        {
                            Console.WriteLine("Id: " + student.Id + ", Name: " + student.Name);
                        }
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower() == "subjects":
                    try
                    {
                        List<Subject> subjectList = Manager.ListSubjects();

                        if (subjectList == null) throw new Exception();

                        Console.WriteLine("Subjects:");
                        foreach (Subject subject in subjectList)
                        {
                            Console.WriteLine(
                                "Id: " + subject.Id +
                                ", Class Number: " + subject.ClassNumber +
                                ", Name: " + subject.Name
                            );
                        }
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("student"):
                    try
                    {
                        var studentId = s.Split(' ')[1];
                        var student = Manager.GetStudent(studentId);

                        if (student == null) throw new Exception();

                        Console.WriteLine("Id: " + student.Id + ", Name: " + student.Name);

                        Console.WriteLine("Subjects Enrolled In:");
                        foreach (string subjectId in student.SubjectsEnrolledIn)
                        {
                            var subject = Manager.GetSubject(subjectId);
                            Console.WriteLine(
                                "Id: " + subject.Id +
                                ", Class Number: " + subject.ClassNumber +
                                ", Name: " + subject.Name
                            );
                        }
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("subject"):
                    try
                    {
                        var subjectId = s.Split(' ')[1];
                        var subject = Manager.GetSubject(subjectId);

                        if (subject == null) throw new Exception();

                        Console.WriteLine("Id: " + subject.Id + ", Name: " + subject.Name);

                        Console.WriteLine("Students In Subject:");
                        foreach (string studentId in subject.StudentsInSubject)
                        {
                            var student = Manager.GetStudent(studentId);
                            Console.WriteLine(
                                "Id: " + student.Id +
                                ", Name: " + student.Name
                            );
                        }
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("all"):
                    try
                    {
                        var subjectId = s.Split(' ')[4];
                        var subjectName = Manager.GetSubject(subjectId)?.Name;
                        var subjectWithAll = Manager.GetSubjectAllStudents(subjectId);

                        if (subjectWithAll == null) throw new Exception();

                        Console.WriteLine("All students with respect to " + (subjectName ?? subjectId) + ":");
                        foreach (var group in subjectWithAll)
                        {
                            foreach (var item in group)
                            {
                                Console.WriteLine(
                                    "\tName: " + item.Item1 +
                                    ", \t\tClass Number: " + item.Item2 +
                                    ", \t\tEnrolled: " + item.Item3
                                );
                            }
                        }
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("alternatives"):
                    try
                    {
                        var subjectId = s.Split(' ')[3];
                        List<Subject> subjectAlternatives = Manager.GetSubjectAlternatives(subjectId);

                        if (subjectAlternatives == null) throw new Exception();

                        Console.WriteLine("Alternatives for " + subjectAlternatives[0].Name + ":");
                        foreach (Subject subject in subjectAlternatives)
                        {
                            Console.WriteLine("Id: " + subject.Id + ", Class Number: " + subject.ClassNumber);
                        }
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("new student"):
                    try
                    {
                        var name = s.Split(' ')[2];
                        var student = Manager.AddStudent(name);

                        if (student == null) throw new Exception();

                        Console.WriteLine("Student " + student.Id + " created");
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("new subject"):
                    try
                    {
                        var name = s.Split(' ')[2];
                        var classNumber = s.Split(' ')[3];
                        var subject = Manager.AddSubject(name, int.Parse(classNumber));

                        if (subject == null) throw new Exception();

                        Console.WriteLine("Subject " + subject.Id + " created");
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("edit student"):
                    try
                    {
                        var studentId = s.Split(' ')[2];
                        var studentName = s.Split(' ')[3];
                        var student = Manager.EditStudent(studentId, studentName);

                        if (student == null) throw new Exception();

                        Console.WriteLine("Student " + student.Id + " was edited");
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("edit subject"):
                    try
                    {
                        var subjectId = s.Split(' ')[2];
                        var subjectName = s.Split(' ')[3];
                        var subjectClassNumber = s.Split(' ')[4];
                        var subject = Manager.EditSubject(subjectId, subjectName, int.Parse(subjectClassNumber));

                        if (subject == null) throw new Exception();

                        Console.WriteLine("Subect " + subject.Id + " was edited");
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("delete student"):
                    try
                    {
                        var studentId = s.Split(' ')[2];
                        var deleted = Manager.DeleteStudent(studentId);

                        Console.WriteLine("Student was " + (deleted ? "" : "not") + " deleted");
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("delete subject"):
                    try
                    {
                        var subjectId = s.Split(' ')[2];
                        var deleted = Manager.DeleteSubject(subjectId);

                        Console.WriteLine("Subject was " + (deleted ? "" : "not") + " deleted");
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("enroll"):
                    try
                    {
                        var studentId = s.Split(' ')[1];
                        var subjectId = s.Split(' ')[2];
                        var enrolled = Manager.Enroll(studentId, subjectId);

                        Console.WriteLine("Student was " + (enrolled ? "" : "not") + " enrolled");
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                case var s when s.Trim().ToLower().StartsWith("disenroll"):
                    try
                    {
                        var studentId = s.Split(' ')[1];
                        var subjectId = s.Split(' ')[2];
                        var disenrolled = Manager.Disenroll(studentId, subjectId);

                        Console.WriteLine("Student was " + (disenrolled ? "" : "not") + " disenrolled");
                        Console.WriteLine("\n");
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Unrecognized command. Please try again.");
                        Console.WriteLine("\n");
                    }
                    break;
                default:
                    Console.WriteLine("Unrecognized command. Please try again.");
                    Console.WriteLine("\n");
                    break;
            }
        }
    }
}


text:
Q: Unmarshal XML via JAXB I have a xml as follows:
<VisitorDataList>
  <VisitorData>
   <Attribute1List>
            <Attribute1>
                <Attribute1Name>name1</Attribute1Name>
                <Attribute1Id>2</Attribute1Id>
            </Attribute1>
            <Attribute1>
                <Attribute1Name>name1</Attribute1Name>
                <Attribute1Id>3</Attribute1Id>
            </Attribute1>
            <Attribute1>
                <Attribute1Name>name1</Attribute1Name>
                <Attribute1Id>1</Attribute1Id>
            </Attribute1>
        </Attribute1List>
     <Attribute2List>
            <Attribute2>
                <Attribute2Name>name2</Attribute2Name>
                <Attribute2Id>113</Attribute2Id>
            </Attribute2>
            <Attribute2>
                <Attribute2Name>name2</Attribute2Name>
                <Attribute2Id>115</Attribute2Id>
            </Attribute2>
            <Attribute2>
                <Attribute2Name>name2</Attribute2Name>
                <Attribute2Id>114</Attribute2Id>
            </Attribute2>
        </Attribute2List>
  </VisitorData>
 </VisitorDataList>

The Attribute1List and Attribute2List is dynamic for both name and value, so they can be Attribute3List or Attribute4List and so on. Now i want to parse this xml via jAXB, the java bean is like:
@XmlRootElement(name = "VisitorDataList")
public class VisitorDataList {

    @XmlElement(name = "VisitorData")
    public List<Visitor> getVisitors() {
        return visitors;
    }

    public void setVisitors(List<Visitor> visitors) {
        this.visitors = visitors;
    }

}

public class Visitor {

    private List<String> attributes= new ArrayList<String>();

        public List<String> getAttributes() {
        return attributes;
    }

    public void setAttributes(List<String> attributes) {
        this.attributes= attributes;
    }
}

My question is how to map all the attribute names into one list? Thanks in advance.

A: You could use JAXB to unmarshal from StAX with a StreamReaderDelegate to strip off the number from the element names.  Your JAXB mappings will then be made to elements
Below is a link to an article I wrote where I use this approach to do case insensitive unmarshalling:

*

*http://blog.bdoughan.com/2010/12/case-insensitive-unmarshalling.html

Java Model
VistorDataList
import java.util.List;

import javax.xml.bind.annotation.*;

@XmlRootElement(name = "VisitorDataList")
public class VisitorDataList {

    private List<Visitor> visitors;

    @XmlElementWrapper(name="VisitorData")
    @XmlElement(name = "AttributeList")
    public List<Visitor> getVisitors() {
        return visitors;
    }

    public void setVisitors(List<Visitor> visitors) {
        this.visitors = visitors;
    }

}

Visitor
import java.util.*;
import javax.xml.bind.annotation.XmlElement;

public class Visitor {

    private List<String> attributes = new ArrayList<String>();

    @XmlElement(name="AttributeName")
    public List<String> getAttributes() {
        return attributes;
    }

    public void setAttributes(List<String> attributes) {
        this.attributes = attributes;
    }

}

Demo Code
Demo
import javax.xml.bind.*;
import javax.xml.stream.*;
import javax.xml.stream.util.StreamReaderDelegate;
import javax.xml.transform.stream.StreamSource;

public class Demo {

    public static void main(String[] args) throws Exception {
        XMLInputFactory xif = XMLInputFactory.newFactory();
        StreamSource xml = new StreamSource("src/forum18071557/input.xml");
        XMLStreamReader xsr = xif.createXMLStreamReader(xml);

        xsr = new StreamReaderDelegate(xsr) {

            @Override
            public String getLocalName() {
                String localName = super.getLocalName();
                if(localName.startsWith("Attribute") && localName.endsWith("List")) {
                    return "AttributeList";
                } else if(localName.startsWith("Attribute") && localName.endsWith("Name")) {
                    return "AttributeName";
                } else if(localName.startsWith("Attribute")) {
                    return "ignore";
                } else {
                    return localName;
                }
            }

        };

        xsr = xif.createFilteredReader(xsr, new StreamFilter() {
            @Override
            public boolean accept(XMLStreamReader reader) {
                if(reader.isStartElement() || reader.isEndElement()) {
                    return !reader.getLocalName().equals("ignore");
                } else {
                    return true;
                }
            }

        });

        JAXBContext jc = JAXBContext.newInstance(VisitorDataList.class);

        Unmarshaller unmarshaller = jc.createUnmarshaller();
        VisitorDataList vdl = (VisitorDataList) unmarshaller.unmarshal(xsr);

        Marshaller marshaller = jc.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        marshaller.marshal(vdl, System.out);
    }

}

Output
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<VisitorDataList>
    <VisitorData>
        <AttributeList>
            <AttributeName>name1</AttributeName>
            <AttributeName>name1</AttributeName>
            <AttributeName>name1</AttributeName>
        </AttributeList>
        <AttributeList>
            <AttributeName>name2</AttributeName>
            <AttributeName>name2</AttributeName>
            <AttributeName>name2</AttributeName>
        </AttributeList>
    </VisitorData>
</VisitorDataList>

A: I tried your XML file to unmarshal using JAXB but I was only able to parse it statically.You can try it once.
visitor.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<VisitorDataList>
  <VisitorData>
   <AttributeList>
            <Attribute>
                <AttributeName>name1</AttributeName>
                <AttributeId>2</AttributeId>
            </Attribute>
            <Attribute>
                <AttributeName>name1</AttributeName>
                <AttributeId>3</AttributeId>
            </Attribute>
            <Attribute>
                <AttributeName>name1</AttributeName>
                <AttributeId>1</AttributeId>
            </Attribute>
        </AttributeList>
     <AttributeList>
            <Attribute>
                <AttributeName>name2</AttributeName>
                <AttributeId>113</AttributeId>
            </Attribute>
            <Attribute>
                <AttributeName>name2</AttributeName>
                <AttributeId>115</AttributeId>
            </Attribute>
                <Attribute>
                <AttributeName>name2</AttributeName>
                <AttributeId>114</AttributeId>
            </Attribute>
        </AttributeList>
  </VisitorData>

visitordatalist.java
package foo.bar.me.too;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="VisitorDataList")
public class visitordatalist {

    List<visitordata> vstd;

    @XmlElement(name="VisitorData")
    public List<visitordata> getVstd() {
        return vstd;
    }

    public void setVstd(List<visitordata> vstd) {
        this.vstd = vstd;
    }

}

visitordata.java
package foo.bar.me.too;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;

public class visitordata {

    List<attributelist> atrl;

    public String toString() {
        return atrl.toString();
    }

    @XmlElement(name="AttributeList")
     public List<attributelist> getAtrl() {
        return atrl;
    }
    public void setAtrl(List<attributelist> atrl) {
        this.atrl = atrl;
    }

}

attributelist.java
package foo.bar.me.too;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;

public class attributelist {

    List<attribute> atr;
     public String toString() {
            return atr.toString();
        }

     @XmlElement(name="Attribute")
    public List<attribute> getAtr() {
        return atr;
    }

    public void setAtr(List<attribute> atr) {
        this.atr = atr;
    }

    }

attribute.java
package foo.bar.me.too;

import javax.xml.bind.annotation.XmlElement;

public class attribute {

    String atrName;
    String atrId;

     public String toString() {
            return atrName+"   "+atrId;

        }

    @XmlElement(name="AttributeName")
    public String getAtrName() {
        return atrName;
    }
    public void setAtrName(String atrName) {
        this.atrName = atrName;
    }

    @XmlElement(name="AttributeId")
    public String getAtrId() {
        return atrId;
    }
    public void setAtrId(String atrId) {
        this.atrId = atrId;
    }

 }

JAXBExample.java
package foo.bar.me.too;

import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

public class JAXBExample {
    public static void main(String[] args) {

     try {

        File file = new File("visitor.xml");
        JAXBContext jaxbContext = JAXBContext.newInstance(visitordatalist.class);

        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        visitordatalist  vstdl = (visitordatalist) jaxbUnmarshaller.unmarshal(file);

        System.out.println(vstdl.getVstd());

      } catch (JAXBException e) {
        e.printStackTrace();
      }

    }

}

A: There is a special arcane knowledge for some special JAXB implementations. For example, for FasterXML (used in WildFly) you should change one property to make it work (just override an additional method in Delegator):
@Override
public Object getProperty(String name) {
    Object property = super.getProperty(name);
    if("org.codehaus.stax2.internNames".equals(name)) {
        return Boolean.FALSE;
    }
    return property;
}


text:
Q: redisgraph.js - Parsing results of MERGE command The documentation has the following example to merge relationships if all the end-points exist. If the MERGE were to be run in the Javascript client, then how can I find out, if the MERGE created the nodes and relationships or not? In other words, how can I deduce if the nodes were present beforehand or not?
At the moment, it seems, some methods of ResultSet for statistics might have to be used. Any thoughts?
GRAPH.QUERY DEMO_GRAPH
"MERGE (charlie { name: 'Charlie Sheen' })
 MERGE (wallStreet:Movie { name: 'Wall Street' })
 MERGE (charlie)-[r:ACTED_IN]->(wallStreet)"

A: the result-set statistics will let you know how many nodes/edges were created, if none that means the pattern existed, otherwise merge created the pattern.


text:
Q: SPOTFIRE how do I shape by column in the map chart with a custom expression I have a spotfire question. I am attempting to create Shapes by Column Values in a Map Chart.
I would like to create these Shapes by a Custom Expression. The custom expression is below, I have simplified it so it is easier to read.
All I am saying is:
if((Current months oil rate - 12MonthAgo Oilrate)/12MonthAgo Oilrate)>0,"UP","Down")
When I run this calculation though it only gives me one value, (there are both positives and negatives so it should give two).
I am not sure what I have done wrong? Any help is appreciated.
 <If(((((Sum(If(CurrentMonth),[OILRATECD],null))
    -
Sum(If(12MonthsAgo),[OILRATECD],null)))))
    /
Sum(If(12MonthsAgo),[OILRATECD],null)))>0,"UP","DOWN")>

ORIGINAL EQUATION:
 <If(((((Sum(If((Month([DATE])=Month(DateAdd("mm",-2,DateTimeNow()))) and (Year([DATE])=Year(DateAdd("mm",-2,DateTimeNow()))),[OILRATECD],null))
    -
Sum(If((Month([DATE])=Month(DateAdd("mm",-${MonthInterval}-2,DateTimeNow()))) and (Year([DATE])=Year(DateAdd("mm",-${MonthInterval}-2,DateTimeNow()))),[OILRATECD],null)))))
    /
Sum(If((Month([DATE])=Month(DateAdd("mm",-${MonthInterval}-2,DateTimeNow()))) and (Year([DATE])=Year(DateAdd("mm",-${MonthInterval}-2,DateTimeNow()))),[OILRATECD],null)))>0,"UP","DOWN")>

A: First, you have a lot of unnecessary parentheses but that shouldn't hurt anything.
If(
    (
        ( --this open parentheses is unneeded
            ( --this open parentheses is unneeded
                (
                    Sum(If((Month([DATE])=Month(DateAdd("mm",-2,DateTimeNow()))) and (Year([DATE])=Year(DateAdd("mm",-2,DateTimeNow()))),[OILRATECD],null))
                    -
                    Sum(If((Month([DATE])=Month(DateAdd("mm",-${MonthInterval}-2,DateTimeNow()))) and (Year([DATE])=Year(DateAdd("mm",-${MonthInterval}-2,DateTimeNow()))),[OILRATECD],null))
                )
            ) --this closed parentheses is unneeded
        ) --this closed parentheses is unneeded
        /
        Sum(If((Month([DATE])=Month(DateAdd("mm",-${MonthInterval}-2,DateTimeNow()))) and (Year([DATE])=Year(DateAdd("mm",-${MonthInterval}-2,DateTimeNow()))),[OILRATECD],null))
    )
    >0,"UP","DOWN")

The reason you are not getting UP and DOWN returned is because the condition isn't met. We need a sample data set with expected output to verify this.
However, here's a reason why you could be getting unexpected results, regarding NULL in your SUM(IF(...,[OILRATECD],NULL)) expression.
TL;DR

If your condtion in your IF() statement isn't ever evaluated to true
  then NULL is returned to SUM(), and SUM(NULL,NULL,NULL) = NULL
  and NULL is not > nor is it < 0, thus your outer IF()
  statement would return NULL instead of "UP" or "DOWN"

LONG VERSION

*

*Spotfire ignored NULL when evaluating SUM() which is what you want. For example, Sum(4,3,NULL) = 7 and this is the behavior we want. However...

*Spotfire doesn't ignore NULL for addition, subtraction, division, and other comparison operators like >. So, 4 - NULL = NULL and NULL / 18 = NULL and so on. This means if either of your two SUM() methods return NULL then your entire expression will be NULL because...

*NULL isn't > nor is it < and certainly not = 0. NULL is the absence of a value, and thus can't be compared or equated to anything. For example, If(NULL > 1,"YES","NO") doesn't return YES or NO... it returns NULL, the lack of a value. Also, If(NULL=NULL,"YES","NO") will also return NULL
HOW TO GET AROUND THIS
Use IS NULL and IS NOT NULL in a IF() statement to set it to a default value, or use 0 in place of NULL in your current expression.
Sum(If((Month([DATE])=Month(DateAdd("mm",-2,DateTimeNow()))) and (Year([DATE])=Year(DateAdd("mm",-2,DateTimeNow()))),[OILRATECD],0))
BIG SIDE NOTE
You said your equation's pseudo code is:
If((Current months oil rate - 12MonthAgo Oilrate)/12MonthAgo Oilrate)>0,"UP","Down")

This doesn't seem to be what you are evaluating. Instead, I read:
x = (-var) + (-2) thus var < -2 (i.e. -3....-6...-55)
if((sum([2 months ago oil rate]) - sum([x months ago oil rate])) > 0, "UP","DOWN")

So you aren't ever looking at the current month's oil rate, but instead are looking at current - 2. Also, you are looking at the SUM() over that entire month... this may be what you want by you may be actually looking for Max() or Min()
OVER FUNCTION
You can handle this a lot easier most likely with a few calculated columns to keep your data / expressions clean and legible

*

*DatePart("yy",[Date]) as [Year]

*DatePart("mm",[Date]) as [Month]

*Max([OILRATECD]) OVER (Intersect([Year],[Month])) as [YearMonthRate] or use SUM() if that's what you really want.

*Check to see the difference with Rank()


text:
Q: hiddenFille data can Not getting In Android Api 30 here my code i try with my latest android 11 os device and i search in internet but i not find any solution also it working in android 10 device perfectly but not working in latest os device thanks
    WhatsappStatusModel whatsappStatusModel;
    String targetPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/WhatsApp/Media/.Statuses";
    File targetDirector = new File(targetPath);
    allfiles = targetDirector.listFiles();


text:
Q: asp.net mvc file upload client side validator I'm looking for a client side validator for input type="file" to validate file names/extensions.
I know this is possible with jQuery validation, but would be nice to have this working as a validation attribute.

A: There is now such an attribute available in the DataAnnotationsExtensions project.

A: You are asking for a client side validation but you are referreing to a validation attribute which is a server side validation.
You should be validating submit on a client with jQuery and then on a server. Also do you really need an attribute for validating a file upload? How many action methods do you have that will be used for a file upload?


text:
Q: ViewPager scrolling on Google Glass How to do smooth scrolling with viewpager on Google Glass?  (in particular viewpagerindicator lib).   I have implemented viewpagers and they work, however swiping on the touchpad quickly scrolls through the views.  I would like to have smooth scrolling similar to the mirror api menus.  Anyone have ideas?  I have attempted to intercept touchevents using the code below, but the overriden methods are not called.  Seems Glass takes the touch events and turns them into d-pad events.  OnPageScrolled(which is useless for what I'm doing) is called, but the other methods are not.
class MyViewPager extends ViewPager{
    public MyViewPager(){
    }

@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
    // TODO Auto-generated method stub
    super.onPageScrolled(arg0, arg1, arg2);
}

@Override
public boolean onInterceptTouchEvent(MotionEvent arg0) {
    // TODO Auto-generated method stub
    return super.onInterceptTouchEvent(arg0);
}

@Override
public boolean onTouchEvent(MotionEvent arg0) {
    // TODO Auto-generated method stub
    return super.onTouchEvent(arg0);
}

}

A: You can now use the GDK's CardScrollView (javadoc link) instead of ViewPager — it should have all of the functionality that you need.

A: I added a GestureDetector to my FragmentActivity, and instead of using the onScroll() event, I used the onFling() event to trigger a page change.
This is the basis for the GestureDetector: http://b2cloud.com.au/how-to-guides/capture-glass-d-pad-events-for-android
And then when a fling was detected, I just updated the page like this:
protected void slideForward() {
    viewPager.setCurrentItem(mPager.getCurrentItem() + 1);
}

protected void slideBackward() {
    viewPager.setCurrentItem(mPager.getCurrentItem() - 1);
}


text:
Q: Problem with aurigma image uploader in asp.net I am using Aurigma image uploader for uploading multiple images in asp.net
i am facing a problem in aurigma image uploader when i upload images it will show error
"Thumbnails of size more than 3 MPixels are not supported in standard version of image uploader."
But this is working fine in Mozilla or other browsers. this problem is occured only with (IE6/7/8).
Thanks in advance

A: Perhaps you are using professional license key for java uploader (i.e. for Mozilla and others) and standard for ActiveX (IE 6/7/8).
Anyway, you should contact Aurigma support for details.


text:
Q: What is the variable(s) or such written before the integration symbol? From 'Distance measures (cosmology)' on Wikipedia:

Cosmologists commonly use the following measures for distances from the observer to an object at redshift $z$ along the line of sight:

*

*Comoving distance:
$$d_C(z)=d_H\int_0^z\frac{dz'}{E(z')}.$$

*Transverse comoving distance:
$$d_M(z)=\left\{\begin{array}{ll}
\frac{d_H}{\sqrt{\Omega_k}}\sinh\left(\frac{\sqrt{\Omega_k}d_C(z)}{d_H}\right) & \Omega_k>0,\\
d_C(z) & \Omega_k=0,\\
\frac{d_H}{\sqrt{|\Omega_k|}}\sin\left(\frac{\sqrt{|\Omega_k|}d_C(z)}{d_H}\right) & \Omega_k<0.
\end{array}\right.$$

*Angular diameter distance:
$$d_A(z)=\frac{d_M(z)}{1+z}.$$

*Luminosity distance:
$$d_L(z)=(1+z)d_M(z).$$

*Light-travel distance:
$$d_T(z)=d_H\int_0^z\frac{dz'}{(1+z')E(z')}.$$
Note that the comoving distance is recovered from the transverse comoving distance by taking the limit $\Omega\to0$, such that the two distance measures are equivalent in a flat universe.

What do you do with the dH that comes up before the integration symbol under 'comoving distance' and 'light-travel distance'?
Not just here, but in general...
Also, the z is a constant in astronomy, so how do you take the derivatives of z in those same two equations?  If the derivative of a constant is always 0?  It doesn't make sense to me....
P.S.  I posted something similar in Astronomy S.E., I hope that is okay... Here, I wanted to understand the general math aspect...

A: We can rewrite the equations with every "calculus $\mathrm d$" deitalicised, so$$d_C(z)=d_H\int_0^z\tfrac{\mathrm dz^\prime}{E(z^\prime)},\,d_T(z)=d_H\int_0^z\tfrac{\mathrm dz^\prime}{(1+z^\prime)E(z^\prime)}.$$The other equations don't contain any such $\mathrm d$, so I won't reproduce those. For all the difference it makes, $d_A,\,d_C,\,d_H,\,d_L,\,d_M,\,d_T$ might as well have been called $r_A,\,r_C,\,r_H,\,r_L,\,r_M,\,r_T$.
It helps to understand why these definite integrals start at $0$. The value of $a:=1+z$ is proportional to the width of the universe, so is a function of time. The usual convention is to take $a=1$, or equivalently $z=0$, in the present day. Then $d_C,\,d_T$ are distances from our present-day location to something observed by dint of light it emitted in the past: in particular, these distances are $0$ if $z=0$.
Of course, $z=0\implies d_C=d_T=0\implies d_A=d_L=d_M=0$. But $d_H$ is approximately proportional to $a$.


text:
Q: How to configure Istio Virtual Service destination protocol How can I configure Istio VirtualService to route traffic to a destination backend that listens on HTTPS?
configuring protocol: HTTPS or scheme: HTTPS didn't work.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: api-rpi-access
spec:
  hosts:
  - "test.example.com"
  gateways:
  - api-gateway
  http:
  - match:
    - uri:
        port: https
        prefix: /
    route:
    - destination:
        host: some-https-service
        port:
          number: 8443
          protocol: HTTPS
        # scheme: HTTPS

Here is my gateway:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: api-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
      privateKey: /etc/istio/ingressgateway-certs/tls.key
    hosts:
    - "test.example.com"

A: In order to perform the TLS termination on istio-ingressgateway and send https traffic to the backend, I had to add the following DestinationRule
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: some-https-service
spec:
  host: diary
  trafficPolicy:
    tls:
      mode: SIMPLE

here are the yamls for Gateway and VirtualService:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: api-gateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: SIMPLE
      serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
      privateKey: /etc/istio/ingressgateway-certs/tls.key
    hosts:
    - "test.example.com"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ext-access
spec:
  hosts:
  - "test.example.com"
  gateways:
  - api-gateway
  http:
  - match:
    - uri:
        port: https
        prefix: /
    route:
    - destination:
        host: some-https-service
        port:
          number: 8443

A: Have you got a destination rule setup also, as an example:
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: dr-test.example.com
spec:
  host: test.example.com
  trafficPolicy: # Apply to all ports
    portLevelSettings:
    - port:
        number: 443
      loadBalancer:
        simple: LEAST_CONN

some good information on istio routing

A: Currently Your gateway is configured to Terminate TLS on gateway. Your VirtualService also needs little modifications.
You need to change Your TLS mode of Your gateway to Passthrough.
    tls:
      mode: PASSTHROUGH

According to istio documentation:

*

*Define a Gateway with a server section for port 443. Note the PASSTHROUGH TLS mode which instructs the gateway to pass the ingress traffic AS IS, without terminating TLS.

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: mygateway
spec:
  selector:
    istio: ingressgateway # use istio default ingress gateway
  servers:
  - port:
      number: 443
      name: https
      protocol: HTTPS
    tls:
      mode: PASSTHROUGH
    hosts:
    - nginx.example.com

*Configure routes for traffic entering via the Gateway:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: nginx
spec:
  hosts:
  - nginx.example.com
  gateways:
  - mygateway
  tls:
  - match:
    - port: 443
      sniHosts:
      - nginx.example.com
    route:
    - destination:
        host: my-nginx
        port:
          number: 443

Hope it helps.


text:
Q: Google api OVER_QUERY_LIMIT - how long I invoked google web service for distance too many times and now I can't call it because I receive error:
OVER_QUERY_LIMIT

Next time I will set pause on 10 call for 5 seconds. But how long I will be locked this way?

A: 2,500 geolocation requests per day => 1,250 seconds or 20 min 50 sec (about limit see here)

A: I used to sleep 0,250 seconds between each request, this works well.
I tried 0,100 seconds but I got OVER_QUERY_LIMIT from time to time


text:
Q: How can i get my "Enemy" to chase the "goal" - Java I have been trying to code a half built simple java game i was given to by a friend (I wanted to try learning coding so he gave me this old assignment from his 1st year of programming class).
He told me to try and build a game using the 2 classes he gave me, a main class and a sub class.
So far I have got everything to work as intended except for finding a way to get my enemy class to move towards the goal regardless of its position. I can get it to always move in a fixed direction towards the goal if I set it up perfectly but I want to be able to find the position of the goal regardless and make its way towards it.
The code need to be written in the peformAction method under Enemy.
If anyone would be kind enough to explain how I can go about this, it would be much appropriated, or even if you can just link me to another post that explains how to do what I'm trying to do.
Thank you in advance.
GameManager (main) Class:
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.util.Random;
import javax.swing.JFrame;

public class GameManager extends JFrame implements KeyListener {
    private int canvasWidth;
    private int canvasHeight;
    private int borderLeft;
    private int borderTop;
    private BufferedImage canvas;
    private Stage stage;
    private Enemy[] enemies;
    private Player player;
    private Goal goal;
    private Graphics gameGraphics;
    private Graphics canvasGraphics;
    private int numEnemies;
    private boolean continueGame;

    public static void main(String[] args) {
        // During development, you can adjust the values provided in the brackets below
        // as needed. However, your code must work with different/valid combinations
        // of values.
        GameManager managerObj = new GameManager(1920, 1280, 30);
    }

    public GameManager(int preferredWidth, int preferredHeight, int maxEnemies) {
        this.borderLeft = getInsets().left;
        this.borderTop = getInsets().top;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        if (screenSize.width < preferredWidth)
            this.canvasWidth = screenSize.width - getInsets().left - getInsets().right;
        else
            this.canvasWidth = preferredWidth - getInsets().left - getInsets().right;
        if (screenSize.height < preferredHeight)
            this.canvasHeight = screenSize.height - getInsets().top - getInsets().bottom;
        else
            this.canvasHeight = preferredHeight - getInsets().top - getInsets().bottom;
        setSize(this.canvasWidth, this.canvasHeight);
        setResizable(false);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
        addKeyListener(this);
        Random rng = new Random(2);
        this.canvas = new BufferedImage(this.canvasWidth, this.canvasHeight, BufferedImage.TYPE_INT_RGB);
        // Create a Stage object to hold the background images
        this.stage = new Stage();
        // Create a Goal object with its initial x and y coordinates
        this.goal = new Goal(this.canvasWidth / 2, Math.abs(rng.nextInt()) % this.canvasHeight);
        // Create a Player object with its initial x and y coordinates
        this.player = new Player(this.canvasWidth - (Math.abs(rng.nextInt()) %  (this.canvasWidth / 2)),
            (Math.abs(rng.nextInt()) % this.canvasHeight));
        // Create the Enemy objects, each with a reference to this (GameManager) object
        // and their initial x and y coordinates.
        this.numEnemies = maxEnemies;
        this.enemies = new Enemy[this.numEnemies];
        for (int i = 0; i < this.numEnemies; i++) {
            this.enemies[i] = new Enemy(this, Math.abs(rng.nextInt()) % (this.canvasWidth / 4),
            Math.abs(rng.nextInt()) % this.canvasHeight);
        }
        this.gameGraphics = getGraphics();
        this.canvasGraphics = this.canvas.getGraphics();
        this.continueGame = true;
        while (this.continueGame) {
            updateCanvas();
        }
        this.stage.setGameOverBackground();
        updateCanvas();
    }

    public void updateCanvas() {
        long start = System.nanoTime();
        // If the player is alive, this should move the player in the direction of the
        // key that has been pressed
        // Note: See keyPressed and keyReleased methods in the GameManager class.
        this.player.performAction();
        // If the enemy is alive, the enemy must move towards the goal. The goal object
        // is obtained
        // via the GameManager object that is given at the time of creating an Enemy
        // object.
        // Note: The amount that the enemy moves by must be much smaller than that of
        // the player above
        // or else the game becomes too hard to play.
        for (int i = 0; i < this.numEnemies; i++) {
            this.enemies[i].performAction();
        }
        if ((Math.abs(this.goal.getX() - this.player.getX()) < (this.goal.getCurrentImage().getWidth() / 2))
            && (Math.abs(this.goal.getY() - this.player.getY()) < (this.goal.getCurrentImage().getWidth() / 2))) {
            for (int i = 0; i < this.numEnemies; i++) {
                // Sets the image of the enemy to the "dead" image and sets its status to
                // indicate dead
                this.enemies[i].die();
            }
            // Sets the image of the enemy to the "dead" image and sets its status to
            // indicate dead
            this.goal.die();
            // Sets the background of the stage to the finished game background.
            this.stage.setGameOverBackground();
            this.continueGame=false;
        }
        // If an enemy is close to the goal, the player and goal die
        int j=0;
        while(j<this.numEnemies) {
            if ((Math.abs(this.goal.getX() - this.enemies[j].getX()) < (this.goal.getCurrentImage().getWidth() / 2))
                && (Math.abs(this.goal.getY() - this.enemies[j].getY()) < (this.goal.getCurrentImage().getWidth()/ 2))) {
                this.player.die();
                this.goal.die();
                this.stage.setGameOverBackground();
                j=this.numEnemies;
                this.continueGame=false;
            }
            j++;
        }
        try {
            // Draw stage
            this.canvasGraphics.drawImage(stage.getCurrentImage(), 0, 0, null);
            // Draw player
            this.canvasGraphics.drawImage(player.getCurrentImage(),
            this.player.getX() - (this.player.getCurrentImage().getWidth() / 2),
            this.player.getY() - (this.player.getCurrentImage().getHeight() / 2), null);
            // Draw enemies
            for (int i = 0; i < this.numEnemies; i++) {
                this.canvasGraphics.drawImage(this.enemies[i].getCurrentImage(),
                this.enemies[i].getX() - (this.enemies[i].getCurrentImage().getWidth() / 2),
                this.enemies[i].getY() - (this.enemies[i].getCurrentImage().getHeight() / 2), null);
            }
            // Draw goal
            this.canvasGraphics.drawImage(this.goal.getCurrentImage(),
                this.goal.getX() - (this.goal.getCurrentImage().getWidth() / 2),
                this.goal.getY() - (this.goal.getCurrentImage().getHeight() / 2), null);
        } catch (Exception e) {
            System.err.println(e.getMessage());
        }
        // Draw everything.
        this.gameGraphics.drawImage(this.canvas, this.borderLeft, this.borderTop, this);
        long end = System.nanoTime();
        this.gameGraphics.drawString("FPS: " + String.format("%2d", (int) (1000000000.0 / (end - start))),
            this.borderLeft + 50, this.borderTop + 50);
    }

    public Goal getGoal() {
        return this.goal;
    }

    public void keyPressed(KeyEvent ke) {
        // Below, the setKey method is used to tell the Player object which key is
        // currently pressed.
        // The Player object must keep track of the pressed key and use it for
        // determining the direction
        // to move.
        if (ke.getKeyCode() == KeyEvent.VK_LEFT)
            this.player.setKey('L', true);
        if (ke.getKeyCode() == KeyEvent.VK_RIGHT)
            this.player.setKey('R', true);
        if (ke.getKeyCode() == KeyEvent.VK_UP)
            this.player.setKey('U', true);
        if (ke.getKeyCode() == KeyEvent.VK_DOWN)
            this.player.setKey('D', true);
        if (ke.getKeyCode() == KeyEvent.VK_ESCAPE)
            this.continueGame = false;
    }

    @Override
    public void keyReleased(KeyEvent ke) {
        // Below, the setKey method is used to tell the Player object which key is
        // currently released.
        // The Player object must keep track of the pressed key and use it for
        // determining the direction
        // to move.
        if (ke.getKeyCode() == KeyEvent.VK_LEFT)
            this.player.setKey('L', false);
        if (ke.getKeyCode() == KeyEvent.VK_RIGHT)
            this.player.setKey('R', false);
        if (ke.getKeyCode() == KeyEvent.VK_UP)
            this.player.setKey('U', false);
        if (ke.getKeyCode() == KeyEvent.VK_DOWN)
            this.player.setKey('D', false);
    }

    @Override
    public void keyTyped(KeyEvent ke) {
    }
}

My Enemy (sub) Class:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Enemy {
    //variables
    private BufferedImage imageRunning;
    private BufferedImage imageOver;
    private BufferedImage imageCurrent;
    int valX = 200;
    int valY = 200;

    public Enemy (GameManager gameManager, int x, int y) {
        try {
            this.imageRunning = ImageIO.read(new File("C:/Users/HUS/Desktop/Assigment222/images/enemy-alive.png"));
            this.imageOver = ImageIO.read(new File("C:/Users/HUS/Desktop/Assigment222/images/enemy-dead.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        this.imageCurrent = this.imageRunning;
    }

    public BufferedImage getCurrentImage() {
        return this.imageCurrent;
    }

    public void performAction() {
        valX += 1;
        valY += 1;
        return;

    }

    public void die() {
        // TODO Auto-generated method stub
        this.imageCurrent = this.imageOver;
    }

    public int getX() {
        // TODO Auto-generated method stub
        return this.valX;
    }

    public int getY() {
        // TODO Auto-generated method stub
        return this.valY;
}

}

My Goal (sub) class:
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Goal {
    private BufferedImage imageRunning;
    private BufferedImage imageOver;
    private BufferedImage imageCurrent;
    int posX = 500;
    int poxY = 500;

    public Goal(int x, int y) {
        try {
            this.imageRunning = ImageIO.read(new File("C:/Users/HUS/Desktop/Assigment222/images/goal-alive.png"));
            this.imageOver = ImageIO.read(new File("C:/Users/HUS/Desktop/Assigment222/images/goal-dead.png"));
        } catch (IOException e) {
            e.printStackTrace();
        }
        this.imageCurrent = this.imageRunning;
    }

    public BufferedImage getCurrentImage() {
        return this.imageCurrent;
    }

    public int getX() {

        return this.posX;
    }

    public int getY() {

        return this.poxY;
    }

    public void die() {
        this.imageCurrent = this.imageOver;
    }

}

A: It's impossible with the current code if you want to restrict the modifications only to the performAction method.
1) The Enemy has no way of accessing (seeing) the coordinates of the goal. This means the code can't figure out the way to the goal because it doesn't have the X and Y of where the destination is.
2) To fix that you would need Enemy to be able to see the X and Y of the Goal. The quickest way would be to use getters and setters in the GameManager class to return the stored Goal object. Then you can modify your Enemy constructor to store the reference to the GameManager that created it.
GameManager:
public Goal getGoal() {
    return goal;
}

Enemy:
 private GameManager gameManager;

 public Enemy (GameManager gameManager, int x, int y) {
        ...
        this.gameManager = gameManager;
 }

The last step would be getting the Goal object from the stored gameManager, and using its X and Y to do some logic (this would be performed inside the performAction method):
int goalX = gameManager.getGoal().getX();
int goalY = gameManager.getGoal().getY();

...some logic to calculate the direction here...

I'm sure you'll know what to do with the numbers and figure out how to move towards the goal from there.
@Edit
If not - one way would be comparing Xs and Ys of both the Enemy and the Goal and then incrementing/decrementing valX and/or valY accordingly.

A: In your method performAction you are currently changing the x and y position respectively by incrementing them by 1 each time the method gets called.
This will move your enemy exactly 1 unit in direction x and 1 unit in direction y.
You instead want to move your character in the direction of the Goal. That's more of a math problem than a programming issue but let's give it a go:
You have 2 positions:
Your Enemy has a position of form  and the same goes for your goal with position
You now want to move your Enemy in the direction of the goal. So you calculate a vector connecting these two points with
You then change the length of the vector to the speed your enemy can move with (maybe define this with a field?) by normalizing the vector and doing a scalar multiplication with your speed.
So with a given speed S this gives you the full formula:

Now let us transform this into code. In the constructor of your Enemy class save the GameManager as a field so you can call the getGoal method on it.
So we add a field private GameManager gameManager and in the Constructor we do this.gameManager = gameManager to store the reference.
Also we adda field private double speed = 2 for our calculation.
And then we change the performAction method to implement our formula. Something like this:
public void performAction()
{
    // Calculate our P_g - P_e
    double dX = gameManager.getGoal().getX() - valX;
    double dY = gameManager.getGoal().getX() - valX;

    // Calculate its length to normalize it
    double divider = Math.sqrt(dX * dX + dY * dY);

    // Normalize it
    dX /= divider;
    dY /= divider;

    // Do a scalar multiplication with our speed
    dX *= speed;
    dY *= speed;

    valX += dX;
    valY += dY;
}

The only problem we are running into here is that we are adding double values to our integer values valX and valY so probably change those to double values generally or else you might run into problems where your enemy will never move at all.

A: A very simple implementation:
public void performAction()
{
    valX += Math.signum(gameManager.getGoal().getX() - valX);
    valY += Math.signum(gameManager.getGoal().getX() - valX);
}


text:
Q: Why the elements disappear after I use push_back() function of vector I am trying to use std::vector in a class to realize a muti-way tree.
Each time when I want to add a child in on of the member, I use a function addMember. I'm using VS2017 to debug this program. In this function scope the parent's children vector has actually add the elements by push_back(), but after exiting the function, the address of vector will change and the elements I have added will disappear.
Here's my code:
#include <iostream>
#include<string>
#include<vector>

using namespace std;

class member {
public:
    string name;
    member* parent;
    vector<member*> children;
    member(string m_name,member* m_parent):name(m_name),parent(m_parent){}
};

class familyTree {
private:
    member ancestor;
public:
    member* getAncestor() { return &ancestor; }
    familyTree(member& m_ancestor):ancestor(m_ancestor){}
    member* searchMember(string name,member* node,bool& flag);
    void addMember(string name, int children_number,vector<string>& children_name);
};

member* familyTree::searchMember(string name, member* node,bool& flag) {
    member* find = NULL;
    if (node) {
        if (node->name == name)
            find = node;
        else {
            if (!flag) {
                for (auto iter = node->children.begin(); iter != node->children.end(); iter++) {
                    find = searchMember(name, *iter, flag);
                    if (flag)
                        break;
                }
            }
        }
    }
    return find;
}

void familyTree::addMember(string name,int children_number,vector<string>& children_name) {
    bool flag = false;
    member* parent = searchMember(name, getAncestor(), flag);
    for (auto i : children_name) {
        member* child = new member(i,parent);
        parent->children.push_back(child);
    }
}

A: I suspect that there is something wrong with the familyTree::searchMember function. Here was what you posted:
member* familyTree::searchMember(string name, member* node, bool& flag) {
    member* find = NULL;
    if (node) {
        if (node->name == name)
            find = node;
        else {
            if (!flag) {
                for (auto iter = node->children.begin(); iter != node->children.end(); iter++) {
                    find = searchMember(name, *iter, flag);
                    if (flag)
                        break;
                }
            }
        }
    }
    return find;
}

Notice that there was no method to set the flag = true once you have found the correct node.
The 2nd if statement should be:
if (node->name == name) {
    find = node;
    flag = true;
}

Otherwise within your for loop,
for (auto iter = node->children.begin(); iter != node->children.end(); iter++) {
    find = searchMember(name, *iter, flag);
    if (flag)
        break;
}

even if there was a successful search, the for loop does not break and so it continues on, and the next child you search is guaranteed to not be a match.
Note that the way your searchMember function is structured results in NULL being returned if you search through a node that does not have a matching name and does not have any children because the for loop is skipped (no children to iterate through). So you end up with a lot of NULL pointers being assigned to parent in addMember.


text:
Q: Returning an array from c++ function into c# script in unity I have a c++ function defined as
extern "C" Point* myFunc(int size) {
  Point *p = new Point[size];
  return p;
}

where point is just a struct defined as
extern "C" typedef struct _point {
  int x;
  int y;
} Point;

and inside my c# code I have
[DllImport("MyLibrary")]
static extern Point[] myFunc(int size);

and I use it as
Point[] newPoints = myFunc(3);
Debug.Log(newPoints.Length);

But the output is
33

The function is just an example, but the lenght of the array returned shouldn't be known before the function call.
What is the correct way of returning an array to c# in order to use it, know its size and access it without incurring in any IndexOutOfRangeException?

A: It is impossible to determine array length from a pointer. It seems instead of throwing an exception, Unity guesses and guesses wrong. The correct way to return data in an array from C++ is to pass an array of correct size in from C#:
extern "C" void GetPoints(Point* points, int size)
{
    for (int i = 0; i < size; i++)
        points[i].x = points[i].y = i;
}

And then on C# side:
[DllImport("MyLibrary", EntryPoint = "GetPoints")]
static extern void GetPointsNative([In][Out][MarshalAs(UnmanagedType.LPArray)] Point[] points, int size);

static Point[] GetPoints(int size)
{
    var points = new Point[size];
    GetPointsNative(points, size);
    return points;
}


text:
Q: W/AudioGroup﹕ device loop timeout i'm trying to do a SIP call in my android. Sound works great on the first call, but when this call is ended and i start a second call, sound is interrupted and i get following warning (multiple lines per second):

W/AudioGroup﹕ device loop timeout`

I start the call with:
mSipManager.makeAudioCall(
    getAccount().getLocalSipProfile(),
    getAccount().getPeerSipProfile(),
    new SipCallListener(),
    0
);

Contents of call listener:

@Override
public void onCallEstablished(SipAudioCall call) {
    call.startAudio();
}

@Override
public void onCallEnded(SipAudioCall call) {
    call.close();
}

// ...

Any idea how to solve that problem?
Thanks in advance
Matthias
// EDIT:
Currently i can reproduce this behaviour only on a Nexus 5 with Dalvik runtime. Changing the Runtime to ART "solves" the problem for this device, but it's not an acceptable solution.


text:
Q: Prove that $z_1,z_2,z_3$ with equal, non-zero modulus, are vertices of an equilateral triangle if and only if $\sum_{cyc}|z_1-z_2|(z_1+z_2) = 0 $ Prove that $z_1,z_2,z_3 \in \Bbb C$ , distinct, with equal, non-zero modulus, are vertices of equilateral triangle if and only if $\sum_{cyc}|z_1-z_2|(z_1+z_2) = 0 $
I tried dividing by $z_3|z_3|\ne0$ and I obtained $$|a-b|(a+b)+|a-1|(a+1)+|b-1|(b+1)=0\text{, where }a=\frac{z_1}{z_3}, b=\frac{z_2}{z_3}, |a|=|b|=1$$
The equivalent condition for the triangle to be equilateral is:
$$z_1^2+z_2^2+z_3^2=z_1z_2+z_2z_3+z_1z_3\text{,  equivalent to} $$
$$a^2+b^2+1= ab+a+b $$
The last condition could be written as $(a-b)^2+(a-1)(b-1)=0$
Surely, I need to prove that the equation in the title implies that the triangle is equilateral. The implication from the fact that the triangle is equilateral, resulting the equation, is obvious.


text:
Q: Deep dive Azure Log analytics cost using KQL query I'm running following Log Analytics Kusto query to get data what uses and thus generetes our Log Analytics cost
 Usage
 | where IsBillable == true
 | summarize BillableDataGB = sum(Quantity) by Solution, DataType
 | sort by Solution asc, DataType asc

and then the output is following:

What kinda query should I use if I want to deep dive more eg to ContainerInsights/InfrastructureInsights/ServiceMap/VMInsights/LogManagement so to get more detailed data what name or namespaces really cost?
Insightmetrics table have e.g these names and namespaces.

I was able maybe able to get something out using following query but something is still missing. Not totally sure if I'm on right or wrong way
union withsource = tt *
| where _IsBillable == true
| extend Namespace, Name

A: Here is the code for getting the name and namespace details. using Kusto query
let startTimestamp = ago(1h);
KubePodInventory
| where TimeGenerated > startTimestamp
| project ContainerID, PodName=Name, Namespace
| where PodName contains "name" and Namespace startswith "namespace"
| distinct ContainerID, PodName
| join
(
    ContainerLog
    | where TimeGenerated > startTimestamp
)
on ContainerID
// at this point before the next pipe, columns from both tables are available to be "projected". Due to both
// tables having a "Name" column, we assign an alias as PodName to one column which we actually want
| project TimeGenerated, PodName, LogEntry, LogEntrySource
| summarize by TimeGenerated, LogEntry
| order by TimeGenerated desc

For more information you can go through the Microsoft document and here is the Kust Query Tutorial.


text:
Q: How to connect kafka python client to k8s service? I have k8s Kafka services running at 10.zz.yy.xx on 9092 port. I have python client installed for kafka. So wanna try producer and consumer working fine or not.
here is producer.py
from kafka import KafkaProducer
kafka_host = "10.zz.yy.xx.:9092"
print(kafka_host)

producer = KafkaProducer(bootstrap_servers=kafka_host)
 print("Initialized")
 producer.send('Hello','This is my text')

TOPIC_NAME = 'items'
producer = KafkaProducer(bootstrap_servers=kafka_host)

producer.send(TOPIC_NAME, b'Test Message')
producer.flush()`

here is consumer.py
from kafka import KafkaConsumer
TOPIC_NAME = 'items'
consumer = KafkaConsumer(TOPIC_NAME)
for message in consumer:
    print(message)

I am getting error as : kafka.errors.NoBrokersAvailable: NoBrokersAvailable.
Am i pointing to wrong services ? Any help would be really appreciated.

A: you don't need to connect to the Zookeper port, but rather to the Kafka Broker port.
Trying to connect to Zookeper will end up with
kafka.errors.NoBrokersAvailable: NoBrokersAvailable error message.
As per documentation

bootstrap_servers – 'host[:port]' string (or list of 'host[:port]' strings) that the consumer should contact to bootstrap initial cluster metadata. This does not have to be the full node list. It just needs to have at least one broker that will respond to a Metadata API Request. Default port is 9092. If no servers are specified, will default to localhost:9092


text:
Q: Auto login on web page I am trying to write an app I want it to open a web page and auto login I am not sure how to go about sending the info to the browser from the app code.

A: So basically you are going to need to load in the webpage within a WebView (You can find instructions for that here and then probably push javascript into the WebView that will fill in the fields and load the page.
In your activity's onCreate:
WebView webview = new WebView(this);
setContentView(webview);

webView.setWebViewClient(new WebViewClient(){
   @Override
   public boolean onPageFinished(WebView view, String url) {
       // Check here if url is equal to your site URL.
   }
});

webview.loadUrl("http://yourwebsite.com/");

This line enables javascript in your WebView:
webView.getSettings().setJavaScriptEnabled(true);

Then you can use the WebViewClient to detect when the page you want has fully loaded. When that happens, you can use:
webView.loadUrl("javascript:document.getElementsByName('username').value = 'username'");
webView.loadUrl("javascript:document.getElementsByName('password').value = 'password'");
webView.loadUrl("javascript:document.forms['login'].submit()");

And it should automatically log you in. It's worth noting that this generally isn't easy to do on a lot of sites since they will randomize the login control ids and it also doesn't generally sit well with users if an application is logging into a website automatically for them.