text:
Q: How to validate DataGrid selected Item in WPF? Project: https://github.com/98gzi/Validate-DataGrid-Selected-Item
Goal
My goal is to click on a datagrid row, get the selected item values and bind it to a textbox. So I can edit the values there, rather than directly in DataGrid.
DataGrid:
<DataGrid ItemsSource="{Binding List}" SelectedItem="{Binding SelectedRecord}" />

Selected record display's the record's property into a textbox:
<TextBox Text="{Binding SelectedRecord.FirstName}" />

This works as it should, until it comes to validation.
Problem
I added the following code to add validation:
XAML
<TextBox Text="{Binding SelectedRecord.FirstName, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" />

View Model Validation
#region IDataErrorInfo
public string Error { get { return null; } }
public Dictionary<string, string> ErrorCollection { get; private set; } = new Dictionary<string, string>();
public string this[string propertyName]
{
    get
    {
        string result = null;

        switch (propertyName)
        {
            case "SelectedRecord.FirstName":
                if (string.IsNullOrWhiteSpace(SelectedRecord.FirstName))
                    result = "First Name cannot be empty";
                break;
            default:
                break;
        }

        if (ErrorCollection.ContainsKey(propertyName))
            ErrorCollection[propertyName] = result;
        else if (result != null)
            ErrorCollection.Add(propertyName, result);

        OnPropertyChanged(nameof(ErrorCollection));

        return result;
    }
}

#endregion

Question
This does not do anything. i.e No errors show up in the UI and also the debugger does not go into debug mode.
Is this the correct approach in validation a selected record? If not, what is the correct approach?

A:
Is this the correct approach in validation a selected record? If not, what is the correct approach?

Not. You are doing wrong.
It is impossible to give a complete answer - it requires more code of your implementation.
Therefore, I am writing what I could understand from your explanations and partial code.
Do you need to validate the values of a single DataGrid row, the one that is currently selected.
And the interface IDataErrorInfo is most likely implemented at the collection level (ViewModel), and not in the element itself.
Therefore, you expect the "SelectedRecord.FirstName" composite index to be queried.
But bindings don't work that way.
The path in the binding only indicates how to find the property along that path.
After finding it, the binding will work directly with the property itself, and not the path specified for its search.
Therefore, it is necessary to implement IDataErrorInfo in the type used to represent the string.
And wait for a request only for the name of a property of this type "FirstName".

Updated my question with project link

Your repository does not have a complete Solution, so I cannot check the changes made - the project is not going to be built.
I will describe here the changes that need to be made.
You add them yourself, and then add your entire Solution to your repository.
So that if there are errors, I can reproduce them.

*

*Remove the BaseViewModel and RelayCommand classes. Their implementation is too simplistic. Add the BaseInpc, RelayCommand, and RelayCommand classes to the project.
These are more advanced implementations. They are easier to use and reduce the likelihood of some bugs.

*ViewModel:
using Simplified;
using System.Collections.ObjectModel;

namespace WpfApp1
{
    public class ViewModel : BaseInpc
    {
        public ViewModel()
        {
            Names.Add(new Model { Id = 1, FirstName = "First Name 1", LastName = "Last Name 1" });
            Names.Add(new Model { Id = 2, FirstName = "First Name 2", LastName = "Last Name 2" });
            Names.Add(new Model { Id = 3, FirstName = "First Name 3", LastName = "Last Name 3" });
        }

        #region Properties
        public ObservableCollection<Model> Names { get; } = new ObservableCollection<Model>();

        private Model _selectedRecord;
        public Model SelectedRecord
        {
            get => _selectedRecord;
            set => Set(ref _selectedRecord, value);
        }
        #endregion
    }
}

*Entity class.
I didn't change the name so you don't get confused, but this is not a MODEL!
The Model in MVVM is where the instances of this entity are created. The part of the ViewModel code that creates the Names collection is, in fact, your Model in MVVM.

using Simplified;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;

namespace WpfApp1
{
    public class Model : BaseInpc, IDataErrorInfo
    {
        private int _id;
        private string _firstName;
        private string _lastName;
        private string _error;

        public int Id { get => _id; set => Set(ref _id, value); }
        public string FirstName { get => _firstName; set => Set(ref _firstName, value); }
        public string LastName { get => _lastName; set => Set(ref _lastName, value); }

        #region IDataErrorInfo
        public string Error { get => _error; private set => Set(ref _error, value); }
        public Dictionary<string, string> ErrorCollection { get; } = new Dictionary<string, string>();
        public string this[string propertyName]
        {
            get
            {
                if (string.IsNullOrWhiteSpace(propertyName))
                    return null;

                string result = null;

                switch (propertyName)
                {
                    case nameof(FirstName):
                        if (string.IsNullOrWhiteSpace(FirstName))
                            result = "First Name cannot be empty";
                        break;
                    default:
                        break;
                }

                if (string.IsNullOrWhiteSpace(result))
                    ErrorCollection.Remove(propertyName);
                else
                    ErrorCollection[propertyName] = result;

                Error = string.Join(Environment.NewLine,
                    ErrorCollection.Where(pair => !string.IsNullOrWhiteSpace(pair.Value))
                        .Select(pair => $"{pair.Key}:\"{pair.Value}\""));

                return result;
            }
        }

        #endregion

    }
}

*Window.
Move data context creation to XAML. It will be more convenient for you to construct the XAML of Windows yourself.

using System.Windows;

namespace WpfApp1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }

}

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <FrameworkElement.DataContext>
        <local:ViewModel/>
    </FrameworkElement.DataContext>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Grid Grid.Column="0">
            <DataGrid ItemsSource="{Binding Names}"  SelectedItem="{Binding SelectedRecord}"/>
        </Grid>

        <StackPanel Grid.Column="1" DataContext="{Binding SelectedRecord}">
            <Label Content="First Name" />
            <TextBox Text="{Binding FirstName, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" />
            <Label Content="Last Name" />
            <TextBox Text="{Binding LastName, ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" />
        </StackPanel>
    </Grid>
</Window>

A: activate the cell_click event handler for the DataGrid. Then
    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        if (e.RowIndex >= 0)
        {
            DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];
            TextBox1.text = row.Cells["id_number"].Value.ToString();
        }
    }

** Replace textbox1.text with the ID of your textbox, dataGridView1 with your datagrid ID and replace "id_number" with the name of your datagride column name.


text:
Q: Why can't I compare two numbers Double class Java using operator "=="? I have tried to make a simple code to compare numbers if is equal using  Double class. This is my simple code:
BufferedReader bfr= new BufferedReader(new InputStreamReader(System.in));
    Double number1;
    Double number2;
    System.out.println("Ask for first number:");
    number1 = Double.parseDouble(bfr.readLine());
    System.out.println("Ask for second number:");
    number2 =  Double.parseDouble(bfr.readLine());

    if(number1==number2) {
        System.out.println("These numbers are equals!");
        System.out.println(number1);
        System.out.println(number2);
    }else {
        System.out.println("They're differents!");
        System.out.println(number1);
        System.out.println(number2);
    }

When I use "int" instead Double and the operator "==" it works fine but when I use "Double" it shows me  they are different numbers even the same numbers are entered. I've tried to use Object.equals() method it works fine but I want to know why "Double" class  does not admit operator "==".

A: The important difference between int and Double here is not the floating point nature (though that can make computations behave in unexpected ways), but the fact that int is a primitive type and Double is a reference type (a wrapper around double).
When you compare reference type values using == you check for object identity. I.e. the expression number1 == number2 means "do the variables number1 and number2 reference the exact same object", which is almost certainly not what you want.
The solution, as you found is to use number1.equals(number2).
Another workaround would be to switch from Double (the wrapper) to double the primitive type. Usually you can just assign one to the other and the appropriate autoboxing/autounboxing will handle the conversion.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Arduino - non-blocking pulsing I am using an Arduino to control a couple of Victor 884's.
After some research, I found out you need to send it some pulses of different durations to make it go (I have no clue what the right terminology here is).
To control it, you do the following.
Stop = 1.5 ms on and 0.5 ms off.
Forward Full Power = 2 ms on and 0 ms off
Backward Full Power = 1 ms on and 1 ms off

So to make the motor stop, I could use some code like this.
void setup() {
    pinMode(13, OUTPUT);
}

void loop() {
    digitalWrite(13, HIGH);
    delayMicroseconds(1500);
    digitalWrite(13, LOW);
    delayMicroseconds(500);
}

The problem is, this code is blocking so I can't do anything without messing of the time.
The solution is to get rid of the delay statement.
I was able to make a non-blocking version based on the BlinkWithoutDelay example.
The problem arises when I try control 3-4 Victors. I tried the copy, paste, rename-with-some-numbers-tacked-on method, but the code quickly gets messy.
So my question is, how should I do this? Should I write some classes to handle it for me (a pain since I have no clue how to write a class in C++) or should I look into using the Arduino's timers to achieve my goal.

A: You can use both the Timer library and create your own classes to keep things clean. Instead of classes you can also create an additional .pde/.ino file containing functions to drive the 884s.
If you are running windows then grab a copy of Visual Studio Professional and the Arduino Plugin. It has an option to create new Cpp file which automatically creates a class for you. http://www.visualmicro.com
Classes are quite easy when you see one working. Another alternative is to create your own library to handle the 884 code but that is more complicated.
Edit: If you are going to learn more C++ then follow the comment by Pawel above. Pawel is right interrupts are best especially if using microSeconds which I missed the first time I read your request.

A: Most probably you might want to learn about pulse width modulation aka PWM: http://arduino.cc/en/Tutorial/PWM


text:
Q: Vuetify - How to access data in form rule Can I access a data element in a rule?
Here is my code running
I'm trying to flip the value of a data element on a text field rule in a Vuetify form.
The rule itself works fine, however I'm unable to access the data element, I'm getting this error:
TypeError: Cannot set property 'disabled' of undefined
Here is my code:
data: function() {
return {
  disabled: false,
  rules:{
    sellerId(value){
      if(value.length == 0){
        this.disabled = true;
        return "What are you trying to do here?";
      }
      else{
        return true;
      }
    }
  },

What am I doing wrong?

A: rules are an array of functions, and if you need the function to be able to access data property, you can define them as component methods:
data: function () {
  return {
    disabled: false
  }
},
methods: {
  sellerId (value) {
    if (value.length === 0) {
      this.disabled = true;
      return "What are you trying to do here?";
    } else {
      return true;
    }
  }
}

And then in your Vuetify component:
<v-text-field :rules="[ sellerId ]"></v-text-field>

A: try to define rules as computed property :
data: function() {
    return {
      disabled: false,
      ...
    }
  },
  computed: {
    sellerIdRules() {
      return [
         (v) => {
        if (value.length == 0) {
          this.disabled = true;
          return "What are you trying to do here?";
        } else {
          return true;
        } ]
      }
    }
  }

A: While this isn't available to a rule function you can accomplish this by assigning the vue instance to a variable, which will bring it into scope by closure.
vm = new Vue({
    el: '#app',
    data: () => ({
        disabled: true,
        rules: [
            value => {
                if (value.length == 0) {
                    vm.disabled = true;
                    return "What are you trying to do here?";
                }
                else {
                    return true;
                }
            }
        ],
'''


text:
Q: How to check, where an application is located under OS X? How to check the location of an application installed under OS X?
I tried it with the method LSFindApplicationForInfo and it works fine if you are searching for the bundle identifier.
But this way is not working if you have installed more than one instances of an app. LSFindApplicationForInfo just gets the location of one instance of an app. Furthermore this function is deprecated in OS X 10.10.
The terminal input mdfind "kMDItemCFBundleIdentifier from the following thread works fine, but it just works if spotlight is enabled.
How to get the locations off all app instances with the same bundle identifier or the same name "name.app" inside source code written in C or Objective-C?
How to find multiple apps with same bundle identifier?
Check if a Mac OS X application is present

A: If you can target 10.10 or later, you can use LSCopyApplicationURLsForBundleIdentifier(). This is documented as returning the URLs of all applications with the given bundle identifier.
It's not clear to me if the app you're attempt to find is one whose properties you control. If it is and you need to support versions of OS X prior to 10.10, one approach you can use is to make the target app claim to support a custom dummy URL scheme. Then you can use LSCopyApplicationURLsForURL() to find all instances of it. You construct a URL with your dummy scheme, such as com-yourcompany-yourproduct-app-identifier-scheme://junk and pass that as input.


text:
Q: Error uploading document When I upload a document to document library that has workflows the following error occurs.

The file Minutes/By Quarter.dwp has been modified by
  i:0#.w|xac0000\sp_admin on 04 Feb 2016 17:39:39 +0800.

File is added to the library but required fields that I tagged does not show up.


text:
Q: Error when using attr_accessible and attr_accessor I have a problem with attr_accessible and attr_accessor.
When I use attr_accessor in model:

attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
attr_accessible :title, :author, :description, :price, :attach

Error:
Server return:
WARNING: Can't mass-assign protected attributes for Product: crop_x, crop_y, crop_w, crop_h

I edited as follow:

attr_accessible :title, :author, :description, :price, :attach
attr_accessible :crop_x, :crop_y, :crop_w, :crop_h

Error:
Server return:
undefined method `crop_x' for #<Product:0x007fe900f88c20>

So, I used both attr_accessible and attr_accessor:

attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
attr_accessible :title, :author, :description, :price, :attach
attr_accessible :crop_x, :crop_y, :crop_w, :crop_h

But server run forever.

A: attr_accessor provides the setter and getter methods for attribute.
attr_accessible says that the attribute can be mass-assigned.


text:
Q: Reference data of d3 element to parent node data I am making a pie chart with d3. Each piece of the graph, has an inner path and and outer path. That way, when the both set of paths need to transform, they are based on the same data set.
So my thought was to bind the data to a set of 'g' (with class '.piece') and then let both the path sets ('.innerpath' and '.outerpath') have there data point to their parent data set.
How can I do this?
pieces = container.selectAll('.piece')
    .data(pie(data))
    .enter().append('g')
    .each(function(d) { this._current = d; }); // store the initial angles

outerPaths = pieces.append('path')
    .data(function(){
    // ??
    }).attr('d', outerArc)
    .attr('class', 'outerpath');

A: To the path add group.
  var path = svg.datum(data).selectAll("path")
      .data(pie)
    .enter().append("g");

To the group add path with outer arc.
path.append("path")
  .attr("fill", function(d, i) { return color(i); })
  .classed("outer", true)//add class outer
  .attr("d", arco)
  .each(function(d) { this._current = d; })

To the group add path with inner arc.
path.append("path")
  .attr("fill", function(d, i) { return color(i + 1); })
  .classed("inner", true)//add class inner
  .attr("d", arci)
  .each(function(d) { this._current = d; })

On change tween both paths.
function change() {
    var value = this.value;
    clearTimeout(timeout);
    pie.value(function(d) { return d[value]; }); // change the value function
    path = path.data(pie); // compute the new angles
    path.select(".outer").transition().duration(750).attrTween("d", arcTweeno); // redraw the arcs
    path.select(".inner").transition().duration(750).attrTween("d", arcTweeni); // redraw the arcs
  }

working code here


text:
Q: Internet through wifi I am renting a place that only provides internet through wifi. My laptop has no problem connecting, but my desktop doesn't have a wifi card.
I have a Linksys WRT54GX4 router. Is it possible for me to send internet from my laptop to the router, then to the desktop?
I know that the opposite configuration works out of the box, where machines connected to the laptop via AD HOC wireless connection will have internet if the laptop is connected via ethernet cable.
Both machines are running arch Linux.

A: There is no need to involve the laptop. Just set up your router as a repeater (google is your friend if you don't know how) or buy a USB wifi dongle and connect directly.

A: The easiest solution would be to make your router get its Internet connection from wifi and plug an Ethernet cable between your router and your desktop computer.
If you can't do that, you can make your laptop a relay. Plug a cable between your laptop's Ethernet port and your desktop's, or use your router as a switch if you want to be able to connect more than one machine.

*

*If you're able to connect multiple machines to the wifi network, you can make your laptop bridge its wifi interface with its wired interface. This way the desktop will effectively be on the wifi network, can get an address with DHCP this way, etc. See Using bridge utils to connect two computers via Linux

*If you can only obtain a single IP address, make your laptop perform NAT. This way your desktop will be able to reach out to the Internet but won't be reachable from the outside. See How do I share internet with Windows from my Linux box?


text:
Q: error LNK2019: unresolved external symbol Ok, so I'm having a problem trying figure out the problem in my code. I have a lot of code so I'm only going to post the relevant parts that are messing up when I compile. I have the following function inside of a class and it will compile and everything will run fine until I call the function "CalculateProbabilityResults" and it runs the 7th line of code within it. I've "de-commented" this line of code in my program so you can find it easier. I'm pretty sure I have the right #include directives needed since it compiles fine when not calling the function, so that can't be the problem can it? I know some of my naming notation needs a little help, so please bear with me. Thanks in advance for the help guys.
int SQLServer::CalculateProbabilityResults(int profile, int frame, int time_period, int TimeWindowSize) {
    ofstream ResultFile;
    stringstream searchFileName;
    stringstream outputName;
    vector<vector<int>> timeFrameItemsets;
    int num = getTimeFrameFile(frame*TimeWindowSize, TimeWindowSize);
    cout << num << endl;

    //outputName << "Results" << getTimeFrameFile((frame*TimeWindowSize), TimeWindowSize) << ".csv";
    cout << outputName.str() << endl;
    outputName.clear();
    //ResultFile.open(outputName.str().c_str());
    ResultFile.close();
    result.resize(0);
    return 0;
}

int getTimeFrameFile(int timeInHours, int timeFrameSize) {
    int fileNum = 0;
    int testWin;
    if (timeInHours > 24) {
        while (timeInHours >24)
            timeInHours -= 24;
    }
    for (testWin = 0; testWin < 24/timeFrameSize; testWin++) {
        if (timeInHours >= testWin*timeFrameSize && timeInHours < (testWin+1)*timeFrameSize)
            fileNum = testWin+1;
    }
    if (fileNum == 0)
        fileNum = testWin+1;
    return fileNum;
}

Call Log
1>------ Rebuild All started: Project: MobileSPADE_1.3, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'MobileSPADE_1.3', configuration 'Debug|Win32'
1>Compiling...
1>main.cpp
1>MobileSPADE.cpp
1>SQLServer.cpp
1>Generating Code...
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Linking...
1>LINK : C:\Users\JoshBradley\Desktop\MobileSPADE_1.3\MobileSPADE_1.3\Debug\MobileSPADE_1.3.exe not found or not built by the last incremental link; performing full link
1>SQLServer.obj : error LNK2019: unresolved external symbol "public: int __thiscall SQLServer::getTimeFrameFile(int,int)" (?getTimeFrameFile@SQLServer@@QAEHHH@Z) referenced in function "public: int __thiscall SQLServer::CalculateProbabilityResults(int,int,int,int)" (?CalculateProbabilityResults@SQLServer@@QAEHHHHH@Z)
1>C:\Users\JoshBradley\Desktop\MobileSPADE_1.3\MobileSPADE_1.3\Debug\MobileSPADE_1.3.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\JoshBradley\Desktop\MobileSPADE_1.3\MobileSPADE_1.3\MobileSPADE_1.3\Debug\BuildLog.htm"
1>MobileSPADE_1.3 - 2 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

A: The compiler thinks that getTimeFrameFile is a SQLServer method:

unresolved external symbol "public: int __thiscall SQLServer::getTimeFrameFile(int,int)"

but you have it defined as a free function:
int getTimeFrameFile(int timeInHours, int timeFrameSize) {

Change that from a free function to a class method will solve the problem:
int SQLServer::getTimeFrameFile(int timeInHours, int timeFrameSize)

A: Put the function getTimeFrameFile above SQLServer::CalculateProbabilityResults.


text:
Q: Select values in a column based on multiple rows in a different column I have a dataframe with sales orders that have multiple products (original dataframe below). I need create a second dataframe showing the sales orders, whether the sales order has only one product or not (standalone), and the name of the product. Any help on how to accomplish this would be greatly appreciated. Thanks gang!
Original dataframe:

 	A	B

1	Sales Order	Product

2	1111	Software

3	1111	Support

4	2222	Hardware

5	3333	Software

6	4444	Hardware

7	4444	Software

Desired Output:

 	A	B	C

1	Sales Order	Standalone	Product (SA)

2	1111	No	Not SA

3	2222	Yes	Hardware

4	3333	Yes	Software

5	4444	No	Not SA

*

*SA stands for Standalone

A: So your starting DataFrame looks like:
  Sales Order   Product
0        1111  Software
1        1111   Support
2        2222  Hardware
3        3333  Software
4        4444  Hardware
5        4444  Software

First create a new DataFrame to hold your results.
res = pd.DataFrame(index=df['Sales Order'].unique(), columns=['Standalone', 'Product'])

Then populate it. This can be done in several ways. Below is a method using DataFrame.groupby.
for sales_order, dft in df.groupby('Sales Order'):
    standalone = 'Yes' if len(dft) == 1 else 'No'
    product = dft.iloc[0, 1] if len(dft) == 1 else 'Not SA'
    res.loc[sales_order] = [standalone, product]


text:
Q: Open Jupyter notebook in committed image in docker container I used docker commit to commit my work on a Jupiter notebook on docker, but my computer crashed. When I try to run the docker container, I can't open the notebook at the time of latest commit.
The following bash commands yield:
docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
7f1b4d6a811f        iess:latest         "/bin/su -l pycbc -c…"   5 minutes ago       Exited (1) 5 minutes ago                        iess
0dcd955ad0b6        4028090df24a        "/bin/su -l pycbc -c…"   14 minutes ago      Exited (1) 11 minutes ago                       vibrant_minsky
d7d76573d511        4028090df24a        "/bin/su -l pycbc -c…"   2 days ago          Up 32 minutes               8888/tcp            relaxed_cartwright

docker images
REPOSITORY                              TAG                       IMAGE ID            CREATED             SIZE
iess                                   latest                    6e07932643eb        9 hours ago         4.6GB
<none>                                  <none>                    dd24d1257a5c        10 hours ago        4.6GB
<none>                                  <none>                    0bdaeb277ab9        10 hours ago        4.6GB
<none>                                  <none>                    911e848f8167        12 hours ago        4.6GB
<none>                                  <none>                    de16c7fce855        20 hours ago        4.6GB
<none>                                  <none>                    147ed70ecf70        21 hours ago        4.6GB
<none>                                  <none>                    792f3f87b8ee        21 hours ago        4.6GB
<none>                                  <none>                    79cbcc4abc27        21 hours ago        4.6GB
<none>                                  <none>                    9abe343a42b1        21 hours ago        4.6GB
<none>                                  <none>                    aea2324b9902        44 hours ago        4.6GB
<none>                                  <none>                    760e78217518        2 days ago          4.6GB

I am not a docker expert (very very very newbie), but I wanted to open start the last container on the list (d7d76573d511), with the image on top of the list (iess:latest created 9 hours ago).

A: If you want to use the new image: iess latest 6e07932643eb you need to stop the container d7d76573d51 they are both trying to use the same port which is causing the new one to crash. To stop the container use docker stop <CONTAINER ID>


text:
Q: How to run a custom grails command from grails executable jar/war I'm using grails 3.2.8. I am generating an executable war file from my grails project that has web functionality in it. However, I've also written some custom grails commands that I'd like to be able to run in production (as cron jobs) from an executable jar/war that I build from the same grails project. I can run them in my development environment as "grails run-cmd ...", but I'd like to be able to deploy an executable jar/war file and run the custom command from the executable jar/war. In other words, I want to deploy a war file for web stuff to one server, and I want to deploy an executable jar file for some cron jobs all from a single grails project. I know how build/run the war file--grails makes that easy. However, I really have no idea how to generate an executable jar file from my project that allows me to run my custom grails commands as cron jobs. Can anyone tell me how to do this?

A: I have found something that seems to work. I've modified the Application.groovy class in my grails project to look like this:
import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration
import grails.ui.command.GrailsApplicationContextCommandRunner

class Application extends GrailsAutoConfiguration {
  static void main(String[] args) {
    if (args.length > 0 && args[0] == "run-command") {
      // If the first argument is 'run-command', then we just want to run a command as if we were running
      // 'grails run-command <grails-custom-command> <args>...'. We are adding the capability of running commands here
      // because this is the class that is run from the executable war generated by running 'grails war'. If we just do the same
      // thing that grails does to run a command, then the commands seem to execute just fine.
      args = args.tail()
      // The following code is copied from GrailsApplicationContextCommandRunner.main(). It is what grails does to make
      // 'grails run-command' work from the grails console/command line. When upgrading grails, it may be necessary to update
      // this code...
      def runner = new GrailsApplicationContextCommandRunner(args[0], Application)
      runner.run(args)
    } else {
      GrailsApp.run(Application, args)
    }
  }
}

I have also changed the dependency in build.gradle for the grails-console dependency from 'console' to 'compile':
compile "org.grails:grails-console" // changed from 'console' dependency since we want to be able to run custom grails commands from the executable jar/war

This is because the GrailsApplicationContextCommandRunner class is in grails-console.
With these changes in place, I can still run the war file with:
java -jar myWarFile.war

However, I am now also able to run my custom commands with the exact same war file like this:
java -jar myWarFile.war run-command my-command <command args>

It seems like there should be a better way to do this, so it would be great if the grails team would comment (and if there isn't a better way, then the grails team should consider adding running custom commands from the executable war file as a grails feature request), but I do seem to be able to run my custom commands from the executable war file this way.


text:
Q: I am trying to use GII feature in YII, but it gives me error when I am opening the gii page It gives me error.
Error 403
You are not allowed to access this page.
I have uncommented this code in the main.php file inside protected directory.
'gii'=>array(
        'class'=>'system.gii.GiiModule',
        'password'=>'admin',
        // If removed, Gii defaults to localhost only. Edit carefully to taste.
        'ipFilters'=>array('127.0.0.1','::1'),
    ),

Please help.

A: Here is the solution to your problem:
http://www.yiiframework.com/wiki/115/why-do-i-get-a-403-error-when-trying-to-use-gii/
You need to add your ip address to the 'ipFilters' array
'ipFilters' => array('127.0.0.1', 'your_ip_address')

A: Are you accessing gii using localhost? Are you able to access your local webserver using localhost? You cannot access your webserver by using localhost if you haven't mapped 127.0.0.1 to localhost which most of the times done by-default for you depending upon your system and the way you installed php / apache

A: 'ipFilters'=>array('127.0.0.1','*.*.*.*')

and then close it or change it back  afterwards...
because
if you don't...
kiddies will take you down


text:
Q: How can I know what form control had focus when ribbon button pressed? Have a custom JS function that gets called when a ribbon button is pressed in the context of a form. In my custom JS function I need to know what form field had the focus just prior to the ribbon button being pressed. I've tried 2 ways (below) without success. Is there any way to do this reliably?
Way #1
According to this, I can get the control I want passed as a parameter to my JS. I've tried using both PrimaryControlId and PrimaryControl parameters.
<JavaScriptFunction FunctionName="OnCustomBtnFunc"
                    Library="$webresource:myJSfile.js">
   <CrmParameter Value="PrimaryControlId" />
   <CrmParameter Value="PrimaryControl" />
</JavaScriptFunction>

For both, I get an object passed to OnCustomBtnFunc() but it does not seem to enable me to determine which form control had the focus prior to the ribbon button being pressed.
Way #2
I call Xrm.Page.ui.getCurrentControl(). This works for form fields of some types but not others e.g. if it is a string field it works but I get null for a lookup.

A: you won't like this answer, but you can use JQuery to quickly grab every Control in your Form and assign it an OnBlur event.  This event can either assign the ID or the control itself to global variable, which you will make accessible to your ribbon (which fires from a different scope).
People do not like this approach because of the different context scopes of the variables and because it involves playing with "unsupported" features of plain HTML.  However, if you ask only the question "how" and not "should we", then this is an easy way for "how" you would do this.


text:
Q: How to Define Product in WooCommerce Shortcode to use on Custom Order Received Page I am trying to understand how to define product in this code after having made some changes to it based on the answer in my previous question Why does WooCommerce Order Shortcode Generate Plugin Notice on Custom Thank You Page?
The notice message have changed and now it asks me to define product. This is the notice:
Notice: Undefined variable: product in /wp-content/themes/storefront/functions.php on line 842

The notice refers to this line:
'purchase_note' => $product ? $product->get_purchase_note() : '',

This is the full code:
function order_cost_breakdown(){

    if ( isset( $_GET['order_id']) && $_GET['order_id'] > 0 ) {

        $order_id = (int) esc_attr( $_GET['order_id'] );

        $order = wc_get_order( $order_id );

        $order_data = $order->get_data();

        $show_purchase_note    = $order->has_status( apply_filters( 'woocommerce_purchase_note_order_statuses', array( 'completed', 'processing' ) ) );

    ob_start();

    ?>

                        <?php _e( 'Product', 'woocommerce' ); ?>
                        <?php _e( 'Total', 'woocommerce' ); ?>

        <?php foreach ( $order->get_items() as $item_id => $item ) {

        wc_get_template( 'order/order-details-item.php', array (
        'order' => $order,
        'item_id' => $item_id,
        'item' => $item,
        'product' => apply_filters( 'woocommerce_order_item_product', $item->get_product( $item ), $item ),
        'show_purchase_note' => $show_purchase_note,
        'purchase_note' => $product ? $product->get_purchase_note() : '',
        ) );
        }
    ?>

    <?php do_action( 'woocommerce_order_items_table', $order ); ?>

    <?php

        foreach ( $order->get_order_item_totals() as $key => $total ){
    ?>

        <?php echo $total['label']; ?>
        <?php echo $total['value']; ?>

        <?php
    }

    ?>

<?php

    return ob_get_clean();

    }

}

Any advice is helpful as I am clearly not an expert.

A: To fix the notice
Replace
<?php foreach ( $order->get_items() as $item_id => $item ) {

    wc_get_template( 'order/order-details-item.php', array (
    'order' => $order,
    'item_id' => $item_id,
    'item' => $item,
    'product' => apply_filters( 'woocommerce_order_item_product', $item->get_product( $item ), $item ),
    'show_purchase_note' => $show_purchase_note,
    'purchase_note' => $product ? $product->get_purchase_note() : '',
    ) );
    }
?>

With
<?php foreach ( $order->get_items() as $item_id => $item ) {
    $product = $item->get_product();

    wc_get_template( 'order/order-details-item.php', array (
        'order'              => $order,
        'item_id'            => $item_id,
        'item'               => $item,
        'product'            => apply_filters( 'woocommerce_order_item_product', $item->get_product( $item ), $item ),
        'show_purchase_note' => $show_purchase_note,
        'purchase_note'      => $product ? $product->get_purchase_note() : '',
    ));
}
?>

That should suffice


text:
Q: MySQL LIMIT x,y performance huge difference on 2 machine I have a query in an InnoDb item table which contains 400k records (only...). I need to page the result for the presentation layer (60 per page) so I use LIMIT with values depending on the page to display.
The query is (the 110000 offset is just an example):
SELECT i.id, sale_type, property_type, title, property_name, latitude,
       longitude,street_number, street_name, post_code,picture, url,
       score, dw_id, post_date
FROM item i WHERE picture IS NOT NULL AND picture != ''
AND sale_type = 0
ORDER BY score DESC  LIMIT 110000, 60;

Running this query on my machine takes about 1s.
Running this query on our test server is 45-50s.
EXPLAIN are both the same:
+----+-------------+-------+-------+---------------+-----------+---------+------+--------+-------------+
| id | select_type | table | type  | possible_keys | key       | key_len | ref  | rows   | Extra       |
+----+-------------+-------+-------+---------------+-----------+---------+------+--------+-------------+
|  1 | SIMPLE      | i     | index | NULL          | IDX_SCORE | 5       | NULL | 110060 | Using where |
+----+-------------+-------+-------+---------------+-----------+---------+------+--------+-------------+

The only configuration difference when query show variables are:

*

*innodb_use_native_aio. It is enabled on the Test server, not on my machine. I tried disabling it and I don't see any significant change

*innodb_buffer_pool_size 1G on Test server, 2G on my machine

Test server has 2Gb of ram, 2 core CPU:

*

*mysqld uses > 65% of RAM at all time, but only increase 1-2% running above query

*mysqld uses 14% of CPU while running the above query, none when idle

My local machine has 8Gb, 8 core CPU:

*

*mysqld uses 28% of RAM at all time, and doesn't really increase while running the above query (or for a so short time I can see it)

*mysqld uses 48% of CPU while running the above query, none when idle

Where and what can I do to have the same performance on the Test server? Is the RAM and/or CPU too low?
UPDATE
I have setup a new Test server with the same specs but 8G of RAM and 4 core CPU and the performance just jumped to values similar to my machine. The original server didn't seem to use all of the RAM/CPU, why are performance so worse?

A: One of the surest ways to kill performance is to make MySQL scan an index that doesn't fit in memory.  So during a query, it has to load part of the index into the buffer pool, then evict that part and load the other part of the index.  Causing churn in the buffer pool like this during a query will cause a lot of I/O load, and that makes it very slow.  Disk I/O is about 100,000 times slower than RAM.
So there's a big difference between 1GB of buffer pool and 2GB of buffer pool, if your index is, say 1.5GB.
Another tip:  you really don't want to use LIMIT 110000, 60.  That causes MySQL to read 110000 rows from the buffer pool (possibly loading them from disk if necessary) just to discard them.  There are other ways to page through result sets much more efficiently.
See articles such as Optimized Pagination using MySQL.


text:
Q: RestKit RKRequests arent sent immediately I am using the great RestKit Framework for an iPhone Application.
I have got a method, where I send requests to a webservice. Sometimes four or more requests per 30 seconds.
My sendMethod looks like:
 - (void) sendLocation {

NSString *username = [userDefaults objectForKey:kUsernameKey];
NSString *password = [userDefaults objectForKey:kPasswordKey];
NSString *instance = [userDefaults objectForKey:kInstanceKey];
NSString *locationname = self.location.locationname;

NSString *url = [[NSString alloc] initWithFormat:@"http://www.someadress.com/%@", instance];

RKClient *client = [RKClient clientWithBaseURL:url username:username password:password];

// Building my JsonObject
NSDictionary *locationDictionary = [NSDictionary dictionaryWithObjectsAndKeys: username, @"username", locationname, @"locationname", nil];
NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjectsAndKeys:locationDictionary, @"location", nil];

NSString *JSON = [jsonDictionary JSONRepresentation];
RKParams *params = [RKRequestSerialization serializationWithData:[JSON dataUsingEncoding:NSUTF8StringEncoding]MIMEType:RKMIMETypeJSON];

[client  post:@"/locations" params:params delegate:self];
 }

Sometimes (especially when sending more requests after another) the value of the count property of the RKRequestQueue Object is > 1.
When my application enters background and then enters foreground the requests in the queue (when foreground is entered) are sent to my Webservice and the delegate
- (void)request:(RKRequest*)request didLoadResponse:(RKResponse*)response {)

for all requests will be called.
So the question is:
 Why doesnt RestKit send some requests immediately (my Webservice doesnt receive anything while a request is stored in the queue)???
Does anyone know a solution or had/has the same problem?

A: I noticed this line where you create the RKClient:
RKClient *client = [RKClient clientWithBaseURL:url username:username password:password];

This basically creates new instance each time sendLocation method is called - are you sure this is your desired behavior? If the url, username and password does not change, you can access previously created client by calling [RKClient sharedClient]. In your current approach, new request queue is created for each new client.
Now back to the point. Take a look on this property of the RKRequestQueue:
/**
* The number of concurrent requests supported by this queue
* Defaults to 5
*/
@property (nonatomic) NSUInteger concurrentRequestsLimit;

As you can see this defaults to 5, so if you have more than that in any of your queues they will wait until the ongoing requests are processed. You also mentioned that the requests stack up when the application is moved to background, and then when it enters the foreground all of them are dispatched. You can control how your requests behave like this:
- (void)backgroundUpload {
    RKRequest* request = [[RKClient sharedClient] post:@"somewhere" delegate:self];
    request.backgroundPolicy = RKRequestBackgroundPolicyNone; // Take no action with regard to backgrounding
    request.backgroundPolicy = RKRequestBackgroundPolicyCancel; // If the app switches to the background, cancel the request
    request.backgroundPolicy = RKRequestBackgroundPolicyContinue; // Continue the request in the background
    request.backgroundPolicy = RKRequestBackgroundPolicyRequeue; // Cancel the request and place it back on the queue for next activation
}

I have found this solution here. Scroll down to Background Upload/Download section.


text:
Q: ansible give error when using variable for ACI I am trying to automate ACI with ansible, very new to ansible, as a start point, I started to create simple Tenant and VRF and I am using a variable with my playbook, here it is my playbook like below.
---
- name: Playbook
  hosts: APIC
  connection: local
  gather_facts: no

  tasks:
    - name: Create new tenant
      aci_tenant:
        host: "{{ apic_host }}"
        username: "{{ apic_username }}"
        password: "{{ apic_password }}"
        tenant: "{{ tenant_name }}"
        validate_certs: False
        description: "{{ tenant_description }}"
        state: present

    # - pause:
    #    seconds: 10

    - name: Add a new VRF
      aci_vrf:
        host: "{{ apic_host }}"
        username: "{{ apic_username }}"
        password: "{{ apic_password }}"
        tenant: "{{ tenant_name }}"
        validate_certs: false
        vrf: "{{ vrf_name }}"
        policy_control_preference: enforced
        policy_control_direction: ingress
        state: present

    # - pause:
    #    seconds: 30

and here is my variable file
---

apic_host: sandboxapicdc.cisco.com
apic_username: admin
apic_password: ciscopsdt
tenant_name: zhajili_TN
tenant_description: 'zhajili_first_ansible_tenant'
ap_name: 'AP'
ap_description: 'AP created with Ansible'
vrf_name: 'zhajili_VRF'

When I execute the playbook I receive the following error.
$ ansible-playbook tenants_vrfs.yml -i inventory -v
No config file found; using defaults

PLAY [Playbook] ************************************************************************************************************************************************************************************************

TASK [Create new tenant] ***************************************************************************************************************************************************************************************
fatal: [apicsim_sandbox]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'apic_host' is undefined\n\nThe error appears to be in '/Users/zhajili/Desktop/ansible/ACI/Cisco Sandbox/Tenants_and_VRFs/tasks/tenants_vrfs.yml': line 8, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n  tasks:\n    - name: Create new tenant\n      ^ here\n"}

PLAY RECAP *****************************************************************************************************************************************************************************************************
apicsim_sandbox            : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0


text:
Q: I want to use php preg_match function to validate score the requirement
-Only two decimal places allowed.
-Values before the decimal point must be at least 1 number.
-Example: 5.09
-return turn and false

A: Here it is
$score = 5.09;
$result = (bool) preg_match("/^[0-9]+(\.[1-9]{1})+([0-9]{1})?$/", $score);
var_dump($result);

.[1-9]{1} means 1 character after decimal (.) must start from 1


text:
Q: Incorrect syntax near '<' Why is SSRS throwing an error stating that there is an incorrect syntax near my less than symbol?
-- ==========================================================
-- Create Stored Procedure Template for SQL Azure Database
-- ==========================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      <Campos,,Adrian>
-- Create date: <7/9/2014,,>
-- Description: <Query is meant to purge records in ONP_IL_MAYWOOD that are older than 3 months.,,>
-- =============================================
CREATE PROCEDURE <Purge_Overnight_3Months, sysname, Purge_Overnight_3Months>
-- Add the parameters for the stored procedure here

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
DELETE FROM tblOverNightPermissions WHERE DateAndTime < DATEADD(month, -3, GETDATE());
END
GO

Error:

Msg 102, Level 15, State 1, Line 6
  Incorrect syntax near '<'.

A: The <Purge_Overnight_3Months, sysname, Purge_Overnight_3Months> is a template parameter for Management Studio. While the file is opened in SSMS hit Ctrl-Shift-M (or choose "Specify Values for Template Parameters…" from the Query Menu). This should bring up a grid that says that there's parameter called Purge_Overnight_3Months (the first value in the angle brackets) with a datatype of sysname and a default value of "Purge_Overnight_3Months" (the third value in the angle brackets). Once you specify a value, and hit "ok", it will replace the entire angle brackets with the value that you chose.

A: Use  [] to escape names in TSQL, not <>
CREATE PROCEDURE [Purge_Overnight_3Months, sysname, Purge_Overnight_3Months]

but you should not use such strange names anyway. How about
CREATE PROCEDURE Purge_Overnight_3Months


text:
Q: Matlab: How to write a function that gets an integer n and always returns the result P = 1*1.2*1.4*....*(1+0.2*(n-1)) I am trying to solve a problem that requires writing a function called repeat_prod(n), that gets an integer n and returns the result of the following function:
P = 1*1.2*1.4*....(1+0.2(n-1))
for exemple if n is 6:
repeat_prod(6)

ans = 9.6768

I tried the following:
function P = repeat_prod(n)
  for 1:n-1
    P = (1+0.2*(n-1));
  end
end

But it does not run. How can I get the loop to work?

A: The logic within your function should be something like below
function P = repeat_prod(n)
  P = 1; % initial value for following cumulative products
  for k = 1:n
    P = P*(1+0.2*(k-1));
  end
end

Compact Version
You can also use prod within your function repeat_prod to replace for loop, i.e.,
function P = repeat_prod(n)
  P = prod(1 + 0.2*((1:n)-1));
end


text:
Q: How to make policy transactions without billing center server up? I have tried to change the gosu class from IBillinPlugin to standalone plugin and tried. But am getting error in different classe
i have explained and expecting


text:
Q: How to set multiple Image Well? I am new to Cocoa and I now wish to set multiple image to image well.
Here is the code snippet:
//--------------show rank 1 image-------------//
int rank1 = rank_fst5[0];
NSString *rank1_path = [NSString stringWithFormat:@"/Users/Desktop/gallery/%d.png",rank1];
NSImage *image1 = [[NSImage alloc] initWithContentsOfFile:rank1_path];
[imageRank1 setImage:image1];

//--------------show rank 2 image-------------//
int rank2 = rank_fst5[1];
NSString *rank2_path = [NSString stringWithFormat:@"/Users/Desktop/gallery/%d.png",rank2];
NSImage *image2 = [[NSImage alloc] initWithContentsOfFile:rank2_path];
[imageRank2 setImage:image2];

The result only shows the first image in "imageRank1".
And if I comment the first show image code, I can get the second one on show. But the two images cannot show concurrently.
Could anyone help me? Thanks.


text:
Q: multiple graphics windows with gWidgets The ggraphics() constructor of the gWidgets package opens a plot window. Is it possible to open several plot windows and to control in which window we plot a graph ? (The help of ggraphics() says: When multiple graphics devices are present, clicking in the window of one will make that the current device. But I want to control the current device with the R code, not with the mouse)

A: You can have multiple ggraphics instances, each having its own device number to do all the things you want. The ggraphicsnotebook widget packages up an interface for this if you want. The bit about clicking on the window is in addition to the usual programmatic ways to specify the current device.


text:
Q: Read data from csv file and pass the values into sql statment using python seqno   soursequery targetquery
1   select count(*) from table  select count(*) from table
2   select count(*) from table  select count(*) from table

I have csv file like above and I have to read seqno and both queries and compare the result in Python. I have to put the testcase status in the same file.
Expected:
if seqno is 1 I have to read first two queries(source and target) and compare the count of both queries.
Thanks,
in advance

A: I think you want something like this.
# Select All From CSV File Where

import csv
# Asks for search criteria from user
search_parts = input("Enter search criteria:\n").split(",")
# Opens csv data file
file = csv.reader(open("C:\\your_path_here\\test.csv"))
# Go over each row and print it if it contains user input.
for row in file:
    if all([x in row for x in search_parts]):
        print(row)


text:
Q: Same component to be used on multiple Nuxt project I have a project where I will need to deploy multiple Nuxt websites, with each one using the same components. I don't want to have redundancy and having to change 10 times the same component in 10 differents projects.
So, do you have an idea of an ideal architecture and technologies to be used in order to create single Nuxt components that can be re-used within all the differents websites ?
I have read documentation about nuxt-custom-elements, would that be a possibility ? What are the down side, restriction and alternatives to this Module ?
Thanks you a lot for your help.
I am currently doing an analysis and research, I would love to hear from your experience with this kind of projects in order to not go into a wrong direction.


text:
Q: React-native facebook login via webview Im trying to login via facebook with react-native.
And obviously for iOS it works because Im using the react-native-fbsdk package.
But what about android?
It doesn't appear that theres a package yet for native login for android?
So do I just use the regular JS sdk? How would I implement a basic webview style login?? When localStorage and such aren't available.
Sorry, just very new to react-native, and can't wrap my head around how to do this properly.

A: Yes, a package exists. Check it here.
It works very well.


text:
Q: Will text fit in GTK# TextView without scroll bar I have a GTK# Text View with word wrap and scroll bars turned on. I know that horizontal scroll bars will not be show because the words will wrap instead.
I want to add some text but before adding it I want to find out if the text will fit without the need for a vertical scroll bar.
I don't want to add the text if it means that the text view will require a vertical scroll bar.
How do I do this?

A: I'm not aware of any way to measure the contents of a TextView without actually updating the text. It's a complex text layout widget that can handle formatted text, images, etc. Inserting text could change the layout quite substantially, so you can't "predict" how some new text will change the size without actually modifying the buffer and recalculating its layout.
It would be easier to suggest a solution if you explain why you need this functionality.
For example, if you simply need to know after adding text whether when the view will have scrollbars, you could use the scroll adjustments - the TextView is a "scrollable" widget, i.e. its layoutspace is virtualised, and is manipulated by a parent ScrolledWindow via "Adjustment" objects that contain the range, page size, scroll increment size, etc. You could detect when they change by accessing them from the ScrolledWindow and subscribing to their change events.


text:
Q: Non normal residuals at auto.arima I´m doing an auto.arima to a time-serie and as a result, i get the model but with non normal residuals (jarque.bera.test). Can i use this model? Or it´s necessary to have normal residuals?
Also for making auto.arima odo i have to use an stacionary serie? I´m using thenon-stacionary with logs. My class exercise did that.
I´m using R-studio 1.1.463 and Windows 10.
emp.ts.log is the time-serie with log.
arima.auto
hist(arima.auto$residuals)
Acf(arima.auto$residuals)
Pacf(arima.auto$residuals)
library(tseries)
jarque.bera.test(arima.auto$residuals)

I expected a p-value >0.05 at Jarque.Bera.Test but i get
data: arima.auto$residuals X-squared = 4101.2, df = 2, p-value < 2.2e-16.

Thank you so much

A: Why would you think that they should be normal OR even independent of each other Or have a constant error variance over time ? auto.arima does not perform tests of parameter significance so there is no need for distributional concerns unless one is concerned about confidence limits for forecasts , as we all should be .
auto.arima simply fits a set of presumed models and that is not modelling in the larger sense it is simply fitting and picks the best of the set that was tried.
That is not what Box & Jenkins had in mind while this is closer https://autobox.com/pdfs/ARIMA%20FLOW%20CHART.pdf reflecting an iterative self-checking process culminating in separating data to signal (the forecast) and noise (the random component).
The problem you are having is probably due to auto.arima not dealing well with the presence of the deterministic structure yielding large errors resulting in a skewed (non-normal) distribution .
"The correlogram should be calculated from residuals using a model that controls for intervention administration, otherwise the intervention effects are taken to be Gaussian noise, underestimating the actual autoregressive effect."
In other words for auto.arima to be useful you needed to have the following circumstances.
1) a series with no pulses,level shifts,seasonal pulses or deterministic time structure like trends et al .
2) a series where the parameters for the underlying arima model are constant over time
3) a series where the error variance of the underlying arima model does not change deterministically at different time points.
failing one or more of these assumptions is probably what caused your conclusion
Bye the way one doesn't willy-nilly use a power transform as there can be negative side-effects i.e. unexpected consequences . See When (and why) should you take the log of a distribution (of numbers)?


text:
Q: Laravel Routes don't return datas, only return View SPA Laravel 5.8 only return the view of SPA for any route.
Iam building a crud with Laravel 5.8 + vue and I want to define 2 routes in routes/web.php
the first route return SPA vue app
the second instead it returns a collection of new App\User instances.
When I try call crud.test/users laravel return SPA crud again and the second route never execute.
But If I remove the first route crud.test/users works.
Route::get('{path}', function () {
  return view('spa');
})->where('path', '(.*)');

Route::get('/users', function () {
  return factory('App\User', 10)->make();
});

I expect to laravel returnme array of 10 Users

A: You are putting a wild card : {path} to catch all requests in the first route!
try to put the /users route first:
Route::get('/users', function () {
  return factory('App\User', 10)->make();
});

Route::get('{path}', function () {
  return view('spa');
})->where('path', '(.*)');


text:
Q: Angular - I added ngbtimepicker in a ngbpopover in the ag grid and the popover is hiding at the back I'm trying to add a ngbtimepicker in a ngbpopover. The popover is triggered and it is hiding at the back of the element. I tried to add some z-index to the popover to bring that to the front, but still It didn't work. But when we try to add a ngbdatepicker it worked as expected.
Any idea how to resolve it
<div>

    <ng-template #popTemplate>
        <ngb-timepicker [(ngModel)]="mytime"></ngb-timepicker>
    </ng-template>
    <input [(ngModel)]="mytime" [ngbPopover]="popTemplate" placement="bottom" />

</div>


text:
Q: Will Thunderbird integrate with the calendar indicator? Since we're past feature freeze does that mean that there will be no more efforts into integration of Thunderbird and Unity?

A: According to this article, Thunderbird has already achieved complete integration with all of the special menu schemes in Unity. Even if 11.10 ships without complete integration, it shouldn't be any trouble to add it in yourself. You'll either be able to manually modify it, or add in a Mozilla PPA which includes a post-feature-freeze version of Thunderbird and Lightning.
It's already quite possible to add Thunderbird to the time/date indicator in Ubuntu: these instructions will take you through it step by step. They also explains how to thoroughly integrate Thunderbird with your Ubuntu desktop.
Since we're in feature freeze, there aren't likely to be major changes to the calendar indicator design before 11.10. This should make it easier for the Thunderbird developers (and independent add-on developers) to update their Unity-ready addons for 11.10. If you're looking for other unity-specific ways to make Thunderbird play nice with Ubuntu check out these three addons:

*

*Ubuntu Unity Messaging Menu Integration

*Unity Launcher Integration

*Ubuntu Unity unread count and quicklist
Note that they may become unnecessary, if Mozilla continues to add Ubuntu/Unity functionality directly into Thunderbird. This AskUbuntu answer gives some other ways that you can customize your Unity Thunderbird launcher.
If you're feeling particularly adventurous, and want to try out the latest and greatest versions of Thunderbird right now, you can try out one of the Mozilla personal package archives:

*

*Thunderbird Stable (the current version)

*Thunderbird Next (beta)


text:
Q: Can't horizontally center TextView I'm new to android and I'm trying to create a simple TextView thingy. I can't horizontally center it, though. Here's my main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="@string/text"
        android:textSize="45sp" />

</LinearLayout>

A: Changing the orientation to vertical resolved the problem

A: Change orientation to vertical
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:text="@string/text"
        android:textSize="45sp" />

</LinearLayout>

A: You need to let the orientation to 'horizontal' and add the gravity property set to 'center_horizontal'
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="horizontal" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center"
    android:text="@string/text"
    android:textSize="45sp" />


text:
Q: Java Play 2 error: reference to unauthorized is ambiguous After I imported a java play 2 app i get a runtime exception of
both method ok(Content) in Results and method ok(JsonNode) in Results match
[error] ReportStatusController.java:40: error: reference to ok is ambiguous
[error]             return ok(responseWrapper.generateResponse(Status.UNAUTHORIZED, "Invalid Token"));

Any suggestions?

A: It means that there are two functions in scope that are called ok and can accept the argument. Try to refer the function in a fully qualified name, or remove imports.
BTW -
Did you mean Ok(...) (note capital O)?

A: Ok I solved the issue finally...
The problem was the my JAVA_HOME system variable was not set and i almost certain the play application used java 8. When i set the JAVA_HOME variable to java 7 path the app run without errors.


text:
Q: How to create custom customer field in Magento login page? I was searching for the latest method to add custom fields on Magento 1.6 login page. All the articles that I found was for earlier versions on Magento and It's not working.

A: *

*Edit customer/form/login.phtml template

*Edit loginPostAction from Mage_Customer_AccountController (see How can I override a Magento controller?)


text:
Q: app works if jar is local to the project and does not if it's referenced by build path (was "flexjson 3.2 strange bug") I have two java projects in my eclipse indigo.
One of them (let's call project A) has the flexjson 3.2 jar in its lib directory.
The other project (let's call project B) has a reference to the same jar, in its build path.
Both projects connect to a REST service, get the JSON and de-serialize it using flexjson annotations.
What is weird here is that project A works and project B does not work. For project B, the deserialization just returns null silently, no exceptions thrown.
To make things better, if, instead of referencing the flexjson jar from A into B, I copy the same jar to B's lib directory and just set B build path to use the "local" jar instead of the reference, then B works.
So my doubt is: what kind of problem this jar may have or what kind of problem eclipse indigo may have in this case?
ps. no I am not using maven.

A: Close project A and then try.This could be happening because of the jar being used by multiple threads.


text:
Q: Jquery combobox dropdown option selections I have been at this one for a day or two...
I can't seem to get the values that are being selected in the dropdown to 'do' anything.
The HTML
<select id="combobox">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
</select>

The Js/Jquery to get my values to do something
function displayVals() {
        var skillValues = $('#combobox').val();
        $('ul#list').append('
x
' + skillValues);
    }

    $('select').change( displayVals );
    displayVals();

I used the following link as the 'basis' for what I am trying to do.
http://jqueryui.com/autocomplete/#combobox
when the select item is being defined by the 'combobox' from jqueryUI it stops doing the thing that makes the
's. I imagine that for some reason the < option>'s are not being selected.
So I am trying to get each selection to show up in a
 when they are selected, and then maybe be deleted with a click event.
Thanks in advance all, any help would be welcome!
edit: http://jsfiddle.net/tPs42/ this is what it is supposed to do right now, so as you can see it works with a regular dropdown selector.
EDIT: okay, I got it to do what i wanted it to do...
$(function() {
  $( "#combobox" ).combobox({
    select: function displayVals() {
        var skillValues = $('#combobox').val();
        $('ul#list').append('
x
' + skillValues);
    }
        });
    });
    $('select').change( displayVals );
    displayVals();

    $('a[name=remove]').click(removeItem);

that did the trick for me to do what i wanted to do.


text:
Q: SwiftUI: Do I need to remove UIHostingController from the controller chain when I remove the controlled view from the view hierarchy? I am trying to migrate UIKit Views in my app to SwiftUI. One of the central elements in my app is a UICollectionView. I am embedding the SwiftUI views using a UIHostingController - so far so good.
I am wondering, since my cells are reusable, what happens to the UIHostingController when the cell is recycled?
Do I need to take it out of the controller chain?
If I need to, what is the best way to do so? (storing the UIHostingController in the cell?)
Eg. a header view looks like this so far:
class HeaderViewCell: UICollectionReusableView {

    var layoutAttributes:GroupHeaderViewLayoutAttributes = GroupHeaderViewLayoutAttributes()

    public func attachContent(model:GroupHeaderModel, controller:UIViewController){
        let view = GroupHeaderView(model: model, layoutAttributes: self.layoutAttributes)
        let hostingController = UIHostingController(rootView: view)
        if let contentView = hostingController.view {
            controller.addChild(hostingController)
            self.addSubviewAndConstrains(contentView)
        }
    }

    override func prepareForReuse() {
        self.subviews.forEach { $0.removeFromSuperview() }
        layoutAttributes = GroupHeaderViewLayoutAttributes()
    }

    override func apply(_ layoutAttributes: UICollectionViewLayoutAttributes) {
        if let attributes = layoutAttributes as? TileViewLayout.HeaderViewAttributes {
            self.layoutAttributes.topBarHeight = attributes.topBarHeight
            self.layoutAttributes.indicatorWidth = attributes.indicatorWidth
        }
    }
}


text:
Q: Is there ever a good time to use int32 instead of sint32 in Google Protocol Buffers? I've been reading up on Google Protocol Buffers recently, which allows for a variety of scalar value types to be used in messages.
According to their documentation, there's three types of variable-length integer primitives - int32, uint32, and sint32.  In their documentation, they note that int32 is "Inefficient for encoding negative numbers – if your field is likely to have negative values, use sint32 instead."  But if you have a field that has no negative numbers, I assume that uint32 would be a better type to use than int32 anyways (due to the extra bit and decreased CPU cost of processing negative numbers).
So when would int32 be a good scalar to use?  Is the documentation implying that it's most efficient only when you rarely get negative numbers?  Or is it always preferable to use sint32 and uint32, depending on the contents of the field?
(The same questions apply to the 64-bit versions of these scalars as well: int64, uint64, and sint64; but I left them out of the problem description for readability's sake.)

A: There is very little good reason to ever use int* rather than sint*. The existence of these extra types is most likely for historical, backwards compatibility reasons, which Protocol Buffers tries to maintain even across its own protocol versions.
My best guess is that in the earliest version they dumbly encoded negative integers in 2's complement representation, which requires the maximally sized varint encoding of 9 octets (not counting the extra type octet).  Then they were stuck with that encoding so as not to break old code and serializations that already used it.  So, they needed to add a new encoding type, sint*, to get a better variably sized encoding for negative numbers while not breaking existing code.  How the designers didn't realize this issue from the get-go is utterly beyond me.
The 64b varint encoding (without type specification, which requires 1 more octet) can encode an unsigned integer value in the following number of octets:
[0, 2^7): one octet
[2^7, 2^14): two octets
[2^14, 2^21): three octets
[2^21, 2^28): four octets
[2^28, 2^35): five octets
[2^35, 2^42): six octets
[2^42, 2^49): seven octets
[2^49, 2^56): eight octets
[2^56, 2^64): nine octets
If you want to similarly encode small magnitude negative integers compactly then you will need to "use up" one bit to indicate the sign.  You can do this through an explicit sign bit (at some reserved position) and magnitude representation.  Or, you can do zig zag encoding, which effectively does the same thing by left shifting the magnitude by 1 bit and subtracting 1 for negative numbers (so the least significant bit indicates the sign: evens are non-negative, odds are negative).
Either way, the cut over points at which positive integers require more space now comes a factor of 2 earlier:
[0, 2^6): one octet
[2^6, 2^13): two octets
[2^13, 2^20): three octets
[2^20, 2^27): four octets
[2^27, 2^34): five octets
[2^34, 2^41): six octets
[2^41, 2^48): seven octets
[2^48, 2^55): eight octets
[2^55, 2^63): nine octets
To make the case to use int* over sint*, negative numbers would have to be extremely rare, but possible, and/or the most common positive values you expect to encode would have to fall right around one of the cut over points that leads to a larger encoding in sint* as opposed to int* (e.g. - 2^6 vs. 2^7 leading to 2x encoding size).
Basically, if you are going to have numbers where some may be negative, then by default use sint* rather than int*. int* will very rarely be superior and usually won't even be worth the extra thought you have to dedicate towards judging whether it is worth it or not IMHO.

A: I'm not familiar with Google Protocol Buffers, but my interpretation of the documentation is:

*

*use uint32 if the value cannot be negative

*use sint32 if the value is pretty much as likely to be negative as not (for some fuzzy definition of "as likely to be")

*use int32 if the value could be negative, but that's much less likely than the value being positive (for example, if the application sometimes uses -1 to indicate an error or 'unknown' value and this is a relatively uncommon situation)

Here's what the docs have to say about the encodings (http://code.google.com/apis/protocolbuffers/docs/encoding.html#types):

there is an important difference between the signed int types (sint32 and sint64) and the "standard" int types (int32 and int64) when it comes to encoding negative numbers. If you use int32 or int64 as the type for a negative number, the resulting varint is always ten bytes long – it is, effectively, treated like a very large unsigned integer. If you use one of the signed types, the resulting varint uses ZigZag encoding, which is much more efficient.
ZigZag encoding maps signed integers to unsigned integers so that numbers with a small absolute value (for instance, -1) have a small varint encoded value too. It does this in a way that "zig-zags" back and forth through the positive and negative integers, so that -1 is encoded as 1, 1 is encoded as 2, -2 is encoded as 3, and so on...

So it looks like even if your use of negative numbers is rare, as long as the magnitude of the numbers (including non-negative numbers) you're passing in the protocol is on the smaller side, you might be better off using sint32.  If you're unsure, profiling would be in order.


text:
Q: make validations in powermail work without declaring the field as required (TYPO3 10, Powermail) is there a possibiliy to make the validations work without declaring the whole field as requiered?
For instance i need a restriction to a given number of characters for all input fields. Well, not all input fields are requiered, but none must contain more than the given number of characters.
It works fine in all fields which are required but not on non required fields. On these fields every validator is ignored. Is there a possiblity to change this behavior? I would need such validations in every second form ... (e.g. restrict to numbers, restrict to correct email without forcing the input of an email address and so on).
Thanks!


text:
Q: Linq to query with multiple row subquery (without join) I'd like to make a query with multiple row subquery as we do in MySql but I want to do it without join, so my sql query is:
select * from html_files_tab where html_files_tab.encoded_id in
(select html_src_files_relationsip_tab.file_fk from html_src_files_relationsip_tab where html_src_files_relationsip_tab.src_fk == '1' );

I tried:
var fileBeans = ( from srcFileTab in conn.Table<FileBean>() where
                  srcFileTab.fileId in ( from srcFileRelationSipTab in
                  conn.Table<HtmlSrcFileRelationship>() where
                  srcFileRelationSipTab.srcFk == encodedSrcId select
                  srcFileRelationSipTab.fileFk ) select srcFileTab ).ToList();

But I get some errors, is there a way to do it without Join?
p.s. using join method:
   var fileBeans = ( from fileTab in conn.Table<FileBean>()
                                  join relationTab in conn.Table<HtmlSrcFileRelationship>()
                                  on fileTab.fileId equals relationTab.fileFk
                                  where relationTab.srcFk == encodedSrcId && relationTab.srcFk == encodedSrcId
                                  select fileTab ).ToList();

Using join I get an exception:
Exception thrown: 'System.NotSupportedException' in SQLite.Net.dll

full stack trace:
   at SQLite.Net.TableQuery`1.GenerateCommand(String selectionList)
   at SQLite.Net.TableQuery`1.GetEnumerator()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at HiTech.DataBase.selectFileBeansBySrc(String encodedSrcId)

A: Instead of trying to recreate SQL in LinQ you can use the LinQ option of nested iterations which is pretty much the same as a subquery.
var tabs = (from srcFileTab in conn.Table<FileBean>()
            from srcFileRelationSipTab in conn.Table<HtmlSrcFileRelationship>()
            where srcFileRelationSipTab.srcFk == encodedSrcId
               && srcFileTab.fileId == srcFileRelationSipTab.fileFk
            select srcFileTab ).ToList();

A:
is there a way to do it without Join?

You could use Any extension and do this.
conn.Table<FileBean>()
    .Select(x=>  conn.Table<HtmlSrcFileRelationship>()
                     .Any(r=> r.srcFk == encodedSrcId  && r.srcFk  == x.encoded_id))
                     // not sure it is encoded_id or encodedSrcId in above statement. Update accordingly.
    .ToList();

A: Can't you do it in two separate queries?
var fileRel = (from srcFileRelationSipTab in
              conn.Table<HtmlSrcFileRelationship>() where
              srcFileRelationSipTab.srcFk == encodedSrcId
              select srcFileRelationSipTab.fileFk).ToList();

var fileBeans = ( from srcFileTab in conn.Table<FileBean>() where
              srcFileTab.fileId in fileRel
              select srcFileTab ).ToList();

A: The direct LINQ equivalent of SQL IN operator is Contains method:
var fileBeans =
    (from srcFileTab in conn.Table<FileBean>()
     where (from srcFileRelationSipTab in conn.Table<HtmlSrcFileRelationship>()
            where srcFileRelationSipTab.srcFk == encodedSrcId
            select srcFileRelationSipTab.fileFk).Contains(srcFileTab.fileId)
     select srcFileTab).ToList();


text:
Q: No suitable module for running kernal found I am new to Linux and really hit a wall with this one. I'm basically trying to set up VirtualBox for Vagrant. I had this working yesterday but today its not after I rebuilt my pc.
I have tried to start and stop the service but still the same errors message.

lsb_release - a = Ubuntu 14.04.3 LTS ( desktop version ) release 14.04
codename trust
uname -r
3.19.0 -25-generic

I have follow troubleshooting guides on this forum
14.10: VirtualBox "No suitable module for running kernel found", Cannot Find Kernel Source
and these steps
sudo apt-get install linux-headers-generic build-essential dkms
sudo apt-get remove --purge virtualbox-dkms
sudo apt-get install virtualbox-dkms

I really don't know enough to solve this. Any help would be appreciated? I'm so fed up I would actually pay someone to talk me through it


text:
Q: How to make A-Frame components talk to each other? I want some components to respond to the user's position and orientation in the scene. I have little experience with interactive a-frame scenes and haven't written a component myself.
Generally, I'd want components to be able to provide callbacks for other components to call, or if that's not possible then some kind of inter-component data handoff. The "receiving" component would change its contents (children), appearance and/or behavior.
If we were to take a really simple example, let's say that I want the scene to include either a box if the user is at x>0, or a sphere if they're at x<=0.
Breaking this down, I'll be happy to understand how to...:

*

*Read user position and make it available for others. I found how to read the position; I guess I could just take the <a-scene> element and set some attribute, such as user-position="1 2 3".

*Write some code, somewhere, that runs a function when this position changes (I'll debounce it, I imagine) and makes changes to a scene. I think that if I wrote my own component to include the whole scene, I'd need to...:

*

*Set the user position as an attribute on that element;

*Define an update method;

*In the update method, compare current vs previous user location.

...but I'm wondering if maybe this is overkill and I can just hook somehow into a-scene, or something else entirely.
If I take the approach I mentioned above, I guess the missing piece is how to "declare" what to render? For example, using ReactJS I'd just do return x > 0 ? <a-box/> : <a-sphere/>;. Is there an equivalent, or would I need to reach into the DOM and manually add/remove <a-box> child and such?
Thank you!
EDIT: I sort of got my box/sphere working (glitch), but it feels quite strange, would love to improve this.

A: How to make A-Frame components talk to each other?
0. setAttribute
You can change any property in any component with
element.setAttribute("component_name", "value");

but I assume you want more than reacting to update calls. Something more flexible than the component schema and a bit more performant when used 60 times per second/
1. events

*

*component 1 emits an event

*components 2 - x listen for an event, and react accordingly.

Not dependant on hard-coded component names, you can easily have multiple recipients, and a possibly stable API:

<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script>
  AFRAME.registerComponent("position-reader", {
    tick: function() {
      // read the position and broadcast it around
      const pos = this.el.object3D.position;
      const positionString = "x: " + pos.x.toFixed(2) +
        ", z: " + pos.z.toFixed(2)
      this.el.emit("position-update", {text: positionString})
    }
  })
  AFRAME.registerComponent("position-renderer", {
    init: function() {
      const textEl = document.querySelector("a-text");
      this.el.addEventListener("position-update", (evt) => {
        textEl.setAttribute("value", evt.detail.text);
      })
    }
  })
</script>
<a-scene>
  <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
  <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
  <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
  <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
  <a-camera position-renderer position-reader>
    <a-text position="-0.5 0 -0.75" color="black" value="test"></a-text>
  </a-camera>
</a-scene>

2. Directly
Taking this literally, you can grab the component "object" reference with
entity.components["componentName"]

and call its functions:
entity.components["componentName"].function();

For example - one component grabs the current position, and tells the other one to print it:

<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script>
  AFRAME.registerComponent("position-reader", {
    init: function() {
      // wait until the entity is loaded and grab the other component reference
      this.el.addEventListener("loaded", evt => {
        this.rendererComp = this.el.components["position-renderer"];
      })
    },
    tick: function() {
      if (!this.rendererComp) return;
      // read the position and call 'updateText' in the 'position-renderer'
      const pos = this.el.object3D.position;
      const positionString = "x: " + pos.x.toFixed(2) +
        ", z: " + pos.z.toFixed(2)
      this.rendererComp.updateText(positionString)
    }
  })
  AFRAME.registerComponent("position-renderer", {
    init: function() {
      this.textEl = document.querySelector("a-text");
    },
    updateText: function(string) {
      this.textEl.setAttribute("value", string);
    }
  })
</script>
<a-scene>
  <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
  <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
  <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
  <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
  <a-camera position-renderer position-reader>
    <a-text position="-0.5 0 -0.75" color="black" value="test"></a-text>
  </a-camera>
</a-scene>

In Your case I'd check the position, and manage the elements in one component. Or use one to determine if the position.x > 0 || < 0, and the other one for visibility changes.

<script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
<script>
  AFRAME.registerComponent("position-check", {
    schema: {
      z: {default: 0}
    },
    tick: function() {
      const pos = this.el.object3D.position;
      // check if we're 'inside', or outside
      if (pos.z >= this.data.z) {
        // emit an event only once per occurence
        if (!this.inside) this.el.emit("got-inside");
        this.inside = true
      } else {
        // emit an event only once per occurence
        if (this.inside) this.el.emit("got-outside");
        this.inside = false
      }
    }
  })
  AFRAME.registerComponent("manager", {
    init: function() {
      const box = this.el.querySelector("a-box");
      const sphere = this.el.querySelector("a-sphere")
      //react to the changes
      this.el.sceneEl.camera.el.addEventListener("got-inside", e => {
        box.setAttribute("visible", true);
        sphere.setAttribute("visible", false);
      })
      this.el.sceneEl.camera.el.addEventListener("got-outside", e => {
        box.setAttribute("visible", false);
        sphere.setAttribute("visible", true);
      })
    }
  })
</script>
<a-scene>
  <a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
  <a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
  <a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
  <a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>

  <a-entity manager>
    <a-box position="0 1 -3" visible="false"></a-box>
    <a-sphere position="0 1 -3" visible="false"></a-sphere>
  </a-entity>
  <a-camera position-check="z: 0"></a-camera>
</a-scene>


text:
Q: How do I redirect a dir to another on linux? For Example: How can I redirect the dir /tmp to /home/userOne/tmp ?
About Why I Do That: Cause I am a common user on the worker linux server, no previleges to read, write and execute the /temp dir. No root, I can't ask for the power cause these's too many difficult. So, I can't use the jps, jstat, jconsole... commands, they are all throwing NullPointerException.
There is the infomations about that:
[userOne@VM-GWZD01-177117 ~]$ stat /tmp
  File: `/tmp'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: fd04h/64772d    Inode: 2           Links: 8
Access: (0750/drwxr-x---)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-11-01 11:36:07.000000000 +0800
Modify: 2019-12-31 03:50:02.000000000 +0800
Change: 2019-12-31 03:50:02.405056408 +0800

[userOne@VM-GWZD01-177117 ~]$ ls /tmp
ls: cannot open directory /tmp: Permission denied

[userOne@VM-GWZD01-177117 ~]$ jps
Exception in thread "main" java.lang.NullPointerException
    at sun.jvmstat.perfdata.monitor.protocol.local.LocalVmManager.activeVms(LocalVmManager.java:148)
    at sun.jvmstat.perfdata.monitor.protocol.local.MonitoredHostProvider.activeVms(MonitoredHostProvider.java:150)
    at sun.tools.jps.Jps.main(Jps.java:62)

Or can I set a dir to java.io.tmpdir as a global jvm-variable ?
This is the output of java.io.tmpdir:
[shxz_ftp@VM-GWZD01-177117 ~]$ java OutputJavaTmpDir
/tmp


text:
Q: ASP.NET MVC and mobile website development Good Morning.
We want to modify our MVC website to use different views in order to service the different mobile resolutions across android and iOS. Is there a framework or recommendation in how can we achieve this?


text:
Q: UITextField doesn't scroll to the end after implementing textRectForBounds and editingRectForBounds in a subclass? I have a UITextField subclass where I am implementing the methods below:
- (CGRect)textRectForBounds:(CGRect)bounds {

  return CGRectInset(bounds , 30, 7);
}

-(CGRect) editingRectForBounds:(CGRect)bounds {
  return CGRectInset(bounds , 30, 7);
}

Because of these two methods, the UITextField doesn't scroll to the end when the text entered gets bigger than the width of UITextField. Is there any solution to this?

A: This is probably a conflict between your custom UITextField CALayer height with insets and it's font size.
You may try one of these adjusts:

*

*Decrease font size;

*Increase the UITextField height on Storyboard or programmatically in your subclass like:
- (void)drawRect:(CGRect)rect {
    CGRect frameRect = self.frame;
    frameRect.size.height = 35 //specify the height you want;
    self.frame = frameRect;
 }

*Decrease the y-coordinate value on CGRectInset;

*Or use UIEdgeInsets to have more control in setting values of each position. Something like:
- (CGRect)textRectForBounds:(CGRect)bounds{
    UIEdgeInsets contentInsets = UIEdgeInsetsMake(5, 30, 5, 30);
    return UIEdgeInsetsInsetRect(bounds, contentInsets);
}

- (CGRect)editingRectForBounds:(CGRect)bounds{
    UIEdgeInsets contentInsets = UIEdgeInsetsMake(5, 30, 5, 30);
    return UIEdgeInsetsInsetRect(bounds, contentInsets);
}

A: Reason - You are using fixed font size for textfield text.
Use this
 textFieldObject.adjustsFontSizeToFitWidth = YES;

Short and simple. If you want to set your minimum font size you can use this
 textFieldObject.minimumFontSize

Enjoy

A: Its not working just because of the font size of the text you have declared in UITextField and the CGRectInset you are applying. Actually it should be as per the font size you are setting. For example, for font size of 14.0, just change your method as below:
- (CGRect)textRectForBounds:(CGRect)bounds {
    return CGRectInset(bounds , 30, 6);
}
-(CGRect) editingRectForBounds:(CGRect)bounds {
    return CGRectInset(bounds , 30, 6);
}

The reason is that the drawing rectangle of the text. For example, when we set font size of UITextField as 14.0 then it requires at least a height of 18.0 to adjust the text in the frame. So it needs 4 pixel extra around the text, you can say it overlay frame. Due to which, in your case, this condition is not satisfying because as far as I guess you have adjusted the font size to 14.0 and as by default frame height of UITextField is 30.0 and your edge masking is of 7.0 each side that means total 14.0. So your rect for text returns 16.0 which in turn blocks the OS from updating the text frame because it is outside of the graphics context. I hope you are clear.
More good answer will be as follows:
- (CGRect)textRectForBounds:(CGRect)bounds {
return CGRectInset(bounds , 30, (30 - self.font.pointSize - 4)/2);
}

-(CGRect) editingRectForBounds:(CGRect)bounds {
    return CGRectInset(bounds , 30, (30 - self.font.pointSize - 4)/2);
}

A: I'm not sure this is what you're looking for, but modifying editingRectForBounds the following way, will make the inset dynamic so once the textbox get's "full", it will lessen the inset so the text will fill the whole textbox.
assuming textInset_ is the wanted inset:
- (CGRect)editingRectForBounds:(CGRect)bounds {
    CGFloat compensate = .0f;
    CGSize size = [self.text sizeWithFont:self.font];
    CGFloat textboxWidth = CGRectGetWidth(self.width);

    // If size of text plus inset (right side) is bigger
    // than textbox's width, don't set an inset
    if (size.width+textInset_ >= textboxWidth) {
        compensate = 0;
    }

    // If text area (textbox width minus two insets) is less than
    // text size, lessen the inset so the text fits in
    else if (textboxWidth - textInset_*2 < size.width) {
        compensate = fabs(size.width - (textboxWidth - textInset_));
    }

    // Text fits in textbox WITH insets
    else {
        compensate = textInset_;
    }
    return CGRectInset(bounds, compensate, 10);
}

A: step 1 - make a custom text field MyTextField first

@interface MyTextField : UITextField
step 2 - override MyTextField methods as per your requirement

///place holder position

- (CGRect)placeholderRectForBounds:(CGRect)bounds
 {
   return CGRectInset(bounds, 8, 8);
 }
 // text position
 - (CGRect)textRectForBounds:(CGRect)bounds {

  return CGRectInset(bounds, 8,4);
 }

 // text position while editing
 - (CGRect)editingRectForBounds:(CGRect)bounds {

     return CGRectInset(bounds, 8, 4);
 }
step 3- import MyTextField in your controller class & make object of MyTextField

#import "MyTextField.h"

-(void) viewWillAppear:(BOOL)animated {

    MyTextField* textfield1 = [[MyTextField alloc] init];
    // and so on

}

With Reference to this link :
- (CGRect) textRectForBounds:(CGRect)bounds not being called


text:
Q: Fuzzy Search in Solr I am working on a a fuzzy query using Solr, which goes over a repository of data which could have misspelled words or abbreviated words.  For example the repository could have a name with words "Hlth" (abbreviated form of the word 'Health').

*

*If I do a fuzzy search  for Name:'Health'~0.35  I get results with word 'Health' but not 'Hlth'.

*If I do a fuzzy search for Name:'Hlth'~0.35 I get records with names 'Health' and 'Hlth'.

I would like to get first query to work.  In my bussiness use-case, I would have to use the clean data to query for all the misspelled or abbreviated words.
Could someone please help and throw some light on why #1 fuzzy search is not working and if there are any other ways of achieving the same.

A: You use fuzzy query in a wrong way.
According to what Mike McCandless saying (http://blog.mikemccandless.com/2011/03/lucenes-fuzzyquery-is-100-times-faster.html):

FuzzyQuery matches terms "close" to a specified base term: you specify an allowed maximum edit distance, and any terms within that edit distance from the base term (and, then, the docs containing those terms) are matched.
The QueryParser syntax is term~ or term~N, where N is the maximum
  allowed number of edits (for older releases N was a confusing float
  between 0.0 and 1.0, which translates to an equivalent max edit
  distance through a tricky formula).
FuzzyQuery is great for matching proper names: I can search for
  mcandless~1 and it will match mccandless (insert c), mcandles (remove
  s), mkandless (replace c with k) and a great many other "close" terms.
  With max edit distance 2 you can have up to 2 insertions, deletions or
  substitutions. The score for each match is based on the edit distance
  of that term; so an exact match is scored highest; edit distance 1,
  lower; etc.

So you need to write queries like this - Health~2

A: You write: "I wanted to match Parkway with Pkwy"
Parkway and Pkwy have an edit distance of 3. You could achieve this by subbing in "~3" for "~2" from the first response, but Solr fuzzy matching is not recommended for values greater than 2 for performance reasons.
I think the best way to approach your problem would be to generate a context-specific dictionary of synonyms and do query-time expansion.

A: Using phonetic filters may solve your problem.
Please consider looking at the following
https://cwiki.apache.org/confluence/display/solr/Filter+Descriptions#FilterDescriptions-PhoneticFilter
https://cwiki.apache.org/confluence/display/solr/Phonetic+Matching
Hope this helps.


text:
Q: Cron */6 hours but with an offset? I have a bunch of devices all running a similar cron job. Currently I'm setting a cron minute and hours to a random number (that way they don't all run at once).
$random_minute $random_hour * * * sudo /bin/script

I want to keep this pattern of making each device random but I also have a script which needs to be run every 6 hours. How can I combine something like above with */6?

A: There aren't that many hours in the day, so why not just
17 3,9,15,21 * * * sudo /bin/script

to run at 03:17 and every 6 hours hence?
The alternatives would involve adding a sleep to the program itself:
0 */6 * * * (sleep 11820; sudo /bin/script)

or running the script more often (say, hourly), and having the script just exit if the actual job was executed within the last < 6 hours.

A: With some cron implementations, you can use:
17 3-23/6 * * * * some command