text:
Q: How to open URL in same window using javascript? <form id="search" action="">
            <input id="findroom" type="text" class="defaultText" title="Room Name">
            <input id="find" type="submit" value="Find">
        </form>
        <script>

            $(document).ready(function(){
              $('#search').submit(function() {
                var r = "/rooms/"+$('#findroom').val();
                open(r);
              });
            });
        </script>

Having trouble with the code above. I am trying to generate a restful URL for use in a Ruby on Rails app. I can generate the URL I need from the form as the var 'r'. When I use open() as above the link opens fine, but in a new window. I need it to open in the same window. Have tried:
open.(r,'_self');

doesn't work
haven't had any luck with:
location.replace
location.href =

Anybody have any ideas please?
Thanks
Barry

A: It's as simple as
window.location = r;

A: To open a new popup, use
window.open(r);

If you want to redirect the current page, use
window.location = r;

A: Correct syntax is
window.open(URL,name,specs,replace)

You just need to give _self in name
Please read more

A: window.open creates a new secondary browser window and loads the referenced resource, whereas windo.location allows for changing the URL of the current window. So what you want is:
window.location = r;

A: Thank you everyone for your help. You're all on the money, but the answer is
e.preventDefault();

It's to do with the form submitting and overriding the window.location command. Once you block the default behaviour it works. This is the full code:
<section id="roomsearch">
        <form id="search" action="">
            <input id="findroom" type="text" class="defaultText" title="Room Name">
            <input id="find" type="submit" value="Find">
        </form>
        <script>

            $(document).ready(function(){
              $('#search').submit(function(e) {
                var r = "/rooms/"+$('#findroom').val();
                window.location = r;
                e.preventDefault();
              });
            });
        </script>

    </section>

Thanks for the time and help.
Barry


text:
Q: Open bootstrap table row in new table with possible field editor I'm using bootstrap table library in my app that to render table with massive data and I need to open row in additional editable table. I found a lot of info in internet how to open row in model and put edited code to my app that to display row info inside div but cannot set it that to open it in editable table. I provide the plunker example.
Updated Cause I didn't get any work solution, I've tried to fix it by myself, so I know the solution isn't so good but for now it works for me. The question is still asking, how to edit field of new rendered table?
This is function of my solution:
   $(function () {
    var $result = $('#form');

$('#table').on('click-row.bs.table', function (e, row, $element) {

    $('.success').removeClass('success');
    $($element).addClass('success');

    //alert('Selected name: ' + getSelectedRow().text);

    function getSelectedRow() {
        var index = $('#table').find('tr.success').data('index');
        return $('#table').bootstrapTable('getData')[index];
    }

    $result.html(

        '
' + '
'+
        '
' + 'Name	' + ' 	' + '' + getSelectedRow().name + '	' + '
' +
        '
' + 'Structure	'  + ' 	' +  '' + getSelectedRow().stargazers_count + '	'+ '
'+
        '
 '+ 'Class	' + ' 	' +  '' + getSelectedRow().forks_count + '	'+ '
'+
        '
 '+ 'Description	' + ' 	' +  '' + getSelectedRow().description + '	'+ '
'+
        '
' + '
'
        );
    })
});

A: You can use modals of boostrap, will open a modal. Check the documentation on http://getbootstrap.com/javascript/#via-javascript, just add the html, css and js references and call this code:
$('#table').on('click-row.bs.table', function (e, row, $element){           $('#myModal').modal('show') //Will be call the modal when you click a row
})
And you can pass all the information to the modal via javascript. Hope you understand me. :)

A: Not sure if I get what you need but i add this code on the
html:

    <input type="text" placeholder="Title1" id="titleForm1"></input>
    <input type="text" placeholder="Title2" id="titleForm2"></input>
    <input type="text" placeholder="Title3" id="titleForm3"></input>
    <input type="text" placeholder="Title4" id="titleForm4"></input>

js:
$('#table').on('click-row.bs.table', function (e, row, $element) {
    /*$result.html(
        '
' +
        JSON.stringify(row, null, 1).replace(/,|}|{/g, " ")
            //JSON.stringify(row).replace(/,/g, "
")
        + '
'
    );*/
    $('#titleForm1').val(row.name);
    $('#titleForm2').val(row.stargazers_count);
    $('#titleForm3').val(row.forks_count);
    $('#titleForm4').val(row.description);
    console.log(row);
})

Hope it helps you.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Linq Into Clause Missing Field I want to get Citizen's Name_surname also in the output but autocomplete does not bring item.name_surname in the list. Why is that happening? Is that field lost while executing "INTO" clause?
TLDR: I can not retrieve patients name while making temporary result.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LINQ_INTO_CLAUSE
{

public class Citizen
{
    public int id;
    public string name_surname;
}

public class Illness
{
    public int id;
    public string illnessName;
}
class Program
{
    static void Main(string[] args)
    {
        Citizen[] patients = new[]              { new Citizen {id = 123,    name_surname = "John"       },
                                                  new Citizen {id = 2345,   name_surname = "Derek"      },
                                                  new Citizen {id = 345,    name_surname = "Ahmed"      },
                                                  new Citizen {id = 31345,  name_surname = "Mehmed"     }};

        Illness[] illnesses = new[]             { new Illness { id = 123,   illnessName = "Flu"         },
                                                  new Illness { id = 7726,  illnessName = "Flu"         },
                                                  new Illness { id = 123,   illnessName = "Headache"    },
                                                  new Illness { id = 2345,  illnessName = "Kolera"      },
                                                  new Illness { id = 31345, illnessName = "Kolera"      }};

        var _queryResult = from s in patients
                           join k in illnesses on s.id equals k.id
                           into temporaryResult
                           from c in temporaryResult
                           select c;

        foreach (var item in _queryResult)
        {
            Console.WriteLine(item.id+"-"+item.illnessName);
        }
    }
}
}

A: You can store it in an anonymous type, you don't need the into:
var _queryResult = from p in patients
                   join i in illnesses on p.id equals i.id
                   select new { Patient = p, Illness = i};

foreach (var x in _queryResult)
{
    Console.WriteLine(x.Illness.id + "-" + x.Illness.illnessName + " - " + x.Patient.name_surname);
}

If you want to use the into keyword to get a group of all illnesses of a citizen you can still store it in  an anonymous type. But don't use from after into which flattens the groups again:
var queryResult = from p in patients
                  join i in illnesses on p.id equals i.id
                  into allPatientIllnesses
                  select new
                  {
                      Patient = p,
                      IlnessList = allPatientIllnesses.ToList()
                  };

foreach (var item in queryResult)
{
    Citizen patient = item.Patient;
    string illnesses = string.Join(",", item.IlnessList.Select(i => i.illnessName));
}

A: You don;t need the into... bit, then you can create a nicer anonymous type with the details you need:
var _queryResult = from s in patients
                   join k in illnesses on s.id equals k.id
                   select new
                   {
                       Name = s.name_surname,
                       Id = k.id,
                       Illness = k.illnessName
                   };

foreach (var item in _queryResult)
{
    Console.WriteLine(item.Name + "-" + item.Id + "-" + item.Illness);
}


text:
Q: Сравнить два массива и удалить одинаковые элементы Имеется два массива:
string[] mods = System.IO.File.ReadAllLines("mods.txt");
string[] mods_temp = System.IO.File.ReadAllLines("mods_temp.txt");

Нужно найти одинаковые элементы и удалить их из обоих массивов.

A: Сначала находим пересечение последовательностей:
var intersect = mods.Intersect(mods_temp).ToArray();

Потом из каждой последовательности выбираем только элементы, отсутствующие в пересечении:
mods = mods.Except(intersect).ToArray();
mods_temp = mods_temp.Except(intersect).ToArray();

A: Метод Enumerable.Except<TSource>(IEnumerable<TSource>, IEnumerable<TSource>)
var mods2 = mods.Except(mods_temp);
var mods_temp2 = mods_temp.Except(mods);


text:
Q: How to set brightness and contrast and saturation of video/Image in directx I am playing video using custom allocator using directshow. I want to set brightness, contrast and saturation of a video. How can I do this?

A: There are two ways you can accomplish that:

*

*Write/Find a Effect DMO that will handle brightness and contrast on you payload.

*Get the IVMRMixerControl9 from the renderer and call GetProcAmpControl.

More information in this MSDN thread.


text:
Q: How to read and display in listview SMS messages sort from old to new messages
I want to display all the messages from devices to listview sorted from old messages to new messages. Currently my code display from new messages up to old messages. Any ideas will be much appreciated.

     ArrayList<String> list_items = new ArrayList<String>();
     ArrayAdapter arrayAdapter;

 public void displaymessage(){
    arrayAdapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1, list_items);
    ContentResolver cResolver = getContentResolver();
    Cursor smsInboxCursor = cResolver.query(Uri.parse("content://sms/inbox"),null,null,null,null);
    int indexBody = smsInboxCursor.getColumnIndex("body");
    if (indexBody < 0 || !smsInboxCursor.moveToFirst()) return;
    do{
        str = smsInboxCursor.getString(indexBody) ;
        arrayAdapter.add(str);
    }while (smsInboxCursor.moveToNext());
}


text:
Q: ComboBox Behavior When presenting a fixed list of countries in a ComboBox control, with no free text entry, the user expectation is that if they begin spelling out the name of the country, it will take them to that country name.  Instead, the default behavior is for it to move to the first item in the list that begins with that character. So, when they hit the second character of the name, it takes them to the first country beginning with that letter.
For example, if I press "S" a bunch of times, it lets me scroll through all of the countries beginning with "S" to get to Singapore. If I press "S", "I", "N", it takes me the first country starting with "S", then the first country starting with "I", then the first country starting with "N". I'd rather have "S", "I", "N" take me to countries beginning with "Sin"
Is there an easy way to enable that latter behavior?

A: You can get this by setting the following properties on the combobox
AutoCompleteMode = Suggest
AutoCompleteSource = ListItems
DropDownStyle = DropDownList

Now, they can't be slacking and typing real slow...but if they type at a reasonable speed it will jump down to what they need.
If they are slow, it will behave like you mentioned


text:
Q: Lightning Component form field - hidden I would like to hide a form field in a Lightning component.  I am trying to do something like the following but the visibility attribute isn't being recognized.
 lightning:select aura:id="leadtier" label="Interested Membership Tier: " required="false" visibility="hidden" value="{!v.InterestedMT}" name="interestedMembershipTier"

A: @Michele-Kleinhomer - If you are trying to hide the field on the form so that you can use the value of that field in your logic, you can specifying the class attribute and set it to slds-hide. Let me know if this works.

A: As for your issue:

but the visibility attribute isn't being recognized

It's because visibility is not a valid attribute for lightning:select. You can refer to what are available attributes for this component on its documentation here.
There are couple of ways to hide particular elements on your component, and you can use aura:if as one of those. You can find more on aura:if on its documentation here.
Also refer to the page Dynamically Showing or Hiding Markup for more details.


text:
Q: generate epoch time in gatling script at dynamicaally I have POST request need to pass the epoch time dynamically. How to generate epoch time and pass it in the request body?
.body(StringBody("""{"window.performance.timing":{"navigationStart":1523957616037,"redirectStart":0,"redirectEnd":0,"fetchStart":1523957616037,"domainLookupStart":1523957616037

A: You need to use session expression (a function of type Session => T) to build body:
.body(StringBody(_ => s"""... ${System.currentTimeMillis()} ...""" ))

This way that expression will be evaluated separately for each user in simulation.
Also many other methods in Gatling DSL can either take "normal" parameter which is evaluated once for whole scenario or session expressions which are evaluated separately for each user.


text:
Q: Laravel 5.0 Query Builder - Where with multiple parameters I've a Laravel 5.0 project, that I need to implement the following logic
$var1= 'A';
$var2= 'B';
$var3= 50;
$data = DataModel::select('attr1','attr2')->where(function($q){
    $q->where('attr3','like','%'.$var1.'%');
    $q->where('attr4','like',$var2.'%');
    $q->where('attr5','=',$var3);
})->get();

The problem is for the "Where" function $var1, var2 and $var3 are undefined variables.
My Question is, How can I pass multiple parameters to the where function?

A: Here, closure function passed in where argument. To inherit variables you have to use use keyword
For example function($q) use($var1, $var2, $var3){...
To learn more about closure function please check php manual.

A: Try this
$var1= 'A';
$var2= 'B';
$var3= 50;
$data = DataModel::select('attr1','attr2')->where(function($q) use ($var1, $var2, $var3) {
    $q->where('attr3','like','%'.$var1.'%')
        ->orWhere('attr4','like',$var2.'%')
        ->orWhere('attr5','=',$var3);
})->get();


text:
Q: Hadoop services are running. But it says fails to connect   package org.myorg;

  import java.security.PrivilegedExceptionAction;

  import org.apache.hadoop.conf.*;
  import org.apache.hadoop.security.UserGroupInformation;
  import org.apache.hadoop.fs.Path;
  import org.apache.hadoop.fs.FileSystem;
  import org.apache.hadoop.fs.FileStatus;

  public class Write{

    public static void main(String args[]) {
           try {
                // UserGroupInformation ugi = UserGroupInformation.createRemoteUser("hbase");

                 UserGroupInformation ugi = UserGroupInformation.getLoginUser();

                 ugi.doAs(new PrivilegedExceptionAction<Void>() {
                     public Void run() throws Exception
                     {
                         Configuration conf = new Configuration();
                         conf.set("fs.default.name", "hdfs://10.72.40.XX:8020/user/hbase");

                        //conf.set("hadoop.job.ugi", "hbase");

                         conf.set("hadoop.job.ugi", "root");
                         FileSystem fs = FileSystem.get(conf);

                         fs.createNewFile(new Path("/user/hbase/test"));

                         System.out.println("File Created");
                        return null;
                     }
                 });
               }
          catch(Exception e)
         {
            e.printStackTrace();
         }

 }
}

This is my java file.
My ip is 10.72.40.XX
  hostname -i

gives this ip to me.
 jps

says
 Jobtracker, namenode, datanode, tasktracker, secondarynamenode, jps

are running.
I compiled this java program using
 javac -classpath hadoop-core-1.1.2.jar -d Write/ Write.java

Created jar using
 jar -cvf Write.jar -C Write/ .

Run this program using
 hadoop-1.2.1/bin/hadoop jar Write.jar org.myorg.Write

It says,
 Retrying 0-9 [10] times

  failed on connection exception: java.net.ConnectException: Connection refused

Then i checked if something is listening at port 8020
 netstat -plten | grep java

 tcp        0      0 ::ffff:127.0.0.1:8020       :::*                        LISTEN      0          55639      15717/java

returns service is listening at port 8020.
Then, for debugging purpose, i replaced ip with localhost, It is succeeded. What could be the problem?
How do i solve it?
Does ip and localhost are different for the same machine?

A: The netstat output indicates that it is only listening on localhost (::ffff:127.0.0.1:8020 is port 8020 on localhost). You could edit your service configuration, where there must be an entry for the interface/IP it listens on. There, you can change localhost/127.0.0.1 to the external IP. For many services, you can use 0.0.0.0 to indicate that it should listen on all services.


text:
Q: Installing I210 driver on a running kernel? I am working on a basic kernel which is not supporting Make command.
The drivers provided by intel use Makefile to install.
So I cant copy the file into my target and run make.
I tried to cross compile but its giving following error.
make[1]: Entering directory /usr/src/linux-headers-3.11.0-15-generic'
/usr/src/linux-headers-3.11.0-15-generic/arch/x86/Makefile:92:
stack protector enabled but no compiler support
rm: cannot remove/home/sigma/karthik1/igb-5.3.4.4/src/.tmp_versions/igb.mod': Permission denied
make[1]: * [crmodverdir] Error 1
make[1]: Leaving directory `/usr/src/linux-headers-3.11.0-15-generic'
make: * [default] Error 2


text:
Q: Restricting word list from within XSD Schema 1.1 (presumably using pattern?) I am modifying my XSD 1.1 Schema so particular words are not allowed to be entered in the corresponding element.
For example, in a simpletype I would like to error where the following characters have been input '/*' and '--' maybe even '&apos including ;'
I can't for the life of me figure out how to restrict multiple characters/words, does it even exist? I can easily restrict each character in turn whereas I want this to error 'My name /* is Craig' this is acceptable 'My name / is craig*'
Any help guys will be very much appreciated.
thanks
Craig

A: I think this is quite hard to achieve with the pattern facet alone. Since you are using XSD 1.1 I would do it with an assertion facet
<xs:assertion test="
    not(contains($value, 'Trump')) and
    not(contains($value, 'Clinton'))"/>


text:
Q: Unable to debug in ipad I am using Xcode 4.6.x and the iPad iOS version is 6.1.3. I have added the device in Provisioning Profile. But when i connect it does not allow me to debug.
I have checked the Base SDK, it is 6.1 and Deployment Target is 6.1. I have tried to switch off and restart the iPad, but it's not working yet.
Can anyone help me ?

A: Check it once again the device id, add to provisioning profile.
Remove old provisioning profile.
Remove the app from the device. and remove form DerivedData folder also
Than add latest provisioning profile.
Than try to debug hopefully its work.

A: First clean your project [alt + clean] i.e. Clean Build Folder, Quit xCode, then remove app from your device.
Now build project and run. Delete all data from Derived Data folder. Also make sure you are not using distribution profile.
Hopefully this will work.


text:
Q: Cohomology, Penrose Triangle, and Shepards Tone There is an interesting everyday depiction of cohomology that nicely demonstrates how cohomology represents an obstructions to a global constructions. This is the fact that the Penrose Triangle represents a nontrivial cohomology class in the "group of distances from the observer" of the circle. Penrose has an article on this here: On The Cohomology of Impossible Figures.
I find this interesting because I find cohomology interesting and the fact there is such an accessible example illuminating it is pretty neat.
A Shepard tone is a sort of auditory analogue of the Penrose Triangle (or Escher's staircase). This is the noise whose pitch appears to be continuously rising, but isn't really.
For a short interval of time it appears as if the pitch is increasing, but at the end of the interval we are back where we were started. In this way a Shepard tone resembles the impossible figures referenced above. Because of this I imagine there could be a similar analysis in terms of cohomology of Shepard tones as with the Penrose triangle.
My question: Can any exact analysis in terms of cohomology of Shepard tones really be made and if so how?
Why do I want an answer to this question? Supposing the answer to this question is yes: If this has an elementary explanation then I would find it a welcome addition to the Penrose Triangle example and if it is not so elementary then it must have some interesting math to it.
This is still a lousy question as it is so I'll try to show my work on it.

*

*I have a naive mental model of the Shepard tone as a function $\mathbb{R} \to \mathbb{R}$ (time to pitch) which is constant and yet has a positive derivative everywhere.

*In contrast with Escher's stairs the problem is more of one going from "infinitesimal to local" than "local to global." This is the basic problem.

*A solution around this may have to do with how the tone is comprised of waves, and these aren't really infinitesimal data.

As an intermediary question, in case the main question doesn't have an answer/has an answer in thetive negative, I'll ask: How can we mathematically recognize the auditory illusion here? How do we get from the more accurate wave description to the paradoxical description in the first bullet point above?

A: The Shepard tone is a periodic signal, and one way to speak of a periodic signal is as a function $S^1\to\mathbb{R}$, where $S^1$ is the unit circle (which is conveniently thought of as an interval $[0,T]$ with the times $0$ and $T$ identified).  The value of the function is the amplitude of the signal at that particular moment in modulo-$T$-time.
A conventional tone, produced by a conventional musical instrument, decomposes into sine waves.  If $f$ is the frequency of the lowest-frequency component, called the fundamental frequency, then all of the other frequencies present in the tone are multiples of $f$, and these are called harmonics.  The fundamental frequency usually defines the pitch of a tone (perceptually, however, it depends on the relative loudness of all the harmonics).
In contrast, the Shepard tone has at any given moment all the frequencies $2^nf$ for all $n\in\mathbb{Z}$.  This means the fundamental frequency, if there were one, can always be divided by two.  Like for distance in the Penrose triangle, let's say the fundamental frequency is ambiguous.  The ambiguity group (using Penrose's terminology) is the set of all $2^n$ multiplicatively, but this is isomorphic to $\mathbb{Z}$ as an additive group.
Although the fundamental is ambiguous, through time we can measure how much the fundamental, if there were one, has changed.  If the Shepard tone doubles in frequency after one period, then the tone corresponds to a generator of $H^1(S^1;\mathbb{Z})$.
(One might think that the relative amplitudes of the frequencies in the Shepard tone are part of the illusion, but I think it's actually just so the sum of all of the frequencies converges.  The Penrose triangle doesn't have this concern because it obstructs the itself that's behind itself, so to speak.)


text:
Q: Application Insights: Filter website health checks? I'm using Azure Application Insights on the free tier. We also use amazon AWS health checks that hits a pre-determined page expecting a 200 response it then does things if it gets a different response.
All the requests from AWS are filling up telemetry pretty quickly.
Is there a simple way to filter or exclude these requests?
Can it be done from the App Insights console, or does it require modifying the telemetry collector on the actual application. I'd rather not create my own implementation of the ITelemtryProcessor...
And if i am stuck going that route, would this work to filter AWS Route53 checks?
public void Process(ITelemetry item)
{
  if (!string.IsNullOrEmpty(item.Context.Operation.SyntheticSource)) {return;}
  this.Next.Process(item);
}

Edit-Update
Has anyone seen this part of the applicationinsights.config I'm not certain by what it means that it will not have correlation headers.
 <ExcludeComponentCorrelationHttpHeadersOnDomains>
    <!--
    Requests to the following hostnames will not be modified by adding correlation headers.
    This is only applicable if Profiler is installed via either StatusMonitor or Azure Extension.
    Add entries here to exclude additional hostnames.
    NOTE: this configuration will be lost upon NuGet upgrade.
    -->
    <Add>core.windows.net</Add>
    <Add>core.chinacloudapi.cn</Add>
    <Add>core.cloudapi.de</Add>
    <Add>core.usgovcloudapi.net</Add>
    <Add>localhost</Add>
    <Add>127.0.0.1</Add>
  </ExcludeComponentCorrelationHttpHeadersOnDomains>

Does anyone have any other resources or tutorials, the only one i was able to find: https://learn.microsoft.com/en-us/azure/application-insights/app-insights-api-filtering-sampling#filtering
It seems that probably most simple way to implement is to grab a collection from the web.config, define the processor in its own class file, then insert the processor into the chain into the global config...

A: You'll have to write a telemetry initializer like you have above.
However, you might want to look more specifically at the synthetic source and verify content and only throw away the amazon health checks instead of all synthetic traffic (you could also look at request name, etc to make your decisions), as i'm not exactly sure what information is in those inbound requests from amazon.
Otherwise, you might be throwing away incoming requests/dependencies/exceptions that might occur from your webtests, which would also show up as synthetic.


text:
Q: Entity Framework - Deleting Complex Object I'm have the following Entity Framwork objects:

Evaluation, Stage, Apartment

Evaluation contains many Stages and Stage contains many Apartments.
I'm trying to deleted a certain stage as follows:
var deletedStages =
  originalEvaluation.Stages.Where(s => s.State == StateTypes.Deleted);

deletedStages.ToList().ForEach(stage =>
{
  stage.Apartments.ToList().ForEach(
    apartment => stage.Apartments.Remove(apartment)
  );

  originalEvaluation.Stages.Remove(stage);
});

deletedStages.ToList().ForEach(stage =>
{
  stage.Apartments.ToList().ForEach(apartment =>
    shechtmanEntities.Apartments.DeleteObject(apartment)
  );

  shechtmanEntities.Stages.DeleteObject(stage);
});
}
}
try
{
  shechtmanEntities.SaveChanges();
}

But I'm keep getting an Exception : "The relationship could not be changed because one or more of the foreign-key properties is non-nullable".
I know it has to do with a null foreign-key, but I can't understand which? and Why?
Thanks.

A: Try just deleting the Evaluation or Stage and rely on a Cascade Delete to remove it's children entities (in your case Apartments) rather than removing them each individually.

A: If you cannot Cascade Delete (SQL server can be funny about that: https://stackoverflow.com/a/6065583/613004) asdutzu suggests, then:
If it's one-to-many relationship (sounds like it is), then you'll need to manually delete each child object and save-changes before deleting the parent. I.E. delete the apartment (or re-assign it to another Stage), then delete the stage, and so on.
Otherwise, if it's many-to-many, and the joining table is exposed through the entity model, delete the joins between the stages and apartments first, then delete the stage. If not, then detach the apartment from the stage and save changes before deleting the stage.


text:
Q: How to display two tooltips with different css parameters when hovering a single element I am want to display 2 tooltips, next to each other.

My first tooltip info displayed at the top side of my image.

That is how my tooltip is made.
It is displayed when hovering over an image.
I want to display a second tooltip on the left side.
I am using different css style which display it on the left side but I don't know how to combine them together.
I need this for my game I am working on in javascript/html.
Note: There might be a time when I want to display only 1 tooltip.
It is supposed to "compare" two of player items.
@Edit:
Here is jsfiddle example: JSFiddle


text:
Q: Multiple inheritance in Qt How to inherit QLabel and QPushButtton too, what I tried shows error messages
/home/test.cpp:206: error: reference to 'setText' is ambiguous
      setText(text);
      ^

Here is what I tried:
class virtualLabel: virtual public QLabel
{
    Q_OBJECT
public:
    explicit virtualLabel(const QString& text="", QWidget* parent=0){}
    ~virtualLabel(){}

};

class virtualPushButton: virtual public QPushButton
{
    Q_OBJECT
public:
    explicit virtualPushButton(const QString& text="", QWidget* parent=0){}
    ~virtualPushButton(){}

};

class customLabel : public virtualLabel, public virtualPushButton
{
    Q_OBJECT
    // Q_DECLARE_INTERFACE
    //Q_INTERFACES(YourInterface OtherInterface)

public:
    explicit customLabel(const QString& text="", QWidget* parent=0);
    ~customLabel();

    QString folderName;

};

Any help appreciated  Thank You

A: You don't.
Apart from the issue with ambiguity you will have a lot more issues.
From the Qt documentation on moc:

Virtual inheritance with QObject is not supported.

(Trust them on that)
Rather use composition and expose the signals, slots and functions you need.
class customLabel : public QWidget
{
    Q_OBJECT
public:
    explicit customLabel(const QString& text="", QWidget* parent=0);
    ~customLabel();
protected:
    QPushButton* button;
    QLabel* label;
};


text:
Q: How to send a JSON object(in get method) over Request with Android? I want to send the following parameter
 data={"method": "category", "parameter": {"id":20, "language":"en"}}

to a web service
How can I do this from android for get method?
i tried but did not work.

A: your JSON is created like this :
 try {
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("method", "category");
                JSONObject jsonObject1 = new JSONObject();
                jsonObject1.put("id", 20);
                jsonObject1.put("language", "en");
                jsonObject.put("parameter",jsonObject1 );
            } catch (JSONException e) {
                e.printStackTrace();
            }

Now you can add this in your request with key as "data"

A: try this
JSONObject jsonObject = new JSONObject();
jsonObject.put("id",20 );
jsonObject.put("language","en");

JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("method", "category");
jsonObject2.put("parameter", jsonObject.toString());


text:
Q: How to detect UIButton background image change? I work on iOS 8 with objective C on Xcode.
I need to create two viewControllers.
First: button with background image that is changed to some random image, and go to second controller.
Second: Present button image name
Both view Controllers are created but, i need to know about :
1.How to detect that the image on the button  is changed on the First view ,if i now on Second viewController?
2.How to pass the file name to the second viewController ?

A: you can get back the image with :
[self.button currentImage]
(also works with currentBackgroundImage/Title/TileColor... rtfm ;))
To pass data to your second view controller many options exists, you can use "prepareForSegue" and set you next view button/NString whatever :)
Good Luck ;)


text:
Q: different ways of adding Jar/setting classpath in Unix I am a java beginner.
I am trying a Java program in a unix system.
I am getting the below error
Exception in thread "main" java.lang.ClassNotFoundException: com.sybase.jdbc.SybDriver
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at reportToCSVg.main(reportToCSVg.java:13)

I know that in eclipse i can just add the jconn.jar to make it work. please advise me the equivalent i need to do such that whenever i run the program in the server, i had included the jar file which is in a another path

A: you can set the classpath as follow:  http://www.ehow.com/how_4784820_set-classpath-eclipse.html
and put your jar file in your projects classpath .
or you can put your jar file as

*

*Select the library and click "Edit" (left side of the window)

*Click "User Libraries"

*Select the library again and click "Add JARs"

http://www.wikihow.com/Add-JARs-to-Project-Build-Paths-in-Eclipse-(Java)

A: You can use Maven to package your -jar file containing all the dependencies if you are using Maven.
If you are using plain Eclipse with Ant -Just use the Fat-jar Plugin.
For Maven add the assembly plugin to pom.xml
<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <mainClass>app.runner.Runner</mainClass>
            </manifest>
        </archive>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
    </configuration>
</plugin>

For the Maven goal use the below -
maven assembly:single


text:
Q: getting the value of multiple checkboxes and using ajax to preform an action with their values I have a table that has checkboxes, if a checkbox is selected i want a raw in the DB to be deleted - using ajax.
with normal form i would simply name all the chexboxs some name lets say name="checkbox[]"
and then simply use foreach($_POST['checkbox'] as $value){}
now i am trying to get all the values of marked checkboxes then put them into an array. seems i am missing something though. here is what i go so far:
var checkboxes = jQuery('input[type="checkbox"]').val();
var temp = new Array();
jQuery.each(checkboxes, function(key, value) {
     temp[] = value;
});

Late on i will just pass temp as variable to ajax call.
Is there anything i am missing ?

A: You can use :checked selector and map method:
var arr = $('input[type="checkbox"]:checked').map(function(){
     return this.value
}).get();

A: You are trying to iterate over the Checkbox values which is wrong . Try this
var $checkboxes = jQuery('input[type="checkbox"]') ;
var temp = new Array();
jQuery.each($checkboxes, function(i) {
     var value = $(this).attr('value');
     temp[i] = value;
});

If you want to pass only checked items just add a condition.
if($(this).is(':checked')){
  var value = $(this).attr('value');
  temp[i] = value;
}

A: Just wrap the table in a form tag, and do this:
var myData = jQuery('#myform').serialize();
jQuery.ajax('myscript.php', {data:myData});


text:
Q: How to convert a D M Y HH:MM:SS string in Java to Julian Date? I have some strings in Java that come in the format: Day Month Year Hour:Minute:Second
7 Jan 2010 23:00:00.000
4 Feb 2010 17:40:00.000

What is the easiest way to parse this string and convert the values to their resulting Julian Dates? I am reading in these strings from Excel so they are not objects with any sort of conversion/formatting utilities (just raw strings). Is there an easy library or function to call to convert these, or would I have to manually write a parser? Thanks

A: java.time
Sure, Java has got a parser for date and time built-in, the DateTimeFormatter class (named so because it can also format date and time back to strings). And a number of classes that can utilize it for producing objects of themselves. In your case you need the LocalDateTime class. A LocalDateTime is a date and time of day without time zone or offset from UTC, so appropriate for holding the data from your string.
This formatter s good for your string:
private static final DateTimeFormatter FORMATTER
        = DateTimeFormatter.ofPattern("d MMM uuuu HH:mm:ss.SSS", Locale.ENGLISH);

Edit: You wrote in a comment:

Plugging in Jan 7 2010 hour 23 into this calculator:
aavso.org/jd-calculator gives
back 2455204.45833. Would this be the exact Julian Date? I believe
your solution was giving the Day instead of Date decimal value

Yes, that's exactly true. The modified code to get the julian date including the fraction is:
    String source = "7 Jan 2010 23:00:00.000";

    LocalDateTime ldt = LocalDateTime.parse(source, FORMATTER);
    // Subtract half a day to compensate for the
    // fact that the Julian day begins at noon
    LocalDateTime dateToUseForJulianDay = ldt.minusHours(12);
    long julianDayNumber = dateToUseForJulianDay.getLong(JulianFields.JULIAN_DAY);
    double juianDateFraction = (double) dateToUseForJulianDay.getLong(ChronoField.NANO_OF_DAY)
            / (double) Duration.ofDays(1).toNanos();
    double julianDate = julianDayNumber + juianDateFraction;

    System.out.println("Julian date: " + julianDate);

And the output is in this example:

Julian date: 2455204.4583333335

It agrees very nicely with thee result you quote from the online calculator.
The Julian day number is the day number since January 1, 4713 BC. The Julian day starts at noon, which Java does not take into account, so as a hack I have subtracted 12 hours to compensate and get the correct day for all times of day. Since the getLong() method only gets the Julian day number as a whole number, I need to find the fraction separately. It's a matter of dividing the nanosecond of the day by the total number of nanoseconds in a day. From the original date and time we would have needed the number of nanos since 12 noon; but since I have already subtracted 12 hours, the nanosecond of the day, since 0:00 midnight, is the number we need.
Further link: Julian day on Wikipedia

A: My library Time4J supports Julian Dates out of the box.
    ChronoFormatter<PlainTimestamp> f =
        ChronoFormatter.ofTimestampPattern(
            "d MMM uuuu HH:mm:ss.SSS", PatternType.CLDR, Locale.ENGLISH);
    Moment j2000 = f.parse("7 Jan 2010 23:00:00.000").atUTC(); // are your timestamps really UTC?
    // eventually also: ".in(Timezone.ofSystem());"

    System.out.println(JulianDay.ofSimplifiedTime(j2000)); // programmer's standard
    // JD(POSIX)2455204.4583333335
    System.out.println(JulianDay.ofEphemerisTime(j2000)); // astronomical definition
    // JD(TT)2455204.459099352

Advantages:

*

*No complex calculation of your owns.

*Support for the astronomical definition on the time scale TT.

*Explicit display of time zone dependencies (whatever you choose).


text:
Q: iOS - Can't get custom view to center in UIViewController I'm having awful trouble getting a custom view to display correctly in a UIViewController. I'm new to iOS and am not sure if I am constraining this correctly.
I have a BaseTabBarController which sets up my three tabs and controllers which works fine. It is in my MainFeedViewController where I'm having trouble constraining my custom views. Currently, my custom view either appears off the top left corner of the device, or when setting constraints programatically as below, the view is anchored to the right side of the screen, and when the device rotates, it's as if the view controller keeps its portrait size in landscape mode.
I'm baffled and need some guidance on setting constraints properly to have the view centred.
Also, should I set the size of my custom view in its Xib, or will it conform to the view size I set the container view to in the MainFeedViewController?
class MainFeedViewController: UIViewController {

  @IBOutlet weak var articlePreview: ArticlePreviewView!

  override func viewDidLoad() {
    super.viewDidLoad()
      setupView()
    }

    func setupView() {
      view.backgroundColor = UIColor(named: "standardBackgroundColor")
      articlePreview.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
      articlePreview.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
      articlePreview.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
      articlePreview.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true

    }
}

class ArticlePreviewView: UIView {

  @IBOutlet var contentView: UIView!
  @IBOutlet weak var articleInfoContainer: UIView!

  required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    initSubviews()
  }

  override init(frame: CGRect) {
    super.init(frame: frame)
    initSubviews()
  }

  func initSubviews() {
    let nib = UINib(nibName: "ArticlePreviewView", bundle: nil)
    nib.instantiate(withOwner: self, options: nil)
    addSubview(contentView)
    contentView.frame = self.bounds
    contentView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
    setupViewTheme()
  }

  func setupViewTheme() {
    contentView.backgroundColor = .blue
    //articleInfoContainer.backgroundColor = .white
  }
}

A: You should not mix auto layout with auto resizing mask and frame size. Remove the code in ArticlePreviewView that sets the frame and autoResizingMask and use constraints, if you want the view to fill its superview you can use
        view.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint.activate([
            view.leadingAnchor.constraint(equalTo: superview.leadingAnchor),
            view.bottomAnchor.constraint(equalTo: superview.bottomAnchor),
            view.trailingAnchor.constraint(equalTo: superview.trailingAnchor),
            view.topAnchor.constraint(equalTo: superview.topAnchor)
            ])


text:
Q: Problem remotely connecting to MySQL database Good afternoon everyone.
I have 3 servers on 2 different networks, all of which run MySQL.
I can use mysql -u<user> -p -h<ip-addr> from server 1 to server 2 and back without a problem.
When I try to use that command from server 3 (which is on a differnet network) to server 1 I get the following:-
$ mysql -u<user> -p -h<hostIP>
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '<hostIP>' (146)
$

I know the same command works from server 2 to server 1 with the same password. My initial thought was that there was a network block between server 3 and server 1 but if that were the case then server 3 would not get a password prompt.
I have also looked at the users table in server 1 and the user has the same password for local connections and network connections (which is why it works from server 2 to server 1).
Is there another port other than 3306 that is used as part of the connection after that password prompt? Or, failing that, what am I missing?
Many thanks,
David

A: There could be multiple reasons for this but to start troubleshooting as it looks like the issue with permissions/grants.
1.Please check and assign proper grants on server 1 :
GRANT ALL PRIVILEGES ON db.* TO 'username'@'server3_ip' IDENTIFIED BY 'Password';

flush privileges;

All is not compulsory in above query.
2.Double Check Bind parameter in in My.cnf .
bind-address 0.0.0.0

Hope this helps else we can debug further.


text:
Q: Finding integer cubes that are $2$ greater than a square, $x^3 = y^2 + 2$ I was given an example of a cube that is $2$ greater than a square number. The pair: $27$ and $25$.
What's the best way to find further pairs ?

A: This diophantine equation you refer to is a special case of a more general Mordell's equation. The key is to factorize the left side in $\mathbb{Z}[\sqrt{-2}]$. Since nobody solved it up until now, I am jumping in to skim through the standard solution to these kind of problems
$$x^3 = y^2 + 2 = (y + \sqrt{-2})(y - \sqrt{-2})\tag{1}$$
Note that both of the factors are relatively prime in $\mathbb{Z}[\sqrt{-2}]$, which follows from the fact that any common factor must divide
$$y + \sqrt{-2} - y + \sqrt{-2} = 2 \sqrt{-2}$$
and thus it must have it's norm dividing $\bf N$$ [2 \sqrt{-2}] = 8$ and $y^2 + 2$ both. Assume that $y$ is odd, so that the norm of the common factor forced to be $1$, implying that any such common factor is unit in the ring, i.e., $\pm 1$.
Since $y \pm \sqrt{-2}$ are relatively prime, they are cubes times units, implying
$$y + \sqrt{-2} = (m_1 + n_1\sqrt{-2})^3 \tag{2}$$
$$y - \sqrt{-2} = (m_2 + n_2\sqrt{-2})^3 \tag{3}$$
for some $m_i, n_i \in \mathbb Z$. Computing the $\sqrt{-2}$ and $\sqrt{-2}$-free parts of both sides in $(2)$ yields
$$y = m_1^3 - 6m_1n_1^2\tag{4}$$
$$1 = 3m_1^2n_1 - 2n_1^3\tag{5}$$
Since the left side of $(5)$ is divisible by $n_1$, one needs to check for $n_1 = 1$ and $n_1 = -1$ respectively for the solutions, the first of which yields in the solution you refer to, i.e., $(3, 5)$ and the second gives you none at all.
So, done and done. Wait... not yet, no. I have assumed that $y$ is odd in a previous result. What if it's even? Well, that's your thing to do now :
Excercise: Prove that $y$ is not even
As a hint, this can be done elementarily by parity arguments through modular arithmetic.


text:
Q: Keeping Firefox from adding ".html" to url I've been messing with .htaccess for a while, and have the following rule:
RewriteRule ^(mypage|myotherpage)/?$ main.php?p=$1 [L,QSA]

If I enter http://mydomain.com/mypage/, it displays main.php as desired.
If I enter http://mydomain.com/mypage (note the lacking trailing backslash), it redirects to http://mydomain.com/mypage.html, and obviously displays a 404 Not Found error.  I've tried this same URL using Chrome on the same PC, and it doesn't add the .html.  I've also tried the same URL on FireFox on another PC, and again it doesn't add the .html.
Earlier when messing with .htaccess, I had rules which added .html to the URL.  I've since gotten rid of these rules, but wonder if FF somehow buffered them?
Any thoughts?  Thanks


text:
Q: How to calculate Total CPU Requests for a Node kubectl describe node node-name

gives us a summary of cpu requests and limits
Resource           Requests              Limits
--------           --------              ------
cpu                3449m (98%)           20700m (591%)
                           ↑

Im trying to get the CPU Requests % from Prometheus Metrics with PromQL in Grafana
I can get the CPU requests Total and sum it by node with
sum by (node) (kube_pod_container_resource_requests_cpu_cores)

not sure how to plug kube_node_status_allocatable_cpu_cores here which gives me allocatable cpu for each node. Note all my nodes have the some number of cores.
How to mix node and container metrics in one query?


text:
Q: Make ajax call after state change I want to implement checkbox-based filtering on my page. When I click on checkbox I want to change state and make ajax call based on checked items.
I have created toggleCheckbox(id) action and reducer that adds/removes id from selected items, but I have no idea where should I place ajax call.
Any ideas?

A: Your component should dispatch the async action, to avoid duplicating the logic for toggling the selected items move it to the async action and change the normal action from toggle to set. Like this:
const toggleCheckbox = id => (dispatch, getState) => {
    const items = toggle(id, getState().selectedItems);
    dispatch(setSelectedItems(items));
    // call API with "items"
};

A: Network calls are asynchronous, and actions are by default synchronous. They are just plain objets. To handle asynchronous behaviour you need a side-effect library like redux-sagas or redux-thunks. Take a look at https://redux.js.org/docs/advanced/AsyncActions.html and https://redux-saga.js.org


text:
Q: Duvida de como usar o IF em uma TRIGGER no mysql Olá! O meu problema é o seguinte eu tenho duas tabelas, uma tabela chamada notas e outra chamada alunos. Preciso fazer uma comparação com o id_aluno na tabela notas e os id presentes na tabela alunos para somente se o id existir na tabela alunos poder inserir o valor nota na tabela notas. Gostaria de saber como poderia fazer isso.

A: As triggers do MySQL não permitem que seja abortado um INSERT, como em outros SGBD como o PostgreSQL.
O que você pode fazer é verificar com uma trigger AFTER INSERT (disparada após inserir a linha) se o código do aluno inserido é valido, e caso não seja pode efetuar um DELETE (é necessário uma chave primária para efetuar este DELETE com segurança).
Por exemplo:
CREATE TRIGGER tg_insert_notas
AFTER INSERT ON notas
FOR EACH ROW
BEGIN
    DECLARE aluno_existe BOOLEAN;

    SELECT EXISTS(SELECT 0 FROM alunos WHERE alunos.id = NEW.id_aluno) INTO aluno_existe;

    IF NOT aluno_existe THEN
        DELETE FROM notas WHERE notas.id = NEW.id;
    END IF;
END//


text:
Q: Deleting Node from Linked List based on User Input Trying to understand how to properly setup a function that will delete from a linked list based on a user specified parameter. So I have a global variable entitled list that holds all the dog structs within them. I can get the list to delete the node the user wants removed if there are multiple structs in the linked list, for some reason though if there is only one node or the node I want deleted is the head of the list the function does not remove it. Any direction for this issue would be greatly appreciated.
void remove_one(char* name)
{

    struct dog *tempList = list;
    struct dog *previous = NULL;

    if (tempList == NULL) {
        return;
    }

    while (tempList != NULL) {
        if (strcmpi(tempList->name, name) == 0) {

            if (previous == NULL) {
                tempList = tempList->next;
            }

            else {
                previous->next = tempList->next;
                free(tempList);
                tempList = previous->next;
            }

            return;
        }

        else {
            previous = tempList;
            tempList = tempList->next;
        }

    }

    return;

}

A: 2 problems here:
if (previous == NULL) {
      tempList = tempList->next;
          }

First, tempList is a local variable, so you don't really delete the head. Next time you enter in the routine, list is still pointing to the same (valid) value.
Second, you don't free the memory.
correct code:
if (previous == NULL) {
      list = tempList->next;  // change global variable so head is "tempList->next"
      free(tempList);  // free templist memory else you get memory leak
          }


text:
Q: SchedulerStateManagerAdaptor failed to fetch data from zookeeper path in Heron Cluster In Heron, I instantiated a SchedulerStateManagerAdaptor named adaptor using IStateManager and created a new Runtime config to saved this adaptor. Then, I created a ISchedulerClient object for invoking its schedulerClient.updateTopology function. Code as follows:
String stateMgrClass = Context.stateManagerClass(this.config); // get state manager instance
IStateManager stateMgr = null;
try {
     stateMgr = ReflectionUtils.newInstance(stateMgrClass);
     FileUtils.writeToFile(filename, "Create IStateManager object success...");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
     e.printStackTrace();
}
stateMgr.initialize(this.config);
stateManagerAdaptor = new SchedulerStateManagerAdaptor(stateMgr, 5000);

Config runtime = Config.newBuilder()
                .putAll(primaryRuntime)
                .put(Key.TOPOLOGY_NAME, Context.topologyName(config))
                .put(Key.SCHEDULER_STATE_MANAGER_ADAPTOR, stateManagerAdaptor)
                .build();

if (!schedulerClient.updateTopology(updateTopologyRequest)) {
     throw new TopologyRuntimeManagementException(String.format(
             "Failed to update " + topology.getName() +" with Scheduler, updateTopologyRequest=" + updateTopologyRequest));
}

However, when I tried to adaptor.getPhysicalPlan in scheduler.onUpdate function that was invoked by instantiated scheduler. This Exception happened:

What's more, I find the Exception in zookeeper log:
2018-07-07 21:01:09,855 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1044] - Closed socket connection for client /218.195.228.24:41348 which had sessionid 0x16469a49d550f23
2018-07-07 21:01:12,001 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x16469a49d550f29, timeout of 4000ms exceeded
2018-07-07 21:01:12,002 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x16469a49d550f28, timeout of 4000ms exceeded
2018-07-07 21:01:12,002 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16469a49d550f29
2018-07-07 21:01:12,003 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16469a49d550f28
2018-07-07 21:01:20,001 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x16469a49d550f2a, timeout of 10000ms exceeded
2018-07-07 21:01:20,003 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x16469a49d550f24, timeout of 10000ms exceeded
2018-07-07 21:01:20,003 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x16469a49d550f23, timeout of 10000ms exceeded
2018-07-07 21:01:20,003 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x16474d4e4bb0003, timeout of 10000ms exceeded
2018-07-07 21:01:20,004 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x16474d4e4bb0004, timeout of 10000ms exceeded
2018-07-07 21:01:20,005 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16469a49d550f2a
2018-07-07 21:01:20,005 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16469a49d550f24
2018-07-07 21:01:20,006 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16469a49d550f23
2018-07-07 21:01:20,006 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16474d4e4bb0003
2018-07-07 21:01:20,006 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16474d4e4bb0004
2018-07-07 21:01:23,779 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.24:41378
2018-07-07 21:01:23,779 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@896] - Connection request from old client /218.195.228.24:41378; will be dropped if server is in r-o mode
2018-07-07 21:01:23,779 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.24:41378
2018-07-07 21:01:23,780 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.24:41380
2018-07-07 21:01:23,780 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@896] - Connection request from old client /218.195.228.24:41380; will be dropped if server is in r-o mode
2018-07-07 21:01:23,780 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.24:41380
2018-07-07 21:01:23,783 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.24:41382
2018-07-07 21:01:23,783 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@896] - Connection request from old client /218.195.228.24:41382; will be dropped if server is in r-o mode
2018-07-07 21:01:23,783 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.24:41382
2018-07-07 21:01:23,784 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb0005 with negotiated timeout 10000 for client /218.195.228.24:41378
2018-07-07 21:01:23,785 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.24:41384
2018-07-07 21:01:23,785 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@896] - Connection request from old client /218.195.228.24:41384; will be dropped if server is in r-o mode
2018-07-07 21:01:23,785 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.24:41384
2018-07-07 21:01:23,786 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb0006 with negotiated timeout 10000 for client /218.195.228.24:41380
2018-07-07 21:01:23,787 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb0007 with negotiated timeout 10000 for client /218.195.228.24:41382
2018-07-07 21:01:23,789 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb0008 with negotiated timeout 10000 for client /218.195.228.24:41384
2018-07-07 21:01:38,005 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x16469a49d550f70, timeout of 30000ms exceeded
2018-07-07 21:01:38,005 [myid:] - INFO  [SessionTracker:ZooKeeperServer@358] - Expiring session 0x16469a49d550f71, timeout of 30000ms exceeded
2018-07-07 21:01:38,005 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16469a49d550f70
2018-07-07 21:01:38,005 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16469a49d550f71
2018-07-07 21:02:19,897 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.24:41428
2018-07-07 21:02:19,899 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.24:41428
2018-07-07 21:02:19,900 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb0009 with negotiated timeout 30000 for client /218.195.228.24:41428
2018-07-07 21:02:26,397 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.24:41436
2018-07-07 21:02:26,398 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.24:41436
2018-07-07 21:02:26,399 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb000a with negotiated timeout 10000 for client /218.195.228.24:41436
2018-07-07 21:02:26,403 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16474d4e4bb000a
2018-07-07 21:02:26,404 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1044] - Closed socket connection for client /218.195.228.24:41436 which had sessionid 0x16474d4e4bb000a
2018-07-07 21:02:29,672 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.43:40088
2018-07-07 21:02:29,675 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.43:40088
2018-07-07 21:02:29,679 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb000b with negotiated timeout 10000 for client /218.195.228.43:40088
2018-07-07 21:02:30,480 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.28:57174
2018-07-07 21:02:30,493 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.28:57174
2018-07-07 21:02:30,498 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb000c with negotiated timeout 10000 for client /218.195.228.28:57174
2018-07-07 21:02:31,233 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.19:52872
2018-07-07 21:02:31,235 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.19:52872
2018-07-07 21:02:31,239 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb000d with negotiated timeout 10000 for client /218.195.228.19:52872
2018-07-07 21:02:34,002 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16474d4e4bb0009
2018-07-07 21:02:34,009 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1044] - Closed socket connection for client /218.195.228.24:41428 which had sessionid 0x16474d4e4bb0009
2018-07-07 21:02:57,272 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.43:40100
2018-07-07 21:02:57,274 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@368] - caught end of stream exception
EndOfStreamException: Unable to read additional data from client sessionid 0x0, likely client has closed socket
    at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:239)
    at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:203)
    at java.lang.Thread.run(Thread.java:748)
2018-07-07 21:02:57,275 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1044] - Closed socket connection for client /218.195.228.43:40100 (no session established for client)
2018-07-07 21:02:57,276 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.43:40102
2018-07-07 21:02:57,277 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.43:40102
2018-07-07 21:02:57,280 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb000e with negotiated timeout 10000 for client /218.195.228.43:40102
2018-07-07 21:02:57,357 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.43:40106
2018-07-07 21:02:57,358 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@896] - Connection request from old client /218.195.228.43:40106; will be dropped if server is in r-o mode
2018-07-07 21:02:57,358 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.43:40106
2018-07-07 21:02:57,362 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb000f with negotiated timeout 30000 for client /218.195.228.43:40106
2018-07-07 21:02:58,936 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.43:40110
2018-07-07 21:02:58,938 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.43:40110
2018-07-07 21:02:58,943 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb0010 with negotiated timeout 30000 for client /218.195.228.43:40110
2018-07-07 21:03:05,562 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.19:52884
2018-07-07 21:03:05,564 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@368] - caught end of stream exception
EndOfStreamException: Unable to read additional data from client sessionid 0x0, likely client has closed socket
    at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:239)
    at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:203)
    at java.lang.Thread.run(Thread.java:748)
2018-07-07 21:03:05,565 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1044] - Closed socket connection for client /218.195.228.19:52884 (no session established for client)
2018-07-07 21:03:05,568 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.19:52886
2018-07-07 21:03:05,569 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.19:52886
2018-07-07 21:03:05,575 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb0011 with negotiated timeout 10000 for client /218.195.228.19:52886
2018-07-07 21:03:05,794 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.19:52888
2018-07-07 21:03:05,795 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@896] - Connection request from old client /218.195.228.19:52888; will be dropped if server is in r-o mode
2018-07-07 21:03:05,796 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.19:52888
2018-07-07 21:03:05,798 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb0012 with negotiated timeout 30000 for client /218.195.228.19:52888
2018-07-07 21:03:43,958 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.24:41544
2018-07-07 21:03:43,960 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to establish new session at /218.195.228.24:41544
2018-07-07 21:03:43,984 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@687] - Established session 0x16474d4e4bb0013 with negotiated timeout 30000 for client /218.195.228.24:41544
2018-07-07 21:03:44,041 [myid:] - INFO  [ProcessThread(sid:0 cport:2181)::PrepRequestProcessor@486] - Processed session termination for sessionid: 0x16474d4e4bb0013
2018-07-07 21:03:44,043 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1044] - Closed socket connection for client /218.195.228.24:41544 which had sessionid 0x16474d4e4bb0013
2018-07-07 21:03:53,413 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] - Accepted socket connection from /218.195.228.28:57186
2018-07-07 21:03:53,415 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@368] - caught end of stream exception
EndOfStreamException: Unable to read additional data from client sessionid 0x0, likely client has closed socket
    at org.apache.zookeeper.server.NIOServerCnxn.doIO(NIOServerCnxn.java:239)
    at org.apache.zookeeper.server.NIOServerCnxnFactory.run(NIOServerCnxnFactory.java:203)
    at java.lang.Thread.run(Thread.java:748)

I don't know what's wrong with it! But when I invoke the adaptor.getPhysicalPlan in the file that created adaptor object, it worked. What reason caused this problem? Thanks for your help.


text:
Q: how to run two foreach loop in one loop in c# I don't know how to describe my problem but what result I wanted is See Image
My Code:
using (SQLiteConnection con = new SQLiteConnection(AppSettings.ConnectionString()))
        {
            con.Open();
            using (SQLiteDataAdapter sda = new SQLiteDataAdapter("Select * From Deals_FF Where Deal_Code = '" + Deal_Code + "'", con))
            {
                DataTable dt = new DataTable();
                sda.Fill(dt);

                foreach (DataRow dr in dt.Rows)
                {
                    int n = SalesRegisterControl.Instance.Sales_Grid.Rows.Add();
                    SalesRegisterControl.Instance.Sales_Grid.ClearSelection();
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[1].Value = dr["Deal_Name"].ToString();
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[2].Value = dr["Deal_Price"].ToString();
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[3].Value = 1;
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[4].Value = dr["Deal_Price"].ToString();
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[5].Value = "FF";
                    break;
                }

                foreach (DataRow dr in dt.Rows)
                {
                    int n1 = SalesRegisterControl.Instance.Sales_Grid.Rows.Add();
                    SalesRegisterControl.Instance.Sales_Grid.ClearSelection();
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n1].Cells[1].Value = dr["Item_Name"].ToString();
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n1].Cells[2].Value = 0;
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n1].Cells[3].Value = dr["Quantity"].ToString();
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n1].Cells[4].Value = 0;
                    SalesRegisterControl.Instance.Sales_Grid.Rows[n1].Cells[5].Value = "FF";
                }
            }
        }

Any Better way to solve this problem?
I add two foreach loop to solve my problem but the code I do is not good how can I do it in better way please guide?

A: You can try to use a bool to control your loop then combine two foreach. when you had run first time bool set false.
bool IsFirst = true;
foreach (DataRow dr in dt.Rows)
{
    int n = SalesRegisterControl.Instance.Sales_Grid.Rows.Add();
    if (IsFirst)
    {
        SalesRegisterControl.Instance.Sales_Grid.ClearSelection();
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[1].Value = dr["Deal_Name"].ToString();
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[2].Value = dr["Deal_Price"].ToString();
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[3].Value = 1;
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[4].Value = dr["Deal_Price"].ToString();
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[5].Value = "FF";
        IsFirst = false;
    } else
    {
        SalesRegisterControl.Instance.Sales_Grid.ClearSelection();
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[1].Value = dr["Item_Name"].ToString();
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[2].Value = 0;
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[3].Value = dr["Quantity"].ToString();
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[4].Value = 0;
        SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[5].Value = "FF";
    }
}

Edit
Or you don't need the first loop only assign values like this.
int n = SalesRegisterControl.Instance.Sales_Grid.Rows.Add();
SalesRegisterControl.Instance.Sales_Grid.ClearSelection();
SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[1].Value = dr["Deal_Name"].ToString();
SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[2].Value = dr["Deal_Price"].ToString();
SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[3].Value = 1;
SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[4].Value = dr["Deal_Price"].ToString();
SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[5].Value = "FF";

foreach (DataRow dr in dt.Rows)
{
    n = SalesRegisterControl.Instance.Sales_Grid.Rows.Add();
    SalesRegisterControl.Instance.Sales_Grid.ClearSelection();
    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[1].Value = dr["Item_Name"].ToString();
    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[2].Value = 0;
    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[3].Value = dr["Quantity"].ToString();
    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[4].Value = 0;
    SalesRegisterControl.Instance.Sales_Grid.Rows[n].Cells[5].Value = "FF";
}


text:
Q: templated function seemingly creates temporary container In an application I am maintainig I came across a persistence class that had 6 functions that all did the same thing except for the type of item that was being persisted. These items are all of the same base class - a candidate for a template function.
However once I had converted them it would seem that when the function is being stepped into to the container that is being written to is always empty (a temporary copy being created?) despite the fact it should have several items in it. To be sure, inspecting the container in the debugger it has zero items it. Also the writing function triggers an event that notifies the client of an change in status, but when that thread goes to extract the item from the deque it is always now empty.
The base class is called CItem and all other items are specialities of that Item (CErrorItem, etc). They all are persisted in a deque (std::deque<std::tr1::shared_ptr<CItem>> m_items;), and to disk. The items are written to disk correctly. Once processed correctly the items are removed from both the deque and disk.
Items are added with the code m_persistence.Add<CErrorItem>(errorItem);
All data for items are stored in simple structs (eg ErrorItemInfo), and the Items take these simple data stores in their constructor. It is this struct that is denoted by the U in the below code. The T is the derived CItem.
The function that adds the items is the following:
template <typename T, typename U>
    std::tr1::shared_ptr<T> CPersistenceManager::Add(const U& item)
{
    std::tr1::shared_ptr<T> newItem = std::tr1::shared_ptr<T>(new T(item));
    // .. a couple of lines calling helper functions to generated a unique timestamped filename
    newItem->Write(filename); // this writes to disk and works.
    m_items.push_back(newItem); // m_items is always empty
    SetEvent(m_itemAddedEvent); // notify the client an item has been added.
    return newItem;
}

The simplest solution is to revert the code back to specific functions, and probably I will do that, but I would like to understand why this is occuring so I can avoid it in the future.

A: shared_ptr<T> is a potentially different type to shared_ptr<CItem>

Could it be that your whole persistence class is getting specialized for every T?


text:
Q: terminating with uncaught exception of type NSException .I have a Signal-Sigbrt error
I Followed other instructions but I don't know what's wrong. Check connections but everything seems alright.
This is my connections, perfectly fine:

Same thing:

A: The exception shows that you are attempting to store something in NSUserDefaults that cannot be stored there.  You can only store:
NSArray, NSData, NSDictionary, NSNumber and NSString.
This is happening in [ViewController6 registerNewUser], somewhere.
That's all I can tell you without seeing the code, but I expect you are attempting to store a custom object that represents a user account, rather than the properties of this object.


text:
Q: FGLRX frame rate capped at 60FPS? I've got a really weird thing where I can't seem to get frame rates to exceed 60FPS exactly. It really seems like a cap is being placed on it, it never exceeds 60.000 FPS, though I know I could get a lot more out of it:
Using GLX_SGIX_pbuffer
279 frames in 5.0 seconds = 55.800 FPS
299 frames in 5.0 seconds = 59.800 FPS
295 frames in 5.0 seconds = 59.000 FPS
296 frames in 5.0 seconds = 59.200 FPS
299 frames in 5.0 seconds = 59.800 FPS
299 frames in 5.0 seconds = 59.800 FPS
298 frames in 5.0 seconds = 59.600 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
299 frames in 5.0 seconds = 59.800 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
299 frames in 5.0 seconds = 59.800 FPS
298 frames in 5.0 seconds = 59.600 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
299 frames in 5.0 seconds = 59.800 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
299 frames in 5.0 seconds = 59.800 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
299 frames in 5.0 seconds = 59.800 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
300 frames in 5.0 seconds = 60.000 FPS
299 frames in 5.0 seconds = 59.800 FPS
300 frames in 5.0 seconds = 60.000 FPS

I can drag the window around smoothly and do other stuff at the same time that fgl_glxgears is running and the FPS doesn't really show any difference. It really seems that things are being limited somewhere. Is there any way to find out where this limit is being enforced and how to disable it?

A: If your monitor cannot display more than 60fps, it does not make any sense for the graphics card to go any faster since you won't be seeing it.
It is swapping buffers with the vertical sync signal (to prevent things like window tearing), there might be ways of disabling this behaviour, but really, why would you want to do that since there is no benefit and will make the picture look worse?


text:
Q: Is this short proof correct? distance between sets For every pair of sets $K, L \subseteq \mathbb R$ we define the distance between them as $d(K,L) = \inf \{|x-y|, x \in K, y \in L\}$
We are asked to prove that if $K$ is closed and $L$ is compact and $K \cap L = \emptyset$ then $d(K,L) > 0$.
What I tried:
define $f: L \to \mathbb R$ by $f(x) = \inf \{|x-y|, y \in K\}$
It follows from the definition that $d(K,L) = \min _{x \in L} f(x)$. Furthermore, since $L$ is compact and $f$ is continuous, we know that $f$ actually attains the value.
Now suppose $d(K,L) = 0$. Since $f$ actually attains that value somewhere, there is $x_0 \in L$ such that $f(x_0) = 0$.
So either $\exists y_0 \in K$ such that $|x_0-y_0| = 0$, which makes no sense since the intersection is empty, or there is a sequence $\{y_k\} \in K$ whos limit is $x_0$.
But since $K$ is closed, this means that $x_0 \in K$, since a closed set contains all of its limit points, so again we arrive at a contradiction.
Is this correct and clear enough?


text:
Q: Keyword only parameter Reference http://docs.python.org/3/glossary.html#term-parameter
keyword-only parameter: specifies an argument that can be supplied only by keyword. Keyword-only parameters can be defined by including a single var-positional parameter or bare * in the parameter list of the function definition before them, for example kw_only1 and kw_only2 in the following:
def func(arg, *, kw_only1, kw_only2):

Instead of single var-positional parameter shouldn't that be single var-keyword parameter?
Maybe i understood something wrong ...

A: No, you must use either the * bare parameter, or use a single *args parameter, called a var-positional parameter (see the next item in that glossary entry). By adding it to your function signature you force any parameters that follow it to be keyword-only parameters.
So the function signature could be:
def func(positional_arg1, *variable_args, kw_only1, kw_only2):

and variable_args will capture any extra positional arguments passed to the function, or you could use:
def func(positional_arg1, *, kw_only1, kw_only2):

and the function will not support extra positional arguments beyond the first one.
In both cases, you can set kw_only1 and kw_only2 only by using them as keyword arguments when calling func(). Without default values (no =<expression> in their definition) they are still required arguments.


text:
Q: Identifying suitable satellite imagery of the South China Sea I've been using the Google Earth Engine API in an attempt to access Landsat 8 imagery for land use change detection in the South China Sea. Initial investigations suggest that Google may have removed imagery of this area from their collection, as when I run the code in the link below all images are clipped to the surrounding mainland coastline of each country.
https://code.earthengine.google.com/b2d2927d5f8abb7c77444cc03dc8ece8
Having checked the following, https://earthexplorer.usgs.gov/ I can confirm that suitable Landsat 8 imagery does exist for this ROI, so my question is:
Is there any documentation where Google specifies why this has been excluded from their Landsat 8 collection? Or have a made a mistake in the code above that somehow excludes the imagery I am looking for?

A: You're using the Landsat 8 T1_SR collection, which is based on the Tier 1 data.  For data to be included in Tier 1 (by the USGS), it has to have a geometric calibration accuracy of ~15m.  None of the images that occur in the sea meet that criteria, so they are only included the in the Tier-2 collection (and therefore aren't very well registered).
You can tell which collection an image is in by the last 2 letters of its ID: LC08_L1GT_121049_20181222_20181227_01_T2
That's a Tier 2 image over the sea.


text:
Q: zlib and buffer sizes I am currently trying to use zlib for compression in one of my projects. I had a look at the basic zlib tutorial and I am confused by the following statements:

CHUNK is simply the buffer size for feeding data to and pulling data
  from the zlib routines. Larger buffer sizes would be more efficient,
  especially for inflate(). If the memory is available, buffers sizes on
  the order of 128K or 256K bytes should be used.
#define CHUNK 16384

In my case I will always have a small buffer already available at the output end (around 80 bytes) and will continually feed very small data (a few bytes) from the input side through zlib. This means I will not hav a larger buffer on either side, but I am planning on using much smaller ones.
However I am not sure how to interpret the "larger buffer sizes would be more efficient". Is this referring to efficiency of the encoding or time/space efficiency?
One Idea I have to remedy this situation would be to add some more layers of buffering had have accumulate from the input and flush to the output repeatedly. However this would mean I would have to accumulate data and add some more levels of copying to my data, which would also hurt performance.
Now if efficiency is just referring to time/space efficiency, I could just measure the impact of both methods and decide on one to use. However if the actually encoding could be impacted by the smaller buffer size, this might be really hard to detect.
Does anyone have an experience on using zlib with very small buffers?

A: It means time efficiency.  If you give inflate large input and output buffers, it will use faster inflation code internally.  It will work just fine with buffers as small as you like (even size 1), but it will be slower.
It is probably worthwhile for you to accumulate input and feed it to inflate in larger chunks.  You would also need to provide larger output buffers.


text:
Q: Safari 14: chrome.permissions.request() not working seamless and tab.url comes blanks always - Extension I have working cross-platform extension which I converted for Safari using xcrun safari-web-extension-converter PATH. Goal of extension is to bookmark any URL into my website account (https://ourdomain.in).
My extension is perfectly working fine for Chrome but for Safari version, everything works well if user allows access permission for every website.
The issue is, even though I have proper optional_permissions and used chrome.permissions.request() method to ask user-consent for ourdomain.in, and we see user allowed access, still tab.url comes blank for chrome.tabs.onUpdated every time.
Here is the case in detail, when user presses extension button, we are checking user is logged into its account or not by opening our website URL into another tab.
var openSignin = function openSignin() {
    console.log('hey');
    chrome.tabs.create({ url: _config.baseURL + '?extension=1', active: false });
};

When this AUTH tab is loaded, following method will be called as it happens in Chrome which in turn extracts public and private tokens generated when any user logs into our website.
chrome.tabs.onUpdated.addListener(function (tabID, changeInfo, tab) {
    if (tab.status == 'complete' && tab.url.startsWith(_config.baseURL)) {
      chrome.tabs.executeScript(tab.id, { code: 'localStorage.getItem("PUBLIC")' }, function (r) {
       localStorage['PUBLIC'] = JSON.parse(r[0]);
       chrome.tabs.executeScript(tab.id, { code: 'localStorage.getItem("PRIVATE")' }, function (r) {
        localStorage['PRIVATE'] = JSON.parse(r[0]);
        if (localStorage['PRIVATE'] && tab.url === _config.baseURL + '?extension=1') {
         chrome.tabs.remove(tabID);
        }
       });
      });
     }
});

The issue lies here is that until user does not grant for "Always Allow on Every Website" (I mean grant permission for https://ourdomain.in/extension?extension=1), chrome.tabs.onUpdate is giving tab.url = "" and it does not give proper URL value so our conditions don't match and know that particular user is signed in or not.
Following is our manifest.json where I have event used optional_permissions:
{
    "name": "EXT NAME",
    "description": "DESCRIPTION",
    "manifest_version": 2,
    "version": "1.0.181",
    "minimum_chrome_version": "23",
    "offline_enabled": true,
    "browser_action" : {
        "default_icon" : {
             "64": "logo/icon.png"
        },
        "default_title" : "Add here"
    },
    "background" : {
        "scripts" : [
            "background.js"
        ]
    },
    "content_scripts": [{
            "js": [ "content.js" ],
            "matches": [ "<all_urls>" ]
    }],
    "icons": {
         "16": "logo/icon_small.png",
         "64": "logo/icon.png"
    },
    "permissions" : [
        "https://*.ourdomain.in/*",
        "activeTab",
        "gcm",
        "storage",
        "notifications",
        "identity",
        "contextMenus",
        "tabs",
        "idle"
    ],
    "externally_connectable": {
        "matches": ["https://*.ourdomain.in/*"]
    },

    "optional_permissions": ["activeTab", "tabs", "storage", "contextMenus", "*://*.ourdomain.in/*"],

    "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
    "web_accessible_resources": [
        "corner.css",
        "js/init.js",
        "content.js",
        "js/jquery.min.js",
        "js/taggle.min.js",
        "js/typeahead.bundle.min.js",
        "ext.html.js",
        "assets/*"
    ],
 "commands": {
         "_execute_browser_action": {
             "suggested_key": {
                 "default": "Ctrl+Shift+S",
                 "mac": "Command+Shift+S"
             },
             "description": "Send a link to DOMAIN!"
         }
     }
}

And following is the code for permission request which is implemented in click event handler of extension button.
chrome.browserAction.onClicked.addListener(function (tab) {
     var reqPerm = {
        permissions: ["activeTab", "tabs", "storage", "contextMenus"],
        origins: ['https://ourdomain.in/']
     };

     chrome.permissions.request(reqPerm, function (granted) {
        if (granted) {
            return go(tab.url);
        } else {
            console.log("Requested not granted.");
            chrome.tabs.sendMessage(tabID, { action: 'signin', text: 'Please allow stash.ai to proceed.' });
        }
    });
});

Here I am able to see Privacy dialog and I do press Allow for the Day.
Now if I see in Safari > Preferences > Websites > Stash Extension, I am clearly able to see ourdomain.in -> Allowed which proves prompt worked as expected I believe.
Still when new tab is opened for authentication, the above mentioned code for chrome.tabs.onUpdate is executed and gives tab.url = ''. This definitely works when Allow for Every website is turned on.
And other thing is, when I open https://ourdomain.in, my extension icon still shows disabled and on click of the icon it again asks me for the permission. If on this tab, I do give permission, everything works smooth.
Thus, chrome.permissions.request() is no use if I have to manually give permission from tab.
Please let me know any suggestions here.

A: The answer was so simple, I have to change my reqPerm like,
var reqPerm = {
        permissions: ["activeTab", "tabs", "storage", "contextMenus"],
        origins: ['https://ourdomain.in/*']
     };

So every endpoint in ourdomain.in works.


text:
Q: Has the Federation ever fought a protracted land war? Starfleet is, we are told again and again, not a military organization.  That being said, they are the group that the Federation turns to in times of war, and they have gone to war on several significant occasions, sometimes during terribly destructive and prolonged conflicts.
But in these times of war, it seems like we only ever hear of starships and away teams doing battle, never dedicated infantry combat.  The answers to other questions on this site indicate that Starfleet includes all branches of the "Federation military," and the M.A.C.O. units do imply some land-based forces, but even they seem like a very small force for a (proto-)galactic civilization.
Has there ever been any mention of a protracted land war in Federation history?  Do they simply not need a large-scale army, given the capabilities of their starships?  Or have land battles been mentioned, and we are left to wonder how exactly they were waged?

A: There were protracted land campaigns during the Dominion War. This was even shown in several episodes, most notably "The Siege of AR-558," where Nog loses his leg in a ground battle against the Jem'Hadar. Other than the Dominion War, I don't know of any major land campaigns conducted by the Federation or Starfleet.

A: In addition to the Dominion War, the Federation fought many land battles against the Cardassians in their war that occurs prior to the events of TNG & DS9.  Chief O'Brien was a tactical officer and soldier prior to becoming an engineer.
He talks about it from time to time during various episodes of both TNG & DS9.  It wasn't until after the war with Cardassia that he switches to engineering and eventually ends up on the Enterprise, then on to Deep Space 9.


text:
Q: What technologies allow bidirectional streaming of video? Wikipedia says that Flash allows "bidirectional streaming of audio and video". Is it possible to do that with other technologies (for example with JavaScript)?
In other words, I want to transfer video from one user of web-site to another one in real time.
I want to have something that is already installed by many users or easy to install (Flash fulfills this requirements). And I want to have something free.

A: You can use WebRTC with just JavaScript to have two way communication within browsers. It can even transmit in many-to-many architecture. As flash is almost dead, webrtc is IMHO the future of p2p communication in web.
There are implementations that use webrtc to stream video&audio to make conferences. Example. There are many other, ready to use solutions like vline.
Keep in mind that not all browsers are well supported - all versions of IE and Safari are lacking native support at the moment, although third party plugins to close the gap are available.

A: Flash is probably going to be your best bet since it is already installed for the vast majority of web users and it already supports the technology you're working with (webcams, microphones, audio/video streams, etc.).


text:
Q: What does SFM on a map mean? I am reading the book A Voyage for Madman by Peter Nichols. There are some maps on some pages. On those maps, I see the acronym "SFM" and have no idea what it means.

I looked SFM up on Google and I found lots of stuff about Source Film Maker, which is a software. I don't think this is what it means here...
I also looked on AcronymFinder and I found lots of results. None of them seems to fit the context.
What does this mean?

A: The first map shows SFM located somewhere notheast of Australia, around 20ºN. The second map, however, shows SFM at a different location, south of the African continent about 40º-50ºS. My conclusion is that SFM is not an acronym for a place on the map. It may be the mapmaker's initials.


text:
Q: SQL Query to get Top 1 with greatest modifieddate From Group BY ID. How can i achieve this? I have a table
CREATE TABLE [dbo].[MergeAndDeleteNonprofitDetails](
    ID int IDENTITY(1,1) PRIMARY KEY,
    [ToJKNonprofitID] [int] NULL,
    [ToNGOID] [int] NULL,
    [ToOrgName] [nvarchar](400) NULL,
    [ToOrgEIN] [nvarchar](50) NULL,
    [ToJKStatus] [int] NULL,
    [ToOrganizationID] [nvarchar](max) NULL,
    [ToOrgZipCode] [nvarchar](50) NULL,
    [ToLastModifiedDate] [datetime2](7) NULL,
    [FromJKNonprofitID] [int] NULL,
    [FromNGOID] [int] NULL,
    [FromOrgName] [nvarchar](400) NULL,
    [FromOrgEIN] [nvarchar](50) NULL,
    [FromJKStatus] [int] NULL,
    [FromOrganizationID] [nvarchar](max) NULL,
    [FromOrgZipCode] [nvarchar](50) NULL,
    [FromLastModifiedDate] [datetime2](7) NULL,
    [IsMerged] [bit]
)

I need to select the data with Greatest ToLastModifiedDate and FromLastModifiedDate GROUP BY ToOrganizationID. How Can i achieve this?
NOTE: There can be multiple data corresponding to one ToOrganizationID with different FromOrganizationID. Hence we need to compare between columns and within one row for finding Greatest ToLastModifiedDate and FromLastModifiedDate.
SAMPLE DATA:

A: with C as
(
  select *,
         row_number() over(partition by ToOrganizationID order by ToLastModifiedDate desc) as rnTo,
         row_number() over(partition by ToOrganizationID order by FromLastModifiedDate desc) as rnFrom
  from MergeAndDeleteNonprofitDetails
)
select *
from C
where rnTo = 1 or
      rnFrom = 1


text:
Q: redirecting a bad post from google with htaccess rewrite I have a problem with several search engines using bad post URLs.
Here is one of the URLs:
/?lang=frThe-Importance-of-Multilingual-Support-for-Consumer-Electronicsleading-translation-services-for-french-spanish-english-montreal-toronto-orlando-miami/real-estate-translation-service-provider-french-spanish-montreal-mississauga-quebec-toronto-orlando-miami-florida/

I have tried the following rewrite in my htaccess file. But it has not worked.
RewriteCond %{QUERY_STRING} lang=frThe-Importance-of-Multilingual-Support-for-Consumer-Electronicsleading-translation-services-for-french-spanish-english-montreal-toronto-orlando-miami\/real-estate-translation-service-provider-french-spanish-montreal-mississauga-quebec-toronto-orlando-miami-florida\/
RewriteRule ^/ / [R=301]

What did I miss?


text:
Q: How to prove that $b_n=\frac{7n-19}{3n+7}$ converges to $\frac73$? How to prove that $b_n=\frac{7n-19}{3n+7}$ converges to $\frac73$?
In other words, we want to prove $\forall\epsilon>0, \exists N\in  \mathbb{R}$ such that $n>N\implies |\frac{7n-19}{3n+7}-\frac73|<\epsilon$.
My scratch: $|\frac{7n-19}{3n+7}-\frac73|=\frac{106}{3(3n+7)}=\frac{106}{9n+21}\lt\epsilon$, then $n>\frac{106-21\epsilon}{9}$, so we can pick $N=\frac{106-21\epsilon}{9}$.
Formal: Let $\epsilon>0$, let $N=\frac{106-21\epsilon}{9}$, then $n>\frac{106-21\epsilon}{9}$, then $\frac{106}{3(3n+7)}\lt \epsilon$, then $|\frac{7n-19}{3n+7}-\frac73|\lt\epsilon.$
However, the answer gives that we should pick $N=\max\{1,\frac{106-21\epsilon}{9}\}$. Why is the $1$ significant?

A: Since $\epsilon$ is arbitrary we don't know if $\frac{106-21\epsilon}{9}$ is positive or negative. So it is appropriate to take $N>$max{$1,\frac{106-21\epsilon}{9}$} since $N$ has to a natural number. If $\frac{106-21\epsilon}{9}$ turns out to be negative or even less than 1, taking a $N\geq1$ will work.

A: $1$ would not be significant if you wanted to prove the existence of a positive integer $N$, which is indeed what we do in proving convergence of a sequence. But what you need is $N\in\mathbb{R}$. However the domain of the sequence is $\mathbb{Z^+}$. So you need to make sure that everything that comes after your selected $N$ is positive.

A: The sequence given above is monotone and bounded. Hence convergent. Use this fact.