Erniekennithjosefa's Profile

200
Points

Questions
38

Answers
47

  • The line

    NavigationUI.setupWithNavController(navigationView, navController); 

    Calls setNavigationItemSelectedListener internally to connect destinations to menu items – this is how a new destination is launched when you click a menu item. Navigation supports <activity> destinations, allowing you to start an activity when clicking on a menu item. You’d add an activity destination to your graph that uses the same id as your menu item:

    <activity   android:id="@+id/nav_login_activity"   android:name=".LoginActivity"/> 

    Then the default setupWithNavController will call startActivity for you.

    • 416 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in .NET.

    It seems that you are using one FtpClient instance for all your transfers.

    The FtpClient represents one connection to an FTP server. FTP protocol does not allow multiple parallel transfers over one connection. You have to open a new connection for every parallel transfer.

    • 549 views
    • 3 answers
    • 0 votes
  • Asked on July 16, 2020 in .NET.

    You can use Linq’s Enumerable.SelectMany to "flatten" the dictionary values, then use Min and Max methods:

    var minDate = errorList.SelectMany(s => s.Value).Min(v => v.Date); var maxDate = errorList.SelectMany(s => s.Value).Max(v => v.Date); 

    However, your Date property is defined as a string, you may not get the results you expect. Updating the definition to DateTime will give the correct results using Min/Max.


    If you instead want to get the Min/Max per dictionary Key, you could project into an anonymous type:

    var perKeyMinMax = errorList.Select(d => new { d.Key,                                      Min = d.Value.Min(v => v.Date),                                      Max = d.Value.Max(v => v.Date)                                }); foreach (var item in perKeyMinMax) {     Console.WriteLine($"Key: {item.Key}, Min: {item.Min}, Max: {item.Max}"); } 
    • 359 views
    • 1 answers
    • 0 votes

  • Source files mismatch when stepping into .NET Framework code

    Please reconnect your DB Access database to refresh your database in case there are some build errors in the db layer.

    Besides, please follow these suggestions to troubleshoot your strange issue:

    1) Tools–>Import and Export Settings–>Reset all settings–>..General to reset all debugging settings.

    2) then, close VS, delete .vs hidden folder under solution folder, bin and obj folder.

    • 389 views
    • 1 answers
    • 0 votes
  • The character_set_% settings that you have seem strange:

    | character_set_client     | latin7          | names | character_set_connection | latin7          | names | character_set_database   | utf8mb4         | ? | character_set_filesystem | binary          | hands-off | character_set_results    | latin7          | names | character_set_server     | utf8mb4         | ? | character_set_system     | utf8            | hands-off 

    I have labeled them in 3 groups:

    • "hands-off" — filesystem and system should not be modified from the default, else internal things are likely to break.
    • "names" — SET NAMES latin7 is, for example, how you specify that the clients are using latin7 encoding. The general move is away from the old default latin1 toward the future standard of utf8mb4. (I used latin7 just to make it stand out.
    • "?" — It is unclear what impact these two have. I recommend leaving them along from the values from installation, which is probably utf8mb4 (for both) in recent versions of MySQL/MariaDB.

    In 5.7.6 GLOBAL character_set_database and collation_database system variables were deprecated; the SESSION version become readonly (deprecation)

    From the 8.0.1 changelog:

    Important Change: The default character set has changed from latin1 to utf8mb4. These system variables are affected:

    • The default value of the character_set_server and character_set_database system variables has changed from latin1 to utf8mb4.

    • The default value of the collation_server and collation_database system variables has changed from latin1_swedish_ci to utf8mb4_0900_ai_ci.

    As a result, the default character set and collation for new objects differ from previously unless an explicit character set and collation are specified. This includes databases and objects within them, such as tables, views, and stored programs. One way to preserve the previous defaults is to start the server with these lines in the my.cnf file:

    [mysqld] character_set_server=latin1 collation_server=latin1_swedish_ci 
    • 456 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Mysql.

    I would write the query as:

    select w.worker, group_concat(t.tool) from worker w  join      workers_tools_usage wtu      on wtu.worker_id = w.id join      tools t      on t.tool_id = wtu.tool_id group by w.worker; 

    I am answer for the following reasons

    • No outer joins are necessary as the question is asked.
    • To show an example of meaningful table aliases, which are abbreviations for the table names.
    • To provide an answer with all the columns qualified by the tables they belong in.
    • 392 views
    • 3 answers
    • 0 votes
  • If I understand your question correctly then

    df['prosecutionHistoryDataBag.prosecutionHistoryData'] 

    is, in fact, a list whose elements are lists of dictionaries. See also my comment above. If that is the case, then the boring way is:

    lst = df['prosecutionHistoryDataBag.prosecutionHistoryData'] for dicts in lst:     for d in dicts:         if d['eventDescriptionText'] == 'SOME TEXT YOU SEARCH FOR':             code = d['eventCode']             date = d['eventDate']             # Do something with code and date. 

    Now, you could flatten that list of lists and use a generator:

    lst = df['prosecutionHistoryDataBag.prosecutionHistoryData'] for d in (d for dicts in lst for d in dicts):     if d['eventDescriptionText'] == 'SOME TEXT YOU SEARCH FOR':         code = d['eventCode']         date = d['eventDate']         # Do something with code and date. 

    Next, squeeze the test into the lists-flattening-generator as well to make the code a bit less readable:

    lst = df['prosecutionHistoryDataBag.prosecutionHistoryData'] for code, date in ((d['eventCode'], d['eventDate']) for dicts in lst for d in dicts if d['eventDescriptionText'] == 'SOME TEXT YOU SEARCH FOR'):     # Do something with code and date. 

    The filter() function doesn’t help much with readability here

    for code, date in ((d['eventCode'], d['eventDate']) for d in filter(lambda d: d['eventDescriptionText'] == 'SOME TEXT YOU SEARCH FOR', (d for dicts in lst for d in dicts))):     # Do something with code and date.         

    but other itertools or more-itertools may be of use (e.g. the flatten() function).

    • 404 views
    • 2 answers
    • 0 votes
  • this will let you access all your entities using indices as a list

    info = [info[::3], info[1::3], info[2::3]] 

    Output:

    In [16]: info[0]                                                                                                                                                                 Out[16]: ['385395982', '3843955682', '248298493']  In [17]: info[1]                                                                                                                                                                 Out[17]: ['3.1', '2.0', '4.2']  In [18]: info[2]                                                                                                                                                                 Out[18]: ['This is dummy text', 'This is also dummy text', 'Another dummy text for you'] 
    • 503 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in php.

    I managed to make it work by calling serializeData method of rest controller. If after getting data you call serializeData method on dataModels then you get extraFields data as well in response JSON. Here is how it would work:

        $data=ActivityPredecessor::find()->where(['activity_id'=>$activity_id])->all();     $data=$this->serializeData($data);//This line will cause extra fields to be returned in response  as well and will make fields and expand query params functional. Without this line only current model's primary fields will be returned. 

    now you can do:

     return $data; 

    Hoep that it helps someone, someday.

    • 423 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in php.

    Yes it’s new syntax introduced in PHP 7 to declare the method returns an array.

    http://php.net/manual/en/functions.returning-values.php#functions.returning-values.type-declaration

    • 375 views
    • 2 answers
    • 0 votes