text:
Q: Change wallpaper in MacOs using voice recognition in Python 3 I am writing a personal assistant in Python 3 for changing wallpaper in macOS. I am getting some error. So help me with this process.
I tried with this code gven below but at first I got:

"IsADirectoryError: [Errno 21] Is a directory:'/Users/suryakantkumar/SofiaAssistant/wallpaper/'" error.

Then after putting a file in directory, it said:

Say something...
You said: change wallpaper
wallpaper changed successfully

But wallpaper didn't changed.
elif 'change wallpaper' in command:
    folder = '/Users/suryakantkumar/SofiaAssistant/wallpaper/'
    for the_file in os.listdir(folder):
        file_path = os.path.join(folder, the_file)
        try:
            if os.path.isfile(file_path):
                os.unlink(file_path)
        except Exception as e:
            print(e)
    api_key = 'fd66364c0ad9e0f8aabe54ec3cfbed0a947f3f4014ce3b841bf2ff6e20948795'
    url = 'https://api.unsplash.com/photos/random?client_id=' + api_key #pic from unspalsh.com
    #f = urllib2.urlopen(url)
    f = urlopen(url)
    json_string = f.read()
    f.close()
    parsed_json = json.loads(json_string)
    photo = parsed_json['urls']['full']
    urllib.request.urlretrieve(photo, '/Users/suryakantkumar/SofiaAssistant/wallpaper/File16') # Location where we download the image to.
    subprocess.call(["killall Dock"], shell=True)
    sofiaResponse('wallpaper changed successfully')

I expected that wallpaper will change but it didn't happened.


text:
Q: How to switch between different applications(mxml file with Application as the root tag) in a big Flex application? I'm new to flex. Now I'm writing an flex application. I plan to split my application into some MXML files(Application as the root tag). How can I switch from one mxml to another?
BTW, what is the best practice for design large flex application? Just one MXML Application and many MXML component or many MXML Application?
Thanks!

A: Its always advisable to create application with many mxml files.
that will allow to modularize the application.
you will be anyway have one main application file and many sub mxml files, which you will add as children to the main app file. splitting application into sub files will keep your code short for each file and development becomes faster. when the file size increases flex builder performance downgrades. also modularising of code will reduce the end swf file size as well the time required to load the application.
you can have one main application file and include the child mxml components like the following.
<?xml version="1.0"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    backgroundColor="white"
    xmlns:components="components.*">
    <mx:HBox width="100%" height="100%" left="10" right="10" top="10" bottom="10">
        <mx:VBox width="100%" height="100%">

            <components:component1 id="comp1"/>

            <components:component2 id="comp2"/>
        </mx:VBox>
        <components:component3 id="comp3"/>
    </mx:HBox>
</mx:Application>

Here component1, component2 and component3 are three different mxml files and they are stored in the folder 'components' under 'src'. the folder is declared in the namespace 'components' in the application root tag. this is how you can include the child components using mxml. for including using actionscript you can use the method 'addChild'.
Cheers,
PK

redpajama_set_name: RedPajamaStackExchange


text:
Q: How can I remove the 'NaN' not removing the data? I'm trying to remove the 'NaN'.
In detail, there is data on one line and 'NaN'.
My data looks like the one below.
     01   02   03   04   05   06     07     08   09    10 ...      12   13  \
0   0.0  0.0  0.0  0.0  0.0  0.0  132.0  321.0  0.0  31.0 ...     NaN  NaN
1   NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...   0.936  0.0
2   NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
3   NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
4   NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
5   NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
6   NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
7   NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
8   NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
9   NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
10  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
11  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
12  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
13  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
14  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
15  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
16  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
17  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
18  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
19  0.0  0.0  0.0  0.0  0.0  0.0  132.0  321.0  0.0  31.0 ...     NaN  NaN
20  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...   0.936  0.0
21  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
22  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
23  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
24  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
25  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
26  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
27  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
28  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN
29  NaN  NaN  NaN  NaN  NaN  NaN    NaN    NaN  NaN   NaN ...     NaN  NaN

          14         15      16   17   18        19   20   21
0        NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
1   8.984375  15.234375  646.25  0.0  0.0  9.765625  0.0  0.0
2        NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
3        NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
4        NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
5        NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
6        NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
7        NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
8        NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
9        NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
10       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
11       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
12       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
13       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
14       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
15       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
16       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
17       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
18       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
19       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
20  8.984375  15.234375  646.25  0.0  0.0  9.765625  0.0  0.0
21       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
22       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
23       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
24       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
25       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
26       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
27       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
28       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN
29       NaN        NaN     NaN  NaN  NaN       NaN  NaN  NaN

[30 rows x 21 columns]

I want to eliminate the NAN between the data and make one data for every 18 lines.
     01   02   03   04   05   06     07     08   09    10 ...      12   13  \
0   0.0  0.0  0.0  0.0  0.0  0.0  132.0  321.0  0.0  31.0 ...     0.936  0.0
1   0.0  0.0  0.0  0.0  0.0  0.0  132.0  321.0  0.0  31.0 ...     0.936  0.0

          14         15      16   17   18        19   20   21
0   8.984375  15.234375  646.25  0.0  0.0  9.765625  0.0  0.0
1   8.984375  15.234375  646.25  0.0  0.0  9.765625  0.0  0.0

I tried option 'dropna()' (using 'how = 'all'' or 'thread = '10'').
But these are not what I want.
How can I remove NaN and merge data?

Add
This is the code that I using(python2).
df_concat = []
for j in range(len(data_file)):
    print("%s data_file_concat  %s %s of %s finished" % (Driver, data_file[j], j, len(data_file)))
    x = pd.read_csv(data_file[j])
    if len(df_concat) != 0:
        df_concat = [df_concat, x]
        df_concat = pd.concat(df_concat, sort=False)
    else:
        df_concat = x
    print("%s df_concat %s of %s finished" %(Driver,j,len(df_concat)))

The df_concat is the data that have NaN.
If you look at the data, there are data in the 0th line from 1 to 10, and data in the 1st line from 11th to 21st.
That is, there are two lines of data.
I want to wrap this in a single line without NaN.
     01   02   03   04   05   06     07     08   09    10 ...      12   13  \
0   0.0  0.0  0.0  0.0  0.0  0.0  132.0  321.0  0.0  31.0 ...     0.936  0.0
1   0.0  0.0  0.0  0.0  0.0  0.0  132.0  321.0  0.0  31.0 ...     0.936  0.0

          14         15      16   17   18        19   20   21
0   8.984375  15.234375  646.25  0.0  0.0  9.765625  0.0  0.0
1   8.984375  15.234375  646.25  0.0  0.0  9.765625  0.0  0.0

Like this result.
I tried to re-index the row to time to using resampling.
df_concat.index = pd.to_datetime(df_concat.index, unit='s')
df_concat_colums=df_concat.columns
start = None
end = None

for i in range(len(df_concat[df_concat_colums[0]])):
    if ~pd.isnull(df_concat[df_concat_colums[0]][i]):
        if start == None:
            start = i
        elif end == None:
            end = i-1
            break

And I save the start and end index.
index_time = df_concat['01'].index[end] - df_concat['01'].index[start]

And I save the index_time to use resampling time.
df_time_merge = df_concat.resample(index_time).mean()

The result of 'df_time_merge' is like this.
enter image description here
It's working!!
But if I have data(starting with Nan) like this, the code didn't working.
enter image description here
If I run same code, the  start = 0 and  end = 0.
Where did I miss?

A: If you have loaded the data into dataframe using Pandas, you can use df.dropna(),
where , df = pd.DataFrame(<your_data_here>)
Also you can pass parameters like below:
df.dropna(how='any')    #to drop if any value in the row has a nan
df.dropna(how='all')    #to drop if all values in the row are nan

A: Have a look at this. https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.dropna.html
df.dropna(args..). Is what you are after.

A: Your complete solution is below:
Be sure, your dataframe structure is regular.
First you split columns of the dataframe into two part. In your case 1-11, 12-21.
your_df=pd.read_csv(...)
columns1=list(range(12))
columns2=list(range(12,22))

df1=your_df[columns1].dropna()
df2=your_df[columns2].dropna().reset_index(drop=True)

df_new=pd.concat([df2,df3], axis=1)

A: Does this do what you want?
def make_sample():
    test=np.full((8,12), np.nan)
    test[0,:6]=np.arange(6)
    test[1,6:]=np.arange(6,18,2)
    test[4:6,:]=2*test[:2,:]
    return test

test=make_sample()

In [74]: test
Out[74]:
array([[ 0.,  1.,  2.,  3.,  4.,  5., nan, nan, nan, nan, nan, nan],
       [nan, nan, nan, nan, nan, nan,  6.,  8., 10., 12., 14., 16.],
       [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan],
       [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan],
       [ 0.,  2.,  4.,  6.,  8., 10., nan, nan, nan, nan, nan, nan],
       [nan, nan, nan, nan, nan, nan, 12., 16., 20., 24., 28., 32.],
       [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan],
       [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan]])

Create an array to identify which rows are NOT all nans
filt=1^np.isnan(test).all(axis=1)

In [78]: filt
Out[78]: array([1, 1, 0, 0, 1, 1, 0, 0])

Use tat array to compress test to rows that are not all nans
compress=np.compress(filt, test, axis=0)

In [80]: compress
Out[80]:
array([[ 0.,  1.,  2.,  3.,  4.,  5., nan, nan, nan, nan, nan, nan],
       [nan, nan, nan, nan, nan, nan,  6.,  8., 10., 12., 14., 16.],
       [ 0.,  2.,  4.,  6.,  8., 10., nan, nan, nan, nan, nan, nan],
       [nan, nan, nan, nan, nan, nan, 12., 16., 20., 24., 28., 32.]])

Set nans to zero
compress[np.isnan(compress)]=0

In [83]: compress
Out[83]:
array([[ 0.,  1.,  2.,  3.,  4.,  5.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0.,  6.,  8., 10., 12., 14., 16.],
       [ 0.,  2.,  4.,  6.,  8., 10.,  0.,  0.,  0.,  0.,  0.,  0.],
       [ 0.,  0.,  0.,  0.,  0.,  0., 12., 16., 20., 24., 28., 32.]])

Add odd to even rows
In [84]: compress[::2,:]+compress[1::2,:]
Out[84]:
array([[ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  8., 10., 12., 14., 16.],
       [ 0.,  2.,  4.,  6.,  8., 10., 12., 16., 20., 24., 28., 32.]])


text:
Q: add mousewheel scroll to jcarousel (not lite) <script type="text/javascript" src="lib/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="lib/jquery.jcarousel.min.js"></script>
<script type="text/javascript" src="lib/jquery.mousewheel.js"></script>

<script type="text/javascript">

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        vertical: true,
        scroll: 2
    });
});

</script>

How can I add a mousewheel scroll to my jcarousel plugin?
I have an up and down arrow in my vertical carousel
and would like to be able to use the mousewheel as well
to scroll up and down.
Also, I would like it to work on mobile platforms, but
that's another issue.
Thanks for the help


text:
Q: wait till function completes calling other functions I have a function1 that calls another function2. Function2 has a for loop in which it calls function3. I want to execute a statement after all 3 calls to function 3 have finished executing. How do I achieve it?
function1: function(){
    function2(args, doSomething(returnValue) {
        if(returnValue == true){
            // do something here
        }
    });
}

function2: function(args, callback){
    for(var i = 0; i < 3; i++){
        function3(args);
    }

    // if function3 completed all 3 times
    callback(true);
}

A: I think all you need to do is to make a variable that increments each time the for loop runs in function2() and check if it is high enough outside of the for loop.
var timesCalled = 0
function1: function(){
    function2(args, doSomething(returnValue) {
        if(returnValue == true){
            // do something here
        }
});
}
function2: function(args, callback){
    for(var i = 0; i < 3; i++){
        function3(args);
        timesCalled++
    }

    if (timesCalled >= 2){// if function3 completed all 3 times
        callback(true);
    }
}

If you want to make sure that function3 does what you want it to 3 times then put the increment in function3. I hope this helps!


text:
Q: Magento - add link to My Account in Main Menu navigation bar I was wondering if it possible to link a category to 'My Account'. Basically I would like to make 'My Account' more prominent, by creating a category - 'My Account' which appears in the main menu navigation bar.
Is there a way of linking this category to 'My Account'? So that when the user clicks on 'My Account' in the navigation bar it links through to through the customers account.
Any ideas?
Fiona

A: It's not the preferred way of doing it. However you can edit the template to display the link in direct association with the categories.


text:
Q: Flutter: How to Check Nested List is Contains a Value How to check if List of Maps contains a target value
For example, I have this model Class:
class Data {
  List<Group>? data;

  Data({this.data});
}

class Group {
  int? id;
  List<Weapon>? weaponItems;
  String? groupName;

  Group({
    this.id,
    this.weaponItems,
    this.groupName,
  });
}

class Weapon {
  int? id;
  String? name;

  Weapon({this.id, this.name});
}

From the model that contains nested list:

Data => Group => Weapon

or see the variables below to see the details of the structure called mainData
final Data mainData = Data(
  data: [
    Group(
      id: 1,
      groupName: 'Assault Riffle',
      weaponItems: [
        Weapon(id: 1, name: 'Ak47'),
        Weapon(id: 2, name: 'M4'),
      ],
    ),
    Group(
     id: 2,
      groupName: 'SMG',
      weaponItems: [
        Weapon(id: 3, name: 'MP5'),
        Weapon(id: 4, name: 'Dual UZI'),
      ],
    ),
  ],
);

then I have one String variable (target value)
String myWeapon = 'Dual Uzi';

How to check if mainData contains 'Dual UZI' from myWeapon?
Is there another way that is more efficient than using a For Loop?

A: You can use the any function to check if something with a certain quality exists. For your example this could be
bool hasMyWeapon = mainData.data?.any((group) => group.weaponItems?.any((weapon) => weapon.name == myWeapon) ?? false) ?? false;


text:
Q: Cómo correr QT Designer en QT5 Windows He instalado PyQT5 sobre Windows mediante pip3 install PyQt5. Sin errores. De hecho desde Python se puede importar el módulo. Problema: ¿cómo puedo correr Qt Designer? No veo ningún designer.exe o similar.
Gracias por adelantado.

A: Qt Designer no viene con pyqt, sino que forma parte del paquete PyQt5-tools, debes instalarlo de forma independiente:
py -3 -m pip install PyQt5-tools

Una vez instalado correctamente te vas a donde tengas instalado Python en tu sistema y lo encontrarás en:

Lib\site-packages\pyqt5-tools\designer.exe

Si instalaste Python en el directorio por defecto (Windows 10) debes encontrarlo en:
C:\Users\TU_USUARIO\AppData\Local\Programs\Python\Python36\Lib\site-packages\PyQt5\designer.exe
            ^                                        ^
            |                                        |
  Cambiar por tu usuario               Cambiar por tu versión de Python

Puedes crear un acceso directo para más comodidad.


text:
Q: How to pull out the name of the primary key column(s) of a MS SQL Server table? I have a MS SQL Server Database with about 75 tables on it, and I am trying to insert records into tables if a record with the same primary key doesn't exist, or update if they do.
I could hard code the primary keys for every table into my vb.net code, but I'd rather not as more tables are to be added at a later date and my code needs to handle this without being changed. Is there a way to pull out the primary key column name(s) from a table using a query so I can loop through each table executing the same code?
Thanks,
Tom
P.S. I am a bit of a newbie when it comes to SQL so if you have the time please be simple and clear with any responses.

A: Have a look at  Find Tables With Primary Key Constraint in Database
SELECT  i.name AS IndexName,
        OBJECT_NAME(ic.OBJECT_ID) AS TableName,
        COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName
FROM    sys.indexes AS i INNER JOIN
        sys.index_columns AS ic ON  i.OBJECT_ID = ic.OBJECT_ID
                                AND i.index_id = ic.index_id
WHERE   i.is_primary_key = 1

A: There is a simpler way of doing this. It is called ADO.NET :)
Basically, you need a DataAdapter to fetch the data from your DB to a DataSet. You then add, modify or remove rows to a DataTable in the DataSet and when you're ready to commit to the DB you tell DataAdapter to do so. The DataSet can keep track of the changes made to it and the DataAdapter knows what statement to use depending on the RowState property of a row/record.
See here how to retrieve and modify data using ADO.NET.


text:
Q: How to install Windows XP on acer I have an Acer laptop core i3. When I try to install Windows XP on my computer, the installation does not complete and a blue screen is displayed with the follwing statement:

Check for viruses on your computer. Remove any newly installed hard drive or harddrive controllers. Check your hard drive to make sure it is properly configured and terminated. Run CHKDSK/F to check for hard drive corruption, and then restart your computer.
  Technical Information:

A: This can mean your hard drive is damaged or got bad sector. Check/scan your hard drive first

A: My personal opinion would be to rather try a different copy of XP. Although there is a chance for the hard drive to be faulty, I think it has got to do with the installation copy instead.


text:
Q: Matrix trace derivatives Hi I am trying to take derivatives of the matrix trace.
I do know that
$$
\frac{d}{dx} Tr[A x]= A^\top
$$
Now assuming $x$ is a complex square matrix,
I am trying to calculate
$$
\frac{d}{dx}Tr[x x^\top], \quad \frac{d}{dx} Tr[x x^\dagger]
$$
Where $x^\top$ Is the matrix transpose and $x^\dagger$ is the hermitian transpose (complex transpose).
How can I go about calculating these derivatives? Are the results the same? Does the transpose or complex transpose change anything? I am very bad with derivatives of matrix traces any help is greatly appreciated.  Thanks!

A: Use the double-dot (:) product to write the two functions
$$\eqalign{
  f &= \operatorname{tr}(XX^T) = X:X \cr
  h &= \operatorname{tr}(XX^H) = X^*:X \cr\cr
}$$
Then the corresponding differentials and gradients are easily calculated as
$$\eqalign{
  df &= 2X:dX \cr
  \frac{\partial f}{\partial X} &= 2X \cr\cr
  dh &= X^*:dX + X:dX^* \cr
  \frac{\partial h}{\partial X} &= X^* \cr
  \frac{\partial h}{\partial X^*} &= X \cr\cr
}$$
The Wirtinger notion of treating $X^*$ and $X$ as independent variables was used.


text:
Q: fresh start issues in phonegap I'm a new user of Phonegap and I'm very confused how everything works. I have created the project on c://ProjectName and built it for android. I open my ADT (Eclipse) and I create a project from the existing code, then I have two project folders : ProjectName  and ProjectName-CordovaLib.

*

*First Question:
What is ProjectName-CordovaLib? Will I ever need to code inside of that folder ?

*Second Question:
I have in ProjectName>www files , I'm familiar with as web programmer.
CSS JS IMG and html files.

When I modify the index.html file and run the app in the emulator, it doesn't seem to have any effect. in ADT the auto-rebuild option is checked. How am I able to modify the file ?
In : ProjectName.java
public class ProjectName extends CordovaActivity
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.init();
        // Set by <content src="index.html" /> in config.xml
        super.loadUrl(Config.getStartUrl());
        super.loadUrl("file:///android_asset/www/index.html");
    }
}

I think these are my problems at the moment. Can you help me please?
My index.html file (Modified):
<!DOCTYPE html>

        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />

        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>MY APP</title>

MY

Hi !

Hello Sekai

A: First Ans: What is ProjectName-CordovaLib?  -> It is the library ot cordoava. in olderversion phongap will provide .jar and now andorid 3.3.0 up it will provide one library.
Second Ans: I have in ProjectName>www -> it the basic common code to use in multiple platform,
In Android you can see www in assets forlder. if not than read "_where-is-www.txt" file and follow instraction.


text:
Q: Plural for Solution Architecture
Solution architecture is a practice of defining and describing an
  architecture of a system delivered in context of a specific solution
  and as such it may encompass description of an entire system or only
  its specific parts.

I want to say that I've specialties in Web Applications and (plural of) Solution Architecture
Which one is the correct?

I have specialties in Web Applications and Solution Architectures.

or

I have specialties in Web Applications and Solutions Architectures.

or

I have specialties in Web Applications and Solutions Architects.

or

I have specialties in Web Applications and Solution Architects.

A: Great question because it demonstrates one of the traps in English for a new speaker. Nathan's answer is a perfectly correct response to the question if we were only looking at it from the point of view of English grammar. BTW, I've also seen it written as Solutions Architecture (but that's verging on the pretentious in my opinion...)
However, the question is raised in the context of an ICT job application or CV and here you have to look a little closer at what is meant by the noun phrase Solution Architecture.
Solution Architecture is both a thing: "I designed the solution architecture for x" and a skill/discipline: "I studied solution architecture as part of my degree"
Looking back at what the OP wants to say and his first example:

I want to say that I've specialties in Web Applications and (plural of) Solution Architecture
I have specialties in Web Applications and Solution Architectures.

I have to admit here that I'm looking at this through the filter of 15 years of reading ICT job applications but the first part of this is a bit weak and a bit vague:

I have specialties in Web Applications

Well, so does my daughter because of the time she spends on Facebook and Instagram

I have specialties in Web (or Web Application) development

is clearer and stronger and is a clue on how to approach the next part - it would be grammatically and semantically correct to say Web Developments but nobody uses it and it would be a giveaway that you are struggling with the language a bit. If you wanted to use the plural form then

I have been responsible for the solution architectures of numerous significant systems

would be quite effective.
Keeping to your brief form though you are probably best to keep to the skills:

I have specialties in Web Application development and Solution Architecture.

A: Unlike, say, Spanish (or Portuguese, I suppose), English only ever pluralizes one word out of a set that go together. For noun phrases like this, it's the last word, so "Solution Architectures" is correct. (A "solution architect" is what you'd call a person with that specialty, but you can't generally say that you specialize in people with a specialty.)


text:
Q: React How to use different states with click event In short:
I'm implementing Simon-Says game app in React Native. (user sees a sequence of flashing buttons, needs to press the buttons in the correct order).
I want to know how to use 2 different states in TouchableOpacity, one of them as a condition to press the button, one for changing the style of the button, and also being notified for this specific press.
So,
I'm having a problem to implement the playerTurn(),
because I'm not sure how to pass the canPress state to the TouchableOpacity button,
considering I'm passing style state that changes in compTurn()
 (function that shows a sequence of flashing buttons - then computer turn's over)
In the player turn, things I need to consider:

*

*after the state canPress changes, the user will be allowed to press on the buttons

*user presses one of the 4 buttons

*the method playerTurn() will be notified which button did the player pressed.  (I'm asking how can I get that notification from the button to the method?)
after that, I can push it's choice to the playerSeq array (if pressed green - pushes 1, etc) and call function that changes the style state (greenFlash for example)

code in short :
export default class App extends Component{
  constructor (props){
    super(props);
    this.seq=[1,2,3,1,4] //will be random, this is just for testing
    this.playerSeq=[]
    ...
    this.state = {
      canPress: false,
      greenB: {
        backgroundColor: 'darkgreen'
      }, ...

  playerTurn(){
    this.setState({canPress: true})
    // if the user pressed on the green button, then I push 1 to the playerSequence
    // More functionality will be here
  }

  render(){
    return (..
    <TouchableOpacity style={[styles.greenB, this.state.greenB]}></TouchableOpacity>
//I ALSO WANT TO PASS THE STATE CANPRESS + NOTIFY PLAYERTURN() THAT THE USER PRESSED ON THIS BUTTON

Full code: (not the full game, note that I'm learning react just in the past few days)
export default class App extends Component{
  constructor (props){
    super(props);
    this.flash=0
    this.round=1
    this.seq=[1,2,3,1,4] //will be random, this is just for testing
    this.playerSeq=[]
    this.win=false
    this.ok=true
    this.score=0

    this.state = {
      canPress: false,
      greenB: {
        backgroundColor: 'darkgreen'
      },
      yellowB: {
        backgroundColor: 'orange'
      },
      blueB: {
        backgroundColor: 'blue'
      },
      redB: {
        backgroundColor: 'red'
      }
    }
    this.play=this.play.bind(this)
    this.greenFlash=this.greenFlash.bind(this)
    this.blueFlash=this.blueFlash.bind(this)
    this.redFlash=this.redFlash.bind(this)
    this.playerTurn=this.playerTurn.bind(this)
  }

  play(){
    this.flash=0
    this.round=1 //round will increase, this is just for test
    this.win=false
    this.ok=true
    this.score=0
    this.compTurn();
    this.playerTurn();
  }

  playerTurn(){
    this.setState({canPress: true})

  }
  compTurn() {
      let intervalId = setInterval(()=> {
        if (this.flash==this.round) {
          clearInterval(intervalId);
        }
        else {
          if (this.seq[this.flash]==1){
            this.greenFlash();
          }
          if (this.seq[this.flash]==2){
            this.yellowFlash();
          }
          if (this.seq[this.flash]==3){
            this.blueFlash();
          }
          if (this.seq[this.flash]==4){
            this.redFlash();
          }
          this.flash++;
        }
      }
      , 1500);
    }

  greenFlash(){
      setTimeout(() => {
        this.setState( {
            greenB:{
              ...this.state.style1, backgroundColor: 'lightgreen'
            }
            })
        }, 200);
      setTimeout(() => {
        this.setState( {
            greenB:{
              ...this.state.style1, backgroundColor: 'darkgreen'
            }
            })
        }, 1000);
    }

  yellowFlash(){
    setTimeout(() => {
      this.setState( {
          yellowB:{
            ...this.state.style1, backgroundColor: 'yellow'
          }
          })
      }, 200);
    setTimeout(() => {
      this.setState( {
          yellowB:{
            ...this.state.style1, backgroundColor: 'orange'
          }
          })
        }, 1000);
   }

  blueFlash(){
    setTimeout(() => {
      this.setState( {
          blueB:{
            ...this.state.style1, backgroundColor: 'lightblue'
          }
          })
      }, 200);
    setTimeout(() => {
      this.setState( {
          blueB:{
            ...this.state.style1, backgroundColor: 'blue'
          }
          })
        }, 1000);
   }

  redFlash(){
    setTimeout(() => {
      this.setState( {
          redB:{
            ...this.state.style1, backgroundColor: 'pink'
          }
          })
      }, 200);
    setTimeout(() => {
      this.setState( {
          redB:{
            ...this.state.style1, backgroundColor: 'red'
          }
          })
        }, 1000);
   }

  render(){
    return (
      <View>
        <TouchableOpacity style={styles.playB}
        onPress={this.play}>
        <Text style={{
          color:'white',
          height: 30,
          width:60,
          }}>START</Text>
        </TouchableOpacity>
        <TouchableOpacity style={[styles.greenB, this.state.greenB]}></TouchableOpacity>
        <TouchableOpacity style={[styles.yellowB, this.state.yellowB]}></TouchableOpacity>
        <TouchableOpacity style={[styles.blueB, this.state.blueB]}></TouchableOpacity>
        <TouchableOpacity style={[styles.redB, this.state.redB]}></TouchableOpacity>
    </View>
    );
  }
}

const styles = StyleSheet.create({
  greenB:{
    padding: 5,
    height: 80,
    width: 80,
    borderRadius:160,
  },
  yellowB:{
    padding: 5,
    height: 80,
    width: 80,
    borderRadius:160,
  },
  blueB:{
    padding: 5,
    height: 80,
    width: 80,
    borderRadius:160,
  },
  redB:{
    padding: 5,
    height: 80,
    width: 80,
    borderRadius:160,
  },
  playB:{
    alignSelf: 'center',
    backgroundColor: 'blue',
  }

});

A: Looks like you want to enable clicking on the buttons if state.canPress = true right? Then upon clicking, you wish to notify by calling playerTurn()?

*

*You can do something like this for e.g your green button.

<TouchableOpacity style={[styles.greenB, this.state.greenB]} onPress={this.state.canPress && () => {
  this.playerTurn(1);
  // Whatever you want to do on green button pressed by player in here.
}>
</TouchableOpacity>

this.setState also has a callback function as its second parameter, which may be more useful in your flash method.


text:
Q: Spark Throwing a "NoClassDefFoundError" Despite jar Indicating Class is Present I am receiving a NoClassDefFoundError despite 7Zip indicating the jar containing the class is present in the uberjar being submitted to run the program. I am submitting with the below line:
spark-submit  --class org.dia.red.ctakes.spark.CtakesSparkMain target/spark-ctakes-0.1-job.jar

The error being thrown is:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/uima/cas/FSIndex
        at org.dia.red.ctakes.spark.CtakesSparkMain.main(CtakesSparkMain.java:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:743)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.ClassNotFoundException: org.apache.uima.cas.FSIndex
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 10 more

The CtakesSparkMain class below calls the CtakesFunction class:
package org.dia.red.ctakes.spark;

import java.util.List;
import java.io.PrintWriter;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import org.apache.uima.jcas.cas.FSArray;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.storage.StorageLevel;
import org.json.JSONObject;

public class CtakesSparkMain {

    /**
     * @param args
     */
    public static void main(String[] args) throws Exception {

        SparkConf conf = new SparkConf().setAppName("ctakes");
        JavaSparkContext sc = new JavaSparkContext(conf);

        JavaRDD<String> lines = sc.textFile("/mnt/d/metistream/ctakes-streaming/SparkStreamingCTK/testdata100.txt").map(new CtakesFunction());

        String first = lines.take(2).get(0);
        PrintWriter out = new PrintWriter("/mnt/d/metistream/ctakes-streaming/SparkStreamingCTK/test_outputs/output.txt");
        out.println(first);
        out.close();
        sc.close();

    }
}

CtakesFunction:
package org.dia.red.ctakes.spark;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;

import org.apache.ctakes.typesystem.type.refsem.OntologyConcept;
import org.apache.ctakes.typesystem.type.textsem.*;
import org.apache.uima.UIMAException;
import org.apache.uima.cas.FSIndex;
import org.apache.uima.cas.Type;

import org.apache.uima.UIMAException;

import org.apache.uima.jcas.JCas;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.cas.impl.XmiCasSerializer;
import org.apache.uima.fit.factory.JCasFactory;
import org.apache.uima.fit.pipeline.SimplePipeline;

import org.apache.uima.jcas.cas.FSArray;
import org.apache.uima.util.XMLSerializer;
import org.apache.spark.api.java.function.Function;

import it.cnr.iac.CTAKESClinicalPipelineFactory;
import org.json.*;

/**
 * @author Selina Chu, Michael Starch, and Giuseppe Totaro
 *
 */

public class CtakesFunction implements Function<String, String> {

    transient JCas jcas = null;
    transient AnalysisEngineDescription aed = null;

    private void setup() throws UIMAException {

        System.setProperty("ctakes.umlsuser", "");
        System.setProperty("ctakes.umlspw", "");
        this.jcas = JCasFactory.createJCas();
        this.aed = CTAKESClinicalPipelineFactory.getDefaultPipeline();

    }

    private void readObject(ObjectInputStream in) {
        try {
            in.defaultReadObject();
            this.setup();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (UIMAException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String call(String paragraph) throws Exception {

        this.jcas.setDocumentText(paragraph);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SimplePipeline.runPipeline(this.jcas, this.aed);
        FSIndex index = this.jcas.getAnnotationIndex(IdentifiedAnnotation.type);
        Iterator iter = index.iterator();

        JSONArray annotationsArray = new JSONArray();
        JSONObject allAnnotations = new JSONObject();

        ArrayList<String> types = new ArrayList<String>();

        types.add("org.apache.ctakes.typesystem.type.textsem.SignSymptomMention");
        types.add("org.apache.ctakes.typesystem.type.textsem.DiseaseDisorderMention");
        types.add("org.apache.ctakes.typesystem.type.textsem.AnatomicalSiteMention");
        types.add("org.apache.ctakes.typesystem.type.textsem.ProcedureMention");
        types.add("import org.apache.ctakes.typesystem.type.textsem.MedicationMention");

        String type;
        String[] splitType;
        FSArray snomedArray;
        ArrayList<String> snomedStringArray = new ArrayList<String>();

        while (iter.hasNext()){
            IdentifiedAnnotation annotation = (IdentifiedAnnotation)iter.next();
            type = annotation.getType().toString();
            if (types.contains(type)){
                JSONObject annotations  = new JSONObject();

                splitType = type.split("[.]");
                annotations.put("id", annotation.getId());
                annotations.put("subject", annotation.getSubject());
                annotations.put("type", splitType[splitType.length - 1]);
                annotations.put("text", annotation.getCoveredText());
                annotations.put("polarity", annotation.getPolarity());
                annotations.put("confidence", annotation.getConfidence());

                snomedArray = annotation.getOntologyConceptArr();
                for (int i = 0; i < snomedArray.size(); i++){
                    snomedStringArray.add(((OntologyConcept)snomedArray.get(i)).getCode());
                }
                annotations.put("snomed_codes", snomedStringArray);
                snomedStringArray.clear();
                annotationsArray.put(annotations);
            }

        }

        allAnnotations.put("Annotations", annotationsArray);
        this.jcas.reset();
        return allAnnotations.toString();
    }
}

I was attempting to modify the repository @ https://github.com/selinachu/SparkStreamingCTK to leverage regular Spark as opposed to SparkStreaming (and Spark 2.0), but haven't been able to resolve this.

A: This is because this is not entirely an uber-jar generated by maven for this project. Spark-submit can not load a class from a jar within a jar. One need a special class loader for this. The right approach would be to explode all jars to put all contained classes in the uber-jar similar how maven shade plugin does it https://maven.apache.org/plugins/maven-shade-plugin/
So you have to change pom.xml file to generate correct uber-jar for this project.

A: Inspired by YuGagarin's feedback, I used SBT assembly to assemble an UberJar of cTAKES itself. Compiling everything into one "true" fat jar resolved the above issue.
However, I should point out there are still some residual issues with cTAKES and Spark that I am currently working through.


text:
Q: Making a drop down list using swift? What is the library to make drop down menu in swift? I am new to Xcode and the Swift language, so can anyone please direct me on how to implement the drop down list in swift?

A: Unfortunately if you're looking to apply UIPopoverController in iOS9, you'll get a deprecated class warning. Instead you need to set your desired view's  UIModalPresentationPopover property to achieve the same result.

Popover
In a horizontally regular environment, a presentation style
  where the content is displayed in a popover view. The background
  content is dimmed and taps outside the popover cause the popover to be
  dismissed. If you do not want taps to dismiss the popover, you can
  assign one or more views to the passthroughViews property of the
  associated UIPopoverPresentationController object, which you can get
  from the popoverPresentationController property.
In a horizontally compact environment, this option behaves the same as
  UIModalPresentationFullScreen.
Available in iOS 8.0 and later.

Reference: https://developer.apple.com/documentation/uikit/uiviewcontroller/1621355-modalpresentationstyle

A: You have to be sure to use UIPickerViewDataSource and UIPickerViewDelegate protocols or it will throw an AppDelegate error as of swift 3
Also please take note of the change in syntax:
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int

is now:
public func numberOfComponents(in pickerView: UIPickerView) -> Int

The following below worked for me.
import UIkit

class ViewController: UIViewController, UIPickerViewDataSource, UIPickerViewDelegate {

    @IBOutlet weak var textBox: UITextField!
    @IBOutlet weak var dropDown: UIPickerView!

    var list = ["1", "2", "3"]

    public func numberOfComponents(in pickerView: UIPickerView) -> Int{
        return 1
    }

    public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int{

        return list.count
    }

    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {

        self.view.endEditing(true)
        return list[row]
    }

    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {

        self.textBox.text = self.list[row]
        self.dropDown.isHidden = true
    }

    func textFieldDidBeginEditing(_ textField: UITextField) {

        if textField == self.textBox {
            self.dropDown.isHidden = false
            //if you don't want the users to se the keyboard type:

            textField.endEditing(true)
        }
    }
}

A: (Swift 3) Add text box and uipickerview to the storyboard then add delegate and data source to uipickerview and add delegate to textbox. Follow video for assistance
https://youtu.be/SfjZwgxlwcc
import UIKit

class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource, UITextFieldDelegate {

    @IBOutlet weak var textBox: UITextField!
    @IBOutlet weak var dropDown: UIPickerView!

    var list = ["1", "2", "3"]

    public func numberOfComponents(in pickerView: UIPickerView) -> Int{
        return 1
    }

    public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int{

        return list.count
    }

    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {

        self.view.endEditing(true)
        return list[row]
    }

    func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {

        self.textBox.text = self.list[row]
        self.dropDown.isHidden = true
    }

    func textFieldDidBeginEditing(_ textField: UITextField) {

        if textField == self.textBox {
            self.dropDown.isHidden = false
            //if you don't want the users to se the keyboard type:

            textField.endEditing(true)
        }
    }
}

A: Using UIPickerview is the right way to go to implement it according to Apple's Human Interface Guidelines
If you select drop down in mobile safari it will show UIPickerview to let the use choose drop down items.
Alternatively
you can use UIPopoverController till iOS 9 as its deprecated but its better to stick with UIModalPresentationPopover of view you want o show as well
you can use UIActionsheet to show the items but it's better to use UIAlertViewController and choose UIActionSheetstyle to show as the former is deprecated in latest versions

A: A 'drop down menu' is a web control / term. In iOS we don't have these. You might be better looking at UIPopoverController. Check out this tutorial for a bit of an insight to PopoverControllers
http://www.raywenderlich.com/29472/ipad-for-iphone-developers-101-in-ios-6-uipopovercontroller-tutorial


text:
Q: how to fix subscribe to observables to get data in rxjava i'm trying to subscribe to a constructor so as not to make the user
signup every time but once they use the phone number register it should
subscribe to user and refresh the data.
i tried this it didn't subscribe but it register the users in my database
compositeDisposable.add(
                            myCatchyAPI.updateUserInfo(Common.API_KEY,
                                    account.getPhoneNumber().toString(),
                                    edt_user_name.getText().toString(),

edt_user_address.getText().toString(),
                                    account.getId())
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .subscribe(updateUserModel ->

all i got was [UPDATE USER API RETURN] success but not subcribing to
updateUserModel
btn_update.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.show();
            AccountKit.getCurrentAccount(new AccountKitCallback<Account>() {
                @Override
                public void onSuccess(Account account) {
                    compositeDisposable.add(
                            myCatchyAPI.updateUserInfo(Common.API_KEY,
                                    account.getPhoneNumber().toString(),
                                    edt_user_name.getText().toString(),
                                    edt_user_address.getText().toString(),
                                    account.getId())
                            .subscribeOn(Schedulers.io())
                            .observeOn(AndroidSchedulers.mainThread())
                            .subscribe(updateUserModel -> {
                                if (updateUserModel.isSuccess())
                                {
                                    // refresh if it already has users before
                                    compositeDisposable.add(
                                            myCatchyAPI.getUser(Common.API_KEY, account.getId())
                                                    .subscribeOn(Schedulers.io())
                                                    .observeOn(AndroidSchedulers.mainThread())
                                                    .subscribe(userModel -> {

                                               if (userModel.isSuccess())
                                               {
                                                  // Common.currentUser = userModel.getResult().get(0);
                                                   //                                                       startActivity(new Intent(UpdateInfoActivity.this,HomeActivity.class));
                                                   //                                                       finish();
                                                   Common.currentUser = userModel.getResult().get(0);
                                                   Intent intent = new Intent(UpdateInfoActivity.this, HomeActivity.class);
                                                   startActivity(intent);
                                                   finish();

                                               }
                                               else
                                               {
                                                   Toast.makeText(UpdateInfoActivity.this, "[GET USER RESULT]"+userModel.getMessage(), Toast.LENGTH_SHORT).show();
                                               }

                                                        dialog.dismiss();

                                                    },
                                                   throwable -> {
                                                       dialog.dismiss();
                                                       Toast.makeText(UpdateInfoActivity.this, "[GET USER]"+throwable.getMessage(), Toast.LENGTH_SHORT).show();
                                                   })
                                    );
                                }
                                else
                                {
                                    Toast.makeText(UpdateInfoActivity.this, "[UPDATE USER API RETURN]"+updateUserModel.getMessage(), Toast.LENGTH_SHORT).show();
                                }
                                dialog.dismiss();
                                    },
                                    throwable -> {
                                dialog.dismiss();
                                        Toast.makeText(UpdateInfoActivity.this, "[UPDATE USER API]"+throwable.getMessage(), Toast.LENGTH_SHORT).show();
                                    })
                    );
                }

                @Override
                public void onError(AccountKitError accountKitError) {
                    Toast.makeText(UpdateInfoActivity.this, "[ACCOUT KIT ERROR ]"+accountKitError.getErrorType().getMessage(), Toast.LENGTH_SHORT).show();
                }
            });
        }
    });
}


text:
Q: How to attach .eml file in Excel using OpenXML SDK? I am using this code. It does attach the file but I can't see anything if I open the file using MS Excel application.
            string targetFile = "test returns tracker.xlsx";
            string placeholder = @"placeholder.PNG";
            string embed = @"embed.docx";
            using (SpreadsheetDocument document = SpreadsheetDocument.Open(targetFile, true))
            {
                WorkbookPart workbookpart = document.WorkbookPart;
                WorksheetPart sheet1 = workbookpart.WorksheetParts.First();

                EmbeddedPackagePart newEmbeddedPackagePart = sheet1.AddNewPart<EmbeddedPackagePart>(@"application/vnd.openxmlformats-officedocument.wordprocessingml.document", "rId100");
                newEmbeddedPackagePart.FeedData(File.Open(embed, FileMode.Open));
                document.WorkbookPart.Workbook.Save();
                // Close the document handle.
                document.Close();
            }

A: newEmbeddedPackagePart.FeedData(File.Open(embed...

Issue in your code is with FeedData. File.Open method gives you a stream but that's empty. You need to seek the data before you can expect that saved In excel as embedded doc
Example of seek is
    FileStream SourceStream = File.Open(filename, FileMode.Open);
    SourceStream.Seek(0, SeekOrigin.End);

Use this source stream in your FeedData to make it work.
newEmbeddedPackagePart.FeedData(SourceStream);

Now you can save the workbook and close the document
References:

*

*http://www.ericwhite.com/blog/forums/topic/adding-workbook-to-chart-as-an-embeddedpackagepart/

*https://learn.microsoft.com/en-us/dotnet/api/system.io.filestream?view=netframework-4.8


text:
Q: Extending Ruby Sequel I am trying to make a library that will handle database connections by extending the Sequel object/module.  but I have not been able to get passed this:
require 'sequel'
class Database
  include Sequel
  def connect()
    self.ado(:conn_string=>"Server=homeServer;Provider=SQLNCLI10;Database=test;Trusted_Connection=yes;")
  end
end
db = LocalDatabase.new()
db.connect()

I get the following error:
test.rb:5:in connect': undefined methodado' for # (NoMethodError) from test.rb:10:in `'
Why can't I see the ado method?

A: In ruby, if you subclass a class, you can call the superclass's singleton methods by calling them as singleton methods of the subclass, but that does not work for included/extended modules. This is one way where modules differ from classes in terms of method lookup.  To understand why, you'll need to read the details on how ruby's method lookup and object model works.
To call singleton methods of the Sequel module, you need to call them with an explicit receiver:
require 'sequel'
class Database
  include Sequel
  def connect()
    Sequel.ado(:conn_string=>"Server=homeServer;Provider=SQLNCLI10;Database=test;Trusted_Connection=yes;")
  end
end
db = LocalDatabase.new()
db.connect()

FWIW, I don't recommend using the ado adapter except for read only workloads.  Since you appear to be connecting to SQL Server, I recommend using the tinytds adapter.

A: What's happening is that the Sequel is being included so it's methods are available as instance methods,  I think you want to extend, i.e.
require 'sequel'
class Database
  extend Sequel
  def connect()
    ado(:conn_string=>
    "Server=homeServer;Provider=SQLNCLI10;Database=test;Trusted_Connection=yes;")
  end
end
db = LocalDatabase.new()
db.connect()


text:
Q: Django Rest Framework - How to save using id and retrieve other columns as well? This question is a continuation of other question from this link here(Django Rest Framework how to save a model with Related Field based on ID)
My situation got solved when I used PrimaryKeyRelatedField() to store data using id on a POST request. This, in turn, created another issue. I was using the same API's GET option to list all the columns from the related (Foreign Key referred)model, after using PrimaryKeyRelatedField() the other columns got disappeared and ID is only showing up. Need help on this.
To be more clear need ID column of the referred table during POST call and need other columns of the model/table during GET call.
PS: I have used serializers.ModelSerializer method

A: You can use serializer's to_representation method to override related objects field only for output data. For example you can use sested serializer to show related object details, like this:
class RelatedSerializer(serializers.ModelSerializer):
    class Meta:
        Model = RelatedModel
        fields = ('id', 'field1', 'field2')

class YourSerializer(serializers.ModelSerializer):
    related_field = serializer.PrimaryKeyRelatedField(queryset=RelatedModel.objects.all())
    class Meta:
        Model = SomeModel
        fields = ('id', 'related_field')

    def to_representation(self, instance):
        self.fields['related_field'] = RelatedSerializer()
        return super(YourSerializer, self).to_representation(instance)


text:
Q: Concatenate string based on a condition I want to assign a value to a new column based on a condition for other rows associated with a user_id.
A user can see the same step with different devices at different times. However, only the first step must be taken into consideration.
e.g. step2 was seen by both mobile and desktop, but was first seen by mobile at 2021-03-16 14:03:16.
Likewise step4 was seen by both desktop and tablet, but first desktop.
To sum up, each step first seen by
step1 = mobile
step2 = mobile
step3 = mobile
step4 = desktop

Since the only device change happened at step4, then assign desktop > mobile to all records for that user_id.
How can I get the first step per user and device as in the expected result below?
Sample data:
+---------+-------+---------------------+---------+
| user_id | step  |     created_at      | device  |
+---------+-------+---------------------+---------+
| user1   | step1 | 2021-03-16 14:03:16 | mobile  |
| user1   | step2 | 2021-03-16 14:04:07 | mobile  |
| user1   | step2 | 2021-03-16 14:03:47 | desktop |
| user1   | step3 | 2021-03-16 14:03:55 | mobile  |
| user1   | step3 | 2021-03-16 14:04:00 | mobile  |
| user1   | step1 | 2021-03-16 14:04:02 | desktop |
| user1   | step2 | 2021-03-16 14:03:16 | mobile  |
| user1   | step3 | 2021-03-16 14:04:07 | mobile  |
| user1   | step4 | 2021-03-16 14:04:08 | desktop |
| user1   | step4 | 2021-03-16 14:04:09 | tablet  |
+---------+-------+---------------------+---------+

The expected result:
+---------+-------+---------------------+---------+---------------------+
| user_id | step  |     created_at      | device  | device_concatenated |
+---------+-------+---------------------+---------+---------------------+
| user1   | step1 | 2021-03-16 14:03:16 | mobile  | mobile > desktop    |
| user1   | step2 | 2021-03-16 14:03:16 | mobile  | mobile > desktop    |
| user1   | step3 | 2021-03-16 14:03:55 | mobile  | mobile > desktop    |
| user1   | step4 | 2021-03-16 14:04:08 | desktop | mobile > desktop    |
+---------+-------+---------------------+---------+---------------------+

A: Given the data as is (as of 11:38 UTC, 2021-04-08), this might help (see PostgreSQL fiddle here):
CREATE TABLE tab
(
  user_id TEXT NOT NULL,
  step    TEXT NOT NULL,
  created_at TIMESTAMP NOT NULL,
  device  TEXT NOT NULL
);

Populate it (slightly rearranged from original data to put it in order - user_id, step & created_at - makes it easier to figure out what's going on):
INSERT INTO tab
VALUES

( 'user1', 'step1', '2021-03-16 14:03:16', 'mobile'),
( 'user1', 'step1', '2021-03-16 14:04:02', 'desktop'),

( 'user1', 'step2', '2021-03-16 14:03:16', 'mobile'),
( 'user1', 'step2', '2021-03-16 14:03:47', 'desktop'),
( 'user1', 'step2', '2021-03-16 14:04:07', 'mobile'),

( 'user1', 'step3', '2021-03-16 14:03:55', 'mobile'),
( 'user1', 'step3', '2021-03-16 14:04:00', 'mobile'),
( 'user1', 'step3', '2021-03-16 14:04:07', 'mobile'),

( 'user1', 'step4', '2021-03-16 14:04:08', 'desktop'),
( 'user1', 'step4', '2021-03-16 14:04:09', 'tablet');

I'll show the steps that led me to the solution - might be helpful (remove surplus field as appropriate for your requirements):
SELECT
  user_id, step, created_at, device,
  FIRST_VALUE(device)     OVER (PARTITION BY user_id, step
                            ORDER BY     user_id, step, created_at),
  FIRST_VALUE(created_at) OVER (PARTITION BY user_id, step
                            ORDER BY     user_id, step, created_at),
  LEAD(device)            OVER (PARTITION BY user_id, step
                            ORDER BY     user_id, step, created_at),
  CONCAT(
  (FIRST_VALUE(device)     OVER (PARTITION BY user_id, step
                            ORDER BY     user_id, step, created_at)),
  ' > ',
  (LEAD(device)            OVER (PARTITION BY user_id, step
                            ORDER BY     user_id, step, created_at)))
  AS device_concatenated,
  ROW_NUMBER() OVER (PARTITION BY user_id, step
                            ORDER BY     user_id, step, created_at) AS rn
FROM tab
ORDER BY user_id, step, created_at;

Result (better viewed on fiddle):
user_id step    created_at  device  first_value first_value lead    device_concatenated rn
user1   step1   2021-03-16 14:03:16 mobile  mobile  2021-03-16 14:03:16 desktop mobile > desktop    1
user1   step1   2021-03-16 14:04:02 desktop mobile  2021-03-16 14:03:16     mobile >    2
user1   step2   2021-03-16 14:03:16 mobile  mobile  2021-03-16 14:03:16 desktop mobile > desktop    1
user1   step2   2021-03-16 14:03:47 desktop mobile  2021-03-16 14:03:16 mobile  mobile > mobile 2
user1   step2   2021-03-16 14:04:07 mobile  mobile  2021-03-16 14:03:16     mobile >    3
user1   step3   2021-03-16 14:03:55 mobile  mobile  2021-03-16 14:03:55 mobile  mobile > mobile 1
user1   step3   2021-03-16 14:04:00 mobile  mobile  2021-03-16 14:03:55 mobile  mobile > mobile 2
user1   step3   2021-03-16 14:04:07 mobile  mobile  2021-03-16 14:03:55     mobile >    3
user1   step4   2021-03-16 14:04:08 desktop desktop 2021-03-16 14:04:08 tablet  desktop > tablet    1
user1   step4   2021-03-16 14:04:09 tablet  desktop 2021-03-16 14:04:08     desktop >   2

Then, we use the above result as a sub-query as follows:
SELECT user_id, step, created_ts, device, dc AS device_concatenated
FROM
(
  SELECT
    user_id, step, created_at, device,
    FIRST_VALUE(device)     OVER (PARTITION BY user_id, step
                                  ORDER BY     user_id, step, created_at),
    FIRST_VALUE(created_at) OVER (PARTITION BY user_id, step
                                  ORDER BY     user_id, step, created_at) AS created_ts,
    LEAD(device)            OVER (PARTITION BY user_id, step
                                  ORDER BY     user_id, step, created_at),
    CONCAT(
    (FIRST_VALUE(device)   OVER (PARTITION BY user_id, step
                                 ORDER BY     user_id, step, created_at)),
    ' > ',
    (LEAD(device)            OVER (PARTITION BY user_id, step
                            ORDER BY     user_id, step, created_at)))
  AS dc,
  ROW_NUMBER() OVER (PARTITION BY user_id, step
                            ORDER BY     user_id, step, created_at) AS rn
  FROM tab
  ORDER BY user_id, step, created_at
) AS t
WHERE rn = 1
ORDER BY user_id, step, device, created_ts;

Result:
user_id   step  created_ts             device   device_concatenated
  user1  step1  2021-03-16 14:03:16    mobile       mobile > desktop
  user1  step2  2021-03-16 14:03:16    mobile       mobile > desktop
  user1  step3  2021-03-16 14:03:55    mobile        mobile > mobile
  user1  step4  2021-03-16 14:04:08   desktop       desktop > tablet

Which is pretty close to the desired result. To obtain the desired result, we need to know how/why for step3, mobile > desktop is valid and mobile > mobile is not? Same goes for step4 - why is desktop > tablet not correct? There isn't even a single entry for mobile for step4... On receiving an explanation, I will edit as appropriate!

A: SELECT DISTINCT
       user_id,
       step,
       MIN(created_at) OVER (PARTITION BY user_id, step) created_at,
       FIRST_VALUE(device) OVER (PARTITION BY user_id, step ORDER BY created_at)
       || ' > ' ||
       FIRST_VALUE(device) OVER (PARTITION BY user_id, step ORDER BY created_at DESC) device_concatenated
FROM tab
ORDER BY user_id, step;

fiddle (thanks to Vérace for sample source data).


text:
Q: How to scale a windows universal desktop app programatically The default scale factor in desktop is 1 but I want to apply an scale factor of 1.75 to a desktop application. I don´t mean the app bounds (that´s easy) but the scale applied to all visual elements, like mobile version does on devices.
Is there any way to achieve this globally?


text:
Q: Taskbar Disappearing on Windows 8.1 It seems that the taskbar disappears permanently whenever I use certain Metro apps on Windows 8.1. That is, when I exit the app, the taskbar is gone from the screen that the Metro app appeared on (yet, it always stays on my other monitor). The only way I am able to resolve to the issue seems to be by restarting entirely. Needless to say, this is a real pain.
Is there any way I can prevent this (short of not using Windows Store apps)? If not, is there a better way to fix this problem once the taskbar disappears (better than restarting)?

A: Restart explorer instead of restarting computer and see if it works.

*

*Ctrl + Shift + Esc to open Task Manager.

*Right click Windows Explorer, restart.

This will close your active explorer windows though.

A: I found this solution for Taskbar and icons that disappear:

*

*Go to Task Manager

*Right click on Explorer, Properties

*Go to Security tab, click Advanced

*Change ownership to Everyone. Check all permissions boxes.

A: For me it turned out that the antivirus system has adopted explorer.exe as a threat???!!! and it was placed in the folder of blocked list and quarantined items. The removal from there solves the problem.


text:
Q: MDX - Sum only selected dimension members? I'm quite new to MDX and I'm having a bit of an issue with the aggregation of one of my measures.
In my DSV I have an "Events" table. We track the agents that run these events, and since multiple agents can be involved in running a single event, I have split this out into a separate table of "Agent" with a bridging table in the middle:
http://imgur.com/uAy3moC
I want to track what is called "Coverage", which is the number of Events held in a particular week and also each agent who ran the event. So if there were 3 events held one week, and one of these events were run by two agents, that would be a coverage of 4.
When I go to analyse the cube, dragging on Week Commencing and my count of Events, I note that it isn't right - It only considers individual events and not the number of agents. Dragging on Agents solves this but I still want to see an overall figure without having to drag on Agents.
So I created a calculated member like so:
CREATE MEMBER CURRENTCUBE.[Measures].[Visit Coverage]
AS
IIF([Agents].[Agent].currentmember.parent IS NULL,
SUM([Agents].[Agent].[Agent], [Measures].[Events Count]),
[Measures].[Events Count]);
So basically, if all agents are selected (parent is null), sum up all of the events count for each agent, otherwise just give me the events for each individual agent if I'm analysing by agent. This works great...and also works if I want to filter by one particular agent, but then falls over if I try to filter by more than one (but less than all) agents, giving me a null value.
I'm completely stumped on how to solve this one, could anyone help me out?
Chris

A: Your table design covers the requirement to count the number of events, avoiding a double-counting of agents via the many-to-many bridge table between the main fact table and the agent dimension table. If you want to have a measure that does not avoid double-counting, then its fact table should directly link the dimension tables.
Hence, I would create a view or named query that has foreign keys to your three dimension tables, and use this as the base of a new measure group in addition to the existing ones. This view or named query could just be built as a join from the main fact table and the bridge table. Then add a count as the coverage measure to this measure group.


text:
Q: perl select specific column and store to different arrays there's a data :
set interfaces ge-1/0/2 unit 101 family inet address 10.187.132.3/27 vrrp-group 1 virtual-address 10.187.132.1
set interfaces ge-1/0/2 unit 102 family inet address 10.187.132.35/27 vrrp-group 2 virtual-address 10.187.132.33
set interfaces ge-1/0/2 unit 103 family inet address 10.187.132.67/27 vrrp-group 3 virtual-address 10.187.132.65
set interfaces ge-1/0/2 unit 104 family inet address 10.187.132.99/27 vrrp-group 4 virtual-address 10.187.132.97
set interfaces ge-1/0/2 unit 105 family inet address 10.187.132.131/27 vrrp-group 5 virtual-address 10.187.132.129
set interfaces ge-1/0/2 unit 106 family inet address 10.187.132.163/27 vrrp-group 6 virtual-address 10.187.132.161
set interfaces ge-1/0/2 unit 107 family inet address 10.187.132.195/27 vrrp-group 7 virtual-address 10.187.132.193
set interfaces ge-1/0/2 unit 108 family inet address 10.187.132.227/27 vrrp-group 8 virtual-address 10.187.132.225

we need to extract some column and store it to a different variable. The data comes from after filtering a file, so it will be $_. Is there any method to store it to a different array?
$address[0] = "10.187.132.3/27"
$vrrp-group[0] = "1"
$virtual-address[0] = "10.187.132.1"

$address[1] = "10.187.132.35/27"
$vrrp-group[1] = "2"
$virtual-address[1] = "10.187.132.33"

I've tried using split but I don't know how to select spesific column on perl which is very easy done with awk (awk {'print $8'}).
@address = split(/\s+/, $_);

but it's failed.
Expected Result:
@address:
$VAR1  = '10.187.132.3/27'
$VAR2  = '10.187.132.35/27'
$VAR3  = '10.187.132.67/27'
$VAR4  = '10.187.132.99/27'
$VAR5  = '10.187.132.131/27'
$VAR6  = '10.187.132.163/27'
$VAR7  = '10.187.132.195/27'
$VAR8  = '10.187.132.227/27'

@vrrp-group:
$VAR1  = '1'
$VAR2  = '2'
$VAR3  = '3'
$VAR4  = '4'
$VAR5  = '5'
$VAR6  = '6'
$VAR7  = '7'
$VAR8  = '8'

@virtual-address:
$VAR1  = '10.187.132.1'
$VAR2  = '10.187.132.33'
$VAR3  = '10.187.132.65'
$VAR4  = '10.187.132.97'
$VAR5  = '10.187.132.129'
$VAR6  = '10.187.132.161'
$VAR7  = '10.187.132.193'
$VAR8  = '10.187.132.225'

A: You can use -n or -p with -a to simulate a similar awk behaviour. perl splits line with spaces and saves fields in the @F array, so you can select your desired positions:
perl -MData::Dumper -lane '
    push @array, {
        q|address| => $F[8],
        q|vrrp-group| => $F[10],
        q|virtual-address| => $F[12]
    };
    END { print Dumper \@array }
' infile

That yields:
$VAR1 = [
          {
            'virtual-address' => '10.187.132.1',
            'address' => '10.187.132.3/27',
            'vrrp-group' => '1'
          },
          {
            'virtual-address' => '10.187.132.33',
            'address' => '10.187.132.35/27',
            'vrrp-group' => '2'
          },
          {
            'virtual-address' => '10.187.132.65',
            'address' => '10.187.132.67/27',
            'vrrp-group' => '3'
          },
          {
            'virtual-address' => '10.187.132.97',
            'address' => '10.187.132.99/27',
            'vrrp-group' => '4'
          },
          {
            'virtual-address' => '10.187.132.129',
            'address' => '10.187.132.131/27',
            'vrrp-group' => '5'
          },
          {
            'virtual-address' => '10.187.132.161',
            'address' => '10.187.132.163/27',
            'vrrp-group' => '6'
          },
          {
            'virtual-address' => '10.187.132.193',
            'address' => '10.187.132.195/27',
            'vrrp-group' => '7'
          },
          {
            'virtual-address' => '10.187.132.225',
            'address' => '10.187.132.227/27',
            'vrrp-group' => '8'
          }
        ];

UPDATE: The script equivalent to the previous one-liner (see comments):
#!/usr/bin/env perl

use warnings;
use strict;
use Data::Dumper;

my @array;

while ( <> ) {
    chomp;
    my @F = split;
    push @array, {
        q|address| => $F[8],
        q|vrrp-group| => $F[10],
        q|virtual-address| => $F[12]
    };
}

print Dumper \@array;


text:
Q: Creating my first rails blog app from rubyonrails.org On running rails server inside the blog folder (also I have successfully installed the required bundles in the blog folder) I get this error:
/usr/lib/ruby/vendor_ruby/bundler/resolver.rb:423:in `block in error_message': undefined method `>' for < 2.0, >= 1.3.0:Gem::Requirement (NoMethodError)
from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:410:in `each'
from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:410:in `inject'
from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:410:in `error_message'
from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:391:in `version_conflict'
from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:129:in `block in resolve'
from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:127:in `catch'
from /usr/lib/ruby/vendor_ruby/bundler/resolver.rb:127:in `resolve'
from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:151:in `resolve'
from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:90:in `specs'
from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:135:in `specs_for'
from /usr/lib/ruby/vendor_ruby/bundler/definition.rb:124:in `requested_specs'
from /usr/lib/ruby/vendor_ruby/bundler/environment.rb:23:in `requested_specs'
from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:11:in `setup'
from /usr/lib/ruby/vendor_ruby/bundler.rb:107:in `setup'
from /usr/lib/ruby/vendor_ruby/bundler/setup.rb:7:in `<top (required)>'
from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in `require'
from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in `require'
from /home/ayush/Rails/blog/config/boot.rb:4:in `<top (required)>'
from bin/rails:3:in `require_relative'
from bin/rails:3:in `<main>'

Heres the Gemfile
source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'

# Use mysql as the database for Active Record
gem 'mysql2'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster.
gem 'turbolinks'

# Build JSON APIs with ease.
gem 'jbuilder', '~> 1.2'

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

boot.rb
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])

Please point out where I am going wrong.Also i am new to this forum so if I did something wrong in posting the question pls do tell me.
Btw I am using ubuntu terminal.
I am using
Rails 4.0.0
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]
Mysql2 for my database
Over the days banging my head I figured that its due to ruby and rails not being compatible...Can anyone tell me how to fix that ?

A: I finally resolved it.
There was some error with compatibility of rails and ruby and i solved that by completely removing the ruby1.8 version as it was somehow selecting it manually.


text:
Q: Access Few Columns of a table from CrudRepository in Spring Boot I have an interface which is extending crud repository
public interface PersonRepo extends CrudRepository<Person, String> {

    @Query(value="select name from PERSON where addr=?1", nativeQuery = true)
    List<Person> getPeronUsingAddress(String addr);

}

Person entity looks like this:
class Person {

private String name;
private String phoneNumber;
private String address;
//along with getters setters and all basic hibernate annotation to persist and retrieve
}

the person object is saved into the databse and at the time of retrieving the native query is working fine as hibernate executes correct query. But I am not able to get the return type.

*

*If the return type is List of Person then I am getting InvalidDataAccessResourceUsageException

*If I create an interface and use the list of interface as return type like
 interface response {
    String getName();
 }

 List of Response interface getPeronUsingAddress(String addr);

then I am getting proxy object in the service. I am not able to get the datas from proxy object.

*Another approach I did is to use List of object as return type. But it is not possible to downcast to my Person Object.
How to do that.? Or is there any other solution by which  I can return selective columns from crud repository and get a Java object with those selected Columns.

A: In order to fetch selected columns from an entity, you can do like below :
class Person {
    private Integer id;
    private String name;
    private String phoneNumber;
    private String address;
    //along with getters setters and all basic hibernate annotation to persist and retrieve
}

Create a DTO or Java Object like below :
public class PersonDTO {

    private Integer id;
    private String name;
    private String phoneNumber;
    private String address;

    public PersonDTO(Integer id, String name, String phoneNumber, String address) {
    // logic here
    }

    //If you want just want name and phone number.
    public PersonDTO(String name, String phoneNumber) {
    // logic here
    }

    // you can't create overridden constructors as all members are of same type and at runtime program won't be able to differentiate unless you provide some logic for it.

   // getters, setters, any other methods here...

}

Now below will be you Query but it's not native, if you want to keep native query then you will need to use ResultTransformer like here
@Query("select new your.package.PersonDTO(p.name, p.phoneNumber) from Person p where p.id = :id")
public PersonDTO getPersonById(Integer id);


text:
Q: probably wood for trees - mysql won't return fulldataset I run the following from php and I get the first record in the table and that's it, an array containing exactly one element.
$sql = 'SELECT id FROM users';
$pass = mysql_query($sql);
var_dump($pass);

$row = mysql_fetch_assoc($pass);
var_dump($row);

But the exact same sql fed straight into the database gives me the full dataset, over 300 records. So what the flip am I doing wrong with the php?
Thanks :)

A: you have to loop through each row:
$sql = 'SELECT id FROM users';
$pass = mysql_query($sql);

while( $row = mysql_fetch_assoc($pass) ) {
    var_dump($row);
}


text:
Q: Simplification of nested time-ordered products I'm trying to progress towards understanding, and perhaps finding a proof for, the "nested" Wick's theorem for time-ordered products $T\{ \ldots \}$ alluded to in part (II) of this answer.
Assuming bosonic operators for now, I've noticed that
$$T\{ T\{ A(t_1)B(t_2) \} T\{ C(t_3)D(t_4) \} \} \equiv T\{ A(t_1)B(t_2)C(t_3)D(t_4) \}\tag{1}$$
through brute force calculation. Is the natural generalisation of this,
$$T\{ T\{ \ldots_1 \} \ldots_2 T\{ \ldots_3 \} \ldots_4 ~~~\ldots~~~ T\{ \ldots_{n-1} \} \ldots_n \} \equiv T\{ \ldots_1 \ldots_2 ~~~\ldots~~~ \ldots_n \},\tag{2}$$
also true?

A: *

*Let us first define a $n$-ary Heaviside step function:
$$\begin{align} \theta&(t_1\geq t_2\geq\ldots \geq t_n)\cr
~:=~&\left\{\begin{array}{rl} 0&\text{if ineq. is violated}, \cr
\frac{1}{m_1!\ldots m_r!}&\text{if ineq. holds and there are $r$ sets of equal} \cr
&\text{times with multiplicities } m_1, \ldots, m_r.   \end{array} \right.\end{align} \tag{A}$$
It satisfies
$$ \sum_{\pi\in S_n} \theta(t_{\pi(1)}\geq t_{\pi(2)}\geq\ldots \geq t_{\pi(n)})~=~1. \tag{B}$$

*Next define time-ordering $T$ for Grassmann-even$^1$ operators as
$$ T(A_1 \ldots A_n)~:=~\sum_{\pi\in S_n} \theta\left( t(A_{\pi(1)})\geq \ldots \geq t(A_{\pi(n)})\right) A_{\pi(1)} \ldots A_{\pi(n)}. \tag{C}$$
Time-ordering $T$ is a multi-linear map and it may be viewed as a symmetric operad
$$T(A_1 \ldots A_n)~=~T(A_{\pi(1)} \ldots A_{\pi(n)}), \qquad \pi~\in~ S_n.\tag{D} $$
It satisfies a generalized idempotency
$$\begin{align}T&\left(T(A_1 \ldots A_r)T(B_1 \ldots B_s)\ldots Z_1 \ldots Z_u \right)\cr
~\stackrel{(C)}{=}~~&\sum_{\pi\in S_r} \theta\left( t(A_{\pi(1)})\geq \ldots \geq t(A_{\pi(r)})\right)\cr
&\sum_{\sigma\in S_s} \theta\left( t(B_{\sigma(1)})\geq \ldots \geq t(B_{\sigma(s)})\right)\ldots\cr
&T\left(A_{\pi(1)} \ldots A_{\pi(r)}B_{\sigma(1)} \ldots B_{\sigma(s)}\ldots Z_1 \ldots Z_u \right)\cr
~\stackrel{(B)+(D)}{=}&T(A_1 \ldots A_r B_1 \ldots B_s \ldots Z_1 \ldots Z_u )
,\end{align}\tag{E} $$
which is OP's eq. (2).
--
$^1$ There is as straightforward generalization to Grassmann-graded operators.


text:
Q: Why TypeScript cannot infer callback argument type based on generics I was expecting TypeScript to infer callback argument type as number in the following example but I'm getting an error.
type EventWatch = {
  <K extends keyof User>(eventName: `${string & K}Changed`, callback: (e: User[K]) => void): void;
};

type User = {
  firstname: string;
  lastname: string;
  age: number;
  on: EventWatch;
}

let john: User = {
  firstname: 'John',
  lastname: 'Doe',
  age: 33,
  on(eventName, callback) {
    if (eventName == 'ageChanged') {
      callback(133) //ERROR:
      /*
    TS2345: Argument of type 'number' is not assignable to parameter of type 'User[K]'.
    Type 'number' is not assignable to type 'never'.
       */
    }
  }
};

It correctly infers the eventName type and recognizes it should be one of three values: "firstnameChanged", "lastnameChanged", "ageChanged". But it cannot figure out its value.
Arguments that I pass to the function are correctly resolved and it gives an error if I send a wrong argument as it should.
john.on('ageChanged', e => {}); //No Error
john.on('salaryChanged', e => {}); //Error: There is no such a key named salary.

Why it won't infer the callback argument type?

A: The problem is that TypeScript does not use control flow analysis to narrow or constrain generic type parameters.  So when you check eventName == 'ageChanged', while the type of the eventName variable might be narrowed, nothing will happen to K.  Before the check, the compiler knows that K extends keyof User, and the check does nothing to change this.  In particular, K is not re-constrained to K extends "age" (and in fact such a narrowing would not be safe, since maybe K is the full keyof User union type).  And therefore callback of type (e: User[K]) => void is not known to be of type (e: number) => void, and you get an error:
on(eventName, callback) {
  // (parameter) eventName: `${K}Changed`
  // (parameter) callback: (e: User[K]) => void
  if (eventName == 'ageChanged') {
    // (parameter) eventName: `${K}Changed` still
    // (parameter) callback: (e: User[K]) => void still
    callback(133) // error
  }
}

There are several feature requests in GitHub to allow some way to narrow generic type parameters based on control flow.  See microsoft/TypeScript#24085 and microsoft/TypeScript#27808 for some of them (and they link to others).  Who knows when or even if this will be implemented.  For now, the easiest change is to suppress the error with a type assertion to tell the compiler what it doesn't know:
on(eventName, callback) {
  if (eventName == 'ageChanged') {
    (callback as (e: number)=>void)(133) // okay
  }
}

But this isn't type safe any longer.

Instead of using generics here, you might consider giving on() a rest parameter of a union of tuples, because there are only a finite list of possible allowable eventName/callback pair types.  And because the eventName parameter is a string literal type, that means your union will be a discriminated union where checking eventName will automatically narrow callback as well.
The idea is something like this:
type EventWatchParams =
  [eventName: "firstnameChanged", callback: (e: string) => void] |
  [eventName: "lastnameChanged", callback: (e: string) => void] |
  [eventName: "ageChanged", callback: (e: number) => void] |
  [eventName: "onChanged", callback: (e: EventWatch) => void];

type EventWatch = {
  (...args: EventWatchParams): void;
};

Note how this means you can only call an EventWatch with two parameters where the first and second parameter types depend on each other.  Of course you don't want to write out EventWatchParams manually; you'd like the compiler to compute it in terms of User automatically. Well, you can do so via a distributive object type (as coined in ms/TS#47109) where you immediately index into a mapped type, like this:
type EventWatchParams = {
  [K in keyof User]: [eventName: `${K}Changed`, callback: (e: User[K]) => void]
}[keyof User]

You can verify that EventWatchParams defined this way is equivalent to the union from before.

So, how does it work with this discriminated-union-of-rest-tuples version?  Well, with TypeScript 4.5 and below you will need to use ...args and index into it with numeric indices.  It's a little ugly, but it is verified as type safe:
on(...args) {
  if (args[0] == 'ageChanged') {
    args[1](133) // okay
  }
}

The narrowing works; if args[0] is ageChanged, then args[1] is narrowed to (e: number) => void.
Once TypeScript 4.6 lands, you can improve this a little by destructuring args into your desired variable names and the control flow analysis will still work:
// TS4.6+
on(...args) {
  const [eventName, callback] = args;
  if (eventName == 'ageChanged') {
    callback(133) // okay
  }
}

This is about as good as you can get, though.  The ideal version where you write on(eventName, callback) instead of on(...args) is waiting on microsoft/TypeScript#46680 and it's not clear if that will be addressed anytime soon.
Playground link to code


text:
Q: sort_array order by a different column, Hive I have two columns, one of products, and one of the dates they were bought. I am able to order the dates by applying the sort_array(dates) function, but I want to be able to sort_array(products) by the purchase date.
Is there a way to do that in Hive?
Tablename is
ClientID    Product    Date
100    Shampoo    2016-01-02
101    Book    2016-02-04
100    Conditioner    2015-12-31
101    Bookmark    2016-07-10
100    Cream    2016-02-12
101    Book2    2016-01-03

Then, getting one row per customer:
select
clientID,
COLLECT_LIST(Product) as Prod_List,
sort_array(COLLECT_LIST(date)) as Date_Order
from tablename
group by 1;

As:
ClientID    Prod_List    Date_Order
100    ["Shampoo","Conditioner","Cream"]    ["2015-12-31","2016-01-02","2016-02-12"]
101    ["Book","Bookmark","Book2"]    ["2016-01-03","2016-02-04","2016-07-10"]

But what I want is the order of the products to be tied to the correct chronological order of purchases.

A: It is possible to do it using only built-in functions, but it is not a pretty site :-)
select      clientid
           ,split(regexp_replace(concat_ws(',',sort_array(collect_list(concat_ws(':',cast(date as string),product)))),'[^:]*:([^,]*(,|$))','$1'),',') as prod_list
           ,sort_array(collect_list(date)) as date_order

from        tablename

group by    clientid
;

+----------+-----------------------------------+------------------------------------------+
| clientid |             prod_list             |                date_order                |
+----------+-----------------------------------+------------------------------------------+
|      100 | ["Conditioner","Shampoo","Cream"] | ["2015-12-31","2016-01-02","2016-02-12"] |
|      101 | ["Book2","Book","Bookmark"]       | ["2016-01-03","2016-02-04","2016-07-10"] |
+----------+-----------------------------------+------------------------------------------+


text:
Q: Problems handling OnTokenValidated with a delegate assigned in startup.cs I want to properly use DI in ASP.NET Core 2.0 in order to have my custom method handle the OnTokenValidated event that fires after a JWT token is validated during authentication.  The solution below works, except that in the handler I use an injected service that hits MemoryCache to check for cached items added elsewhere in a controller (I've verified that they're added and persisted), and when it's accessed, the cache is always empty.  I suspect this is because my custom handler object is being created by a different container (due to the early BuildServiceProvider() call?) and is utilizing a separate instance of MemoryCache (or similar).
If that's the case, I guess I'm not clear on how to properly add and reference my class and method in ConfigureServices() in startup.cs so that it works as intended.  Here's what I have:
public void ConfigureServices(IServiceCollection services)
    {
    services.AddMemoryCache();
    ...
    services.AddScoped<IJwtTokenValidatedHandler, JwtTokenValidatedHandler>();
    // add other services
    ...
    var sp = services.BuildServiceProvider();
    services.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, bOptions =>
        {
            // Configure JwtBearerOptions
            bOptions.Events = new JwtBearerEvents
            {
                OnTokenValidated = sp.GetService<JwtTokenValidatedHandler>().JwtTokenValidated
            };
        }

My custom handler class is below.  The ValidateSessionAsync() call uses an injected AppSessionService to access the MemoryCache object and ensure a cache entry exists:
public class JwtTokenValidatedHandler : IJwtTokenValidatedHandler
{
    AppSessionService _session;
    public JwtTokenValidatedHandler(AppSessionService session)
    {
        _session = session;
    }
    public async Task JwtTokenValidated(TokenValidatedContext context)
    {
        // Add the access_token as a claim, as we may actually need it
        var accessToken = context.SecurityToken as JwtSecurityToken;
        if (Guid.TryParse(accessToken.Id, out Guid sessionId))
        {
            if (await _session.ValidateSessionAsync(sessionId))
            {
                return;
            }
        }
        throw new SecurityTokenValidationException("Session not valid for provided token.");
    }
}

If the custom OnTokenValidated method contained simple logic and didn't need an injected service I would inline it with an anonymous function or declare it privately in startup.cs.  I'd prefer to fix this approach if I can, but I'd be open to other ones.

A: Instead of using static/singleton events, consider subclassing JwtBearerEvents and using the JwtBearerOptions.EventsType option:
public class CustomJwtBearerEvents : JwtBearerEvents
{
    AppSessionService _session;
    public CustomJwtBearerEvents(AppSessionService session)
    {
        _session = session;
    }

    public override async Task TokenValidated(TokenValidatedContext context)
    {
        // Add the access_token as a claim, as we may actually need it
        var accessToken = context.SecurityToken as JwtSecurityToken;
        if (Guid.TryParse(accessToken.Id, out Guid sessionId))
        {
            if (await _session.ValidateSessionAsync(sessionId))
            {
                return;
            }
        }
        throw new SecurityTokenValidationException("Session not valid for provided token.");
    }
}

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddScoped<CustomJwtBearerEvents>();

        services.AddAuthentication()
            .AddJwtBearer(options =>
            {
                options.EventsType = typeof(CustomJwtBearerEvents);
            });
    }
}


text:
Q: Laplace's equation, separation of variables Ok so I have a question with tutorial solutions but there are a few points I don't understand.
Q: Find the solution to Laplace's equation  $$(∇^2)u=0$$ in the unit square $d=\{(x,y):0≤x≤1,0≤y≤1\}$ subject to the boundary conditions
\begin{align*}
u&=0&\text{ on }x=0,x=1, \\
u&=\sinπx&\text{ on }  y=0, y=1.
\end{align*}
If someone could explain in detail all the steps that would be great! Mainly I don't understand how you know whether to use:

*

*$λ=k^2>0$,   $F=Ae^{(kx)} + Be^{(-kx)}$

*$λ=0$,  $F=Ax+B$

*$λ=-k^2<0$,  $F=A\cos(kx) + B\sin(kx)$

and then why  $k=nπ$ making $λ=-n^2π^2$
then why we use form (1.) for G eqn
and then just generally solving for the solution


text:
Q: Class can not be created I'm new in ActionScript, and I'm trying to make my first application. I have a main class - subclass of Sprite. and another one class, wich should manage some evnts, like keyboard's key pressing. Here is it's initialisation:
private var controller:GameObjectController;
...
controller = new GameObjectController(this);

Here is controller:GameObjectController itself:
public class GameObjectController extends InteractiveObject
{
    var textField:TextField;

    public function GameObjectController(mainSprite: Sprite)
    {
    addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);

    textField = new TextField();
    textField.text = "Hello, World";
    mainSprite.addChild(textField);
    }

    private function onKeyDown(event: KeyboardEvent):void
    {
    textField.text = event.keyCode.toString();
    }

}

but when I'm trying to run this, I have an error:

ArgumentError: Error #2012: Class GameObjectController$ can not be
  created.

What am I doing wrong?

A: From the docs: InteractiveObject

The InteractiveObject class itself does not include any APIs for
  rendering content onscreen. To create a custom subclass of the
  InteractiveObject class, extend one of the subclasses that do have
  APIs for rendering content onscreen, such as the Sprite, SimpleButton,
  TextField, or MovieClip classes.

So I would suggest trying to subclass Sprite instead and see if that fixes your problem.

A: Firstly, dont extend InteractiveObject. As the API says:

The InteractiveObject class itself does not include any APIs for rendering content onscreen. To create a custom subclass of the InteractiveObject class, extend one of the subclasses that do have APIs for rendering content onscreen, such as the Sprite, SimpleButton, TextField, or MovieClip classes.

so instead use (eg):
public class GameObjectController extends Sprite
{
    ....
}

Secondly, arguments for the constructor need to be the same as the extended class - for display classes, that means zero arguments.

A: flash.display.InteractiveObject is an abstract class that can not be subclassed.  Instead, extend from flash.display.Sprite.
Don't forget to import Sprite and place your code in a package:
package
{
    import flash.display.Sprite;

    public class GameObjectController extends Sprite
    {
        var textField:TextField;

        public function GameObjectController(mainSprite: Sprite)
        {
            addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);

            textField = new TextField();
            textField.text = "Hello, World";
            mainSprite.addChild(textField);
        }

        private function onKeyDown(event: KeyboardEvent):void
        {
            textField.text = event.keyCode.toString();
        }
    }
}


text:
Q: Objective-C method with variable arguments - first argument skipped? I'm following Stephen Kochan's Programming in Objective-C, 6th edition, and I'd like some help with this particular method. Basically I have a class, AddressBook, that has two instance variables: an NSMutableArray called book, and an NSString called bookName. Quite self-explanatory.
book holds AddressCards, and I was trying to implement a method that takes multiple variables of type id and adds all of them to the array book. Here it is:
-(void) addCards:(id)firstCard, ... NS_REQUIRES_NIL_TERMINATION
{
    va_list argumentList;
    va_start(argumentList, firstCard);

    id theArgument = firstCard;
    while ((theArgument = va_arg(argumentList, id)))
    {
        [self addCard:theArgument];
    }
    va_end(argumentList);
}

The addCard method is a customised implementation of NSMutableArray's addObject method. Problem is, the first argument that I provide to addCards isn't added to book. Here is main.m and the accompanying output:
int main(int argc, const char * argv[])
{
    @autoreleasepool
    {
        AddressCard *card1 = [[AddressCard alloc] initWithName:@"Joseph Brown" andEmail:@"jbrown@yahoo.com"];
        AddressCard *card2 = [[AddressCard alloc] initWithName:@"Thomas Walter" andEmail:@"t.walter@gmail.com"];
        AddressCard *card3 = [[AddressCard alloc] initWithName:@"Jonathan Green" andEmail:@"jon_green@gmail.com"];
        AddressCard *card4 = [[AddressCard alloc] initWithName:@"Elizabeth White" andEmail:@"elizwhite@live.com"];

        AddressBook *myBook = [[AddressBook alloc] initWithName:@"My Address Book"];

        [myBook addCards:card1, card2, card3, card4, nil];

        NSLog(@"Lookup: Joseph Brown");

        if ([myBook lookup:@"joseph Brown"] == nil)
        {
            NSLog(@"Not Found!");
        }

        else
        {
            [[myBook lookup:@"Joseph Brown"] print];
        }
        [myBook list];
    }
    return 0;
}

Output:
2014-06-25 11:43:25.997 AddressBook[19454:303] Lookup: Joseph Brown
2014-06-25 11:43:25.999 AddressBook[19454:303] Not Found!
2014-06-25 11:43:25.999 AddressBook[19454:303] ======== Contents of My Address Book ========
2014-06-25 11:43:26.000 AddressBook[19454:303] Thomas Walter           t.walter@gmail.com
2014-06-25 11:43:26.000 AddressBook[19454:303] Jonathan Green          jon_green@gmail.com
2014-06-25 11:43:26.000 AddressBook[19454:303] Elizabeth White         elizwhite@live.com
2014-06-25 11:43:26.001 AddressBook[19454:303] =============================================
Program ended with exit code: 0

lookup does exactly that: looks up the AddressCard specified by the argument to it; print prints the AddressCard in a nice format; list also does its namesake: list the contents of book. Now, as can be seen in the output, Joseph Brown, although added to the AddressBook as card1, isn't actually added, as proved twice by the output. What's wrong?

A: In your code
id theArgument = firstCard;
while ((theArgument = va_arg(argumentList, id)))

you did not do anything with firstCard. second argument overrides it
-(void) addCards:(id)firstCard, ... NS_REQUIRES_NIL_TERMINATION
{
    va_list argumentList;
    va_start(argumentList, firstCard);

    id theArgument = firstCard;
    while (theArgument)
    {
        [self addCard:theArgument];
        theArgument = va_arg(argumentList, id);
    }
    va_end(argumentList);
}

A: Alternative solution using an NSArray...
AddressCard *card1 = [[AddressCard alloc] initWithName:@"Joseph Brown" andEmail:@"jbrown@yahoo.com"];
AddressCard *card2 = [[AddressCard alloc] initWithName:@"Thomas Walter" andEmail:@"t.walter@gmail.com"];
AddressCard *card3 = [[AddressCard alloc] initWithName:@"Jonathan Green" andEmail:@"jon_green@gmail.com"];
AddressCard *card4 = [[AddressCard alloc] initWithName:@"Elizabeth White" andEmail:@"elizwhite@live.com"];

AddressBook *myBook = [[AddressBook alloc] initWithName:@"My Address Book"];
[myBook addCards:@[card1, card2, card3, card4]];

-(void)addCards:(NSArray *)cards {
    for (AddressCard *card in cards) {
        [self addCard:card];
    }
}