text:
Q: Cannot read property 'isInterleavedBufferAttribute' of undefined I'm tring to use three.js   "version": "0.113.2".
I have the message Cannot read property 'isInterleavedBufferAttribute' of undefined.
My three.js have following  code as the messaged say.
However, I didn't do it myself.Some things my code is conducing this.
Someone tell me how to fix this problem.
function get( attribute ) {

    if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; }

    return buffers.get( attribute );

}

function remove( attribute ) {

    if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; }

    var data = buffers.get( attribute );

    if ( data ) {

        gl.deleteBuffer( data.buffer );

        buffers.delete( attribute );

    }

}

function update( attribute, bufferType ) {

    if ( attribute.isInterleavedBufferAttribute ) { attribute = attribute.data; }

    var data = buffers.get( attribute );

    if ( data === undefined ) {

        buffers.set( attribute, createBuffer( attribute, bufferType ) );

    } else if ( data.version < attribute.version ) {

        updateBuffer( data.buffer, attribute, bufferType );

        data.version = attribute.version;

    }

}

}
A part of my code which tries  to add pointcloud on the scene.
If add comment the last line scene.add( points ),the error message will stop.
        var vertices = [];
        var colors = [];
        var pcUrl = " <?php echo $pcUrl ?> ";
        var req = new XMLHttpRequest();
        req.open("get", pcUrl, true);
        req.send(null);
        req.onload = function(){
        convertCSVtoArray(req.responseText);
        }

        function convertCSVtoArray(str){
            line = str.split("\n"); /

            for (var  i  =0; i< line.length-1 ; ++i){
                row = line[i].split(',');

                var x = row[0];
                var y = row[1];
                var z = row[2];

                vertices.push( x, y, z );
            }
        }
        var geometry = new THREE.BufferGeometry();
        geometry.setAttribute( vertices );

        var material = new THREE.PointsMaterial( { color: 0xff4444 } );
        var points = new THREE.Points( geometry, material );
        scene.add( points );

A:
geometry.setAttribute( vertices );

It should be:
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );


text:
Q: Auto Focus and Auto Exposure in AVFoundation on Custom Camera Layer What is the best way to create an accurate Auto Focus and Exposure for AVFoundation custom layer camera?, for example, currently my camera preview layer is square, I would like the camera focus and exposure to be specify to that frame bound. I need this in Swift 2 if possible, if not please write your answer I would be able to convert it myself.
Current Auto Focus and Exposure: But as you can see this will evaluate the entire view when focusing.
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    //Get Touch Point
    let Point = touches.first!.locationInView(self.capture)
    //Assign Auto Focus and Auto Exposour
    if let device = currentCameraInput {
        do {
            try! device.lockForConfiguration()
            if device.focusPointOfInterestSupported{
                //Add Focus on Point
                device.focusPointOfInterest = Point
                device.focusMode = AVCaptureFocusMode.AutoFocus
            }

            if device.exposurePointOfInterestSupported{
                //Add Exposure on Point
                device.exposurePointOfInterest = Point
                device.exposureMode = AVCaptureExposureMode.AutoExpose
            }
            device.unlockForConfiguration()
        }
    }
}

Camera Layer: Anything in the 1:1 ratio should be considered as focus and exposure point, and anything outside this bound would not even be considered as a touch event for camera focus.

A:  public func captureDevicePointOfInterestForPoint(pointInLayer: CGPoint) -> CGPoint

will give you the point for the device to focus on based on the settings of your AVCaptureVideoPreviewLayer. See the docs.

A: Thanks to JLW here is how you do it in Swift 2. First, we need to setup Tap gesture you can do this programmatically or Storyboard.
    //Add UITap Gesture Capture Frame for Focus and Exposure
    let captureTapGesture: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "AutoFocusGesture:")
    captureTapGesture.numberOfTapsRequired = 1
    captureTapGesture.numberOfTouchesRequired = 1
    self.captureFrame.addGestureRecognizer(captureTapGesture)

Create a function base on our selector in captureTapGesture.
/*=========================================
* FOCUS & EXPOSOUR
==========================================*/
var animateActivity: Bool!
internal func AutoFocusGesture(RecognizeGesture: UITapGestureRecognizer){
    let touchPoint: CGPoint = RecognizeGesture.locationInView(self.captureFrame)
    //GET PREVIEW LAYER POINT
    let convertedPoint = self.previewLayer.captureDevicePointOfInterestForPoint(touchPoint)

    //Assign Auto Focus and Auto Exposour
    if let device = currentCameraInput {
        do {
            try! device.lockForConfiguration()
            if device.focusPointOfInterestSupported{
                //Add Focus on Point
                device.focusPointOfInterest = convertedPoint
                device.focusMode = AVCaptureFocusMode.AutoFocus
            }

            if device.exposurePointOfInterestSupported{
                //Add Exposure on Point
                device.exposurePointOfInterest = convertedPoint
                device.exposureMode = AVCaptureExposureMode.AutoExpose
            }
            device.unlockForConfiguration()
        }
    }
}

Also, if you like to use your animation indicator, please use touchPoint at your touch of an event and assign it to your animated layer.
//Assign Indicator Position
touchIndicatorOutside.frame.origin.x = touchPoint.x - 10
touchIndicatorOutside.frame.origin.y = touchPoint.y - 10

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to dump an output from SQL Server Profiler 2008 to a CSV-like file I am debugging stored procedures, and right now I am interested in what ran in what order and which which parameters as opposed to how fast things ran and what may sneak in between and cause a slowdown.
So, I captured a couple of minutes worth of trace. The problem is that there is too much stuff, and I need to narrow it down. If I do File -> Save As, I get the following options:

*

*Trace File...

*Trace Template...

*Trace Table...

*Trace XML File...

*Trace XML File for Replay...

Now, these are decent options, but what I really want is a tabular format, such as CSV. I think that commas in SP trace would probably mess up the CSV format. I would gladly use something else, such as || as a delimiter.
Once I do have the tabular format, I can filter it down using grep, etc. and then easily process it with Python to see the exact things I want. I started parsing the XML file with a script, but found myself spending too much time on the trace XML file format (have not used lxml library before).
So ... is there an easier way? Can I at least copy it to Excel somehow?

A: If you save it into a trace table; you can get the data in a table in SQL Server which will let you manipulate it to your hearts content; including dumping it out to CSV if still required. The text data column is fully represented in the table.

If you choose Save → Trace Table. You will be prompted for the name of the table and the database. Lets say you call it ProfilerTemp in the database scratch.
Enter those; you can query the table using
select * from scratch.dbo.ProfilerTemp

You will see everything in the trace window in the table. If you didnt filter down to just stored procedures and want just them in the select
Select textdata from [Scratch].[dbo].[ProfilerTemp]
  where eventclass = 10
  And textdata like 'exec %'
  and not cast(TextData as nvarchar(max))= 'exec sp_reset_connection'

This filters out non procedure calls and any connection resets you may have. You may need to add more filters depending on what you are trying to do.
If you want this out as a text file; choose query - results to file and run the query. This will prompt for the file name and give you the parameter text as a text file.

A: TL;DR: Copy into a text editor, manually prep, then paste into Excel.
I have very little experience with SQL Server, so I don't know if this will work for others, but it did for me:

*

*Select desired rows in SQL Server Profiler. Ctrl + C to copy.

*Paste into a plain text editor that can do regular expression search and replace (e.g. Notepad++ in my case).

*Regex replace (N'(''')?[^']*?)\r\n(([^']*?)\r\n)?(([^']*?)\r\n)? with $1 $4 $6

*

*This clears all newlines from SQL scripts.

*Keep doing "Replace All" until no more results are found.

*Regex replace (Batch(Starting|Completed)[^\\]*?)\r\n with $1

*

*This clears newlines from more SQL stuff. Again, keep replacing until no results.

*Regex replace \r\nset with set

*

*This clears all newlines from Audit Login scripts

*You may need to do more replacing, you get the idea.

*Paste into excel using the "Text Import Wizard." Use tabs as the deliminator.

*Sort by the first column and remove any unhelpful rows (e.g. "Audit Login" in my case). You may also need to manually move some data over a column (e.g. "EntityFramework" data in my case)

A: Try this:

*

*Open SSMS

*run  select  * from fn_trace_gettable('D:\abc.trc',default)

*Right click and select with headers

*Paste it into Excel

A: I had a bunch of SQL Profiler trace files containing deadlock trace events that I needed to analyze. I ended up converting them to a single XML file using SQL Profiler, and then reading that XML file with Python, using the lxml and pandas libraries.
As the data ends up in a pandas Dataframe, you can easily convert it to CSV, Excel, ... or analyze it in Python (if you're familiar with pandas).
The script is available as a gist. It's written specifically for deadlock trace files, as I didn't have any other traces available. In other words, you might need to tweak it a little bit to serve your purpose. Don't worry if the XML file is large (several 100 MBs); the script uses iterparse(), which means the file won't be read into memory and only the relevant elements will be captured. E.g. an xdl file of ca. 220MB was parsed in less than 13 seconds.
Saving the trace files as XML (xdl extension):

Make sure you select the option all events in a single file.


text:
Q: Load Julia modules on demand I I have a very simple question. Is it possible to load modules on demand in Julia. That is, can the modules be loaded when they are actually needed instead of being loaded at "parse-time" at the top level.
The use case scenario I have in mind is that I have some set of code that is able to do some plotting using PyPlot, but code is far from always executed.
At the moment this means that I have at top level a statement like using PyPlot, which takes quite a load of time to load.
(Yes i know: One should not restart Julia to often, bla bla bla... but nevertheless this is a point of annoyance)
Is there a way to ensure that PyPlot is only loaded is if is actually needed?
The simplest idea would have been to include the using PyPlot inside the function that actually do the plotting
function my_plot()
    using PyPlot
    plot(1:10,1:10)
end

but this results in a syntax error:
ERROR: syntax: "using" expression not at top level

So, is there another way to achieve this?

A: The "using" statement runs when the line of code is encountered, and does not have to be at the top of the file.  It does need to be in global scope, which means that the variables in the module loaded with "using" will be available to all functions in your program after the "using" statement is executed, not just a single function as might happen in the local scope of a function.
If you call the using statement as an expression within a Julia eval statement, all code executed within the "eval" statement in Julia is automatically done so in global scope, even if the eval is syntactically called within a function's local scope. So if you use the macro @eval
function my_plot()
    @eval using PyPlot  # or without the macro, as eval(:(using PyPlot))
    plot(1:10,1:10)
end

this acts as if the using PyPlot is done outside a function, and so avoids the syntax error.


text:
Q: Create nested object from flat array I currently have an array of objects which I'm trying to reshape into a nested object with the ID as an object key, and target that ID with the parent id if it's not "0". I've tried several approaches but I'm struggling big time! The main stumbling block for me is anything beyond one or two layers deep. Ideally I need this to be dynamic so it can handle potentially any depth although in the wild I doubt it will go beyond 3 layers.
Here is the incoming array of objects:
[

  {
    ID: "1671",
    parent: "0",
  },
  {
    ID: "1223",
    parent: "0",
  },
  {
    ID: "1668",
    parent: "0",
  },
  {
    ID: "1688",
    parent: "0",
  },
  {
    ID: "1669",
    parent: "0",
  },
  {
    ID: "1681",
    parent: "1669",
  },
  {
    ID: "1680",
    parent: "1669",
  },
  {
    ID: "1670",
    parent: "1669",
  },
  {
    ID: "1682",
    parent: "1669",
  },
  {
    ID: "1433",
    parent: "1682",
  },
  {
    ID: "1684",
    parent: "1682",
  },
  {
    ID: "1672",
    parent: "1684",
  },
  {
    ID: "1685",
    parent: "1672",
  },
  {
    ID: "1686",
    parent: "1672",
  },
  {
    ID: "1683",
    parent: "0",
  },
  {
    ID: "1230",
    parent: "0",
  },
  {
    ID: "1667",
    parent: "0",
  },
  {
    ID: "1687",
    parent: "0",
  }
];

And here is the desired transformation:
1671: {
    ID: "1671",
    parent: "0",
  },
  1223: {
    ID: "1223",
    parent: "0",
  },
  1668: {
    ID: "1668",
    parent: "0",
  },
  1688: {
    ID: "1688",
    parent: "0",
  },
  1669: {
    ID: "1669",
    parent: "0",
    children: {
      1681: {
        ID: "1681",
        parent: "1669",
      },
      1680: {
        ID: "1680",
        parent: "1669",
      },
      1670: {
        ID: "1670",
        parent: "1669",
      },
      1682: {
        ID: "1682",
        parent: "1669",
        children: {
          1433: {
            ID: "1433",
            parent: "1682",
          },
          1684: {
            ID: "1684",
            parent: "1682",
            children: {
              1672: {
                ID: "1672",
                parent: "1684",
                children: {
                  1685: {
                    ID: "1685",
                    parent: "1672",
                  },
                  1686: {
                    ID: "1686",
                    parent: "1672",
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  1683: {
    ID: "1683",
    parent: "0",
  },
  1230: {
    ID: "1230",
    parent: "0",
  },
  1667: {
    ID: "1667",
    parent: "0",
  },
  1687: {
    ID: "1687",
    parent: "0",
  }

Most of my failed approaches have been using Array.reduce() and other types of recursion but to no avail, so I'm interested to see if there is a solution for this.
Thanks

A: You can use recursive function like this:
function findFor(parentId) {
  // create a new object to store the result
  var z = {};

  // for each item in a
  for (var i = 0; i<a.length; i++){

    // find all children of parentId
    if (a[i].parent === parentId) {

      // recursively find children for each children of parentId
      var ch = findFor(a[i].ID);

      // if it has no children, skip adding the children prop
      var o = Object.keys(ch).length === 0 ? {} : { children: ch };
      z[a[i].ID] = Object.assign(o, a[i]);
    }
  }

  return z;
}

// find all item whose parent is "0"
console.log(findFor("0"));

var a = [
  { ID: "1671", parent: "0", },
  { ID: "1223", parent: "0", },
  { ID: "1668", parent: "0", },
  { ID: "1688", parent: "0", },
  { ID: "1669", parent: "0", },
  { ID: "1681", parent: "1669", },
  { ID: "1680", parent: "1669", },
  { ID: "1670", parent: "1669", },
  { ID: "1682", parent: "1669", },
  { ID: "1433", parent: "1682", },
  { ID: "1684", parent: "1682", },
  { ID: "1672", parent: "1684", },
  { ID: "1685", parent: "1672", },
  { ID: "1686", parent: "1672", },
  { ID: "1683", parent: "0", },
  { ID: "1230", parent: "0", },
  { ID: "1667", parent: "0", },
  { ID: "1687", parent: "0", }
];

function findFor(parentId) {
  var z = {};
  for (var i = 0; i<a.length; i++){
    if (a[i].parent === parentId) {
      var ch = findFor(a[i].ID);
      var o = Object.keys(ch).length === 0 ? {} : { children: ch };
      z[a[i].ID] = Object.assign(o, a[i]);
    }
  }

  return z;
}

console.log(findFor("0"));

A: A single loop non recursive approach by respecting the parents.

var flat = [{ ID: "1671", parent: "0" }, { ID: "1223", parent: "0" }, { ID: "1668", parent: "0" }, { ID: "1688", parent: "0" }, { ID: "1669", parent: "0" }, { ID: "1681", parent: "1669" }, { ID: "1680", parent: "1669" }, { ID: "1670", parent: "1669" }, { ID: "1682", parent: "1669" }, { ID: "1433", parent: "1682" }, { ID: "1684", parent: "1682" }, { ID: "1672", parent: "1684" }, { ID: "1685", parent: "1672" }, { ID: "1686", parent: "1672" }, { ID: "1683", parent: "0" }, { ID: "1230", parent: "0" }, { ID: "1667", parent: "0" }, { ID: "1687", parent: "0" }],
    tree = function (data, root) {
        var o = {};
        data.forEach(function(a) {
            a = Object.assign({}, a);
            if (o[a.ID] && o[a.ID].children) {
                a.children = o[a.ID].children;
            }
            o[a.ID] = { [a.ID]: a };
            o[a.parent] = o[a.parent] || {};
            o[a.parent][a.parent] = o[a.parent][a.parent] || {};
            o[a.parent][a.parent].children = o[a.parent][a.parent].children || {};
            o[a.parent][a.parent].children[a.ID] = a;
        });
        return o[root][root].children;
    }(flat, '0');

console.log(tree);
.as-console-wrapper { max-height: 100% !important; top: 0; }


text:
Q: Possible to run Wine / CrossOver / PlayOnLinux in parallel? Is it possible to run Wine, CrossOver and PlayOnLinux in parallel? I'm testing all three in order to:

*

*See which applications run better on which platform

*Which of these is easier to use for non-technical users

An unrelated question: it looks like there is a "meta-package" for Wine on Ubuntu that includes multiple Wine packages - is it similar for CrossOver / PlayOnLinux?

A: The answer is yes. Also, using them at the same time may be necessary in order to be able to run certain programs.
All three are in fact based on Wine.
Playonlinux installs wine whether this is already installed or not. In fact, one of its most interesting features is that it can install and use different versions of wine for different programs and program versions, and in this way cope with version regressions. The corresponding Wine program is automatically downloaded and used, or it can be selected by the user who knows what he's doing. Playonlinux also installs Winetricks to run wine scripts.
Wine installs in ~/.wine. Playonlinux installs in ~/.PlayOnLinux/wineprefix/. But running wine from menus after it was installed by playonlinux would create the ~/.wine folder. From this point of view using Playonlinux already involves in a way using Wine as a separate program. There is no point really in installing Wine after installing playonlinux. Playonlinux installs Wine, which then can be then used from playonlinux or separately.
For example, I have installed ImgBurn in Playonlinux, but then went to menus, wine, and installed foobar2000 there just to test and this player now is available from wine but not from playonlinux. But programs like Foobar2000 and ImgBurn are easily installed in all of the three options. Others, like msoffice, especially older versions, are a different matter.
Playonlinux is a GUI, but also a program with supplementary specific features. It seems made for games, but I cannot tell whether it is really better then crossover, for example, in dealing with games.
Crossover has impressed me greatly, but it still may lack some features offered by playonlinux, so having both makes sense. The big advantage with crossover is in the way it facilitates the installation of programs that are difficult to put to work in Wine and playonlinux, like older versions of msoffice. It installs in ~/.cxoffice. I have not tested it enough but I believe it to be indeed a superior program. (While I was not able to install msofficexp in the other two, in Crossover it was very easy to do.)
For many small programs it makes little sense having all these three programs at the same time. But for certain special cases like msoffice (which i tested) or games (which i didn't test), and I guess for bigger and complex programs in general crossover and playonlinux may be necessary, so that one could be .
After you test them please report here your conclusions.

Update: I was able to install Kindle for PC in Crossover, but it would not run. In Playonlinux, Kindle for PC is registered in the list of software that can be selected for installation; after selecting it, a specific Wine version 1.4 was installed and the application was able to run. This is a good example how PlayOnLinux is very necessary.


text:
Q: "object = this" in java I'm familiar with the 'this' keyword used in java, it is used to reference the current object. The following piece of code shows how a node of a LinkedList is created:
class Node {
    Node next = null;
    int data;

    public Node(int d) {
        data = d;
    }

    void appendToTail(int d) {
        Node end = new Node(d);
        Node n = this;
        while (n.next != null) {
            n = n.next;
        }
        n.next = end;
    }
}

But here I'm not sure what the following line in the above code states:
Node n = this;

I'm pretty sure that 'this' here is referenced to the current object, but is this object head, tail or any other node in the LinkedList? Not sure if my question makes perfect sense, but any help is greatly appreciated.

A:
I'm pretty sure that 'this' here is referenced to the current object

Yup.

but is this object head, tail or any other node in the LinkedList?

That depends where the method was called from or if the list contains this Node at all.
All the method does is assign a temporary reference to the current Node so it can be iterated over. You can't say which Node it is without more information.

From comments - If you call appendToTail() on the head, this will be the head. If you call it on the tail, this will be the tail. If you call it on a middle node, this will be that middle node.

A: I assume the appendToTail(int d) method appends the newly created node to the end of the list regardless of which Node its called from.
What happens is that one must find the end of the list in order to append the new Node to the end of it. Since we know that the node it is called from is in the list, it's an ideal starting point. Hence we choose the starting point as "this" node. But, this node is not necessarily the end of the list (in fact, it can be anywhere in the list), so we store it in a temporary variable Node n = this and continue changing our temporary variable until its the last node in the list, to which the new node can be added.
It's equivalent to starting from a random point (this) in a list and moving from that point to the end, wherever that is.
Hope this answered your question.


text:
Q: How to use nose's assert_raises? I've searched for documentation, but couldn't find any. There were a couple that didn't explain much.
Can someone explain to me Nose's
assert_raises(what should I put here?)

function and how to use it?

A: While the accepted answer is correct, I think there is a better use to assert_raises method.
If you simply want to assert that an exception occurs, it's probably simpler and cleaner to use @raises syntax.
@raises(HTTPError)
def test_exception_is_raised:
    call_your_method(p1, p2)

However, assume you want to do bit more with the raised exception, for example: we need to assert that raised HTTPError is of type 401: Unauthorized, instead of 500: Server Error.
In such a situation above syntax is not that helpful, we should use the assert_raises but in a different way.
If we do not pass it a callable as the second parameter assert_raises will return back a context which we can use to further test the exception details.
def test_exception_is_raised:
    with assert_raises(HTTPError) as cm:
         call_your_method(p1, p2)
    ex = cm.exception # raised exception is available through exception property of context
    ok_(ex.code == 401, 'HTTPError should be Unauthorized!')

A: The assert_raises() function tests to make sure a function call raises a specified exception when presented with certain parameters.
For example, if you had a function add that adds two numbers, it should probably raise a TypeError when you pass it, say, an integer and a string.  So:
from nose.tools import assert_raises

def add(x, y):
    return x + y

assert_raises(TypeError, add, 2, "0")

The first argument is the exception type you expect. The second is the function to call. The rest of the arguments will be passed to the function (in this case, they will become x and y inside the function).
If the expected exception is raised by the function, the assertion passes.


text:
Q: Update php variable on change multiple inputboxes For a school project i have to build an website this website works with an API it collects data from the cloud ERP system. The query what is being send to the API needs to be updated when an input box changes.
<?php
  $genre = "*";
  $zaal = "*";
?>

For now i have set the variables i need to a wildcard(*) when a wildcard i deliverd to the API it does not matter what the value is. so a wildcard needs to be the default value.
<form class="w3-container">

    Genre:

    <select class="w3-input" name="genre" id="genre">
      <option value="*" selected >Geen voorkeur</option>
      <option value="Cabaret">Cabaret</option>
      <option value="Circus">Circus</option>
    </select>

    Zaal:

    <select class="w3-input" name="zaal" id="zaal">
      <option value="*" selected >Geen voorkeur</option>
      <option value="Grote zaal">Grote zaal (900 zitplaatsen)</option>
      <option value="Philipszaal">Philipszaal (500 zitplaatsen)</option>
      <option value="Kameleon">Kameleon (120 zitplaatsen)</option>
    </select>

</form>
<?php
  echo $api-data = file_get_contents("https://<mycompany>.yesplan.nl/api/events/date%3A%23nextyear%20location%3A".$zaal."%20profile%3A".$genre."?api_key=<mycompanyapikey>");
?>

I want that these variables change when the input changes how do i manage that?
These code is just a small part from the real site. the site is still in development if you want to see te page in action have a look over here if you head over to "adviesnavigator" you will see the sector it's all about. on the left te form which needs to be auto updated and on the right the page where the data needs to be from the API. Note: this data still needs to be filterd out to show the user only what they need to see!!!!

A: You can only do that by using a ajax call because you cannot reassign a php variable once the page is load.
What you can do it you can make a ajax call can then fetch the data


text:
Q: Using javafxpackager for non-JavaFX2 application I have a Java application consisting of several prebuild JAR files and I need to deploy them for different platforms. I recently discovered javafxpackager which is able to create native installers/binaries for Windows, Mac and Linux for a JavaFX2 apps. Since my app is prebuild and doesn't use JavaFX2 it I didn't get the packager to work with my app.
Does anyone have some experience with this and can help? Or is there another tool which provides the functionality of javafxpackagerfor non-JavaFX2 applications?

A: You can do this.

*

*Build your app into jars as you are currently doing.

*Run the javafxpackager with the -createjar switch to create a new jar based on your existing jar.  The new jar will include manifest entries which allow you to run the jar using java -jar app.jar.

*Run the javafxpackager again with -deploy and -native switches to package the jar and java runtime as a native application with installer (a self-contained application).

The important commands are these:
echo make an executable jar file
$JAVA_HOME/bin/javafxpackager -createjar -srcdir . -appclass start.HelloWorldSwing -srcfiles HelloWorldSwing.jar -noembedlauncher -outdir . -outfile HelloWorld.jar

echo package the jar and java runtime as a native application with installer
$JAVA_HOME/bin/javafxpackager -deploy -srcdir . -srcfiles HelloWorld.jar -outdir . -outfile HelloWorld -appclass start.HelloWorldSwing -native -name HelloWorld

Here is a complete OS X script you can use to build a java application, create a native application package for it, install the native package and run the installed application.  The script uses javafxpackager to create the native application package.  The installed application is a Swing application which does not use JavaFX (just to demonstrate that javafxpackager doesn't need to work only with JavaFX code).  Also the javafxpackager command in the script makes use of a jar previously created with the jar command to show that javafxpackager does not need to work on raw class files, but can take as input a jar previously built with some other toolchain.
You can create packages for other operating systems and packaging formats, e.g. Windows Apps and Linux RPM or DEB packages.  See the javafxpackager documentation for details of how to customize installs for each OS.  If you use the command line javafxpackager tool, then you will need to create packaging shell scripts for each of your target operating systems.  If you use the javafx ant packaging tasks, then you can use the same packaging ant script across operating systems.  Look at the source for the javafx samples such as Ensemble or SwingInterop for examples on using the ant packaging tasks to build native bundles.
To build windows installers you need to install additional freeware software on your machine as outlined in the javafxpackager documentation.  To build rpms you will need the rpmbuild packaging utilities installed on your machine.  Currently it is not possible to build native packages for all OSes from a single machine (you can only build the native packages which are specific to that machine type).

Remember that javafxpackager native packages are just one of many Java application deployment options.  Others include webstart, executable jar files, 3rd party packaging options and browser embedded applications.  Choose the option which is most appropriate to your application, users, development skill and complexity comfort level.

An alternate toolchain I have used in the past with excellent success for native packages of unix software (especially for server side applications for enterprises), is maven with the rpm maven plugin builds created using jenkins deploying to a nexus repository with the nexus yum plugin.  This toolchain allows you to go from code checkin to a set of deployable packages with yum dependency management.  This alternate toolset does require a bit of sophistication to use though and doesn't cover the range of platforms that javafxpackager does.

A: I have a working JavaFX 2 app and I use JavaFX Ant Tasks (http://docs.oracle.com/javafx/2/deployment/javafx_ant_task_reference.htm#CIADCBJG) to create an application bundle for Mac OS X.  I know that JavaFX Ant Tasks isn't exactly the same as JavaFX Packager tool, but they're quite similar in terms of the functionality they provide.
I changed the main application class of my JavaFX 2 app to not use any JavaFX stuff and just pop up a Window using AWT.
import java.awt.*;
public class MainApplication {
    public static void main(String [] args) {
        Frame f = new Frame("Example 1");
        f.show();
    }
}

I then run the Ant build script (unaltered) again to create a new application bundle.
The new application bundle can be launched on Mac without a problem.
So I think you might be able to use javafxpackager for non-JavaFX2 apps, at least Java AWT-based apps.


text:
Q: How to redistributes hours in monthly report into a table with XSLT I have an XML report with hourly values in a row. I'd like to redistribute those values this way:
 - One column per hour
 - One row per day
What would be the basis of an XSL that would redistribute those values?
Here is a snipet of the XML file:
<?xml version="1.0" encoding="UTF-8"?>
<Report >
    <Heading>
        <General_information>
            <Date Execution="2016-05-20 22:15:00+02:00" Begin="2012-04-01 00:00:00+02:00" End="2012-05-01 00:00:00+02:00" TimeOffset="+02:00" DST="-1"/>
            <Calculation_description>Monthly-hourly report</Calculation_description>
        </General_information>
    </Heading>
    <Results_list Repetition="3600" >
        Hour
        <Result_line Number="2" Epoch="1333234800" Date="2012-04-01 01:00:00+02:00">
            <Line_name>2012-04-01 01:00:00+02:00</Line_name>
            <Val> </Val>
        </Result_line>
    ...
        <Result_line Number="476" Epoch="1334941200" Date="2012-04-20 19:00:00+02:00">
            <Line_name>2012-04-20 19:00:00+02:00</Line_name>
            <Val >13.16</Val>
        </Result_line>
        <Result_line Number="477" Epoch="1334944800" Date="2012-04-20 20:00:00+02:00">
            <Line_name>2012-04-20 20:00:00+02:00</Line_name>
            <Val >15.93</Val>
        </Result_line>
    ...
        <Result_line Number="720" Epoch="1335819600" Date="2012-04-30 23:00:00+02:00">
            <Line_name>2012-04-30 23:00:00+02:00</Line_name>
            <Val>25.52</Val>
        </Result_line>
        <Result_line Number="721" Epoch="1335823200" Date="2012-05-01 00:00:00+02:00">
            <Line_name>2012-05-01 00:00:00+02:00</Line_name>
            <Val >38.52</Val>
        </Result_line>
    </Results_list>
</Report>

I was thinking on basing a solution either on the Result_line/@Number attribute modulus 24 or on a Result_line/@Date attribute substring. But I only master for-each loops that I suspect to be a bad solution.
Off course I would add Header and Dates columns at a later stage.
For the moment I know to use XSLT 1.0.
Thanks

A: If your table is regular, and each date starts on hour = 2  and has exactly 24 hours, listed in order, you could do something quite simple as:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="utf-8" indent="yes"/>

<xsl:template match="/Report">

                <xsl:for-each select="Results_list/Result_line[position() < 24]">

                        <xsl:value-of select="@Number"/>

                </xsl:for-each>

            <xsl:for-each select="Results_list/Result_line[@Number mod 24 = 2]">

                        <xsl:value-of select="substring-before(@Date, ' ')"/>

                    <xsl:for-each select=". | following-sibling::Result_line[position() < 23]">

                            <xsl:value-of select="Val"/>

                    </xsl:for-each>

            </xsl:for-each>

</xsl:template>

</xsl:stylesheet>

However, this will fail if a date is allowed to have 23 or 25 hours.

Alternatively, you could group the lines by date, using Muenchian grouping, and generate a cell for each line in the date's row:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="utf-8" indent="yes"/>

<xsl:key name="line-by-date" match="Result_line" use="substring-before(@Date, ' ')" />

<xsl:template match="/Report">

        <xsl:for-each select="Results_list/Result_line[count(. | key('line-by-date', substring-before(@Date, ' '))[1]) = 1]">
            <xsl:variable name="date" select="substring-before(@Date, ' ')" />

                        <xsl:value-of select="$date"/>

                    <xsl:for-each select="key('line-by-date', $date)">

                            <xsl:value-of select="Val"/>

                    </xsl:for-each>

        </xsl:for-each>

</xsl:template>

</xsl:stylesheet>

I did not include a table header here, because I don't know what it should show.


text:
Q: Xamarin Android jQuery AJAX doesn't work in Release Mode I have an app for Android in Xamarin. I have a HTML page in my WebView and I use AJAX for requests. In debug mode it works perfect but in release mode it gives error.
$.ajax({
   type: "POST",
   url: 'http://****.com',
   data: data,
   contentType: "application/json; charset=utf-8",
   dataType: "json",
   success: function(data, status) {
      alert('success')
   },
   error: function(xmlRequest) {
      alert('error')
   }
});

Here is my webview code:
 WebView app_view = null;
 WebSettings app_web_settings = null;

protected override void OnCreate(Bundle savedInstanceState)
{
   base.OnCreate(savedInstanceState);
   // Set our view from the "main" layout resource
   SetContentView(Resource.Layout.Main);

   app_view = FindViewById(Resource.Id.webViewApp) as WebView;
   app_web_settings = app_view.Settings;
   app_web_settings.JavaScriptEnabled = true;
   app_web_settings.AllowUniversalAccessFromFileURLs = true;
   app_web_settings.DomStorageEnabled = true;
   app_web_settings.DatabaseEnabled = true;
   app_web_settings.SetRenderPriority(WebSettings.RenderPriority.High);
   app_view.SetLayerType(LayerType.Hardware, null);
   my_web_client = new MyWebViewClient(this);
   web_client = new WebChromeClient();
   app_view.SetWebViewClient(my_web_client);
   app_view.SetWebChromeClient(web_client);

  string app_url = "file:///android_asset/app_pages/home.html";
  app_view.LoadUrl(app_url);
  app_view.AddJavascriptInterface(new Foo(this), "foo");
}

A: I changed my ajax request and I use jsonp method. It works successfull in release mode.
 $.ajax({
        crossDomain: true,
        contentType: "application/json; charset=utf-8",
        url: 'http://****.com',
        data: data,
        dataType: "jsonp",
        success: function(data, status) {
          alert('success')
        },
        error: function(xmlRequest) {
          alert('error')
        }
      });


text:
Q: Google app engine php zip extension I am using Google app engine and I want to create a zip archive using the zip extension which is supported in the current version. The problem is that every time i call ZipArchive::close it returns false and ZipArchive::getStatusString returns "Failure to create temporary file: Read-only file system". I am creating the zip file in the cloud storage like this:
$zip = new ZipArchive();
$zip->open("gs://whatever/somethig.zip", ZipArchive::OVERWRITE); //returns true
$zip->addFromString('file.txt', "some random data"); //returns true
$zip->numFiles; // = 1
$zip->close(); // returns false
$zip->getStatusString(); //returns Failure to create temporary file: Read-only file system

and it should be writable, it actually is with file_set_content or whatever. I tried the same code with a couple of variations:

*

*already existing zip file;

*not existing zip file;

*ZipArchive::CREATE as a second parameter of the ZipArchive::open call

*Using ZipArchive::addFile to add the file from cloud storage

Maybe it tries to create a temporary file on some other place not on the cloud storage, but this thing that i'm doing is very common scenario and i doubt that this is an app engine bug, after all they claim that they support the zip extension here.
Does someone have some idea what can be the problem?
Thank you.

A: Looks like a bug - can you open an issue in the issue tracker?


text:
Q: Why won't the Javascript in my script tags work? I learning javascript, and practicing with event handlers.
I've written the correct code (Im sure...) to make an mp3 play when a button (button1) is clicked.
I tried putting the code in the beginning.
I've tested to see if I typed in the right path for the mp3.
I've tried deleting the sort of irrelevent 2 lines of event handlers in the middle of the script.
I don't know what is going on! Can someone help?

<button id="button1" onclick="playMusic()">MUSIC</button>
<button id="button2">VIDEOS</button>
<button id="button3">PICTURES</button>

<button id="button4">BRAIN GAMES</button>
<button id="button5">TALK TO FAMILY
</button>
<button id="button6">STORIES</button>

A: You need to escape the backslashes - \ will break your file paths. Change \ to \\, and it should work. Keep in mind that JavaScript can't normally access the local file system like this though.
TALK TO FAMILY

JS:
var music = new Audio("C:\Users\\sared\\Documents\\baccara.mp3");


text:
Q: using if statement in mysql query I would like to use if statement in sql query :
what I want :
if(tractions_delivery.send_date_id !=0 ){

           date_send_commodities.id  = tractions_delivery.send_date_id
}

my query :
        from

            tractions_delivery,user_address,province,city,date_send_commodities,users

        WHERE

        tractions_delivery.tr_id = $tr_id
        AND
        tractions_delivery.address_id = user_address.id
        AND
        user_address.province_id = province.id
        AND
        user_address.city_id      = city.id
        AND
        //not work
        (tractions_delivery.send_date_id IS NOT 0 date_send_commodities.id  = tractions_delivery.send_date_id)

        AND
        users.id = user_address.user_id

A: You can only use if statements in stored procedures or functions. If you just write a sql statement unfortunately you cannot use if statements around the query. But you can use logic in the query itself, e.g.:
SELECT CASE WHEN col1 = col2 THEN'col1 equals col2' else 'col1 doesnt equal col2' ELSE
FROM table1

So around doesnt work, but in the field list you can create CASE WHEN ELSE END logic.

A: CASE or IF() operators can be of help.
Examples,
SELECT (CASE 1 WHEN 1 THEN 'One' WHEN 2 THEN 'Two' ELSE 'More' END) 'Result';

OR
SELECT IF(1=1, 'One', 'Two') 'Result';

These CASE and IF() operators can be used in the SELECT clause to conditionally interpret column values and return in the resultset.
Note: Do not confuse CASE operator here with 'CASE conditional syntax block' that ends with END CASE.

A: You could use the CASE-statement
SELECT
*
FROM
 tractions_delivery,
 user_address,
 province,
 city,
 date_send_commodities,users
WHERE
 tractions_delivery.tr_id = $tr_id AND
 tractions_delivery.address_id = user_address.id AND
 user_address.province_id = province.id AND
 user_address.city_id = city.id AND
 CASE WHEN tractions_delivery.send_date_id != 0 THEN date_send_commodities.id = tractions_delivery.send_date_id ELSE 1=1 END AND
 users.id = user_address.user_id


text:
Q: error C2440: 'initializing' : cannot convert from 'std::vector<_Ty>' to 'const std::vector<_Ty> &` Question1> Why the following code doesn't work?
Question2> What is the correct way to design it?
#include <iostream>
#include <vector>
#include "boost/shared_ptr.hpp"

using namespace std;

class BaseClass
{};

class SubClass : public BaseClass
{};

int main()
{
    std::vector<boost::shared_ptr<SubClass> > vecSubClassShared;

    boost::shared_ptr<SubClass> sub1(new SubClass);

    vecSubClassShared.push_back(sub1);

    // Error    1   error C2440: 'initializing' : cannot convert from 'std::vector<_Ty>' to 'const std::vector<_Ty> &`
    const std::vector<boost::shared_ptr<BaseClass> >& vecBaseShared = vecSubClassShared;
}

A: In the view of the C++ compiler, shared_ptr<BaseClass> and shared_ptr<DerivedClass> are different, unrelated types. While the compiler knows, that normal Pointers can be converted from Derived* to Base*, it does not know that conceptually the same should apply for shared_ptrs, because it does not know "smart pointers" being pointer-like.
The same applies for vector or for templates in general: two instantiations of a template are two different class, with no relation betwen them (if not designed explicitly). So the compiler sees a vector<Something> bound to a reference to a vector<SomethingElse> which are not related types, so the reference binding fails.
But even if the types were somehow related, the binding would fail:
long l = 5;
int& ir = l; //ERROR

A: shared_ptr<BaseClass> and shared_ptr<SubClass> are distinct, unrelated types, so there's no way for a vector of one to alias a vector of the other, because there's no guarantee that their object layout is the same.
This means that to e.g. pass const std::vector<boost::shared_ptr<BaseClass> >& to a function you'll have to construct a temporary vector of the desired type.  You can however do this without incrementing the reference counts on the shared pointers, using shared pointer aliasing:
#include <vector>
#include <memory>

struct B {};
struct D: public B {};

template<typename T, typename U>
std::vector<std::shared_ptr<T>> shared_vector_static_cast(
   const std::vector<std::shared_ptr<U>> &v)
{
   std::vector<std::shared_ptr<T>> w;
   for (const std::shared_ptr<U> &p: v)
      w.push_back(std::shared_ptr<T>(std::shared_ptr<void>(), p.get()));
   return w;
}

int main() {
    std::vector<std::shared_ptr<D>> v{std::make_shared<D>()};
    const std::vector<std::shared_ptr<B>> &w = shared_vector_static_cast<B>(v);
}


text:
Q: Displaying text from another activity on a TextView I am trying to use putExtra() and getExtra() to send String Data from one activity to another, such that the retrieved string is to be displayed on a TextView and when running.
When i run the program i get a classCastException on onCreate() method.
I am new to android so any assistance will be appreciated.
Here is my sample code:
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sales);

    //TextView
    TextView model1 = (TextView)findViewById(R.id.model1);
    TextView model2 = (TextView)findViewById(R.id.model2);
    TextView model3 = (TextView)findViewById(R.id.model3);

    //Bundle
    Bundle bundle = getIntent().getExtras();
    String Mod1 = bundle.getString("model1");
    String Mod2 = bundle.getString("model2");
    String Mod3 = bundle.getString("model3");

//setting values
model1.setText(Mod1);
model2.setText(Mod2);
model3.setText(Mod3);
   }

A: Your widgets model1,model2,model3 are either not TextView or you do not pass strings to the intent that you pass to the new Activity. Also you could try to clean your projects, maybe your R.java file is messed up. You could also paste the LogCat or tell us which is the line that gives you the ClassCastException.


text:
Q: Can this code be done in less steps? I have a problem with thinking something is much more difficult than it really is.  So I was just wondering if there is a shorter way of writing my code. Basically just want to let a user know how hot || cold they are but felt like I did it in way too many lines of code. And is Math.abs() the easiest way to convert every number to a positive? Any insight will be greatly appreciated.
$("#guessButton").click(function(e) {
        e.preventDefault();
        counter++;
        $('#count').text(counter);
        var guess = $('#userGuess').val();
        if (guess == number) {
            $('#feedback').text("You've guessed the number!!");
            $('#guessList').append("
"+guess+"
");
        } else if (Math.abs(number-guess) <= 50 && Math.abs(number-guess) >= 30) {
            $('#feedback').text("Cold");
            $('#guessList').append("
"+guess+"
");
        } else if (Math.abs(number-guess) <= 30 && Math.abs(number-guess) >= 20) {
            $('#feedback').text("Warm");
            $('#guessList').append("
"+guess+"
");
        } else if (Math.abs(number-guess) <= 20 && Math.abs(number-guess) >= 10) {
            $('#feedback').text("Hot");
            $('#guessList').append("
"+guess+"
");
        } else if (Math.abs(number-guess) <= 10 && Math.abs(number-guess) >= 1) {
            $('#feedback').text("Very Hot");
            $('#guessList').append("
"+guess+"
");
        } else if (Math.abs(number-guess) > 50) {
            $('#feedback').text("Ice Cold");
            $('#guessList').append("
"+guess+"
");
        }
    });

A: Here's a quick response to your question that I think might help. I made a few assumptions about global variables but should help for the most part I hope.
$("#guessButton").click(function(e) {
    e.preventDefault();
    counter++; //ill assume this is global
    $('#count').text(counter);

    var feedBack;
    var guess = $('#userGuess').val();
    var absVal = Math.abs(number-guess); //ill assume number is global

    if (guess == number) {
        feedBack = "You've guessed the number!!";

    }else if (absVal > 50) {
        feedBack = "Ice Cold";

    }else if (absVal >= 30) {
        feedBack = "Cold";

    } else if (absVal >= 20) {
        feedBack = "Warm";

    } else if (absVal >= 10) {
        feedBack = "Hot";

    } else if (absVal >= 1) {
        feedBack = "Very Hot";

    }

    $('#feedback').text(feedBack);
    $('#guessList').append("
"+guess+"
");
});


text:
Q: Woocommerce API Error 100 Invalid JSON Returned I'm loading product information automatically through the woocommerce V2 product api.  It works fine for the most part, but the odd time I will get a "100" "Invalid JSON Returned" even on identical calls.
Its intermittent and it doesn't provide any more information then that.  I've checked the JSON args and they are identical to ones that work.  I've validated the JSON syntax, no issues.  If I run the same thing again, sometimes it loads without that error.
Not sure if anyone has seen this before and can provide insight?

A: For all intents and purposes this error seems to be directly related to a time out during the load.  It will continue if you are running API calls through a loop.  If you keep track of items not updated, just try again.   Like I said in my comment above, try and keep your actual call as lean as possible.  Lots of images can bog it down, especially if you have image processing plugins smushing stuff etc.

A: I fixed it by disabling the "New Images Optimisation" on the SG Optimiser plug in


text:
Q: What does "@Override" and " extends Page>" mean? @Override
public Class< ? extends Page> getHomePage() {
            return HomePage.class;
}

public Class<HomePage> getHomePage(){
        return HomePage.class;
}

The first one has an annotation
    Override. What does that mean or
    what does it send to the framework.
Will both the methods return the same class. I mean what does this mean  ? extends Page. I mean the ? Mark.

A: JavaDoc

A: @Override—

the @Override annotation informs the compiler that the element is meant to override an element declared in a superclass (overriding methods will be discussed in the the lesson titled "Interfaces and Inheritance").

Also See

*

*Javadoc

*when-do-you-use-javas-override-annotation-and-why

A: And to the second question: a wildcard.
Both methods will return the same object (the Class instance representing HomePage), but they are declared in different ways, allowing the wild-carded version to be used by methods that don't care what kind of Page you have, as long as it's a subclass of Page.

A: 1) Override Annotation
Javadoc : Indicates that a method declaration is intended to override a method declaration in a superclass. If a method is annotated with this annotation type but does not override a superclass method, compilers are required to generate an error message.
2) ? means any. for example :  < ? > means any java data type can be here
< ? extends Page > means any subclass of Page is allowed here.


text:
Q: Whay my Enum property be changed in http-response? I have a web-service and have this code:
roomStay = new RoomStay
            {
                PlaceType = stay.hotelInfo.propertyType,
                GeneralDescription = GenerateGeneralDescription(stay.hotelInfo).Result,
                IsRefundableRoom = !stay.nonRefundable,
                ProviderType = Supplier.BetterBooking,
                BasicPropertyInfo = new BasicPropertyInfo
                {
                    SupplierCode = stay.hotelInfo?.hotelName + stay.hotelInfo?.areaName
                                                          ,
                    Images = imageList,
                    NewImages = newImageList.ToArray()
                                                          ,
                    Address = $"{area + address + city + countryName  }" //$"{hotelStaticDataResult.hotelInfo?.address?.countryName} {hotelStaticDataResult.hotelInfo?.address?.cityName} {string.Join(" ", hotelStaticDataResult.hotelInfo?.address?.addressLines.ToArray())}"
                                                          ,
                    City = ""//cityName
                                                          ,
                    Name = stay.hotelInfo.hotelName
                                                          ,
                    Facilities = new List<FacilityCategory>()//facilitieList
                                                            ,
                    Longitude = longitude//hotelStaticDataResult.hotelInfo?.position.longitude
                                                            ,
                    Latitude = latitude// hotelStaticDataResult.hotelInfo?.position.latitude
                                                            ,
                    Telephone = string.Empty//hotelStaticDataResult?.hotelInfo?.contactNumbers?.Where(a => a.phoneType == "Phone").FirstOrDefault()?.phoneNumber
                                                            ,
                    Description = string.Empty,
                    TextItems = stay.hotelInfo?.textItems.Select(a => new TextItemsModelOTA()
                    {
                        Title = a.title == null || string.IsNullOrEmpty(a.title) ? string.Empty : a.title,
                        Description = a.description == null || string.IsNullOrEmpty(a.description) ? string.Empty : a.description,
                        TitleEnumType = (TitleEnumType)Utility.GetEnum<TitleEnumType>(a.title).Result
                    })//hotelStaticDataResult.hotelInfo?.textItems.ToJson()
                                                            ,
                    Code = hotelKey// searchrs.Result.transactionId + "$" + searchrs.Result.searchId + "$" + stay.stayId + "$" + stay.hotelInfo.hotelName
                                                            ,
                    RateProviderKeyValues = new List<RateProviderKeyValue>() { new RateProviderKeyValue() { Key = decimal.Parse(stay.hotelInfo.starRating.ToStringSafe()), Value = RateProvider.AAA } }.ToArray()

                },
                RoomRates = roomRate
                                                ,
            };

In the TextItem property, I have TextEnumType property that this type is enum like:
public enum TitleEnumType
    {
        Facilities = 0,
        Rooms = 1,
        Meals = 2,
        Payment = 3,
        PropertyDescription = 4,
        NumberOfRooms = 5,
        CheckInTime = 6,
        CheckOutTime = 7,
        HotelRemarks = 8,
        None = 9
    }

With tow method that are below, I get the string with GetStringForEnum(string model) method and convert to Enum using GetEnum<T>(string model) like:
public static int GetEnum<T>(string model)
    {
        var newModel = GetStringForEnum(model);

        if (!Enum.IsDefined(typeof(T), newModel))
        {
            return (int)Enum.Parse(typeof(T), "None", true);

        }

        return (int)Enum.Parse(typeof(T), newModel, true);
    }

    private static string GetStringForEnum(string model)
    {
        Regex rgx = new Regex("[^a-zA-Z0-9 -]");
        var nonAlphanumericData = rgx.Matches(model);
        if (nonAlphanumericData.Count < 0)
        {
            return model;
        }
        foreach (var item in nonAlphanumericData)
        {
            model = model.Replace((string)item, "");
        }
        return model;
    }

Note: the GetEnum<T>(string model) method generate enum as true.
After my roomStay model be generated and before send this roomStay http-response all of my data is correct. but when I receive this roomStay in my website and controller, this roomStay is not correct.
What is my problem?

A: It's because the method you are calling to get the enum is asynchronous. So at the time you return your RoomStay object the TextItems.TitleEnumType is the default of 0. Try:
public static GetEnum<T>(string model)
    {
            var newModel = GetStringForEnum(model);

            if (!Enum.IsDefined(typeof(T), newModel.Result))
            {
                var test1 = (int)Enum.Parse(typeof(T), "None", true);
                return test1;
            }

            var test = (int)Enum.Parse(typeof(T), newModel.Result, true);
            return test;
    }

    private static GetStringForEnum(string model)
    {
            Regex rgx = new Regex("[^a-zA-Z0-9 -]");
            var nonAlphanumericData = rgx.Matches(model);
            if (nonAlphanumericData.Count < 0)
            {
                return model;
            }
            foreach (var item in nonAlphanumericData)
            {
                model = model.Replace((string)item, "");
            }
            return model;
    }


text:
Q: How can i make a custom file explorer with an HTA application? I want to make a custom file explorer to go through the files and folders like you would with the normal window explorer. I want it to have the same basic function like being able to go folder to folder and back up to the previous folders and be able to open and execute files and such. How can i do this? Can anyone help get me started?

A: Are you sure HTA still runs? I thought it was killed of by various security enhancements? Assuming a HTA runs Javascript OK, here are some javascript libraries that have interactive file tree functionality:
http://john-smith-js.com/filetree.html
http://dhtmlx.com/docs/products/dhtmlxTree/
Post back if you would like to continue down this path.


text:
Q: Is decent HTTPs implementation for medium public site always a paid solution? I'm aware that for adding HTTPs to a site, one can either:

*

*buy a overpriced SSL certificate from a reputed CA like
VeriSign

*or purchase a much lower priced certificate from several
other companies

*or one could even use his/her own self signed
certificate i.e, for free.

But for a decent HTTPs implementation that is:

*

*you want most of standard browsers recognize the certificate(there shouldn't be any warnings/ errors on standard browsers)

*security is tight rather than just a false impression of secure site.

*brand name of CA is not that really important to you.

*for a public site similar to LinkedIn but smaller in scale(no financial transactions, but users profile data).

*economical pricing
Would implementing such an HTTPs always come at a price ? What is the cost effective way to implement it ? I don't want to spend hundred of dollars an year initially, when I have lower user base.

A: StartSSL offers certificates at prices based on the effort it takes to validate the data that you want to have validated, rather than based on the added value percieved by the customer. As a result, domain validated certificates are free, because validation can be fully automated. These kinds of certificates ensure that the client is talking to the domain advertised in the common name, rather than to some man-in-the-middle or some host that the domain resolves to as a result of DNS poisoning.
None of the personal information that you provide will be available in a domain validated certificate. If it would, than it would imply that the CA actually validated that information.
For a lot of sites, this is enough security. For shops, banks and other sites that require certain personal information from the client, this is clearly not enough. These sites should use certificates that not only ensure that the user communicates with the site that he wants to, but also that the site is run by the company that he wants to do business with.


text:
Q: Does one have to enclose an android logging statement in an if(DEBUG)? I was surprised to learn that one has to enclose an android logging statement in an
if(DEBUG) {
  Slog.d(...);
}

see
https://stackoverflow.com/a/2020964/398348
It is cumbersome.
In the android documentation, it seems to say that one does not have to - the
api seems similar to log4j where the log level is configured via external means using a properties file, and only logs above the log level are output.
I would have expected that the implementation of Log.d() would have the if() inside it, so that the developer does not have to enclose it.
class Log {
  void d() {
    if(DEBUG) {....}
  }
...
}

Can someone please clarify?
Note: I do not wish to use proguard as mentioned in several places.

A: I use it all the time. Really helps when you publish your application.
You really don't want all that logging printing at a production app.
By using a simple static boolean DEBUG you can easily turn debugging on and off.


text:
Q: DNS issue after domain migration So, we migrated (not me, a contractor) our old domain to a new one, we were abc.local, now we are xyz.local. We also changed the DNS server from 1.2.3.4.5 to 10.9.8.7 (just examples, not real data here)
The migration added all workstation to the new xyz.local domain with no issues, however it did not change the DNS to the new one, and the old DNS is now gone.
I tried to change them via GPO running the netsh command, but I get "the remote procedure call was cancelled" error 8007071a when I try to apply the GPO from the DC.
My account is Domain admin. I cannot remote-in to those workstations now, so I cannot change the DNS. Remember that the workstations are joined to the new domain but they have the old DNS server configured which doesn't exist anymore.
Do you guys have any idea to try with to accomplish this?
Thank you.

A: If they are getting their IPs via DHCP, ensure you include the DNS server addresses in DHCP.  Otherwise you're probably going to have to visit each machine and change their DNS server entries to the DC.
Either way, after it's changed reboot them so they are properly logged into the domain.

A: The only way to make your new domain work again from the static ip configuration of your clients is to make the DNS server available again.
This can be done by:

*

*Adding an additional IP address to the existing network interface (routing issues?)

*Second network interface in the old network 10.5.x.x (virtual/physical environment?)

*Setting up a new server with the old IP 10.5.x.x with DNS services which forwards all queries to the new DNS server 10.20.x.x

After you made DNS available for the clients again, you can change IP settings through GPO.


text:
Q: MongoDB Aggregate Subtract Java Driver 3.3 I'm using the subtract operator as in the following shell query but can't figure out how to do the subtraction in Java.
db.deviceDetail.aggregate([
    {$match: {'accountId':23, 'status':'Stopped'}},
    {'$project': {
            'durationDiff': {'$subtract': [1479093620000, '$durationDate']},
            'stopStartDiff': {'$subtract': [1479093620000, '$stopStart']},
            'stopStart': 1,
            'durationDate': 1,
            '_id':0
        }
    },
    {'$match': {$or:[{'durationDiff': {'$gt': 0}}, {'stopStartDiff': {'$gt': 0}}]}}
 ])

The Java API seems to not support the subtract operator, so how should one define the durationDiff and stopStartDiff calculations below?
AggregateIterable<Document> rslt = coll.aggregate(Arrays.asList(
                match(and(eq("assetName", "accountId"), eq("assetName", "accountId"))),
                project(fields(
                        excludeId(),
                        include(
                            "durationDiff", ...,
                            "stopStartDiff", ...,
                            "stopStart",
                            "durationDate"
                        )
                )),
                match(or(gt("durationDiff", 0), gt("stopStartDiff", 0)))
        ));

Sample document:
  {
    "_id" : ObjectId("563064a4e4b0ea032ae14f77"),
    "accountId" : NumberLong(23),
    "stopStart" : NumberLong("1460133175000"),
    "status" : "Stopped",
    "durationDate" : NumberLong("1460133175000")
}

A: You can try something like for the simple use case you've. You will have to do the same for other variable. This will calculate the durationDiff.
For 2.x Version
BasicDBList values = new BasicDBList();
values.add(1479093620000L);
values.add("$durationDate");

AggregateIterable<Document> rslt = dbCollection.aggregate(Arrays.asList(
            project(fields(
                    excludeId(),
                    include(
                            "durationDiff",
                            "durationDate"
                    ),
                    new BasicDBObject("durationDiff", new BasicDBObject("$subtract", values))
                    )
            )
    ));

For 3.x Version
Using BsonDocument - Type Safe Version
BsonArray operands = new BsonArray();
operands.add(new BsonInt64(1479093620000L));
operands.add(new BsonString("$durationDate"));

BsonDocument subtract = new BsonDocument("$subtract", operands);

AggregateIterable<BsonDocument> rslt = dbCollection.aggregate(Arrays.asList(
        project(fields(
                excludeId(),
                include(
                        "durationDiff",
                        "durationDate"
                ),
                new BsonDocument("durationDiff", subtract)
                )
        )
));

Using Document - Non Type Safe Version
AggregateIterable<Document> rslt = dbCollection.aggregate(Arrays.asList(
        project(fields(
                excludeId(),
                include(
                        "durationDiff",
                        "durationDate"
                ),
                new Document("durationDiff", new Document("$subtract", Arrays.asList(1479093620000L, "$durationDate")))
                )
        )
));


text: Q: a basic question about variable in Mathematica I can't describe exactly the problem I'm experiencing, but this kind of problem has a remarkable feature, that is, commands which couldn't work in the before can be executed correctly when i turn off the Mathematica and reopen it. Later, I know function "Clear[]", it can also solve this kind problem in the most occasions. But sometimes it's not very convenient to use Clear[] for multiple variables. I think this kind problem probably has something to do with the naming of variables and the life cycle and scope, and I want to ask 1. if there are some good habits to avoid such problems, and 2. whether there is a way to solve it other than restart Mathematica.


text:
Q: Making the Background Image of a UIView on Aspect Fit I'm working on a sort of drawing app using objective-c, and for one of my UIViews, I want there to be a background image to it. However, I want this background image on the actual UIView, not a separate UIImageView. I did that using this:
self.tempDrawImage.image = [UIImage imageNamed:@"image.jpg"];

In this code, tempDrawImage is a UIImageView I made programmatically, and after initializing it, I wrote this later in the code so that the drawings would appear on top of the image. I don't know if this is helpful, but I thought I'd include it anyway just in case it does help.
- (UIImageView *)tempDrawImage
{
    if(!_tempDrawImage) _tempDrawImage = [UIImageView new];
    return _tempDrawImage;
}

- (void)drawRect:(CGRect)rect
{
    UIGraphicsGetCurrentContext();
    [self.tempDrawImage.image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
}

Now, I'm struggling to make the image that I set to image.jpg in the beginning aspect fit. How could I do that?

A: Try this
self.tempDrawImage.contentMode = UIViewContentModeScaleAspectFit;

A: You can use UIViewContentModeScaleAspectFit
 self.tempDrawImage.contentMode = UIViewContentModeScaleAspectFit;


text:
Q: register with gatt stack failed Error BLE android Samsung I got this "register with GATT stack failed" error on Samsung S7 marshmallow. The scenario is that I am working with 21 BLE peripherals (nrf52). I scan available devices and then connect => write data => disconnect devices one by one. After trying a few times, it give me this error. If I exist the application , it is recover back. Please help!
Already Try : Write on main UI thread for all connectGatt, disconnectGatt method. I know the question is duplicate to
GATT callback fails to register on stackoverflow. But it is not working for me.
This is code
public boolean connect(final String address) {
        if (mBluetoothAdapter == null || address == null) {
            Log.w(TAG, "BluetoothAdapter not initialized or unspecified address.");
            return false;
        }

        // Previously connected device.  Try to reconnect.
        if (mBluetoothDeviceAddress != null && address.equals(mBluetoothDeviceAddress)
                && mBluetoothGatt != null) {
            Log.d(TAG, "Trying to use an existing mBluetoothGatt for connection.");
            if (mBluetoothGatt.connect()) {
                mConnectionState = STATE_CONNECTING;
                return true;
            } else {
                return false;
            }
        }

        final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
        if (device == null) {
            Log.w(TAG, "Device not found.  Unable to connect.");
            return false;
        }
        // We want to directly connect to the device, so we are setting the autoConnect
        // parameter to false.
         mBluetoothGatt = device.connectGatt( this,false, mGattCallback);

        Log.d(TAG, "Trying to create a new connection.");
        mBluetoothDeviceAddress = address;
        mConnectionState = STATE_CONNECTING;
        return true;
    }

 public void disconnect() {
        if (mBluetoothAdapter == null || mBluetoothGatt == null) {
            Log.w(TAG, "BluetoothAdapter not initialized");
            return;
        }
        Handler handler = new Handler(Looper.getMainLooper());
        handler.post(new Runnable() {
            @Override
            public void run() {
                mBluetoothGatt.disconnect();
            }
        });
    }

 public void close() {
        if (mBluetoothGatt == null) {
            return;
        }
        Log.w(TAG, "mBluetoothGatt closed");
        mBluetoothDeviceAddress = null;
        mBluetoothGatt.close();
        mBluetoothGatt = null;
    }

In my Main Activity, I used broadcast receiver
 public final BroadcastReceiver myUpdateReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
              /*
    Broadcast receiver will listen the listener respond from registered service UartService.class
     */
            final String action = intent.getAction();
            if (BluetoothConstants.ACTION_GATT_CONNECTED.equals(action)) {
                Log.d("Connected Device ", intent.getStringExtra(action) + "is connected ");

                //Connection made, here you can make a decision: do you want to initiate service discovery.
                // P.S. If you are working with multiple devices,
                // make sure that you start the service discovery
                // after all desired connections are made
                // }
            }
            if (BluetoothConstants.ACTION_GATT_DISCONNECTED.equals(action)) {
                if (filterQueue.size() != 0) {
                    mDevice = filterQueue.poll();
                    progressDlg.setMessage("Start Initiating to " + mDevice.getName());
                    progressDlg.show();
                    Handler handler = new Handler(Looper.getMainLooper());
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            mService.connect(mDevice.getAddress(), getApplicationContext());
                            scanLeDevice(false);
                        }
                    });

                } else {
                    progressDlg.cancel();
                    connectionQueue.clear();
                }
            }

            /* if uart servcie is discovered, will preload based on the appointement name,
            * Setting value will get from global variable.*/

            if (BluetoothConstants.ACTION_GATT_SERVICES_DISCOVERED.equals(action)) {
                mService.enableTXNotification();
                mDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(intent.getStringExtra(action));

                    Handler handler = new Handler(Looper.getMainLooper());
                    handler.post(new Runnable() {
                        @Override
                        public void run() {
                            mService.writeRXCharacteristic(value);
                        }
                    });
                    Log.d("Sent Value", "Sent Value");

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

            }

            // Action Data Available is thel listener which will be trigger when data is successfully send.
            if (action.equals(UartService.ACTION_DATA_AVAILABLE)) {

                        Handler handler = new Handler(Looper.getMainLooper());
                        handler.post(new Runnable() {
                            @Override
                            public void run() {
                                mService.disconnect();
                            }
                        });

                        // mService.disconnect();
                        if (filterQueue.size() == 0) {
                            progressDlg.cancel();
                            connectionQueue.clear();
                        }
                        if (txValue[0] == 0) {
                        } else {
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }

                if (action.equals(UartService.DEVICE_DOES_NOT_SUPPORT_UART)) {
                    mService.disconnect();
                    if (connectionQueue != null) {
                        connectionQueue.poll();
                    } else {
                        progressDlg.cancel();
                    }
                }
            }
        }
    };

 private ScanCallback mScanCallback = new ScanCallback() {

        @Override
        public void onScanResult(int callbackType, ScanResult result) {
   /* Connect to device found */
            Log.i("callbackType", String.valueOf(callbackType));

            BluetoothDevice device = result.getDevice();
            byte[] manufacturerData = BleUtils.getManufacturerAdvertisementData(result.getScanRecord().getBytes());

            Log.e(TAG, Arrays.toString(manufacturerData));
            if (device != null) {
                if (result.getRssi() > -92 && device != null && device.getName() != null) {
                    {
                        if (device.getName().contains("-")) {
                            mLeDeviceListAdapter.addDevice(new BleDevice(device, result.getRssi(), manufacturerData));
                            mLeDeviceListAdapter.notifyDataSetChanged();
                            onDeviceFound(device);
                        }
                    }
                } else {
                    if (mLeDeviceListAdapter != null) {
                        mLeDeviceListAdapter.clear();
                    }
                }

            } else {
                // adapter.resetColor(0);
                //writeLine("No Device Detected");
            }

        }

        @Override
        public void onBatchScanResults(List<ScanResult> results) {
   /* Process a batch scan results */
            for (ScanResult sr : results) {
                Log.i("Scan Item: ", sr.toString());
            }
        }
    };

The following is my logcat :
05-14 17:45:05.254 5018-5200/? E/BtGatt.GattService: [GSIM LOG]: gsimLogHandler: com.example.jinghu.smartmagazine, msg: MESSAGE_STOP_SCAN
05-14 17:45:05.254 5018-5182/? E/BtGatt.ScanManager: default value of curScanSetting 0 is choosen
05-14 17:45:08.064 5018-5115/? E/BluetoothRemoteDevices: aclStateChangeCallback: State:Connected to Device:F5:E8:84:5E:09:XX, linktype is 2
05-14 17:45:08.094 5018-5352/? E/bt_btif: already has a pending command!!
05-14 17:45:08.804 5018-5115/? E/bt_btif_gatt: bta_to_btif_uuid: Unknown UUID length 63201!
05-14 17:45:09.434 24160-24160/com.example.jinghu.myapp E/UartService: mBluetoothGatt nullandroid.bluetooth.BluetoothGatt@4ed0d4f
05-14 17:45:09.604 5018-5352/? E/bt_btif: Connection doesnt exist. Drop indication!
05-14 17:45:10.254 5018-5352/? E/bt_btm: btm_ble_get_search_if search_if=4
05-14 17:45:10.254 5018-5352/? E/bt_btif: bta_gattc_mark_bg_conn unable to find the bg connection mask for: f5:e8:84:5e:09:a6
05-14 17:45:10.294 5018-5352/? E/bt_btm: btm_sec_disconnected :: clear unused flags. p_dev_rec->sm4 : 0
05-14 17:45:10.304 5018-5115/? E/BluetoothRemoteDevices: aclStateChangeCallback: State:DisConnected to Device:F5:E8:84:5E:09:XX
05-14 17:45:10.304 3981-4166/? E/BluetoothEventManager: ACTION_ACL_DISCONNECTED
05-14 17:45:10.324 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.324 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.324 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.344 5018-5018/? E/BluetoothPbapService: Device  F5:E8:84:5E:09:A6 not waiting for authorization..Skipping cancel dialog...
05-14 17:45:10.424 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.424 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.424 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.494 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.494 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.494 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.584 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.584 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.584 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.694 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.694 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.694 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:10.754 24160-24160/com.example.jinghu.myApp E/ViewRootImpl: sendUserActionEvent() mView == null
05-14 17:45:12.054 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:12.054 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:12.054 5018-5352/? E/bt_btif: Register with GATT stack failed.
05-14 17:45:12.064 5018-5352/? E/bt_btif: bta_gattc_deregister Deregister Failedm unknown client cif
05-14 17:45:33.104 3528-4160/? E/Watchdog: !@Sync 1813 [05-14 17:45:33.111]
05-14 17:46:03.104 3528-4160/? E/Watchdog: !@Sync 1814 [05-14 17:46:03.113]
05-14 17:46:33.104 3528-4160/? E/Watchdog: !@Sync 1815 [05-14 17:46:33.115]

A: You need to call close() on the BluetoothGatt object when you're done with it. Otherwise you will eventually run out of available BluetoothGatt objects.


text:
Q: Align div with fixed position on the right side I want to show a div which is always visible even as the user scrolls the page. I have used the CSS position: fixed; for that.
Now I also want to show the div at the right hand corner of the parent div.
I tried to use this CSS code to achieve the goal:
.test {
  position: fixed;
  text-align: right;
}

But it doesn't align the element on the right side.
My example page can be found here, the div element I want to align is called test under the parent class parent.
Is there any CSS or JavaScript solution to aligning the fixed position element on the right side of the screen?

A: Trying to do the same thing. If you want it to be aligned on the right side then set the value of right to 0. In case you need some padding from the right, set the value to the size of the padding you need.
Example:
.test {
  position: fixed;
  right: 20px; /* Padding from the right side */
}

A: You can use two imbricated div. But you need a fixed width for your content, that's the only limitation.

A: Use the 'right' attribute alongside fixed position styling. The value provided acts as an offset from the right of the window boundary.
Code example:
.test {
  position: fixed;
  right: 0;
}

If you need some padding you can set right property with a certain value, for example: right: 10px.
Note: float property doesn't work for position fixed and absolute

A: With position fixed, you need to provide values to set where the div will be placed,
since it's a fixed position.
Something like....
.test
{
   position:fixed;
   left:100px;
   top:150px;
}

Fixed - Generates an absolutely positioned element, positioned relative to the browser window. The element's position is specified with the "left", "top", "right", and "bottom" properties
More on position here.

A: make a parent div, in css make it float:right
then make the child div's position fixed
this will make the div stay in its position at all times and on the right

A: I use this to put a div (with its stuff inside) at the bottom-right of the page with some margin:
.my-div-container{
    position: fixed;
    bottom: 1rem;
    left: 90%;
}

A: Here's the real solution (with other cool CSS3 stuff):
#fixed-square {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 9500;
    transform: rotate(-90deg);
}

Note the top:0 and right:0.  That's what did it for me.

A: The best solution I found is to give the element a left margin . The elements below it in left margin will be ckickable

#my_id{
      margin-left: 75%;
      position:fixed;
      right: 0;
    }

    My Text

  Stack Overflow

A: Just do this. It doesn't affect the horizontal position.
.test {
 position: fixed;
 left: 0;
 right: 0;
 }


text:
Q: List not Expand when use Fragment I want to use Expandable Listview in Fragment.
I get Group name but when click on that unable to open child elements.
public class SavedTabsFragment extends Fragment {

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.saved_tab, null);
    ExpandableListView elv = (ExpandableListView) v.findViewById(R.id.list);
    elv.setClickable(true);
    SavedTabsListAdapter  adapter= new SavedTabsListAdapter(getActivity());
    /*adapter.setInflater( inflater,
            getActivity());*/
    elv.setAdapter(adapter);
    return v;
}
 }

SavedTabsListAdapter
public class SavedTabsListAdapter extends BaseExpandableListAdapter {

private String[] groups = { "People Names", "Dog Names", "Cat Names",
        "Fish Names" };
private Context ctx;
private LayoutInflater inflater;
private String[][] children = { { "Arnold", "Barry", "Chuck", "David" },
        { "Ace", "Bandit", "Cha-Cha", "Deuce" }, { "Fluffy", "Snuggles" },
        { "Goldy", "Bubbles" } };

public SavedTabsListAdapter(Context ct) {
    ctx = ct;
    inflater = (LayoutInflater) ctx
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getGroupCount() {
    return groups.length;
}

@Override
public int getChildrenCount(int i) {
    return children[i].length;
}

@Override
public Object getGroup(int i) {
    return groups[i];
}

@Override
public Object getChild(int i, int i1) {
    return children[i][i1];
}

@Override
public long getGroupId(int i) {
    return i;
}

@Override
public long getChildId(int i, int i1) {
    return i1;
}

@Override
public boolean hasStableIds() {
    return true;
}

@Override
public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {

    view = inflater.inflate(R.layout.grouprow, null);
    CheckedTextView tv = (CheckedTextView) view
            .findViewById(R.id.textView1);
    tv.setText(getGroup(i).toString());
    return view;
}

@Override
public View getChildView(int i, int i1, boolean b, View view,
        ViewGroup viewGroup) {

    view = inflater.inflate(R.layout.childrow, null);
    TextView tv = (TextView) view.findViewById(R.id.textView1);
    tv.setText(getChild(i, i1).toString());
    return view;
}

@Override
public boolean isChildSelectable(int i, int i1) {
    return true;
}

}

A: Try out with the below Adapter code. Its working now.
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckedTextView;
import android.widget.TextView;

public class SavedTabsListAdapter extends BaseExpandableListAdapter {

    private String[] groups = { "People Names", "Dog Names", "Cat Names",
            "Fish Names" };
    private Context ctx;
    private LayoutInflater inflater;
    private String[][] children = { { "Arnold", "Barry", "Chuck", "David" },
            { "Ace", "Bandit", "Cha-Cha", "Deuce" }, { "Fluffy", "Snuggles" },
            { "Goldy", "Bubbles" } };

    public SavedTabsListAdapter(Context ct) {
        ctx = ct;
        inflater = (LayoutInflater) ctx
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getGroupCount() {
        return groups.length;
    }

    @Override
    public int getChildrenCount(int i) {
        return children[i].length;
    }

    @Override
    public Object getGroup(int i) {
        return groups[i];
    }

    @Override
    public Object getChild(int i, int i1) {
        return children[i][i1];
    }

    @Override
    public long getGroupId(int i) {
        return i;
    }

    @Override
    public long getChildId(int i, int i1) {
        return i1;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

    @Override
    public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {

        view = inflater.inflate(R.layout.grouprow, null);
        CheckedTextView tv = (CheckedTextView) view
                .findViewById(R.id.textView1);
        tv.setText(getGroup(i).toString());
        return view;
    }

    @Override
    public View getChildView(int i, int i1, boolean b, View view,
            ViewGroup viewGroup) {

        view = inflater.inflate(R.layout.childrow, null);
        TextView tv = (TextView) view.findViewById(R.id.textView1);
        tv.setText(getChild(i, i1).toString());
        return view;
    }

    @Override
    public boolean isChildSelectable(int i, int i1) {
        return true;
    }

}


text:
Q: Find most fat directories by it's own size I would like to list most fat directories by it's own size sorted by size descending.
'Directory own size' means size of the directory excluding size of all it's subdirectories.
For example, we have directory structure:
    /tmp/D1
            |-- 5m.file
            |-- D2
            |   |-- 2m.file
            |   `-- D4
            |       `-- 4m.file
            `-- D3
                `-- 3m.file

By for executing command and passing /tmp/D1 as argument I'd like to get result like
    5m      /tmp/D1
    4m      /tmp/D1/D2/D4
    3m      /tmp/D1/D3
    2m      /tmp/D1/D2

du -Sh . | sort -rh | head -n 10

+x to limit to current filesystem only
du -Shx . | sort -rh | head -n 10

A: You can use du with an -S option for this
From the man page

-S, --separate-dirs
            do not include size of subdirectories

$ du -Sh /foo/bar/temp2/ | sort -rh

84K     /foo/bar/temp2/
40K     /foo/bar/temp2/tempo
4.0K    /foo/bar/temp2/opt/logs/merchantportal
4.0K    /foo/bar/temp2/opt/logs
4.0K    /foo/bar/temp2/opt
4.0K    /foo/bar/temp2/folder
4.0K    /foo/bar/temp2/bang

Now checking in the normal way with the -s option, which is inclusive of all sub-directories.
$ du -sh /foo/bar/temp2/opt
12K     /foo/bar/temp2/opt

which is the summation of sizes of the sub-folders /foo/bar/temp2/opt/logs/merchantportal, /foo/bar/temp2/opt/logs and the base folder itself
The -h formats the size in the human readable format according to the man page. If you forcefully want to format the output in 1-Mbyte blocks you can use the option du -Sm


text:
Q: If/else for conditional  option I am having troubling getting a simply if/else conditional for options in an html select form. If the value for bid is 'N', then I want one option for the select field to change to "Y" and vice versa. I know my db connection is good and other php works and the form was updating the db fine until I tried to work in the php conditional code within the  so I just need to get the syntax correct.
 /* fetch associative array */
 while ($row = mysqli_fetch_assoc($result)){
 ?>

 <form method="post" name="update" action="update.php" >
 <select name="bid">

 <option value="<?php echo $row['bid']; ?>" selected="selected">
 <?php echo $row['bid']; ?></option>

 <? if ($row['bid'] == 'N') {
 ?>

 <option value="Y">Y</option>

 <?   } else {

 ?>

 <option value="N">N</option>

 <? }
 ?>

</select>
<input type="submit" name="Submit" value="update" >
</form>

<?
}

A: if statement expect expression and you have syntax error in your statement
if (echo $row['bid']; == 'N')

the syntax error because of echo and the semicolon ;
you should change your condition to
if ($row['bid'] == 'N'){

if $row['bid'] string then you need to compare with strcmp , like this
if (strcmp($row['bid'] , 'N') == 0){

also you need to move <input> tag outside the <select>

A: Your <input type="submit"> was inside your <select>, so I moved it outside.
It is also incorrect to use the if statement in this manner:
if (echo $row['bid']; == 'N')

correct would be this:
if ($row['bid'] == 'N')

Here is the corrected code:
<form method="post" name="update" action="update.php" >
<select name="bid">

<?php
echo '<option value="'.$row['bid'].'" selected="selected">'.$row['bid'].'</option>';

if ($row['bid'] == 'N') echo '<option value="Y">Y</option>';
else echo '<option value="N">N</option>';

echo '</select>';
?>

<input type="submit" name="Submit" value="update" >
</form>

A: Your condition is bad, you must remove echo and ;. it should like this
<? if ($row['bid'] == 'N') { ?>

And your submit button should be presented out side the select field.
Your codes should look like this:
<form method="post" name="update" action="update.php" >
    <select name="bid">

       <option value="<?=$row['bid']?>" selected="selected">
           <?=$row['bid']?>
       </option>

      <?php if ($row['bid'] == 'N') {
          echo '<option value="Y">Y</option>';
      } else {
          echo '<option value="N">N</option>';
      }
      ?>

     </select>
     <input type="submit" name="Submit" value="update" >
 </form>

A: Your if condition has bad syntax. Remove the semicolon and echo statement.
<form method="post" name="update" action="update.php" >
 <select name="bid">

 <option value="<?php echo $row['bid']; ?>" selected="selected">
 <?php echo $row['bid']; ?></option>

 <? if ($row['bid'] == 'N') {
 ?>

 <option value="Y">Y</option>

 <?   } else {

 ?>

 <option value="N">N</option>

 <? }
 ?>

 <input type="submit" name="Submit" value="update" >

 </select>
 </form>


text:
Q: ubuntu 19.04 wifi very slow - was alright for a couple of months Suddenly the wifi has become unbearably slow.
This was running OK before with the same 19.04
Have tried changing wifi dongle without any success
LAN connection is not affected
Dongle tried:
  Tenda
  Edimax
  Netis WF2111

A: If the dongle and your normal wifi both fail, it's probably not your computer but your router that is not functioning properly. Try restarting your router, move closer to it, etc.
This is too general a question in my opinion so I cant provide a less general answer for you either :( Hope it helps tho :)


text:
Q: UML: Java Defender or Default Methods Since the release of Java 8 you may provide default implementations of methods in interfaces.
I have been looking for a way to realize this in UML but could not find anything on the matter. The case of default implementations in interfaces probably is too special to be adopted to in the UML specs.
But still the Question:
Is there a way to display these default methods in UML?

A: There is nothing special about this situation from UML perspective, that's what stereotypes are for.
UML represents a conceptual model, which is not tied to a language-specific situation, so you can model it for example in this way:

How such model will be implemented is different matter. In Java you could use interfaces, in C++ (which doesn't have interfaces) you would abstract classes, in Ruby you might take a yet different approach, but the model can** still be the same.
**By can I mean that it is common practice to commit to a particular language already at the modeling level, so one would alter to model to better fit the target language.

A: There are three types of methods within an interface in java 8:

*

*static

*default

*abstract

Abstract methods are generally italic

+ sayAbstract() : void

Static methods are generally u̲n̲d̲e̲r̲l̲i̲n̲e̲d̲:

+̲ ̲s̲a̲y̲S̲t̲a̲t̲i̲c̲(̲)̲ ̲:̲ ̲v̲o̲i̲d̲

Since default methods are a sort of instance methods, format them accordingly:

+ sayDefault() : void


text:
Q: Error trying to install Windows 7 on Dell XPS13 9360 I just bought a brand new Dell XPS13 9360. It came with Windows 10 but I'd like to install Windows 7 on it because I really, really want to stay on Windows 7 and not upgrade until they pry it out of my cold, dead hands.
When trying to install Windows 7, I ran into a few problems and I solved them. I used the DISM tool to load the drivers for USB3 which got me past an error in the installation. Now I'm able to see the partitions, I deleted the Windows 10 partition and created a new partition for Windows 7. But when trying to install in it I get a new error:
Windows cannot be installed to this disk. This computer's hardware may not support booting to this disk. Ensure that the disk's controller is enabled in the computer's BIOS menu.

This happens when I set the boot to UEFI mode. If I try to set the boot to legacy mode in the BIOS, then I don't see the drive at all in the Windows 7 installation. If I try to set the drive to AHCI (it's currently RAID) I get BSOD.
I googled this problem but no solution that I found worked.
Can anyone help?

A: I discovered that the Kabylake processor simply doesn't support Windows 7, so it can't be installed. Also the SDD (LiteOn NVMe CX2-8B512-Q11 NV) doesn't have Windows 7 drivers. (I called LiteOn and they told me that.) So I'll get another laptop.

A: So the workaround for this is to use a Samsung NVMe, and the drivers here: http://ftp.hp.com/pub/softpaq/sp71501-72000/sp71553.exe
here's an info page for it ftp://ftp.hp.com/pub/softpaq/sp71501-72000/sp71553.html
You'll start the installer, get to the step where you choose the drive you want to install on, browse to that driver and hit ok, then exit that and click Install again and the drive should be accessible.
Downside is the drivers on Dell's site are for Win10 only, and the Qualcomm Killer 1353 driver blue-screens when you connect to wifi


text:
Q: How to format data from table column with the same class using javascript i have table row inside a foreach looping that are have some columns with the same class, my question is how can i format each data in that column to be like ###,### (format number using comma) in javascript?
this is a sample for my table structure:

<?php foreach () { ?>

            400000

            500000
            500000
            0
            0

            500000
            500000
            0
            0

            500000
            500000
            0
            0

            500000
            500000
            0
            0

            500000
            500000
            0
            0

            500000
            500000
            0
            0

<?php } ?>

A: You can get all the elements with the specific class name and then format its innerHTML. below is a working snippet.

var allTds = document.getElementsByClassName("sum");

for (var i = 0; i < allTds.length; i++) {

  allTds[i].innerHTML = allTds[i].innerHTML.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
td{
   border:1px solid;
  }

      400000

      500000
      500000
      0
      0

      500000
      500000
      0
      0

      500000
      500000
      0
      0

      500000
      500000
      0
      0

      500000
      500000
      0
      0

      500000
      500000
      0
      0

The regex reference taken from this answer. https://stackoverflow.com/a/2901298/2592042


text:
Q: Why are hard links are not updated when modified with an editor I am using Mac OS X, but the command line.  I want to make a link from my .profile file, to another file on my system so that updating one updates the other and vice versa.
This article makes me think that a hard link is what I need.  The command I have been using is:
ln .profile ~/Newpath/.profile
This kind of works, in that a file is created at Newpath, however, updating one file does not automatically update the other nor vice versa.
I have tried ln with simple files on my desktop, and the links do indeed update each other.  I am wondering if anybody has experience with links not working with dot files or with files in their home directory on Mac for some reason.
Any idea what could be going on here?

A: Perhaps the directories where these files reside are on different filesystems / partitions? Hard links can only exist on a single partition.
if test x"$(stat -f'%d' .)" != x"$(stat -f'%d' ~/Newpath)"; then
  echo "Directories are on different partitions"
fi

A: Beware that many editors write to a temporary file and rename finally to the target file.
This will cause your hard-linking to be lost.

A: I just tested it on my Mac, it worked perfectly well.
Updating either of them, the other one would be updated too.
BTW, symbolic link should work as well as hard link.

A: I also faced the same issue when writing with TextEdit. So then, I tried with cat command and it worked perfectly.

A: dubiousjim's comment pointed out my issue:

I think git will break hard links every time you checkout a new copy
  of the file. EDIT: Yes, I just verified it will, even if the hard
  links are in a single repo


text:
Q: Keychain not working on Release Scheme So I'm having a frustrating issue. I created 3 schemes (Dev, QA, Release). Those 3 changes the configurations with some macros for me to point to 3 different URLs for our API.
The issue I'm having is that my keychain doesn't work for QA and Release (it seems very inconsistent) so when I try to get something from the keychain, nothing ever comes back. I'm now worried about when I submit this for a release that it won't work...any ideas? let me know if I need to explain something more, I probably didn't do a good job explaining