text:
Q: Reordering rows based on number formed by combining columns in Python I have a dataframe formed with pandas as seen below:
        a  b  c  d  e  f  g  h  i  j  k  l  m  n  o
    1   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
    2   0  0  0  0  0  0  1  0  1  0  1  0  0  1  0
    3   0  1  0  0  1  0  1  0  1  0  1  0  0  1  0
    4   0  0  0  0  0  1  0  1  0  0  1  0  0  1  0
    5   0  0  1  1  0  1  0  1  0  0  1  0  0  1  0
    6   1  0  0  1  0  1  0  1  0  0  1  0  0  1  0
    7   0  0  0  0  0  0  0  0  0  0  0  0  0  1  0
    8   0  0  0  0  0  0  0  0  1  0  1  0  0  1  0
    9   0  0  0  0  0  0  0  0  0  0  0  1  1  1  0
    10  0  0  0  1  0  1  0  1  0  0  1  0  0  1  0
    11  0  0  0  0  0  0  0  1  0  0  1  0  0  1  0
    12  0  0  0  0  1  0  1  0  1  0  1  0  0  1  0
    13  0  0  0  0  0  0  0  0  0  0  1  0  0  1  0
    14  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1
    15  0  0  0  0  1  0  1  0  1  0  1  0  0  1  0
    16  0  0  0  0  0  0  0  0  0  0  0  1  0  1  0

I want to sort the rows so that they are ordered in descending order. The value of the row is the number formed by combining the columns. For example, row 1 is 000000000000000 and row 2 is 000000101010010. The final result should have Row 6 as the first row and row 1 as the last row. I've tried
    dat.sort_values(by=['a'], ascending=False, axis=0)

but this only sorts by the first column. Is there another way I could reorder the rows?

A: Sort by all columns in their current order:
df.sort_values(by=df.columns.tolist(), ascending=False)

#    a  b  c  d  e  f  g  h  i  j  k  l  m  n  o
#6   1  0  0  1  0  1  0  1  0  0  1  0  0  1  0
#3   0  1  0  0  1  0  1  0  1  0  1  0  0  1  0
#5   0  0  1  1  0  1  0  1  0  0  1  0  0  1  0
#10  0  0  0  1  0  1  0  1  0  0  1  0  0  1  0
#12  0  0  0  0  1  0  1  0  1  0  1  0  0  1  0
#15  0  0  0  0  1  0  1  0  1  0  1  0  0  1  0
#4   0  0  0  0  0  1  0  1  0  0  1  0  0  1  0
#2   0  0  0  0  0  0  1  0  1  0  1  0  0  1  0
#11  0  0  0  0  0  0  0  1  0  0  1  0  0  1  0
#8   0  0  0  0  0  0  0  0  1  0  1  0  0  1  0
#13  0  0  0  0  0  0  0  0  0  0  1  0  0  1  0
#9   0  0  0  0  0  0  0  0  0  0  0  1  1  1  0
#16  0  0  0  0  0  0  0  0  0  0  0  1  0  1  0
#7   0  0  0  0  0  0  0  0  0  0  0  0  0  1  0
#14  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1
#1   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0

A: Using a key for sort
df.loc[df.astype(str).sum(1).sort_values(ascending=False).index]
Out[871]:
    a  b  c  d  e  f  g  h  i  j  k  l  m  n  o
6   1  0  0  1  0  1  0  1  0  0  1  0  0  1  0
3   0  1  0  0  1  0  1  0  1  0  1  0  0  1  0
5   0  0  1  1  0  1  0  1  0  0  1  0  0  1  0
10  0  0  0  1  0  1  0  1  0  0  1  0  0  1  0
15  0  0  0  0  1  0  1  0  1  0  1  0  0  1  0
12  0  0  0  0  1  0  1  0  1  0  1  0  0  1  0
4   0  0  0  0  0  1  0  1  0  0  1  0  0  1  0
2   0  0  0  0  0  0  1  0  1  0  1  0  0  1  0
11  0  0  0  0  0  0  0  1  0  0  1  0  0  1  0
8   0  0  0  0  0  0  0  0  1  0  1  0  0  1  0
13  0  0  0  0  0  0  0  0  0  0  1  0  0  1  0
9   0  0  0  0  0  0  0  0  0  0  0  1  1  1  0
16  0  0  0  0  0  0  0  0  0  0  0  1  0  1  0
7   0  0  0  0  0  0  0  0  0  0  0  0  0  1  0
14  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1
1   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0


text:
Q: Изменить порядок вывода сообщений об ошибках (jQuery Validate) Имеется форма, которая валидируется при помощи jQuery Validate:
https://codepen.io/anon/pen/EGXyvr
Код валидации выглядит следующим образом:
$("#submit").on("click", function() {
let orderForm = $('#order'),
    successMsg = $(".success");

orderForm.validate({
    rules: {
        fullName: {
            required: true
        },
        eMail: {
            required: true,
            email: true
        },
        question: {
            required: true
        }
    },

    messages: {
        fullName: {
            required: "The name field is required"
        },
        eMail: {
            required: "The e-mail field is required",
            email: "The e-mail address must contain @ symbol"
        },
        question: {
            required: "The question field is required"
        }
    },

    errorElement: "div",

    errorPlacement: function(error, element) {
        error.insertAfter('#submit');
    },

    submitHandler: function() {
        successMsg.show();
        setTimeout(function() {
            location.reload();
        }, 2500);
    }
})

});
Как изменить порядок вывода сообщений об ошибках, чтобы сообщение "The name field is required" выводилось первым, а "The question field is required" - последним?

A: error.insertAfter('#submit');

Добавляет сообщения об ошибке после кнопки "Submit". Соответственно, получается инверсия порядка.
Предлагаю, добавить div для вывода сообщений об ошибке. И добавлять их туда через append
Вот пример (переделанный ваш)
https://codepen.io/eustatos/pen/MZoexZ?editors=1000

A: Так происходит потому что insertAfter вставляет елемент после выбраного вами елемента. То есть, сначала после кнопки submit у вас добавилась ошибка для поля fullName, затем после кнопки добавилась ошибка для поля eMail, подвинув вниз предыдущую ошибку (ошибку для поля fullName) и так же произошло с ошибкой для question.
Например можно сделать так:
errorPlacement: function(error, element) {
  document.querySelector('.errors-wrapper').append(error[0]);
}

или же:
errorPlacement: function(error, element) {
  $('.errors-wrapper').append(error);
}

Добавив блок с классом .errors-wrapper туда, где нужно вывести ошибки.
Или же используйте insertBefore

redpajama_set_name: RedPajamaStackExchange


text:
Q: What exactly is a torque? I know there are a number of questions concerning torque on this site, but I still don't quite understand what it is.
A video by veritasium on gyroscopic precession on you tube really got me puzzled about the nature of torque. Perhaps I have some terminology errors which account for my lack of understanding, but assuming I roughly know what I am talking about when I say torque, my questions are:

*

*What can torque be described as? (Is it a force, energy, etc.)

*How can its vector be perpendicular to the force applied? Is this the conclusion drawn from some mathematical work or is there some other logic behind it?

A: Torque is a twisting force that tends to cause rotation (or elastic twisting) of the object to which it is applied. The vector is merely the axis of rotation and a direction along that axis (e.g. in or out).
Think of using a wrench to tighten a bolt. You pull on the wrench in one direction but the axis of rotation of the bolt is perpendicular to that. As you tighten the bolt, the direction you are applying force changes as the wrench moves (consider say a quarter turn of the bolt) but the axis of rotation remains the same.
If you tighten a conventional bolt clockwise, it rotates into the threaded hole - this establishes a choice of direction along the axis - i.e. a vector.
The magnitude of the twisting effect depends on how long the wrench is. This is a matter of leverage. So the units of torque are force x distance: N m.

A: First of all It is not a force. It is the turning effect of a force.Like force is responsible for linear acceleration of a particle, in the very same way torque is responsible angular acceleration of a particle about a given point. Linear accn is the rate of change of velocity in the same way angular accn is rate of change of angular. Now a question comes into the mind why does it depends on force and radius vector of point of application of force from the axis of rotation. Imagine a door. First apply some force perpendicular to the plane of door near the knob. Then apply the same amount of force near the hinge of the door. Now you can see the difference. In the first case the door closed in Less time as compared with the second situation. Why?? Because the torque which is force x radius vector is greater in the second situation, and so is the angular acceleration.
Hope this helps.

A: In classical mechanics,kinematics variables in translational motion are in analogy with rotational motion so that simple problem models could be obtained.So torque comes out  as vector that is in analogy with force showing rotating effect. Sign convention used for angular velocity,angular acceleration are in analogy with that In Translational mechanics.


text:
Q: Requested page not on server error while using ajax in php i was stdying dropdown using ajax in php. i want to load the second drop downlist based in the first drop.
i wrote the following code,but its giving the requested page not on server error

Category code:

<select name="catcod" onchange="ajaxFunction()" >
<option value="00" selected="selected">--Select--</option>
<?php
$i=0;
while($catcod=mysql_fetch_array($cq))
{

        print "<option value=\"".$catcod ['cat_code']."\">".$catcod ['cat_desc']."</option>";

}?>
</select>

Item number:	<input type="text" name="itemnum" id="itemnum">

Description of Item:	<input type="text" name="desc" id="desc">

Number of items:	<input type="text"  name="nom" id="nom">

Date of purchase:	<input style="color:#888;" maxlength="6"type="text"  name="date" id="date" value="DDMMYY">

Orginal cost:	<input type="text"  name="orgcost" id="orgcost">

Employee code:	<input type="text" maxlength="6" name="emp" id="emp">

    <input type="submit" value="Update">

the ajax code is as follows
   function ajaxFunction(){
   var ajaxRequest;

   try{

  ajaxRequest = new XMLHttpRequest();
  }catch (e){

  try{
  ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
  }catch (e) {
  try{
     ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
  }catch (e){

     alert("Your browser broke!");
     return false;
  }
  }
  }
  ajaxRequest.onreadystatechange = function(){
  if(ajaxRequest.readyState == 4){
  var ajaxDisplay = document.getElementById('ajaxdiv');
  ajaxDisplay.innerHTML = ajaxRequest.responseText;
  }
  }
  var catcod = document.getElementById('catcod').value;

  ajaxRequest.open("GET", "ajax.php  ?catcod="+catcod, true);
  ajaxRequest.send(null);
  }

and the ajax.php page is as follows

<?php
include_once '../header.php';

?>

<?php
$catcode=$_GET['catcod'];
include_once '../includes/Configurations.php';
$link = mysql_connect($_dbConfig['dbServer'],$_dbConfig['dbUser'],$_dbConfig['dbPassword'])or die(mysql_error());
$db = mysql_select_db($_dbConfig['dbName'], $link) or die(mysql_error());
$catnum_query ="select cat_desc,cat_no from item_master where cat_code=$catcode";
$cat=mysql_query($catnum_query,$link);?>
<select name="catcnum">
<?php
while($catnum=mysql_fetch_array($cat))
{
print "<option value=\"".$catnum ['cat_no']."\">".$catnum ['cat_desc']."</option>";
}?>
</select>

A: In your code there is no id attribut for select tag but you are using
   var catcod = document.getElementById('catcod').value;

first provide id for select tag as
  <select name="catcod" id="catcod" onchange="ajaxFunction()" >

And change this below line (there is unnecessary gap at url)
 ajaxRequest.open("GET", "ajax.php  ?catcod="+catcod, true); //find the gap

To
  ajaxRequest.open("GET", "ajax.php?catcod="+catcod, true);


text:
Q: Default String Sort Order Is the default sort order an implementation detail?  or how is it that the Default Comparer is selected?
It reminds me of the advice.  "Don't store HashCodes in the database"
Is the following Code guaranteed to sort the string in the same order?
string[] randomStrings = { "Hello", "There", "World", "The", "Secrete", "To", "Life", };
randomStrings.ToList().Sort();

A: Strings are always sorted in alphabetical order.
The default (string.CompareTo()) uses the Unicode comparison rules of the current culture:
    public int CompareTo(String strB) {
        if (strB==null) {
            return 1;
        }

        return CultureInfo.CurrentCulture.CompareInfo.Compare(this, strB, 0);
    }

A: This overload of List<T>.Sort uses the default comparer for strings, which is implemented like this:

This method performs a word (case-sensitive and culture-sensitive)
  comparison using the current culture. For more information about word,
  string, and ordinal sorts, see System.Globalization.CompareOptions.

A: If you do not specify a comparer then sort will use the default comparer which sorts alphabetically.  So to answer your question yes that code will always return the strings in the same order.
There is an overload to the sort method that allows you to specify your own comparer if you wish to sort the data in a different order.

A: I wanted to post a reply related to cultural things while you sort your strings but Jon already added it:-(. Yes, I think you may take into acc the issue too because it is selected by default the alphabetical order, the random strings if existed as foreign besides English (i.e Spanish) will be placed after English after all, they appear in the same first letters though. That means you need a globalization namespace to deal with it.
By the way, Timothy, it is secret not secrete :D

A: Your code creates a new list copying from the array, sorts that list, and then discards it. It does not change the array at all.
try:
Array.Sort(randomStrings);


text:
Q: Date histogram aggregation seems incorrect with calendar_interval and when offset >= 30 days Based on this doc, elasticsearch supports Calendar-aware interval on data histogram aggregation. Specially for a "quarter" interval:

"One quarter is the interval between the start day of the month and time of day and the same day of the month and time of day three months later, so that the day of the month and time of day are the same at the start and end."

My understanding of this is every bucket in the response should start at the same day, but that's not the case when I use offset >= 30 days. Some buckets start at, say 5th of the month,  while one other bucket starts at the 6th of the month. Is this a bug or am I missing anything?
Elasticsearch Version: 7.17
Steps to reproduce:
PUT /test01
{
  "mappings": {
    "properties": {
      "date": { "type": "date" }
    }
  }
}

POST /test01/_doc { "date": 1642658400000 } // 01/20/2022, 6AM UTC
POST /test01/_doc { "date": 1645336800000 } // 02/20/2022, 6AM UTC
...
POST /test01/_doc { "date": 1660975200000 } // 08/20/2022, 6AM UTC
// basically one document every month from January to August

Queries:
{
    "size": 0,
    "aggs": {
        "ShiftedQuarter": {
            "date_histogram": {
                "calendar_interval": "quarter",
                "min_doc_count": 1,
                "time_zone": "UTC",
                "offset": "+20d", // offset is less than 30 days
                "field": "date"
            }
        }
    }
}

returns below as expected (every bucket starts at the 21st day of the month):
"aggregations": {
    "ShiftedQuarter": {
      "buckets": [
        {
          "key_as_string": "2021-10-21T00:00:00.000Z",
          "key": 1634774400000,
          "doc_count": 1
        },
        {
          "key_as_string": "2022-01-21T00:00:00.000Z",
          "key": 1642723200000,
          "doc_count": 3
        },
        {
          "key_as_string": "2022-04-21T00:00:00.000Z",
          "key": 1650499200000,
          "doc_count": 3
        },
        {
          "key_as_string": "2022-07-21T00:00:00.000Z",
          "key": 1658361600000,
          "doc_count": 1
        }
      ]
    }
  }

However if the query use a offset that is large than 30, like
{
    "size": 0,
    "aggs": {
        "ShiftedQuarter": {
            "date_histogram": {
                "calendar_interval": "quarter",
                "min_doc_count": 1,
                "time_zone": "UTC",
                "offset": "+35d",
                "field": "date"
            }
        }
    }
}

then some bucket starts at the 5th but some starts at the 6th:
"aggregations": {
    "ShiftedQuarter": {
      "buckets": [
        {
          "key_as_string": "2021-11-05T00:00:00.000Z",
          "key": 1636070400000,
          "doc_count": 1
        },
        {
          "key_as_string": "2022-02-05T00:00:00.000Z",
          "key": 1644019200000,
          "doc_count": 3
        },
        {
          "key_as_string": "2022-05-06T00:00:00.000Z", // 06 as opposed to 05 for other buckets
          "key": 1651795200000,
          "doc_count": 3
        },
        {
          "key_as_string": "2022-08-05T00:00:00.000Z",
          "key": 1659657600000,
          "doc_count": 1
        }
      ]
    }
  }


text:
Q: Upgrade Nuget Gallery - EF AutomiaticMigration issue I self-host nuget gallery inside my company. I am trying to upgrade it but I have following error:
Unable to update database to match the current model because there are pending changes and automatic migration is disabled.
Either write the pending model changes to a code-based migration or enable automatic migration.
Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.

I don't know how can I upgrade my database from powershell/cmd on server. I don't have a VisualStudio installed there.
UPDATE
I tried to run manually migrate.exe from EF but I have:
ERROR: Could not load file or assembly 'F:\\NugetGallery\\bin\\NuGetGallery.Website' or one of
 its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)


text:
Q: How to properly write the function sequence $f_n(x)=x^{x^{x^{.^{.^{.^{x}}}}}}$ How can I express the following as a function sequence? Namely, how can I properly express $f_n(x)$?
Here are the following function graphs:

Text only (color-coded with image):

*

*$\color{red}{f_1(x)=x^x}$

*$\color{blue}{f_2(x)=x^{x^x}}$

*$\color{green}{f_3(x)=x^{x^{x^x}}}$

*$\color{purple}{f_4(x)=x^{x^{x^{x^x}}}}$

*$\color{orange}{f_5(x)=x^{x^{x^{x^{x^x}}}}}$

*$f_6(x)=x^{x^{x^{x^{x^{x^x}}}}}$
So how may I express $f_n(x)$? e.g. $f_n(x)=x^{x^{x^{.^{.^{.^{x}}}}}}$?

A: $f_1(x) = x^x, \; f_n(x) = x^{\; f_{n-1}(x)}$

A: The operation is referred to as tetration.  Using your notation:
$$f_1(x) = ^2\!\!x$$
$$f_2(x) = ^3\!\!x$$
and so on.


text:
Q: Shared classes and functionality between c# and c++ I have a C# WinForm project which edits stuff and saves it in a file using several classes that are stored directly as bytes. I had another C# project (Console) that used those same classes to read the previous saved data and work with it. In order not to have functionalities duplicated, and because this data structure is frequently changing, I kept these classes in a separate DLL that both projects included.
Now, however, I need that functionality to be used natively in C++, but of course I cannot simply include that same DLL in the project. I have tried to get an idea of how to work around that but I think I am mixing several concepts...
Is there any solution that allowed me to instantiate classes from that library, read their data and call their methods in both C# and C++ without the need of duplicating a lot of stuff?
The solutions I have (probably wrongly) considered include:
1- Keep the C# DLL, but allowing the COM interop and work with that. Then somehow create and maintain wrappers for C++.
2- Rewrite the DLL in C++ (it's still small, for now, so it's not a problem) and import it within C#. P/Invoke does not seem to work with member functions though, so I would still need to create a wrapper.
As a side note, the stored classes make use of C# Lists and Dictionaries. If there is a solution that works only with custom-generated classes, I wouldn't mind to create my own data structures.


text:
Q: PowerPivot Pivot Table displays all rows instead of context rows I'm looking for guidance on what changes need to be made to the model to get this pivot to display the proper rows under their respective jusridictions.
Currently the pivot displays ALL tax detail rows for each jusridiction.
Image 1 was removed due to posting limits.
Image 2 is the pivot after adding in the tax type.

Image 3 is the data model, showing the relation between the invoice data and the tax data. There can be 1 to many tax rows per invoice row.

If this question has been asked and answered before please provide a link. I don't have the time to scan 1000+ posts on PowerPivot to see if they apply. I did go through 150 of them with no joy.


text:
Q: How Split a Large events table in google bigquery into multiple table based on event_type? Hi I would like to split a large bigquery table (10 Billion Event Records) into multiple tables based on the event_type in the large table.
Note the events table is time/day/event_time partitioned. Further assume that it as a year of data(365 days)
let's assume the event_type=['sign-up', 'page-view']
My approach:

*

*Create a new table, each for the event type

*Run and insert job, for each event type for each day[also i will be using dml inside a python script]

My questions:

*

*what load job type should i use: copy or load job?

*can i queue the load jobs to google big query?[would it work asynchronously?]

*would google big query process this load job in parallel?

*Is there anything I need to do it interms of using multiprocessing inorder to speed up the process? [the load job is handled by bigquery, if i can queue in the jobs than i don't need to do any multiprocessing on the client side]

Any pointers to an efficient solution is highly appreciated.

A: You can use query jobs for your requirement. Load jobs are used to ingest data into BigQuery from GCS buckets or local files.
The quotas and limits for query jobs can be found here. These quotas and limits apply to query jobs created automatically by running interactive queries, scheduled queries, and jobs submitted by using the jobs.query and query-type jobs.insert API methods. In a project, up to 300 concurrent API requests per second per user can be made.
The query jobs that use the jobs.insert method will be executed asynchronously. The same can be achieved using the Python client library (as you intended) as shown below. Please refer to this doc for more information.
from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client()

# TODO(developer): Set table_id to the ID of the destination table.
# table_id = "your-project.your_dataset.your_table_name"

job_config = bigquery.QueryJobConfig(destination=table_id)

sql = """
    SELECT corpus
    FROM `bigquery-public-data.samples.shakespeare`
    GROUP BY corpus;
"""

# Start the query, passing in the extra configuration.
query_job = client.query(sql, job_config=job_config)  # Make an API request.
query_job.result()  # Wait for the job to complete.

print("Query results loaded to the table {}".format(table_id))

Since the jobs will be running concurrently, there is no need to implement explicit multiprocessing.


text:
Q: Error! File In use: SQLSERVER I am trying to copy a database from one folder to another. There is no program at all running except operating system.(I mean all windows shut)
I keep getting this :

The action cannot be completed because
  the file is open is another program
  close file and try again

Multiple attempts results in the same error.
What could be keeping that file open and how can I carry on with copy / delete / overwrite files(DB) as this problem is something very common.

A: Try net stop mssqlserver /y and see what happens. Naturally I'm assuming here it's okay to stop the DB server.

A: Go to Task Manager and see, it's sqlservr.exe proccess is running. If so, kill it and try again. Also there is a useful small program called 'Unlocker' which allows to look which proccesses are attached to the file, kills them and let the file be deleted or moved.
A similar tool is WhoLockMe!

A: This error can be solved by stopping MSSQLSERVER service form configuration Tool in Microsoft Sql Server as shown with diagram in the link below:
Solve Error The action can't be completed because the file is open in SQL SERVER(MSSQLSERVER)

Some time while moving a database (.mdf) from one location to other
  location on hard disk drive you encounter with the error 'The action
  can't be completed because the file is open in SQL SERVER(MSSQLSERVER)
  ' as shown in the diagram below:
The action can't be completed because the file is open in SQL SERVER
Steps to solve error 'The action can't be completed because the file
  is open in SQL SERVER' as shown in below: Step 1: Click on Start Icon
  on the task bar . Select Microsoft SQL Server folder and then click on
  SQL Server Configuration Manager as shown in the picture below:
The action can't be completed because the file is open in SQL SERVER

Step 2: SQL SERVER Configuration Manger window  will open on the left
  side of this window select SQL Server Services . In SQL server
  services  right click on the service SQL Server (MSSQLSERVER) and
  click on Stop as shown in the picture below:
The action can't be completed because the file is open in SQL SERVER

Step 3: As the process will stop move the file from one location to
  other and then again start this process by right click on it. Email
  ThisBlogThis!Share to TwitterShare to Facebook

A: Open the Microsoft SQL Server Management Studio,then open Object Explorer .Right Click and you can find Restart the connection.This will stop the SQL Server and you can delete or transfer the database.

A: I usually prefer to use first party tools for this kind of thing, process monitor from sysinternals is my tool of choice for this kind of thing.  Just watch out if you have a lot of background services running cause you will see lots of activity going through.  Really useful for watching your registry as well.
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx


text:
Q: CsvProvider with semicolon separator and predefined schema I'd like to create a type using the FSharp.Data.CsvProvider (v1.1.10) to process CSV files with a ";" separator and a predefined schema.
The following line reports an error:
type CsvType1 = CsvProvider<Sample="1;2;3", Separator=";", Schema="category (string), id (string), timestamp (string)">

The error is:

Specified argument is neither a file, nor well-formed CSV: Could not find file '...\1;2;3'.

Setting Sample to "", null or not setting it at all creates other errors.
Using a separator of "," and a sample of "1,2,3" works fine.. but that cannot read my csv files.
What am I doing wrong?

A: This is a bug in FSharp.Data (fixed in 2.0.0-alpha3) which thinks 1;2;3 is a file and doesn't try to parse it as a CSV snippet, but you can use the following instead which will work:
CsvProvider<Sample="category (string); id (string); timestamp (string)", Separator=";">

A: Looks like a bug in CSV provider: text parser doesn't support custom separators for sample texts.
, is not allowed in CSV file URIs and 1,2,3 is treated as a text sample correctly. ; is allowed and 1;2;3 is treated as a file name.


text:
Q: Neo4j how to orderBy collection I have node structure where i have parent nodes and child nodes. Child nodes have :has relation ship with parent node.
My current query is
 Match (p:Parent)
 Where Id(p) = 2
 WITH p
 Match (c:CHILD)
 WHERE (p)-[:has]-(c)
 return p,collect(DISTINCT c) as child[0..9]

Now my problem is all child nodes are arranged by their id's and i am only able to receive first 9 childs ordered by their id.
How can i specify order of childs?

A: Try this:
You can use an in-between WITH to order your nodes.
Btw. you should have consistent label spelling!
 Match (p:Parent)-[:has]-(c:CHILD)
 Where Id(p) = 2
 WITH p, c order by id(c) asc
 return p,collect(DISTINCT c)[0..9] as child


text:
Q: How Read from a Data File into a Structure of Vectors I am trying to figure out how to store binary data that is saved to a .dat file "customer.dat" into a structure of vectors. I thought I have had it a few times, but with no luck.
Basically, I have a working method of storing the data into the .dat file, the newEntry function, but I can not seem to work out on how to bring the data back one set at a time into an order structure of vectors. The function in question is the searchDisplay function.  Here is the code:
#include <iostream>
#include <fstream>
#include <vector>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>

using namespace std;

const int NAME_SIZE = 51, ADDR_SIZE = 51, PHONE_SIZE = 14;

struct Client {
char name[NAME_SIZE];
char address1[ADDR_SIZE];
char address2[ADDR_SIZE];
char phone[PHONE_SIZE];
double acctBal;
double lastPay;
};

//void welcome();
int menu();
int newEntry();
int searchDisplay();

int main() {
    int selection;
    int option = 0;
    int end;

    //welcome();

    while (option != 6) {
        selection = menu();

        if (selection == 1) {
            cin.ignore();
            end = newEntry();
            if (end == 0) {
                return 0;
            }
        } else if (selection == 2) {
            end = searchDisplay();
            if (end == 0) {
                return 0;
            }
        }
    }
return 0;
}

int menu() {
int selection;
cout << "User please enter the number that corresponds with what you wish to do..."
         << endl;
    cout << "1)     Add An Entry" << endl
         << "2)     Search for a Specfic Person and erase." << endl;
    cin  >> selection;

    return selection;
}

int newEntry() {
    string input;
    Client person;
    char response = 'y';

    //create file object and open file
    fstream customer("customer.dat", ios::app | ios::binary);

    if (!customer) {
        cout << "Error opening file. Program aborting." << endl;
        return 0;
    }

do {
        cout << "Enter person information:" << endl << endl;
        cout << "Name:                                " << endl;
        getline(cin, input);
        strcpy(person.name, input.c_str());
        cout << endl << person.name;

        cout << endl << "Street Adress (And Apartment Number):" << endl;
        cin  >> person.address1;
        getline(cin, input);
        strcpy(person.address1, input.c_str());

        cout << endl << "City, State, Zipcode:                " << endl;
        cin  >> person.address2;
        getline(cin, input);
        strcpy(person.address2, input.c_str());

        cout << endl << "Phone:                               " << endl;
        cin  >> person.phone;
        getline(cin, input);
        strcpy(person.phone, input.c_str());

        cout << endl << "Account Balance:                     " << endl;
        cin  >> person.acctBal;
        //input validation to ensure a non neg number
        cin.ignore();

        cout << endl << "Last Payment:                        " << endl;
        cin  >> person.lastPay;
        //input validation to ensure a non neg number

        customer.write(reinterpret_cast<char *>(&person), sizeof(person));

        cout << endl << "Do you want to enter another record? (Enter Y for Yes, N for No) " << endl;

        cin >> response;

        cout << "_______________________________________________" << endl << endl;

        if (toupper(response) == 'Y') {
            cin.ignore();
        }
    } while (toupper(response) == 'Y');

    customer.close();

    return 1;
}

/********************************************
 My main problem is with the below function
 ********************************************/

int searchDisplay() {
    vector<Client> store(2);
    Client foo;
    int i = 0;

    fstream customer("customer.dat", ios::in | ios::binary);

    if (!customer) {
        cout << "Error opening file. Program aborting." << endl;
        return 0;
    }

    //MY HOPE WAS THIS WOULD STORE EACH SET OF DATA INTO THE STRUCTURE OF VECTORS

    customer.read(reinterpret_cast<char *>(&store), sizeof (store[0]));

    while (!customer.eof()){
        cout << store[i].name << ":" << endl
             << store[i].address1 << endl
             << store[i].address2 << endl
             << store[i].phone << endl
             << store[i].acctBal << endl
             << store[i].lastPay << endl << endl;

        i++;

        customer.read(reinterpret_cast<char *>(&store), sizeof (store[i]));
    }

    customer.close();
    return 1;
}

Sorry if any of the coding is a little off in its indenting, I was having issues with the method of putting the code onto the text block.
But yes, any help would be great.  This is my first time working with vectors significantly and first time ever with more file classes.

A: Your first problem is the opening of the data file for writing. You are currently opening it with the flag "ios::app", when it should be "ios::out". Over here (gcc version 4.7.2) i get no output to file when opening the file with "ios::app".
Using "ios::out" it creates a file and dumps the data into it.
The second problem is in the line where you open and read the file. You are missing a "[0]". Check the corrected version below:
customer.read(reinterpret_cast<char *>(&store[0]), sizeof (store[0]));
Making this modifications you can get closer to the desired results.
The main problem here is that writing and reading binary files is a bit different from regular text files, that have indications of line endings, for example. You need to organize your data differently, which can be quite complicated. Try Serializing with Boost.


text:
Q: Object fetch same api endpoint I'm creating two instances of this object on every page of my website. When it loads, it
the makes a fetch call to /cities.json for data, that it then stores in session storage.
Next time the object
is created (on another page), it checks session storage before calling the api endpoint, to prevent
needless data requests. However, when the object is first created it makes two calls to the /cities.json api - because two instances typehead exist.
Apart from moving the call to outside of the object creation, which I don't want to do, as other objects also require this same api
endpoint, and I'd like to find a pattern that could work for each.

Index.js
import Typeahead from '../typeahead'

    var typeaheadElements = [].slice.call(document.getElementsByClassName('typeahead'));
    if (typeaheadElements.length) {
      typeaheadElements.map(function (element) {
        new Typeahead(element);
      });
    }

Typeahead.js
import fetchPromise from '../utilities/fetchSetStorage.js';

function Typeahead(element) {
  init.call(this);

  function init() {
    var input = element.getElementsByTagName('input')[0];
    if (input) {

      let citiesData = fetchPromise('./cities.json', 'citiesJson');
      Promise.all([citiesData]).then(function(values) {
        items = values[0];
        element.getElementsByTagName('input')[0].removeAttribute('disabled');
      });

      input.addEventListener('input', handleChange.bind(this));
      element.addEventListener('keydown', handleKeyDown.bind(this));
      element.addEventListener('click', handleElementClick.bind(this));
      document.addEventListener('click', handleDocumentClick.bind(this));
    }
  }
}

fetchSetStorage.js
export default function fetchPromise(url, storageKey) {
  if(sessionStorage.getItem(storageKey)) {
    let storageKeyVal = JSON.parse(sessionStorage.getItem(storageKey));
    return storageKeyVal;
  }

  return fetch(url)
    .then(function(response) {
      if (response.status !== 200) {
        console.log('Looks like there was a problem. Status Code: ' +
          response.status);
        return;
      }
      return response;
    })
    .then(response => response.json())
    .then(response => {
      sessionStorage.setItem(storageKey, JSON.stringify(response))
      return response;
    })
    .catch(function(err) {
      console.log('Fetch Error :-S', err);
    })
}

function Typeahead(element) {
  init.call(this);

  function init() {
    var input = true;
    if (input) {
      console.log('input')
      let citiesData = fetchPromise('/echo/json/', 'citiesJson');
      Promise.all([citiesData]).then(function(values) {
        items = values[0];
        console.log(values);
      });
    }
  }
}

function fetchPromise(url, storageKey) {
  if (sessionStorage.getItem(storageKey)) {
    let storageKeyVal = JSON.parse(sessionStorage.getItem(storageKey));
    return storageKeyVal;
  }

  return fetch(url)
    .then(function(response) {
      if (response.status !== 200) {
        console.log('Looks like there was a problem. Status Code: ' +
          response.status);
        return;
      }
      return response;
    })
    .then(response => response.json())
    .then(response => {
      sessionStorage.setItem(storageKey, JSON.stringify(response))
      return response;
    })
    .catch(function(err) {
      console.log('Fetch Error :-S', err);
    })
}

var typeaheadElements = [].slice.call(document.getElementsByClassName('typeahead'));
if (typeaheadElements.length) {
  console.log('typeaheadfound');
  typeaheadElements.map(function(element) {
    new Typeahead(element);
  });
}

  Typeahead

  Typeahead

A: My "dirty" solution:
Typeahead.js
import fetchPromise from '../utilities/fetchSetStorage.js';

let isFetched = false;

function Typeahead(element) {
  init.call(this);

  function init() {
    var input = element.getElementsByTagName('input')[0];
    if (input && !isFetched) {
      isFetched = true;
      let citiesData = fetchPromise('./cities.json', 'citiesJson');
      Promise.all([citiesData]).then(function(values) {
        items = values[0];
        element.getElementsByTagName('input')[0].removeAttribute('disabled');
      });

      input.addEventListener('input', handleChange.bind(this));
      element.addEventListener('keydown', handleKeyDown.bind(this));
      element.addEventListener('click', handleElementClick.bind(this));
      document.addEventListener('click', handleDocumentClick.bind(this));
    }
  }
}


text:
Q: Python Regex Determining With New Line and Excluding \W I am trying to get "Genre" strings related to unique movies from IMDb "Coming Soon" pages. In Python regex is a bit different at least for me. This is my source string and I have to work on it, DOM parsing is not the case.
UPDATED SAMPLE
Shazam! (2019)

132 min
                                  -
                                Action
|
Adventure
|
Fantasy
|
Sci-Fi

    We all have a superhero inside us, it just takes a bit of magic to bring it out. In Billy Batson's case, by shouting out one word - SHAZAM! - this streetwise 14-year-old foster kid can turn into the adult superhero Shazam.

Director:

David F. Sandberg

Stars:
Zachary Levi,
Djimon Hounsou,
Mark Strong,
Michelle Borth

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Pet Sematary (2019)

Horror
|
Thriller

    Louis Creed, his wife Rachel, and their two children Gage and Ellie move to a rural home where they are welcomed and enlightened about the eerie 'Pet Sematary' located nearby. After the tragedy of their cat being killed by a truck, Louis resorts to burying it in the mysterious pet cemetery, which is definitely not as it seems, as it proves to the Creeds that sometimes, dead is better.

Directors:

Kevin Kölsch
|

Dennis Widmyer

Stars:
John Lithgow,
Jason Clarke,
Amy Seimetz,
Naomi Frenette

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

The Best of Enemies (2019)

Biography
|
Drama
|
History

    Civil rights activist Ann Atwater faces off against C.P. Ellis, Exalted Cyclops of the Ku Klux Klan, in 1971 Durham, North Carolina over the issue of school integration.

Director:

Robin Bissell

Stars:
Sam Rockwell,
Taraji P. Henson,
Wes Bentley,
Anne Heche

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Peterloo (2018)

154 min
                                  -
                                Drama
|
History

70
        Metascore

    The story of the 1819 Peterloo Massacre where British forces attacked a peaceful pro-democracy rally in Manchester.

Director:

Mike Leigh

Stars:
Rory Kinnear,
Maxine Peake,
Neil Bell,
Philip Jackson

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Teen Spirit (2018)

92 min
                                  -
                                Drama
|
Music

51
        Metascore

    Violet is a shy teenager who dreams of escaping her small town and pursuing her passion to sing. With the help of an unlikely mentor, she enters a local singing competition that will test her integrity, talent and ambition. Driven by a pop-fueled soundtrack, Teen Spirit is a visceral and stylish spin on the Cinderella story.

Director:

Max Minghella

Stars:
Elle Fanning,
Rebecca Hall,
Millie Brady,
Elizabeth Berrington

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Storm Boy (2019)

99 min
                                  -
                                Adventure
|
Drama
|
Family

    A beautiful and contemporary retelling of Colin Thiele's classic Australian tale. 'Storm Boy' has grown up to be Michael Kingley, a successful retired businessman and grandfather. When Kingley starts to see images from his past that he can't explain, he is forced to remember his long-forgotten childhood, growing up on an isolated coastline with his father. He recounts to his grand-daughter the story of how, as a boy, he rescued and raised an extraordinary orphaned pelican, Mr Percival. Their remarkable adventures and very special bond has a profound effect on all their lives. Based on the beloved book, Storm Boy is a timeless story of an unusual and unconditional friendship.

Director:

Shawn Seet

Stars:
Jai Courtney,
Geoffrey Rush,
David Gulpilil,
Erik Thomson

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

April 12

Hellboy (2019)

Action
|
Adventure
|
Fantasy
|
Sci-Fi

    Based on the graphic novels by Mike Mignola, Hellboy, caught between the worlds of the supernatural and human, battles an ancient sorceress bent on revenge.

Director:

Neil Marshall

Stars:
David Harbour,
Milla Jovovich,
Ian McShane,
Daniel Dae Kim

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Missing Link (2019)

95 min
                                  -
                                Animation
|
Adventure
|
Comedy
|
Family
|
Fantasy

    Plot kept under wraps.

Director:

Chris Butler

Stars:
Zoe Saldana,
Hugh Jackman,
Emma Thompson,
Matt Lucas

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

After (2019)

Drama
|
Romance

    A young woman falls for a guy with a dark secret and the two embark on a rocky relationship. Based on the novel by Anna Todd.

Director:

Jenny Gage

Stars:
Selma Blair,
Hero Fiennes Tiffin,
Peter Gallagher,
Jennifer Beals

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Little (2019)

Comedy
|
Fantasy

    A woman is transformed into her younger self at a point in her life when the pressures of adulthood become too much to bear.

Director:

Tina Gordon

Stars:
Justin Hartley,
Regina Hall,
Marsai Martin,
Tone Bell

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

High Life (2018)

110 min
                                  -
                                Adventure
|
Drama
|
Horror
|
Mystery
|
Sci-Fi

81
        Metascore

    A father and his daughter struggle to survive in deep space where they live in isolation.

Director:

Claire Denis

Stars:
Robert Pattinson,
Juliette Binoche,
André Benjamin,
Mia Goth

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Les filles du soleil (2018)

115 min
                                  -
                                Drama
|
War

59
        Metascore

    A Kurdish female battalion prepares to take back their town from extremists.

Director:

Eva Husson

Stars:
Golshifteh Farahani,
Emmanuelle Bercot,
Zübeyde Bulut,
Sinama Alievi

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Sauvage (2018)

99 min
                                  -
                                Drama

78
        Metascore

    Leo is 22 and sells his body on the street for a bit of cash. The men come and go, and he stays right here - longing for love. He doesn't know what the future will bring. He hits the road. His heart is pounding.

Director:

Camille Vidal-Naquet

Stars:
Félix Maritaud,
Eric Bernard,
Nicolas Dibla,
Philippe Ohrel

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

April 19

The Curse of La Llorona (2019)

93 min
                                  -
                                Horror
|
Mystery
|
Thriller

    Ignoring the eerie warning of a troubled mother suspected of child endangerment, a social worker and her own small kids are soon drawn into a frightening supernatural realm.

Director:

Michael Chaves

Stars:
Linda Cardellini,
Raymond Cruz,
Marisol Ramirez,
Patricia Velasquez

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Penguins (2019)

Documentary

    The story of Steve, an Adélie penguin, on a quest to find a life partner and start a family. When Steve meets with Wuzzo the emperor penguin they become friends. But nothing comes easy in the icy Antarctic.

Directors:

Alastair Fothergill
|

Jeff Wilson

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Under the Silver Lake (2018)

139 min
                                  -
                                Comedy
|
Crime
|
Drama
|
Mystery
|
Thriller

59
        Metascore

    Sam, intelligent but without purpose, finds a mysterious woman swimming in his apartment's pool one night. The next morning, she disappears. Sam sets off across LA to find her, and along the way he uncovers a conspiracy far more bizarre.

Director:

David Robert Mitchell

Stars:
Andrew Garfield,
Riley Keough,
Topher Grace,
Callie Hernandez

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Rafiki (2018)

83 min
                                  -
                                Drama
|
Romance

62
        Metascore

    "Good Kenyan girls become good Kenyan wives," but Kena and Ziki long for something more. When love blossoms between them, the two girls will be forced to choose between happiness and safety.

Director:

Wanuri Kahiu

Stars:
Samantha Mugatsia,
Neville Misati,
Nice Githinji,
Charlie Karumi

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Breakthrough (2019)

116 min
                                  -
                                Biography
|
Drama

    When her 14-year-old son drowns in a lake, a faithful mother prays for him to come back from the brink of death and be healed.

Director:

Roxann Dawson

Stars:
Topher Grace,
Sam Trammell,
Chrissy Metz,
Rebecca Staab

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Little Woods (2018)

105 min
                                  -
                                Crime
|
Drama
|
Western

    A modern Western that tells the story of two sisters, Ollie and Deb, who are driven to work outside the law to better their lives. For years, Ollie has illicitly helped the struggling residents of her North Dakota oil boomtown access Canadian health care and medication. When the authorities catch on, she plans to abandon her crusade, only to be dragged in even deeper after a desperate plea for help from her sister.

Director:

Nia DaCosta

Stars:
Tessa Thompson,
Lily James,
Lance Reddick,
Luke Kirby

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

Fast Color (2018)

100 min
                                  -
                                Drama
|
Sci-Fi
|
Thriller

56
        Metascore

    A woman is forced to go on the run when her superhuman abilities are discovered. Years after having abandoned her family, the only place she has left to hide is home.

Director:

Julia Hart

Stars:
Gugu Mbatha-Raw,
Saniyya Sidney,
David Strathairn,
Lorraine Toussaint

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

High on the Hog (2017)

85 min
                                  -
                                Action
|
Crime
|
Drama
|
Thriller

    With a potent strain of pot sweeping the City, DTA agents attempt to infiltrate a small town farming operation that has a strong leader and interesting family members.

Director:

Tony Wash

Stars:
Sid Haig,
Joe Estevez,
Robert Z'Dar,
Fiona Domenica

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

April 26

Avengers: Endgame (2019)

Action
|
Adventure
|
Fantasy
|
Sci-Fi

    After the devastating events of Avengers: Infinity War (2018), the universe is in ruins. With the help of remaining allies, the Avengers assemble once more in order to undo Thanos' actions and restore order to the universe.

Directors:

Anthony Russo
|

Joe Russo

Stars:
Brie Larson,
Bradley Cooper,
Scarlett Johansson,
Chris Hemsworth

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

Watch Trailer

    if (typeof uet == 'function') {
    uet("be", "SmallTrailerWidget", {wb: 1});
    }

    if (typeof uex == 'function') {
    uex("ld", "SmallTrailerWidget", {wb: 1});
    }

The White Crow (2018)

127 min
                                  -
                                Biography
|
Drama

    The story of Rudolf Nureyev's defection to the West.

Director:

Ralph Fiennes

Stars:
Oleg Ivenko,
Ralph Fiennes,
Louis Hofmann,
Adèle Exarchopoulos

    if (typeof uet == 'function') {
    uet("bb", "SmallTrailerWidget", {wb: 1});
    }

expected result is
Adventure
Fantasy
Sci-Fi

Horror
Thriller

Biography
Drama
History

History

every movie starts with \(20..\) and then some movies follow new empty lines, some movies follow (min) and there is "|" char between that I determine with \W however I couldn't come up with a single regex. Is there anyone has an idea about it. Thank you.
Edit: The web page used for crawling is https://www.imdb.com/movies-coming-soon/2019-04/ .However, I have to use the text sample that I give.

A: Now that you made that update, arghh, it is beyond me, but the below can handle the original post
Given the original info try this:
Part 1 - The string
>>> string = '''Shazam! (2019)

132 min
                              -
                            Action
|
Adventure
|
Fantasy
|
Sci-Fi

We all have a superhero inside us, it just takes a bit of magic to bring it out. In Billy Batson's case, by shouting out one word - SHAZAM! - this streetwise 14-year-old foster kid can turn into the adult superhero Shazam.

Director:

David F. Sandberg

Stars:
Zachary Levi,
Djimon Hounsou,
Mark Strong,
Michelle Borth

Pet Sematary (2019)

Horror
|
Thriller

Louis Creed, his wife Rachel, and their two children Gage and Ellie move to a rural home where they are welcomed and enlightened about the eerie 'Pet Sematary' located nearby. After the tragedy of their cat being killed by a truck, Louis resorts to burying it in the mysterious pet cemetery, which is definitely not as it seems, as it proves to the Creeds that sometimes, dead is better.

Directors:

Kevin Kölsch
|

Dennis Widmyer

Stars:
John Lithgow,
Jason Clarke,
Amy Seimetz,
Naomi Frenette

The Best of Enemies (2019)

Biography
|
Drama
|
History

Civil rights activist Ann Atwater faces off against C.P. Ellis, Exalted Cyclops of the Ku Klux Klan, in 1971 Durham, North Carolina over the issue of school integration.

Director:

Robin Bissell

Stars:
Sam Rockwell,
Taraji P. Henson,
Wes Bentley,
Anne Heche

Peterloo (2018)

154 min
                              -
                            Drama
|
History

70
    Metascore

    The story of the 1819 Peterloo Massacre where British forces attacked a peaceful pro-democracy rally in Manchester.

Director:

Mike Leigh

Stars:
Rory Kinnear,
Maxine Peake,
Neil Bell,
Philip Jackson'''

.
.
.
.
Part 2 - The code
>>> categories_group = re.findall('\(20[\d]{2}\)[\S\s]*?((?:[\S]+[\s]*\|[\s]*){1,}[\S]*)', string)

>>> for categories in categories_group:
        print('\n'*3)
        print(categories)

#Output

Action
|
Adventure
|
Fantasy
|
Sci-Fi

Horror
|
Thriller

Biography
|
Drama
|
History

Drama
|
History

.
.
.
Part 3 - Further Code to eliminate |\n
>>> categories_eliminate_OR = []

>>> for categories in categories_group:
        categories_eliminate_OR.append(categories.replace('|\n', ''))

>>> for categories in categories_eliminate_OR:
        print('\n'*2)
        print(categories)

#Output
Action
Adventure
Fantasy
Sci-Fi

Horror
Thriller

Biography
Drama
History

Drama
History

A: Sooo, if you're willing to accept some non-captures, I think the below should work. Keep in mind, I updated the regex so that it will also capture single terms now. Also, you can run the below through the eliminate_OR lines I posted above to deal with the |\n
>>> categories_group = re.findall('Director[\S\s]+?Star|\(20[\d]{2}\)[\S\s]*?((?:[\S]+[\s]*\|[\s]*){1,}[\S]*|[A-Z]+[\w]+)', string)

>>> for categories in categories_group:
        print(categories)

#Output

Action
|
Adventure
|
Fantasy
|
Sci-Fi

Horror
|
Thriller

Biography
|
Drama
|
History

Drama
|
History

Drama
|
Music

Adventure
|
Drama
|
Family

Action
|
Adventure
|
Fantasy
|
Sci-Fi

Animation
|
Adventure
|
Comedy
|
Family
|
Fantasy

Drama
|
Romance

Comedy
|
Fantasy

Adventure
|
Drama
|
Horror
|
Mystery
|
Sci-Fi

Drama
|
War

Drama

Horror
|
Mystery
|
Thriller

Documentary

Drama
|
Romance

Biography
|
Drama

Crime
|
Drama
|
Western

Drama
|
Sci-Fi
|
Thriller

Action
|
Crime
|
Drama
|
Thriller

Action
|
Adventure
|
Fantasy
|
Sci-Fi

With

Biography
|
Drama

.
.
One thing, the following sentence will cause With to be captured because I can't figure out a truly completely reliable way to make the regex ignore the line because Movie Titles themselves can be of variable length.
After the devastating events of Avengers: Infinity War (2018), the universe is in ruins. With the help


text:
Q: populate words in each line in the file into temporary array $ cat file
line1: Joe Frank tom Jim Michelle Antony
line2: Frank Joe tom Jim Antony Michelle higgs julien
$ arr=`cat file | grep line1`
$ echo $arr
line1: Joe Frank tom Jim Michelle Antony
$ echo ${arr[1]}
line1: Joe Frank tom Jim Michelle Antony

whereas I expected Joe as output of echo ${arr[1]}
Is there any shortest way to get into temp array the each name in the lines.

A: How about
arr=(`grep line1 file`)

or better yet
read -a arr < <(grep line1 file)

A: grep line1 file | cut -f2 -d " "

... check this way


text:
Q: How to combine 4 or more tables with different joins, avoiding some minor duplication I'm trying to build a query for combining 4 of my tables into a pre-created table,
my query was running smoothly for the first 3 tables.
Here is my query
 (*query and tables are already simplified)
INSERT INTO goaltable
SELECT  b.employeeID, b.employeeName, a.grupID,
        a.shiftID, b.scheduleDate, b.scheduleWorkTime,
        c.hierarchyID, c.companyID, c.city1, c.phone,
        d.machineID, d.tapDate, e.tapTime, e.tapID

    FROM mstrattendance AS b LEFT JOIN workgrup AS a
        ON b.employeeID = a.employeeID
            AND b.scheduleDate = a.scheduleDate

        LEFT JOIN mstremployee as c
            ON b.employeeID = c.employeeID

        --working query limit

        LEFT JOIN rawfpmachine as d
            ON b.employeeID = d.employeeID AND b.scheduleDate = d.tapDate

        RIGHT JOIN rawfpmachine as e
            ON b.employeeID = c.employeeID AND b.scheduleDate = d.tapDate;

I already tried different query for the last part of code, but it keeps returning null values, or making the whole tables null.
Here is my tables
CREATE TABLE "mstrattendance" ("employeeID" varchar(16),"employeeName" varchar(64),"scheduleDate" varchar(10),"scheduleWorkTime" varchar(5));

INSERT INTO mstrattendance ("employeeID","employeeName","scheduleDate","scheduleWorkTime")
VALUES
('193011','Asuk','13-08-2016','07:30'),
('193011','Asuk','14-08-2016','07:00'),
('193011','Asuk','15-08-2016','99:99'),
('193015','Bara','13-08-2016','07:30'),
('193015','Bara','14-08-2016','07:00'),
('193015','Bara','15-08-2016','99:99'),
('193015','Anna','13-08-2016','99:99'),
('124012','Anna','14-08-2016','07:30'),
('124012','Anna','15-08-2016','07:00');

CREATE TABLE "workgrup" ("employeeID" varchar(16),"shiftID" varchar(4),"scheduleDate" varchar(10),"grupID" varchar(3));

INSERT INTO workgrup ("employeeID","shiftID","scheduleDate","grupID")
VALUES
('193011','1P1','13-08-2016','PO'),
('193011','1P1','14-08-2016','PO'),
('193011','1P1','15-08-2016','PO'),
('193015','1P1','13-08-2016','PO'),
('193015','1P1','14-08-2016','PO'),
('124012','1P2','14-08-2016','FA');

CREATE TABLE "mstremployee" ("employeeID" varchar(16),"companyID" varchar(4),"hierarchyID" varchar(10),"city1" varchar(32),"phone" varchar (16));

INSERT INTO mstremployee ("employeeID","companyID","hierarchyID","city1","phone")
VALUES
('193011','ALU','1001021','Kartaja','0832851'),
('193015','ALU','1001021','Kartaja','0832117'),
('124012','GLA','1002003','Angertang','0811345');

CREATE TABLE "rawfpmachine" ("employeeID" varchar(16),"machineID" varchar(4),"tapDate" varchar(10),"tapTime" varchar(5),"tapID" varchar (2));

INSERT INTO rawfpmachine ("employeeID","machineID","tapDate","tapTime","tapID")
VALUES
('193011','001','13-08-2016','07:50','00'),
('193011','002','13-08-2016','12:02','02'),
('193011','002','13-08-2016','12:56','03'),
('193011','001','13-08-2016','16:40','01'),
('193015','001','13-08-2016','07:58','00'),
('193015','002','13-08-2016','12:01','02'),
('193015','002','13-08-2016','12:58','03'),
('193015','001','13-08-2016','16:33','01'),
('124012','003','14-08-2016','07:54','00'),
('124012','004','14-08-2016','12:03','02'),
('124012','004','14-08-2016','12:56','03'),
('124012','003','14-08-2016','16:38','01'),
('193011','001','14-08-2016','07:58','00'),
('193011','001','14-08-2016','16:01','01');

my goal is to create table like this
CREATE TABLE "goaltable" ("employeeID" varchar(16),"employeeName" varchar(64),"scheduleDate" varchar(10),"scheduleWorkTime" varchar(5),"shiftID" varchar(4),"groupID" varchar(3)),"companyID" varchar(4),"hierarchyID" varchar(10),"city1" varchar(32),"phone" varchar (16),"machineID" varchar(4),"tapDate" varchar(10),"tapTime" varchar(5),"tapID" varchar (2));

INSERT INTO goaltable ("employeeID","employeeName","scheduleDate","scheduleWorkTime","shiftID","grupID","companyID","hierarchyID","city1","phone","machineID","tapDate","tapTime","tapID")
VALUES
('193011','Asuk','13-08-2016','07:30','1P1','PO','ALU','1001021','Kartaja','0832851','001','13-08-2016','07:50','00'),
('193011','Asuk','13-08-2016','07:30','1P1','PO','ALU','1001021','Kartaja','0832851','002','13-08-2016','12:02','02'),
('193011','Asuk','13-08-2016','07:30','1P1','PO','ALU','1001021','Kartaja','0832851','002','13-08-2016','12:56','03'),
('193011','Asuk','13-08-2016','07:30','1P1','PO','ALU','1001021','Kartaja','0832851','001','13-08-2016','16:40','01'),
('193015','Bara','13-08-2016','07:30','1P1','PO','ALU','1001021','Kartaja','0832117','001','13-08-2016','07:58','00'),
('193015','Bara','13-08-2016','07:30','1P1','PO','ALU','1001021','Kartaja','0832117','002','13-08-2016','12:01','02'),
('193015','Bara','13-08-2016','07:30','1P1','PO','ALU','1001021','Kartaja','0832117','002','13-08-2016','12:58','03'),
('193015','Bara','13-08-2016','07:30','1P1','PO','ALU','1001021','Kartaja','0832117','001','13-08-2016','16:33','01'),
('124012','Anna','14-08-2016','07:30','1P2',,'FA','GLA','1002003','Angertang','0811345','003','14-08-2016','07:54','00'),
('124012','Anna','14-08-2016','07:30','1P2','FA','GLA','1002003','Angertang','0811345','004','14-08-2016','12:03','02'),
('124012','Anna','14-08-2016','07:30','1P2','FA','GLA','1002003','Angertang','0811345','004','14-08-2016','12:56','03'),
('124012','Anna','14-08-2016','07:30','1P2','FA','GLA','1002003','Angertang','0811345','003','14-08-2016','16:38','01'),
('193011','Bara','14-08-2016','07:00','1P1','PO','ALU','1001021','Kartaja','0832117','001','14-08-2016','07:58','00'),
('193011','Bara','14-08-2016','07:00','1P1','PO','ALU','1001021','Kartaja','0832117','001','14-08-2016','16:01','01');

any help is much appreciated, thank you in advance.
*UPDATE
here is my newest and closest to goal query
INSERT INTO goaltable
SELECT  b.employeeID, b.employeeName, b.scheduleDate, b.scheduleWorkTime, a.grupID,
    a.shiftID, c.companyID, c.hierarchyID, c.city1, c.phone,
    d.machineID, d.tapDate, d.tapTime, d.tapID

FROM mstrattendance AS b LEFT JOIN workgrup AS a
    ON b.employeeID = a.employeeID
        AND b.scheduleDate = a.scheduleDate

    LEFT JOIN mstremployee as c
        ON b.employeeID = c.employeeID

    INNER JOIN rawfpmachine as d
        ON b.employeeID = d.employeeID AND b.scheduleDate = d.tapDate

--this query is worked

but I still not same as my goal table, because there is still some duplicate in there, just when there are a day off.
goal table wannabe
and... I can't post image..
As you can see, there is a duplication every time scheduleDate value 99:99
the rest rows is great though (or I didn't notice)
and I'm not supposed to use WHERE scheduleWorkTime <> '99:99';


text:
Q: CodeIgniter - unlimited parameters? I am currently using CodeIgniter.
I am trying to write a function that can take an unlimited number of paramaters.
So in the controller it will be something like
function test($name, $others){
    foreach($others){
       //do something
    }
}

and I could call it like
example.com/control/test/some name/param1/param2/param3/param4/param5...

How can I set this up?

A: you could also do it like this:
function foo($params=array())
{
    $params=func_get_args();
    //print_r($params);
}

so any url like:
site.com/controller/foo/param1/param2/param3/param4
would create an array of parameters.

A: You can get an associated array of URI segments with the uri_to_assoc function in the URI class. So in your controller, you might do something like this:
function test($name){
    $uri_seg = $this->uri->uri_to_assoc(4);

    foreach($uri_seg as $para){
        // Do something with each of the URI segments passed in here after $name
    }
}

A: It's not clear why you need an unlimited (variable) number of arguments, but you may want to consider why you need them.
You can use alternative URI semantics for certain types of arguments. Often the URI design is the path to a thing in a system. Unlimited parameters may not refer to the resource, but rather describe its attributes. Tags are a good example of this.
/chicken/red+tall+fat

Tags implement easily in CodeIgniter with a single parameter.
If the parameters refer to a node, you can consider a similar approach:
/hen-house.bunk4.topshelf/chicken

Or, if the hierarchy is important as a path, you can use the func_get_args() solution above.


text:
Q: How to show multiple image one after one by for loop from Firebase I want to develop an app, Where it takes the string and convert it on word array which I already did. But the problem is when I use for loop and Firebase query to show Image from firebase storage one after one by thread.sleep(5000);.It's doesn't work. It's alway's show only last word image and also last word.
Here is my code:
                String str=matches.get(0).toLowerCase();

                final String[] word=str.split(" ");

                //speexhTxt.setText(word.length);

                // speexhTxt.setText(String.valueOf(one));

                for (i=0;i<word.length;i++) {
                    progressBar.setVisibility(View.VISIBLE);

                    imageHide.setVisibility(View.GONE);
                    signImage.setVisibility(View.VISIBLE);

                    firebaseFirestore= FirebaseFirestore.getInstance();
                    collectionReference=firebaseFirestore.collection("dumbsign");

                    Query query=collectionReference.whereEqualTo("word",word[i]);

                    final int finalI = i;
                    query.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                        @Override
                        public void onComplete(@NonNull Task<QuerySnapshot> task) {

                            if (task.isSuccessful()){

                                for (QueryDocumentSnapshot doc : task.getResult()){

                                    Glide.with(getApplicationContext()).
                                            load(doc.getString("image_url"))
                                            .into(signImage);
                                    speexhTxt.setText(word[finalI]);

                                    progressBar.setVisibility(View.GONE);

                                }
                            };

                            try {
                                Thread.sleep(5000);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }

                    });

                }

A: You're putting your thread.sleep() after the loop is done, so basically what your code is doing is loading all the images and then sleeping the thread for 5000 milliseconds, you should put it inside the for loop, here for example:
for (QueryDocumentSnapshot doc : task.getResult()){

          Glide.with(getApplicationContext()).
          load(doc.getString("image_url")).into(signImage);
          speexhTxt.setText(word[finalI]);
          progressBar.setVisibility(View.GONE);
          try {
             Thread.sleep(5000);
          } catch (InterruptedException e) {
              e.printStackTrace();
          }

}

Note, i do NOT recommend using Thread.sleep() on your main Thread read this:
  How to call a method after a delay in Android


text:
Q: Accessing Google Cloud SQL instance from Google Compute Engine? After spending a few hours, this is the only real documentation I can find for accessing Cloud SQL from outside of GAE: https://developers.google.com/cloud-sql/docs/external
The problem is, this is for a Java application (via JDBC).
I need to access my Cloud SQL DB from within a PHP, Dart, or NodeJS application. I thought by giving my GCE instance rights to connect to Cloud SQL, this would be easy. But no arrangement of socket strings (using mysql drivers) seems to be effective.
For argument's sake, let's say I'm trying to connect with a PHP app. My mysql connection array looks like this:
(
  'driver'    => 'mysql',
  'unix_socket'     => '/cloudsql/project-id:instance-id',
  'host'      => 'localhost',
  'database'  => 'dbname',
  'username'  => 'root',
  'password'  => '',
  'charset'   => 'utf8',
  'collation' => 'utf8_unicode_ci',
  'prefix'    => '',
)

This is as close as I got, but I'll get a generic "Can't connect to local MySQL server through socket" error.

A: While this is an older question, I just thought I should share what I've found in regards to this.
First off, you were attempting to connect to a MySQL Server on your GCE instance, not your remote CloudSQL instance.
To begin

*

*Go into your dashboard and request an IP for your CloudSQL Instance.

*Go to CloudSQL Access Control and add your GCE IP address.

*Connect to CloudSQL from GCE via mysql-client and add a new (non-root) user

*Use the CloudSQL IP and the new non-root user to access CloudSQL from GCE PHP files.

Hope this helps.

A: The Cloud SQL team are working on improving the connectivity from Compute Engine. If you send this question to google-cloud-sql-discuss@googlegroups.com, they will be able to follow up.

A: You could connect indirectly I.E. Create a Java-based App Engine App that provides an interface to the database for you, and consume that interface from your PHP app?
For example: Java App Engine App has a 'getEmployees' method call that calls a Select query on the DB and then formats and returns the results as a JSON file. Your PHP app would then call this method and consume the JSON...


text:
Q: Evaluate $\lim_{n \rightarrow \infty} \int_0^{+\infty} \frac{e^{-n^2x}}{\sqrt{|x-n^2|}} dx$ It's an exercise I took from an exam of Measure Theory.
Using all the theorems it needs, evaluate:
$$\lim_{n \rightarrow \infty} \int_0^{+\infty} \frac{e^{-n^2x}}{\sqrt{|x-n^2|}} dx $$
It has an additional hint: from $n>2$ look at the integral like $$ \int_0^{+\infty} = \int_0^1 + \int_1^{n^2-n} + \int_{n^2-n}^{n^2+n}+\int_{n^2+n}^{+\infty}$$
Moreover the function has no elementary primitive, but it is the product of two functions that do have elementary primitive. This can be helpful after having done the right considerations.

A: Following the given hint we have that for $n\geq 2$,
i) if $x\in [0,1]$ then
$$\frac{e^{-n^2x}}{\sqrt{|x-n^2|}}\leq \frac{1}{\sqrt{n^2-1}},$$
ii) if $x\in [1,n^2-n]$ then
$$\frac{e^{-n^2x}}{\sqrt{|x-n^2|}}\leq \frac{e^{-n^2}}{\sqrt{n}},$$
if $x\in [n^2+n,+\infty)$ then
$$\frac{e^{-n^2x}}{\sqrt{|x-n^2|}}\leq \frac{e^{-n^2x}}{\sqrt{n}}.$$
By using these estimates, you may show that the three related integrals go to zero. It remains to consider the integral:
$$\int_{n^2-n}^{n^2+n}\frac{e^{-n^2x}}{\sqrt{|x-n^2|}} \,dx\leq e^{-n^2(n^2-n)}\int_{n^2-n}^{n^2+n}\frac{dx}{\sqrt{|x-n^2|}}=e^{-n^2(n^2-n)}2\int_{0}^{n}\frac{dt}{\sqrt{t}}.$$
Can you take it from here?


text:
Q: How do I avoid using dynamic when mocking an Excel.worksheet? I'm trying to mock an Excel spreadsheet using NSubstitute or other mocking framework and MSTest (Visual Studio 2010). I'm not sure if there's a better way than this--and this doesn't quite work for testing:
Here's an example (this is all prototype code right now, and not very clean):
int[] lowerBounds = { 1, 1 };
int[] lengths = { 2, 2 };

//Initialize a 1-based array like Excel does:
object[,] values = (object[,])Array.CreateInstance(typeof(object), lengths, lowerBounds);
values[1,1] = "hello";
values[2,1] = "world";

//Mock the UsedRange.Value2 property
sheet.UsedRange.Value2.Returns(values);

//Test:
GetSetting(sheet, "hello").Should().Be("world");  //FluentAssertions

So far, so good: this passes if the GetSetting method is in the same project as my test. However when GetSetting is in my VSTO Excel-Addin project, it fails with the following error on the first line of the GetSetting function:
System.MissingMethodException: Error: Missing method 'instance object [MyExcel.AddIn] Microsoft.Office.Interop.Excel.Range::get_Value2()' from class 'Castle.Proxies.RangeProxy'.

For reference, the GetSetting grabs a value from columnA in the sheet, and returns the value in columnB.
public static string GetSetting(Excel.Worksheet sheet, string settingName) {
  object[,] value = sheet.UsedRange.Value2 as object[,];
  for (int row = 1; row <= value.GetLength(1); row++) {
    if (value[1, row].ToString() == settingName)
      return value[2, row].ToString();
  }
  return "";
}

The final interesting piece is if I redefine the signature of my method as follows:
public static string GetSetting(dynamic sheet, string settingName)
it works in the VSTO project.
So what is going on, and what's the best way to do something like this?
Thanks!

A: The VS2012 update: Moq & Interop Types: works in VS2012, fails in VS2010?
First up: Something has changed: How do I avoid using dynamic when mocking an Excel.worksheet?
I encountered the same problem Mocking Excel objects using NSubstitute. The dynamic resolved the problem just as you mention. However I wanted to find the root cause.

When your Project has a reference to Microsoft.Office.Interop.Excel.Extensions.dll you need to check if the Embed Interop Types property is visible. If it is that means your targeting .Net 4.0 (which I could guess from the dynamic keyword).

You can leave the Test Project targeting .Net 4.0 but you need to you
  change the VSTO Project .Net framework back to 3.5. Then you'll
  probably have to do some explicit casting and fully qualify things to
  get rid of these errors:

C# Office Excel Interop "object does not contain definition for" errors, here are a couple of examples:
.Net 4.0:
if (tmpsheetName == xlApp.ActiveSheet.Name)

.Net 3.5 equivalent
Worksheet activeSheet = (Worksheet)xlApp.ActiveSheet;
if (tmpsheetName == activeSheet.Name)

Another example:
rn.Select();

.Net 4.0
xlApp.Selection.HorizontalAlignment = Constants.xlCenter;
xlApp.Selection.Font.Bold = true;
xlApp.Selection.Merge();

.Net 3.5 equivalent
rn.HorizontalAlignment = Constants.xlCenter;
rn.Font.Bold = true;
rn.Merge();

Proceed to fix all the .Net 3.5 vs 4.0 syntax errors as per the above examples. Dont forget to remove the dynamic parameter type and replace it the original Worksheet. Finally fire up the Test again and it will pass!!!
Given all the grief I experienced with Microsoft.CSharp.DLL in this thread I am of the opinion testing VSTO .Net 4.0 projects with Mocking Frameworks doesn't work.

A: It turns out that mocking very complex COM interop objects such as the Excel object or the InDesign object using any of the castle-based frameworks (nsubstitute, ninject, etc.), does not provide enough of a performance boot. Run times for tests are still measurable in seconds. (Multiplying that out by tens or hundreds of tests makes the unit tests still too slow to run under TDD principles of testing constantly.)
Testing the Excel logic then should be considered an integration test, and as such, running against the actual Excel object should be fine, making mocking not very useful in such a scenario. Results will be far more useful testing against an actual object.
Testing to an abstraction layer placed between Excel and the application would allow for fast testing of the application logic. And testing the abstraction layer-to-excel under integration testing should suffice to thoroughly test the application.


text:
Q: spring mvc 3.0 caching I'm using spring mvc 3.0 with eclipselink and jpa and I'm experiencing following issue: I have this field in my app:
@OneToMany(mappedBy = "stadium")
private Set<FootballMatch> footballMatches = new HashSet<FootballMatch>();

when there is triggered some action that adds new items into set via Set.add(), the changes doesn't show up in the browser, althought there are new rows in the database. When I clear the browser cache, nothing happens. I have discovered that a way how to force load new values is to redeploy the app, even without change of single line. So the app is returning old values, caching it somewhere. How do I force it to load allways updated values?
I was thinking of something like getLastModified(), but I don't know where should I implement it.

A: Since it is a bidirectional relationship, ensure that you are setting both sides of the relationship.
See,
http://en.wikibooks.org/wiki/Java_Persistence/Relationships#Object_corruption.2C_one_side_of_the_relationship_is_not_updated_after_updating_the_other_side
Also ensure you are changing, merging, committing the correct objects.
Try using EntityManager.refresh() to refresh the object, do you get the updated values?  If you do not, then your database does not have the data.
Are you caching the EntityManager in your application?  If you have an old EntityManager around it will not see new changes.  Normally a new EntityManager should be created for each request/transaction.
EclipseLink maintains an object cache by default, this can be disabled using the persistence.xml property,
"eclipselink.caching.shared"="false"
See,
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching


text:
Q: Date validator in javascript I have few months java experience, but now I am trying to write my first javascript to validate a date input. I am not sure what is wrong in the code.
            Available start date
            <input type="text" onsubmit="isValidDate()" class="w-input" maxlength="256" name="Start-date" data-name="Start date" placeholder="dd/mm/yyyy" id="Start-date" th:value="${possibleStartDate}" />

Also what is the better alternative to alert ? Something like a red small message under the textfield that the input is incorrect when submit button is pressed. I know it is better to have separate file for the javascript, but I am not sure where in the html to put the  tags to link the file.

A: There were quite a few things which needed a little tweak:

*

*var dateString = document.getElementById("Start-date") should be var dateString = document.getElementById("Start-date").value;

*var day = parseInt(parts[1], 10); should be var day = parseInt(parts[0], 10); and var month = parseInt(parts[0], 10); should be var month = parseInt(parts[1], 10); to support dd/mm/yyyy

*Inputs don't fire onsubmit unless they are a part of a form you can try onblur instead

*I have wrapped the input with div with children indicating success/error to show the message better. (The messages are hidden shown using classes on the root div and supporting styles)

*I have spearated out the validation of a date string from DOM manipulation so you can reuse the validation across multiple places
NOTES:

*

*You may be better off setting the input type as date (the browser will open up a date picker if it supports it)

*You can also optionally use libraries like momentjs to make common date operations a little easier.

/**
 * Function which takes a string as an input and validates if it
 * is a date in the dd/mm/yyyy format
 * @param {string} dateString - The string representation of the date to validate
 8 @returns {boolean} value indicating if the date is valid (true) or not (false)
 */
function isValidDate(dateString) {
  var validDate = true;

  // First check for the pattern
  if (!/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(dateString)) {
    return false;
  }

  // Parse the date parts to integers
  var parts = dateString.split("/");
  var day = parseInt(parts[0], 10);
  var month = parseInt(parts[1], 10);
  var year = parseInt(parts[2], 10);

  if(isNaN(day)  || isNaN(month) || isNaN(year)){
    return false;
  }

  // Check the ranges of month and year
  if (year < 1000 || year > 3000 || month < 1 || month > 12) {
    return false;
  }

  var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

  // Adjust for leap years
  if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {
    monthLength[1] = 29;
  }

  // Check the range of the day
  if (!(day > 0 && day <= monthLength[month - 1])) {
    return false;
  }

  return true;

};

/**
 * Function which executes each time the input loses focus (onblur)
 */
function validateDate() {
  // Get a reference to the container
  var container = document.querySelector('.date');

  // Clear stale error/success messages
  container.className = container.className.replace('success', '');
  container.className = container.className.replace('error', '');

  // Get current value of input
  var dateString = document.getElementById("Start-date").value;

  // Test if the string is a valid date
  var isValid = isValidDate(dateString);

  // Update classess of container to show success/error
  if (!isValid) {
    container.className += ' error';
  } else {
    container.className += ' success';
  }
}
div.date .error {
  display: none;
  background: red;
  color: white;
}

div.date .success {
  display: none;
  background: darkgreen;
  color: white;
}

div.date.success .success {
  display: block;
}

div.date.error .error {
  display: block;
}

  Available start date
  <input type="text" onblur="validateDate()" class="w-input" maxlength="256" name="Start-date" data-name="Start date" placeholder="dd/mm/yyyy" id="Start-date" th:value="${possibleStartDate}" />

Please enter a valid date

Date is valid

A: If you're using the EcmaScript Date Time String Format, you can use the Date constructor. (Info
var dateString = document.getElementById("Start-date").value;
var validDate = !(isNaN( new Date(dateString) )

HTML5 also supports a type="date" in the <input> tag. This will prevent the browser from submitting the form if the date is invalid.
Also, I think you meant
var dateString = document.getElementById("Start-date").value;

Instead of
var dateString = document.getElementById("Start-date");

Because document.getElementById("Start-date") is an object.


text:
Q: Resteasy - Override Method with generics Right now i am working with resteasy. I have build a little Rest Application with the following struktur:
Controller Class:
@PATH("/rest")
public abstract class Controller<T>
{
  @POST
  public Response post(T ressource){[..]}

  @PUT
  public Response put(T ressource){[..]}

  @DELETE
  @Path("/{id}")
  public Response delete(@PathParam(value = "id") int id)

  @GET
  public Response get(){[..]}
}

ConrollerA Class (This is only an Example):
PATH("/rest/A")
public class ControllerA extends Controller<RessourceA>
{
  @Override
  public Response post(RessourceA ressource){[..]}

  [..]

  @Override
  public Response get(){[..]}
}

I start the server with jetty right now and everytime i make a POST Request to "/rest/A", the Server tells me, that there is no such a method but if i make a GET Requst to the Path it all works.
Is there a Problem with Jetty or Java if i override a Method with generic typs?
If i write the "@POST" annotation above the method it works, but i do not want this kind of solution. Do i have to make some settings in the web.xml or is the problem with java?


text:
Q: GraphQL Codegen duplicates RegisterDocument with typescript-urql The codegen.ts config below results in duplicating the RegisterDocument entries.
codegen.ts:
const config: CodegenConfig = {
  overwrite: true,
  schema: "http://localhost:4000/graphql",
  documents: "src/graphql/**/*.graphql",
  generates: {
    "src/generated/graphql": {
      preset: "client",
      plugins: [
        "typescript-urql"
      ],
      config: {
        documentVariableSuffix: 'test2'
      }
    }
  }
};

the output:
export const RegisterDocument = {"kind":"Document", ...}

export const RegisterDocument = gql`
    mutation Register($username: String!, $password: String!) {
  register(options: {username: $username, password: $password}) {
    errors {
      field
      message
    }
    user {
      id
      username
      createdAt
    }
  }
}
    `;

export function useRegisterMutation() {
  return Urql.useMutation<RegisterMutation, RegisterMutationVariables>(RegisterDocument);
};

Seemingly either the documentVariableSuffix param didn't affect the output const naming or it was a wrong param. The use of the typescript-operations or/and typescript packages only led to more duplicates.
What is the way to have typescript-urql register the mutation differently?
UP. The register mutation I need typings for:
const registerMutationDocument = graphql(`
  mutation Register($username: String!, $password: String!) {
    register(options: { username: $username, password: $password }) {
      errors {
        field
        message
      }
      user {
        id
        username
        createdAt
      }
    }
  }
`)

A: I'm Charly, from The Guild, working on GraphQL Code Generator.
The preset: "client" is not meant to be used in combination with other plugins.
You must use either the client-preset or typescript-urql-plugin which provides 2 different ways to get typed GraphQL Operations.
The typescript-urql-plugin generates React hooks while, the client-preset generated typed GraphQL documents that can be used with URQL's native useQuery() and useMutation().
We now recommend using the client-preset that provides a better developer experience and smaller generated code for the same result.
You will find a guide to setup the client-preset with URQL here: https://the-guild.dev/graphql/codegen/docs/guides/react-vue

A: After a few attempts with various code pieces it seems I've got it to work. Thank you mr. Poly for the hints.
Here's the take.
First, the present iteration of graphql-codegen watches for .ts/.tsx documents not *.graphql ones. Second the only plugins needed are the ones listed in the docs.
const config: CodegenConfig = {
  overwrite: true,
  schema: "http://localhost:4000/graphql",
  documents: "src/graphql/mutations/*.ts",
  generates: {
    "src/generated/graphql/": {
      preset: "client",
      plugins: []
    }
  }
};

Third the way to put the mutations etc. to a dedicated folder that I used was to create one at src/graphql/mutations. The register.ts holding the mutation had the following code:
import { graphql } from '../../generated/graphql';

export const registerMutationDocument = graphql(`
  mutation Register($username: String!, $password: String!) {
    register(options: { username: $username, password: $password }) {
      errors {
        field
        message
      }
      user {
        id
        username
        createdAt
      }
    }
  }
`);

The only problem for me was if I tried to add a field to it that didn't exist on the model the editor froze.
The usage within the component:
import { registerMutationDocument } from '../graphql/mutations/register';
...
const [, register] = useMutation(registerMutationDocument);


text:
Q: Utilising available method syntax within Generic Repository Pattern So we are using C# with a generic repository to do some stuff like retrieving records from db. So we have something like this in our implementation class.
    public async Task<IList<TEntity>> GetAllAsync(Expression<Func<TEntity, bool>> predicate)
    {
        IQueryable<TEntity> query = (predicate != null) ? context.Set<TEntity>().Where(predicate) : context.Set<TEntity>();
        return await query.ToListAsync();
    }

Here we use the where clause to do some filtering. Where we are facing a bit of difficulty is how to take advantage of the LINQ extension methods available to us. Now we have a service which uses the generic repository class through a Unit of Work. I have omitted the unit of work for simplicity.
    public async Task<List<Product>> GetStockTransactionsAsync(string warehouse, string product)
    {
        var stockTransation= await _unitOfWork.stockRepository.GetAllAsync(p => p.product == product && p.warehouse == warehouse);
        return null;
    }

Say we now just want to use LINQ method syntax, something like this would work in our Service class method.
    var stockTransation= (await _unitOfWork.stockRepository.GetAllAsync(p => p.product == product && p.warehouse == warehouse)).Take(5);

By doing this we have ruined the IQueryable stuff that I really was keen to maintain, due to the size large size of the db; we want to run SQL, not do anything in memory.
Is there a good way to pass in LINQ method syntax like we would a predicate for where or what we do for select or includes. So we could use Take(n), Max, Sum() etc... all within the generic repository methods. Does anyone know a good approach for this?

A: It looks like you complicating it too much.
You can simply return IQueryable<TEntity> from your repository:
public interface IGenericRepository
{
    IQueryable<TEntity> Set<TEntity>();
}

public class EntityFrameworkRepository : IGenericRepository
{
    // ...
    public IQueryable<TEntity> Set<TEntity>()
    {
        return _context.Set<TEntity>();
    }
}

// usage
IGenericRepository repository = ...;
var stockTransation = repository.Set<Product>()
    .Where(p => p.product == product && p.warehouse == warehouse)
    .Take(5)
    .ToArray();

In this case, SQL query will be generated and executed only after .ToArray() to take only 5 items matching this condition - no in-memory filtering will be done.
If you need to implement any custom methods, you can do it as extension methods in LINQ-alike way:
public static class QueryableExtensions
{
    // This one doesn't make much sense, actually
    public static IQueryable<TEntity> GetAll(this IQueryable<TEntity> queryable, Expression<Func<TEntity, bool>> predicate)
    {
        return predicate == null
            ? queryable
            : queryable.Where(predicate);
    }
}

// usage
IGenericRepository repository = ...;
var stockTransation = repository.Set<Product>()
    .GetAll(p => p.product == product && p.warehouse == warehouse)
    .Take(5)
    .ToArray();

I have implemented it in synchronous way to make it simpler, but it can easily be translated into async code.


text:
Q: smarty throwing error on using $smarty.post We are using smarty as template system for one of our form, please check add/edit form code...
<form action="{$MAIN_URL}products/add" method="post" class="clearfix">
<input type="text" name="cname" value="{if $smarty.post.cname}{$smarty.post.cname}{elseif $editdetails.product_name}{$editdetails.product_name}{/if}" />

its throwing following error...
Undefined variable: post in <b>/root/smarty/libs/sysplugins/smarty_internal_data.php</b> on line 291

It works fine if we remove {if $smarty.post.cname}{$smarty.post.cname} please help to fix. thanks.

A: I think it should be
{if isset($smarty.post) && isset($smarty.post.cname)}

but for the sake of brevity, this should work
{if isset($smarty.post.cname)}{$smarty.post.cname}{elseif $editdetails.product_name}{$editdetails.product_name}{/if}

A: Rather than {$smarty.post.cname}, is your variable actually called {$post.cname}? You other {$editdetails} would seem to imply that.
This assumes that $smarty is the PHP Smarty object variable, and not a template variable.


text:
Q: Is $[0,1] ∩ Q$ open or closed in real numbers? According to https://en.wikipedia.org/wiki/Closed_set, " $(0,1) ∩ Q^c $ is not closed in the real numbers". Why is it so?
I think that its complement is $(-∞,0)∪ (1,∞) ∪ Q^c$ is open and all points of $(0,1) ∩ Q^c $ are within or on the boundary, so I think $(0,1) ∩ Q^c $ is closed.
Is $[0,1] ∩ Q$ also open?

A: It is neither open nor closed:

*

*$0\in[0,1]\cap\mathbb Q$, but $[0,1]\cap\mathbb Q$ contains no interval $(-\varepsilon,\varepsilon)$ and therefoere $[0,1]\cap\mathbb Q$ is not open;

*you can take a sequence $(x_n)_{n\in\mathbb N}$ of elements of $[0,1]\cap\mathbb Q$ which converges to, say $\sqrt{\frac12}$, but $\sqrt{\frac12}\notin[0,1]\cap\mathbb Q$ and therefore $[0,1]\cap\mathbb Q$$ is not closed.


text:
Q: DataStage - issue with an input sequential file with pipe delimited Source: Text file in UNIX box
DS Stage: Sequential file
Sample record (Line 1):
Div03|Fac-12|Labor|2,543.30

Short desc:

*

*Stage is Pipe delimited and all are VarChar

*connected to a transformer to convert it to Decimal(19,2)

*output is a table in Oracle, but couldn't read the last record (2,543.30)

*last record (2,543.30), display as 0
HELP:
I need to display the last record as is and doesn't have comma but still have decimal. How?

A: Cause , (comma) is treated as string in datastage, remove it first and then try to read it


text:
Q: AndEngine: animated sprite not working with physics handler Animated sprite not performing animation with a physics handler:
I'm using AnalogOnScreenControl of the AndEngine GLES2 to move a sprite. The sprite is a person and so to show leg movement I've made it an animated sprite:
final AnimatedSprite person = new AnimatedSprite(personX, personY,
            this.mPersonTextureRegion, vertexBufferObjectManager);
    person.setScaleCenterY(this.mPersonTextureRegion.getHeight());
    person.setScale(2);

For movement I'm creating a physics handler:
final PhysicsHandler physicsHandler = new PhysicsHandler(person);
person.registerUpdateHandler(physicsHandler);
scene.attachChild(person);

and this is the code of the screen control:
    final AnalogOnScreenControl analogOnScreenControl = new AnalogOnScreenControl(
            0, CAMERA_HEIGHT
                    - this.mOnScreenControlBaseTextureRegion.getHeight(),
            this.mCamera, this.mOnScreenControlBaseTextureRegion,
            this.mOnScreenControlKnobTextureRegion, 0.1f, 200,
            this.getVertexBufferObjectManager(),
            new IAnalogOnScreenControlListener() {
                @Override
                public void onControlChange(
                        final BaseOnScreenControl pBaseOnScreenControl,
                        final float pValueX, final float pValueY) {
                     physicsHandler
                     .setVelocity(pValueX * 100, pValueY * 100);
                     person.animate(new long[] { 200, 200, 200 }, 3, 5,
                     false);

                }

The screen control works flawlessly for the animated sprite but when I create the physics handler it doesn't animate.
But it animates when I don't create a physics handler.
So why doesn't it animate when I create a physics handler?

A: Your animation will only show the first tile, if you restart the animation all the time.
Check if the animation is running with "isAnimationRunning()".
public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl, final float pValueX, final float pValueY)
{
    if(person!= null)
    {
        //Move your person
        final Vector2 velocity = Vector2Pool.obtain(pValueX * 10, pValueY * 10);
        person.setLinearVelocity(velocity);
        Vector2Pool.recycle(velocity);
        //Check if person is moving. Don't start a new animation, when your animation is already running
        if((pValueX != 0 || pValueY != 0) && person.isAnimationRunning() == false)
        {
            person.animate(new long[] { 200, 200, 200 },0,2,false);
        }
        //Stop animation, when there is no movement
        else if(pValueX == 0 && pValueY == 0 && person.isAnimationRunning() == true)
        {
            person.stopAnimation();
        }
    }
}

A: Figured it out! Animation must started only if pValueX isn't 0, i.e., if sprite is moving.
public void onControlChange(final BaseOnScreenControl pBaseOnScreenControl, final float pValueX, final float pValueY) {
if (pValueX > 0) {
//animate
}

else
//stop animation

 physicsHandler.setVelocity(pValueX * 100, pValueY * 100);
}