text:
Q: Add custom add-button in material-table Currently I have a simple material-table like this:
<MaterialTable
    options={myOptions}
    title="MyTitle"
    columns={state.columns}
    data={state.data}
    tableRef={tableRef} // Not working
    editable={{
      onRowAdd: ...,
      onRowDelete: ...,
      onRowUpdate: ...
    }}
  />;

where I'm trying to a create new add button (not edit the current one): each Row in the Bar Column should have a custom add button. I've looked through the MaterialTable source code but I couldn't reproduce the code that is used for the default add button which is:
        calculatedProps.actions.push({
          icon: calculatedProps.icons.Add,
          tooltip: localization.addTooltip,
          position: "toolbar",
          disabled: !!this.dataManager.lastEditingRow,
          onClick: () => {
            this.dataManager.changeRowEditing();
            this.setState({
              ...this.dataManager.getRenderState(),
              showAddRow: !this.state.showAddRow,
            });
          },
        });

in particular I can't get to access the dataManager variable.

That is how the current table looks like, and I need to add the add button where there is the red sign.

A: I think this is what you are looking for:

The Actions column represents the default actions set. I added an specific button using custom column rendering (docs):
//..previous columns definition
{
  title: "Custom Add",
  field: "internal_action",
  editable: false,
  render: (rowData) =>
    rowData && (
      <IconButton
        color="secondary"
        onClick={() => addActionRef.current.click()}
      >
        <AddIcon />
      </IconButton>
    )
}

*Using rowData as conditional, prevents from rendering while filling the addition row.
Then I triggered the add action as shown here:
const MyComponent() {

const addActionRef = React.useRef();

return (
    <>
        <button onClick={() => addActionRef.current.click()}>
            Add new item
        </button>

        <MaterialTable
            //...
            components={{
                Action: props => {
                    //If isn't the add action
                    if (typeof props.action === typeof Function || props.action.tooltip !== 'Add') {
                            return <MTableAction {...props} />
                    } else {
                            return
;
                    }}
                }}
            editable={{
                onRowAdd: (newData, oldData) => Promise.resolve(); //your callback here
            }}
        />
    </>
);
}

I extended the original snippet in order to complete the addition cycle. If you need to handle different types of actions, I think Editable section from the oficial docs would be handy.
Hope this works for you! Full code and sandbox here:
import React, { Fragment, useState } from "react";
import MaterialTable, { MTableAction } from "material-table";
import AddIcon from "@material-ui/icons/AddAlarm";
import IconButton from "@material-ui/core/IconButton";

export default function CustomEditComponent(props) {
const tableRef = React.createRef();
const addActionRef = React.useRef();

const tableColumns = [
    { title: "Client", field: "client" },
    { title: "Name", field: "name" },
    { title: "Year", field: "year" },
    {
    title: "Custom Add",
    field: "internal_action",
    editable: false,
    render: (rowData) =>
        rowData && (
        <IconButton
            color="secondary"
            onClick={() => addActionRef.current.click()}
        >
            <AddIcon />
        </IconButton>
        )
    }
];

const [tableData, setTableData] = useState([
    {
    client: "client1",
    name: "Mary",
    year: "2019"
    },
    {
    client: "client2",
    name: "Yang",
    year: "2018"
    },
    {
    client: "client3",
    name: "Kal",
    year: "2019"
    }
]);

return (
    <Fragment>
    <MaterialTable
        tableRef={tableRef}
        columns={tableColumns}
        data={tableData}
        title="Custom Add Mode"
        options={{
        search: false
        }}
        components={{
        Action: (props) => {
            //If isn't the add action
            if (
            typeof props.action === typeof Function ||
            props.action.tooltip !== "Add"
            ) {
            return <MTableAction {...props} />;
            } else {
            return
;
            }
        }
        }}
        actions={[
        {
            icon: "save",
            tooltip: "Save User",
            onClick: (event, rowData) => alert("You saved " + rowData.name)
        }
        ]}
        editable={{
        onRowAdd: (newData) =>
            Promise.resolve(setTableData([...tableData, newData]))
        }}
    />
    </Fragment>
);


text:
Q: CSS to make a text field look like password field How can I set the CSS for an input field of type text in html to appear as a password field, i.e. the text in the input seems to get replaced with a symbol such as the asterisk ("*") or a dot ("•")?
I have this constraint:
<input name="passwordish" type="text" id="inputPassword" placeholder="Password" >

EDIT: Sorry if this was not clear, but for some snowflakish reasons I can't change the field type!

A: Recommended that you change text type to password
<input name="password" type="password" id="inputPassword" placeholder="Password" >
OR this
CSS Tricks
input { -webkit-text-security: none; }
input { -webkit-text-security: circle; }
input { -webkit-text-security: square; }
input { -webkit-text-security: disc; /* Default */ }

Update:
Mozilla/FireFox
Explination
Try this:
input {
    text-security: circle; /* IE/Safari */
    -moz-text-security: circle; /* FireFox */
    -webkit-text-security: circle; /* Chrome/Safari  */
}

Update:

*

*Firefox no more supports the following css:

*

*-webkit-text-security

*-moz-text-security
Tested on Firefox 69.0, Windows 10, 64bit,

A: You may use this:
actualText = "";
function myFunction() {
  var x = document.getElementById("myText").value;
  var tempText = x.replace(/\*/g,"");
  if(tempText == "")
  {
    actualText = actualText.substr(0, actualText.length - 1);
  }
  else {
    actualText += x.replace(/\*/g,"");
  }
  document.getElementById("myText").value = "";
  for (var i=0;i<x.length;i++)
  {
    document.getElementById("myText").value += "*";
  }
}

Only problem is that you will not be able to use the actuall text.
Update:Added a variable that will store the text too. Use variable actualText to access original text ;)
Also about calling this function: you will have to call this function in onkeyup event of input

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to redirect ANY external links to a specific url format using .htaccess? I want to redirect all the external links, i.e., links like http://www.someothersite.com/anything in my site(say http://www.example.com) to http://www.example.com/something.
Here the problem I am facing is how to take care of http://www.someothersite.com/anything because its value is not fixed. It could be from any different domain.

A: First of all, .htaccess configures an HTTP Server which handles incoming requests, requests for resources on your server, not external ones. But since you've explicitely asked for a .htaccess way of redirecting external links, I will outline three approaches:

*

*Use .htaccess and mod_substitute to replace all external links on your pages with a fixed internal one.

*Use PHP and output buffering to replace all external links with internal ones.

*Use JavaScript to redirect external links to internal ones on click.

All methods have advantages and disadvantages.
1. .htaccess and mod_substitute
If have not tested this, but theoretically, it should work.
Place the following in your .htaccess and replace www.yourdomain.com with your domain:
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|(<a\s[^>]*)href=\"https?://([^/]+)(?<!www\.yourdomain\.com)/[^\"]*\"|$1href=\"http://www.yourdomain.com/your-fixed-link\"|i"

This adds an output filter to all request bodies with HTML content and uses a regular expression to replace any external URL in the href attribute of every link with your fixed one.
Drawbacks:

*

*Your domain must be fixed (sub2.yourdomain.com and yourdomain.com will be considered external).

*You must use an Apache HTTP server which has mod_substitute loaded.

2. PHP and output buffering
If you already use PHP to generate your pages, you can add output buffering with a callback which replaces external links with internal ones:
<?php
function replace_links($html)
{
    return preg_replace('~(<a\s[^>]*)href="https?://([^/]+)(?<!www\\.yourdomain\\.com)/[^"]*"~i', '$1href="http://www.yourdomain.com/your-fixed-link"', $html);
}

ob_start('replace_links');

// generate page
?>

This will prevent PHP from sending the content of the page directly to the browser, but writes everything to an internal buffer. At the end of the script, the callback is executed and may modify the content of that buffer before it will be sent to the browser.
Advantages over the .htaccess method: More control over the substitution. You could exclude more than one internal domain from the replacement by using preg_replace_callback in combination with a callback which checks the actual domain in the link. Furthermore, the substituted URL does not have to be fixed.
3. Redirecting with JavaScript
The following JavaScript probably is the most popular way of doing what you want:
(function() {
    function redirectLink(evt) {
        var matches = /^https?:\/\/([^\/]+)\//i.exec(this.href);
        if (matches && matches[1] != 'www.yourdomain.com') {
            window.location.href = 'http://www.yourdomain.com/your-fixed-link';
            evt.preventDefault();
            return false;
        }
    }

    var links = document.getElementsByTagName('a'), i;
    for (i = 0; i < links.length; i++)
        links[i].addEventListener('click', redirectLink, false);
})();

Just make sure that this code is placed after all links (e.g. at the end of the document) or is executed on the DOMContentLoaded event.
Advantages over the .htaccess method: Same as with the PHP method described above.
Disadvantages: The user must have JavaScript enabled, so this is not guaranteed to work always.


text:
Q: How do I prevent installing nuget packages that aren't 100% .Net Core 2.0 compatible? I understand that .Net Core 2 has a compatibility shim that allows it use Nuget packages that don't specifically target .Net Core/Standard 2. This gives it access to 70% of Nuget. Great - nice feature.
How do I prevent installing nuget packages that aren't fully compatible with .Net Core 2/.Net Standard 2? Or warn me at point of installing that it is being used with the shim?
I created a new .Net Core 2.0 project installed EF 6.1.3 (which I knew didn't work)  and nothing prevented me or warned that it didn't target .Net Standard <=2 at the point of install.
I am happy to "run with scissors" but I kind of feel I should be getting a warning before I install MVC5 and EF 6.1.3 into a .Net Core 2 application. I would really like to prevent junior devs from installing unsupported packages etc.
I guess further to Matt Ward answer - my main point is - can it be detected that something is actually 100% compatible at install or are we always just in the situation where we need to make determination ourselves that package works "well enough". I hoped that there was a technical mechanism that detected missing coverage API coverage and could tell us that the nuget package may not operate as it did before. So I guess MS say 70% compatibility - I want to fail if I try to install the 30%

A: Installing Entity Framework 6.1.3 into a .NET Core 2.0 project there is a NU1701 warning in the Errors window about Entity Framework 6.1.3 being restored using .NET Framework 4.6.1 and that it may not be fully compatible.
You could turn the NU1701 warning into an error in the project so you could not install any NuGet package that does not explicitly support .NET Core 2.0. This can be done by adding the WarningAsErrors property to the project.
<PropertyGroup>
  <OutputType>Exe</OutputType>
  <TargetFramework>netcoreapp2.0</TargetFramework>
  <WarningsAsErrors>NU1701</WarningsAsErrors>
</PropertyGroup>

Then if you try to install Entity Framework 6.1.3 the restore will fail, the changes will be rolled back, and the NuGet package will not be installed.
You can also set the DisableImplicitAssetTargetFallback property to true which will prevent .NET 4.6.1 being added to the AssetTargetFallback property which is used when checking NuGet package compatibility with .NET Core 2.0 projects.
<PropertyGroup>
  <OutputType>Exe</OutputType>
  <TargetFramework>netcoreapp2.0</TargetFramework>
  <DisableImplicitAssetTargetFallback>true</DisableImplicitAssetTargetFallback>
</PropertyGroup>

A: If you wan to be 100% sure, run the package against .NET Portability Analyzer and .NET Standard 2.0 profile.
It won't tell you if the API will be called or not (and is in no way an automatic process), just if the Assembly contains any API which is not .NET Standard 2.0 compatible.
However, you can also only run your application against the Analyzer, as the .NET Portability Analyzer should be able to follow any references made from the application and check these too.
Update
You can als build this into your build server pipeline, to get a more automatic guarantees.
The .NET Portability Analyzer Docs.
Visual Studio is not required for this, just download it from https://github.com/Microsoft/dotnet-apiport/releases and run
From the docs:

*

*Type the following command to analyze the current directory: \...\ApiPort.exe analyze -f .

*To analyze a specific list of .dll files, type the following command: \...\ApiPort.exe analyze -f first.dll -f second.dll -f third.dll

Old Answer (may be useful in conjcution with Matt's answer)
Untested, but give it a try:
<!-- old dotnet tooling/.NET Core 1.x -->
<PackageTargetFallback>netstandard2.0;portable-net45+win8</PackageTargetFallback>
<!-- new dotnet tooling/.NET Core 2.0 -->
<AssetTargetFallback>netstandard2.0;portable-net45+win8</AssetTargetFallback>

Typically you want to have it like
<!-- old dotnet tooling/.NET Core 1.x -->
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
<!-- new dotnet tooling/.NET Core 2.0 -->
<AssetTargetFallback>$(AssetTargetFallback);dotnet5.6;portable-net45+win8</AssetTargetFallback>

Where $(PackageTargetFallback) will tell MSBuild to keep the old values and append the values after that to it. But since $(PackageTargetFallback) probably (can't look/dig deeper in right now) have the .NET Framework moniker there, you'll override it with your own values.
Additionally
Given that PackageTargetFallback is now deprecated, one should use AssetTargetFallback instead.

A: As far as I know .Net portability analyzer tool can not 100% determine the platform that does not support installation, such as system.runtime.Loader, after tool analysis, 100% supports the framework platform, but it does not
Screenshot of analysis results:analyse System.Runtime.Loader


text:
Q: comparing items in list of keys in dictionary I have a dictionary with values for each keys as list of items. I want to compare the item at every index in the list of every key in dictionary and check if it is identical or not.
dict1=OrderedDict([('A1', ['G', 'N', 'K', 'G', 'I', 'R', 'E', 'L']),
                   ('B1', ['G', 'N', 'K', 'G', 'I', 'R', 'E', 'L']),
                   ('C1', ['G', 'N', 'R', 'G', 'I', 'R', 'R', 'L'])])

I would like to check if index 0 in the list of key A1 is similar to index 0 in keys B1 and C1. Similarly, I want to check for every index in key A1 the respective index in the list of other keys are the same or not.
I tried but could not compare the index for each key in the dictionary.

A: You could zip the lists together and then compare each element to each corresponding elements.
dict1=OrderedDict([('A1', ['G', 'N', 'K', 'G', 'I', 'R', 'E', 'L']),
                   ('B1', ['G', 'N', 'K', 'G', 'I', 'R', 'E', 'L']),
                   ('C1', ['G', 'N', 'R', 'G', 'I', 'R', 'R', 'L'])])

for i, elems in enumerate(zip(*dict1.values())):
    print "%d %s" % (i, elems)
    if any(elems[0] != check_elem for check_elem in elems[1:]):
        print "The key A1 is different at index %d" % (i)

And this gives:
0 ('G', 'G', 'G')
1 ('N', 'N', 'N')
2 ('K', 'K', 'R')
The key A1 is different at index 2
3 ('G', 'G', 'G')
4 ('I', 'I', 'I')
5 ('R', 'R', 'R')
6 ('E', 'E', 'R')
The key A1 is different at index 6
7 ('L', 'L', 'L')


text:
Q: Save Uri as a file android So in my app it is receiving an image from another application
      Intent intent = getIntent();
    String action = intent.getAction();
    String type = intent.getType();
    if (Intent.ACTION_SEND.equals(action) && type != null) {
        handleSendImage(intent); // Handle single image being sent

public void handleSendImage(Intent a)
{
    Uri pic = (Uri) a.getParcelableExtra(Intent.EXTRA_STREAM);
}

From here I want to save the Uri as an image in my image gallery.
I know how to save a file in the gallery I am just not sure how I get the Uri in the correct format to save it. I know it contains the image because picView.setImageURI(pic); causes the picture to appear in my activity. I just want to be able to save that image into the gallery. Any ideas on how I would do that? I thought that I could convert the ImageView to a bitmap and go from there but that seems really inefficient to me and there has to be a better way to do it. Since I know you can create Uris from Files but can you create a File from a Uri?


text:
Q: How to simplify a leading-NA count function, and generalize it to work on matrix, dataframe I wrote a leading-NA count function, it works on vectors. However:
a) Can you simplify my version?
b) Can you also generalize it to work directly on matrix, dataframe (must still work on individual vector), so I don't need apply()? Try to avoid all *apply functions, fully vectorize, it must still work on a vector, and no special-casing if at all possible.
leading_NA_count <- function(x) { max(cumsum((1:length(x)) == cumsum(is.na(x)))) }
# v0.1: works but seems clunky, slow and unlikely to be generalizable to two-dimensional objects

leading_NA_count <- function(x) { max(which(1:(length(x)) == cumsum(is.na(x))), 0) }
# v0.2: maybe simpler, needs max(...,0) to avoid max failing with -Inf if the which(...) is empty/ no leading-NAs case: e.g. c(1,2,3)

# (Seems impossible to figure out how to use which.max/which.min on this)

leading_NA_count <- function(x) { max(cumsum((1:length(x)) == cumsum(is.na(x)))) }
set.seed(1234)
mm <- matrix(sample(c(NA,NA,NA,NA,NA,0,1,2), 6*5, replace=T), nrow=6,ncol=5)
mm
     [,1] [,2] [,3] [,4] [,5]
[1,]   NA   NA   NA   NA   NA
[2,]   NA   NA    2   NA    1
[3,]   NA    0   NA   NA   NA
[4,]   NA   NA    1   NA    2
[5,]    1    0   NA   NA    1
[6,]    0   NA   NA   NA   NA

leading_NA_count(mm)
[1] 4 # WRONG, obviously (looks like it tried to operate on the entire matrix by-column or by-row)
apply(mm,1,leading_NA_count)
[1] 5 2 1 2 0 0 # RIGHT

A: This works whether mm is a matrix, vector or data.frame.  See ?max.col for more info:
max.col(cbind(!is.na(rbind(NA, mm)), TRUE), ties = "first")[-1] - 1

A: For part (a) of your question this is the simplest function I could think of:
leadingNaCount = function(x) { sum(cumprod(is.na(x))) }


text:
Q: Highlight any data value in a column that is repeated a certain number of times Is it possible to use conditional formatting to highlight any non specific value if it is repeated a certain number of times in a single column?
Basically what I want the sheet to do is highlight the value if it is repeated less than or greater than six times in a column. Is this possible using conditional formatting or any other way? Any help would be appreciated.
Example

A: Copied from a Comment:

Assuming data starts in A1 as shown in your example, select cell A1 and create a conditional format rule with this formula: =AND(COUNTIF(A:A,A1)<>6,A1<>"") and then apply to column A:A – tigeravatar Feb 27 at 19:38


text:
Q: Trying to display user meta by "name" - not by "ID" I have a form on my website where users can submit their own posts and one of the fields has a dropdown containing various countries so a user can enter their location. I would like this location to be displayed when the post is published so I have written the below code to achieve this:
<?php echo stripslashes(get_user_meta($uid, 'user_location', true)); ?>

However, this only displays the category "ID" number (not the category "name" of the location). What can I write so the NAME of the location is displayed?

A: Use get_category() to convert the ID into a category data object.
$cid = get_user_meta($uid, 'user_location', true);
$c = get_category($cid);
echo $c->name;


text:
Q: QListWidget with items checkable on item click i have a QListWidget with checkable items and it is working fine so far. Now i want to check the items not only by clicking onto the small checkbox rect but just by clicking onto the item itself.
So i implemented the function
void TagList::on_tagList_itemClicked(QListWidgetItem *item)
{
    if( item==nullptr )
        return;

    clicked_ = true;
    if( item->data(Qt::CheckStateRole) != Qt::Checked  )
        item->setData( Qt::CheckStateRole, Qt::Checked );
    else
        item->setData( Qt::CheckStateRole, Qt::Unchecked );
    clicked_ = false;
}

(clicked_ is a class variable for my dirty hack described next.)
Which sets the checkstate on item click, BUT Now the items are no longer checkable by click onto the checkbox rect because it is toggled twice, by the ListWidget and by my slot.
Unfortunately the ListWidget uses only a single column model, so i cannot distinguish the click onto the Checkbox from the click onto the item by the model index.
Then i also implemented
void TagList::onModelItemChanged(QModelIndex tl, QModelIndex br, QVector<int> roles)
{
if( (roles.empty() || roles.contains(Qt::CheckStateRole)) && !clicked_ ){
    qDebug() << "changed with no click";
    clicked_ = true;
    if( tl.data(Qt::CheckStateRole)== Qt::Unchecked )
        ui->tagList->model()->setData(tl,Qt::Checked,Qt::CheckStateRole);
    else
        ui->tagList->model()->setData(tl,Qt::Unchecked,Qt::CheckStateRole);
    clicked_ = false;
}else{
    qDebug() << "changed after click";
}
}

and connected it to the dataChanged signal of the model. This works fine BUT the list is also editable so whenever i rename an object in the list, the checkstate changes and unfortunately the List Widget also ignores the roles vector of the dataChanged signal. So the roles.empty() case always applies :( and renameing triggers a checkstate change...
Has anyone a simple solution for this case? I dont want to create my own model just for this simple case.

A: You just need to unset the Qt::ItemIsUserCheckable flag when adding new item:
void TagList::addNewTag(QString name)
{
    QListWidgetItem *item= new QListWidgetItem(name, ui->tagList);
    item->setFlags(item->flags() & (~Qt::ItemIsUserCheckable));
    item->setCheckState(Qt::Unchecked);
    ui->tagList->addItem(item);
}

So that the item's check state won't change when user clicks on the checkbox.
Then implement the on_tagList_itemClicked slot as you did:
void TagList::on_tagList_itemClicked(QListWidgetItem *item)
{
    if(item == nullptr)
        return;
    if(item->data(Qt::CheckStateRole) != Qt::Checked)
        item->setData(Qt::CheckStateRole, Qt::Checked);
    else
        item->setData(Qt::CheckStateRole, Qt::Unchecked);
}

A: The hacky but working solution is to start a QTimer::singleshot() for 60ms on every datachanged signal of the model and to block the itemClicked signal until the timer is finished.
If you have better solutions, please let me know.


text:
Q: When a C program calls another function under z/Linux what sort of linkage is used When a C program calls an external routine under z/OS there a specific linkage used depending on the instructions used to call and return from the external routine.
Use Case - 1
Using the standard Branch and Link sequence, GPR14 has the return to address, GPR15 has the entry point address of the routine being called, GPR13 contains the address of a 72 byte register save area that is used to save GPR14, GPR15, GPR0, GPR1, GPR2, GPR3, GPR4, GPR5, GPR6, GPR7, GPR8, GPR9, GPR10, GPR11 AND GPR12, the first 12 bytes of the register save area contain, a 4 byte value that can have multiple meanings, a backward register save area pointer and a forward register save area pointer. It is the responsibility of the called program to save the callers registers in the passed register save area and to acquire a new register save area for its use and load the address of the gotten register save area into r13.
To return to the calling program, the executing program restores, gpr13 and gpr14, gpr15, gpr0-gpr12 from the register save area and then branches to the address in gpr14, registers gpr0 and gpr1 are not restored but can be used to return values to the calling program.
Use Case - 2
Should the called routing opt to use the branch and stack instruction at entry, the callers registers are stored in a linkage stack entry. It is the called programs responsibility to acquire a new registers save area the and load the address of the gotten register save area into r13. On return the called program issues a PR (program return instruction) this restores the callers gpr14, gpr15 and gpr2-gpr13, gpr0 and gpr1 are not restored but can be used to return values to the calling program. The linkage stack entry is freed.
In both use cases above, the the entry and exit linkages differ depending on whether or not the called program is executing as a non-reentrant or reentrant program.
So getting back to the the question that I asked, under z/Linux if a C program were to call an external routine what would the entry and exit linkages look like.
Thank you for any information you might choose to share.
JD


text:
Q: Regex match not validating correctly I have the following regex ^(2[0-3]|1?[0-9])?(\:[0-5]?[0-9])?$
8:45 matches, however 08:45 does not.
How can this be re-written to also allow 08:45?

I would also like like to check for either the . or : if possible instead of just the .

A: As well as "1", also allow "0" at the start of the hours before "20:00":
^(2[0-3]|[01]?[0-9])?(:[0-5]?[0-9])?$

Note that you don't need to escape colons - they have no speacial regex meaning.
Also, since everything is optional, this regex matches a blank string.
If you want to match something, add (?!$) after ^. ^(?!$) is a negative look ahead anchored to start that requires that end of input does not follow the start of input (ie, the input is not zero length).

A: Please try this regEx.
[0]?\d[:\.]\d\d
which can capture 8:45 08:45 8.45 and 08.45
or click this to see the result.
https://regex101.com/r/tLEqhH/1


text:
Q: Entropy based on euclidian distances between datapoints / clusters centers? Is it possible to define any useful entropy or conditional entropy which is based on the distance between datapoint(s) and cluster center(s), instead of basing on the number of points assigned to cluster like it is defined in for example to compute the v-measure ? I am not implying that I want an equivalent to v-measure, but I just wonder if it is possible and maybe useful to define a conditional entropy based on distances.
So, What I'm looking for is a kind of conditional entropy based on distances, which allow to have an idea about the "homogeneity" and "completeness" of clusters, with respect to distances.

A: As @Anony-Mousse commented, k-mean relate to minimizing entropy in its clustering algorithm (which uses the euclidean distance), as does the EM algorithm. The k-means is also based on the distance between data points as you would like.
Data points are usually in some system of coordinates which you are already working with, and the euclidean distance gives you the distance of the shortest path between them as a measure for differentiating homogeneity between clusters. But the algorithm which uses the measure is what assures completeness of the cluster, the measure it works with is assumed in the representation of the space of datapoints.
You could just say, that the distance between points is
    $k \log( d_{i,j} + 1 )$
where $d_{i,j}$ is the distance between points so that it resembles entropy measures. But since this is strictly monotonically increasing as a function the clustering will not change, but can affect the inferred number of clusters. It penalizes large distances from creating large effects with the logarithmic increase on the distance.
I believe that conditional entropy will be applicable only under a constrained space of datapoints. You would have then probabilities of points in clusters based maybe on a bootsrap measure or some Bayesian view with priors on placements. It would get complicated and is a separate question in itself. Without the constrained space to place probabilities on the distribution on points in relation to each other would need some normalization and therefor a constrained space unless some other definition can apply. The paper you link to for the V-measure uses this conditional entropy without euclidean distances it seems and more based on labeling. You could replace the conditional probability measures there to have distances rather than the ratios of class membership in equation (1) of the paper so that the inverse sum of distances is there.


text:
Q: while using azure form recognizer for medical prescription some key value pair(like no of quantity and refills ) are not getting extracted while using azure form recognizer for medical prescription some key-value pair(like no of quantity and refills ) are not getting extracted.
How can we extract that thing? or we have to use any other machine learning library to do that.
The problem is we have one form and we have created 5 samples out of it for azure form recognizer.
the form is in  .tiff format.
no. of refills is usually written as -
n refills, refills n, refills 1,2,3,4,5.
Example: "Odefsey 200-25-25 mg tabs TAKE ONE TABLET BY MOUTH ONCE DAILY. #90 tabs, 3 Refills needs to be broken into

*

*
  Drug Name: Odefsey

*
  Strength: 200-25-25 mg

*
  Dosage Form: tabs

*
  Directions: ONE TABLET BY MOUTH ONCE DAILY

*
  Quantity: 90

*
  Refills: 3

Quantity and Refills are not recognized by Azure text analytics for Health
We have to extract refills from below pic

A: Can you please try the latest Form Recognizer release and see if it resolves the issue - https://learn.microsoft.com/en-us/azure/cognitive-services/form-recognizer/whats-new
You can try it out in the Form Recognizer sample tool - https://fott-preview.azurewebsites.net/


text:
Q: Random number analysis Given a series of randomly generated data how can I figure out how random it actually is?  Is R-lang a good tool for this matlab? What other questions can can these tools answer about randomly generated data? Is there another tool better for this?

A: First you need to decide what kind of randomness you're testing for.  Do you have in mind a uniform distribution inside some range?  That's usually what people have in mind, though you may have some other flavor of randomness such as a normal distribution.
Once you have a candidate distribution, you can test the goodness of fit to that distribution.  The Kolmogorov-Smirnov test is a good general-purpose test. I believe it's called ks.test in R.  But I also believe it assumes distinct values, so that could be a problem if you're sampling from such a small range of values that the same value appears more than once.
S. Lott mentioned Knuth's Seminumerical Algorithms in the comments.  That book has a good introduction to the chi-squared test and the Kolmogorov-Smirnov tests for goodness of fit.
If you do suspect you have uniform random values, the DIEHARD test that Dirk Eddelbuettel mentioned is a standard test.

A: According to Wikipedia (Randomness):

The central idea is that a string of
  bits is random if and only if it is
  shorter than any computer program that
  can produce that string (Kolmogorov
  randomness) — this means that random
  strings are those that cannot be
  compressed.

Therefore, given the random stream of numbers, save it to a file, and compress it using your favorite tool (zip, rar, ...). The compression ratio can be interpreted as measure of randomness... Even better, I would use it as a relative score to compare the randomness of two data series.

A: I recommend reading Chapter 10 of Beautiful Testing: Testing a Random Number Generator. It's a little more approachable than most texts on the topic. Maybe, if we're nice, the author of that chapter, John Cook, might stop by and give his input.

A: The DieHarder test battery by Robert G. Brown --- which reimplements and extends the old DIEHARD by Marsaglia et al -- has been wrapped into the R package RDieHarder which you could start with.
Note that RDieHarder versions need their particular matching DieHarder releases -- and we're not there yet for the most recent development version of the latter.
Edit Also, for the subset of cryptographioic tests, the NIST suite (which is included in DieHarder) should be appropriate as that is what it was designed for.

A: There's as always a toolbox for it.

A: For theory, the above mentioned reference by Knuth is useful and to link Amro's response, there is work by Li & Vitanyi which relates here.
link text


text:
Q: Mono.Cecil producing "Invalid CIL" Goal:
The goal of this snippet is to create a modified version, at runtime, of an executable to prevent it from blocking the thread.
Problem:
I am using Mono.Cecil to perform the patch; however, something about the way it's recompiled is causing ANY modified method to throw an InvalidProgramException. To prove that the program is not invalid, I went ahead and rewrote it using the modification I want in C# and recompiled it. Manually compiling the program with the changes worked perfectly; however, the IL of the patched methods are the EXACT same except for the file alignment.
Code:
    private static void PatchStartup(TypeDefinition definition)
    {
        ILProcessor il = definition.Methods.First(x => x.Name == "Start").Body.GetILProcessor();

        int index = default(int);

        for (int i = il.Body.Instructions.Count - 1; i != 0; i--)
            if (il.Body.Instructions[i].OpCode == OpCodes.Newobj)
            {
                index = i + 2;
                break;
            }

        List<Instruction> removedInstructions = new List<Instruction>();

        for (int i = index; i < il.Body.Instructions.Count; i++)
            removedInstructions.Add(il.Body.Instructions[i]);

        foreach (var i in removedInstructions) il.Remove(i);

        il.InsertAfter(il.Body.Instructions[il.Body.Instructions.Count - 1], il.Create(OpCodes.Ret));

        il.Body.Variables.Clear();
        il.Body.InitLocals = false;

        il.Body.Optimize();
        il.Body.OptimizeMacros();
    }

Original IL:
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static
    void Start (
        string[] args
    ) cil managed
{
// Header Size: 12 bytes
// Code Size: 258 (0x102) bytes
// LocalVarSig Token: 0x1100000C RID: 12
.maxstack 3
.locals init (
    [0] string,
    [1] class [mscorlib]System.Exception
)

/* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
/* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
/* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
/* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
/* 0x00001000 02           */ IL_0014: ldarg.0
/* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
/* 0x00001006 14           */ IL_001A: ldnull
/* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
/* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
/* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001017 14           */ IL_002B: ldnull
/* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
/* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
/* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001028 14           */ IL_003C: ldnull
/* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
/* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
/* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x00001039 14           */ IL_004D: ldnull
/* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
/* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
/* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
/* 0x0000104A 16           */ IL_005E: ldc.i4.0
/* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
/* 0x00001050 D080000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
/* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
/* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
/* 0x0000105F 14           */ IL_0073: ldnull
/* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
/* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
/* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
/* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
/* 0x00001075 14           */ IL_0089: ldnull
/* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
/* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
/* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
/* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
/* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

/* 0x0000108D 2A           */ IL_00A1: ret

/* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
/* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
/* 0x00001098 26           */ IL_00AC: pop
.try
{
    /* 0x00001099 7E7500000A   */ IL_00AD: ldsfld    string [mscorlib]System.String::Empty
    /* 0x0000109E 0A           */ IL_00B2: stloc.0
    /* 0x0000109F 2B06         */ IL_00B3: br.s      IL_00BB
    // loop start (head: IL_00BB)
        /* 0x000010A1 287600000A   */ IL_00B5: call      string [mscorlib]System.Console::ReadLine()
        /* 0x000010A6 0A           */ IL_00BA: stloc.0

        /* 0x000010A7 06           */ IL_00BB: ldloc.0
        /* 0x000010A8 728C020070   */ IL_00BC: ldstr     "exit"
        /* 0x000010AD 6F7700000A   */ IL_00C1: callvirt  instance bool [mscorlib]System.String::Contains(string)
        /* 0x000010B2 2CED         */ IL_00C6: brfalse.s IL_00B5
    // end loop

    /* 0x000010B4 7296020070   */ IL_00C8: ldstr     "Saving..."
    /* 0x000010B9 287800000A   */ IL_00CD: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010BE 287900000A   */ IL_00D2: call      void [Eco.Core]Eco.Core.Plugins.StorageManager::SaveAndFlush()
    /* 0x000010C3 72AA020070   */ IL_00D7: ldstr     "Done"
    /* 0x000010C8 287800000A   */ IL_00DC: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010CD 16           */ IL_00E1: ldc.i4.0
    /* 0x000010CE 287A00000A   */ IL_00E2: call      void [mscorlib]System.Environment::Exit(int32)
    /* 0x000010D3 DE18         */ IL_00E7: leave.s   IL_0101
} // end .try
catch [mscorlib]System.Exception
{
    /* 0x000010D5 0B           */ IL_00E9: stloc.1
    /* 0x000010D6 72B4020070   */ IL_00EA: ldstr     "Caught an exception checking for console input, console input disabled. (probably safe to ignore)"
    /* 0x000010DB 287800000A   */ IL_00EF: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010E0 07           */ IL_00F4: ldloc.1
    /* 0x000010E1 6F7B00000A   */ IL_00F5: callvirt  instance string [mscorlib]System.Exception::get_Message()
    /* 0x000010E6 287800000A   */ IL_00FA: call      void [mscorlib]System.Console::WriteLine(string)
    /* 0x000010EB DE00         */ IL_00FF: leave.s   IL_0101
} // end handler

/* 0x000010ED 2A           */ IL_0101: ret
} // end of method Startup::Start

Runtime-Modified IL:
// Token: 0x06000029 RID: 41 RVA: 0x00002DE0 File Offset: 0x00000FE0
.method public hidebysig static
    void Start (
        string[] args
    ) cil managed
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x00000FEC 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x00000FF1 286300000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x00000FF6 284700000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x00000FFB 286400000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x00001000 02           */ IL_0014: ldarg.0
    /* 0x00001001 286500000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x00001006 14           */ IL_001A: ldnull
    /* 0x00001007 FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x0000100D 736700000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x00001012 286800000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001017 14           */ IL_002B: ldnull
    /* 0x00001018 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x0000101E 736900000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x00001023 286A00000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001028 14           */ IL_003C: ldnull
    /* 0x00001029 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x0000102F 736B00000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x00001034 286C00000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001039 14           */ IL_004D: ldnull
    /* 0x0000103A FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001040 736D00000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x00001045 286E00000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x0000104A 16           */ IL_005E: ldc.i4.0
    /* 0x0000104B 286F00000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001050 D07F000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x00001055 280E00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x0000105A 287000000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x0000105F 14           */ IL_0073: ldnull
    /* 0x00001060 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x00001066 737100000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x0000106B 287200000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001070 285600000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x00001075 14           */ IL_0089: ldnull
    /* 0x00001076 FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x0000107C 737300000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001081 6F7400000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x00001086 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x0000108B 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x0000108D 2A           */ IL_00A1: ret

    /* 0x0000108E 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x00001093 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001098 26           */ IL_00AC: pop
    /* 0x00001099 2A           */ IL_00AD: ret
} // end of method Startup::Start

Manually Modified IL:
// Token: 0x06000029 RID: 41 RVA: 0x000030A8 File Offset: 0x000012A8
.method public hidebysig static
    void Start (
        string[] args
    ) cil managed
{
    // Header Size: 12 bytes
    // Code Size: 174 (0xAE) bytes
    .maxstack 3

    /* 0x000012B4 726E020070   */ IL_0000: ldstr     "Eco Server {0}"
    /* 0x000012B9 287D00000A   */ IL_0005: call      string [Eco.Shared]Eco.Shared.Authentication.EcoVersion::get_Version()
    /* 0x000012BE 286200000A   */ IL_000A: call      string [mscorlib]System.String::Format(string, object)
    /* 0x000012C3 287E00000A   */ IL_000F: call      void [Eco.Shared]Eco.Shared.Utils.Log::WriteLine(string)
    /* 0x000012C8 02           */ IL_0014: ldarg.0
    /* 0x000012C9 287F00000A   */ IL_0015: call      void [Eco.Core]Eco.Core.Utils.CommandLine::SetCmdLine(string[])
    /* 0x000012CE 14           */ IL_001A: ldnull
    /* 0x000012CF FE062D00002B */ IL_001B: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>(string)
    /* 0x000012D5 738100000A   */ IL_0021: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::.ctor(object, native int)
    /* 0x000012DA 288200000A   */ IL_0026: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.LoginSession>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012DF 14           */ IL_002B: ldnull
    /* 0x000012E0 FE062E00002B */ IL_002C: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>(string)
    /* 0x000012E6 738300000A   */ IL_0032: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::.ctor(object, native int)
    /* 0x000012EB 288400000A   */ IL_0037: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Authentication.VerifyResult>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x000012F0 14           */ IL_003C: ldnull
    /* 0x000012F1 FE062F00002B */ IL_003D: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>(string)
    /* 0x000012F7 738500000A   */ IL_0043: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::.ctor(object, native int)
    /* 0x000012FC 288600000A   */ IL_0048: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerListing[]>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001301 14           */ IL_004D: ldnull
    /* 0x00001302 FE063000002B */ IL_004E: ldftn     !!0 [Eco.Core]Eco.Core.Serialization.SerializationUtils::DeserializeJson<class [Eco.Shared]Eco.Shared.Services.ServerInfo>(string)
    /* 0x00001308 738700000A   */ IL_0054: newobj    instance void class [mscorlib]System.Func`2<string, class [Eco.Shared]Eco.Shared.Services.ServerInfo>::.ctor(object, native int)
    /* 0x0000130D 288800000A   */ IL_0059: call      void class [Eco.Shared]Eco.Shared.Serialization.JsonUtil`1<class [Eco.Shared]Eco.Shared.Services.ServerInfo>::set_Deserialize(class [mscorlib]System.Func`2<string, !0>)
    /* 0x00001312 16           */ IL_005E: ldc.i4.0
    /* 0x00001313 288900000A   */ IL_005F: call      void [Eco.Shared]Eco.Shared.Utils.StreamPool::Initialize(bool)
    /* 0x00001318 D0BC000001   */ IL_0064: ldtoken   [Eco.Core]Eco.Core.Utils.ThreadSafeDictionary`2
    /* 0x0000131D 282C00000A   */ IL_0069: call      class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
    /* 0x00001322 288A00000A   */ IL_006E: call      void [Eco.Shared]Eco.Shared.Networking.RPCManager::Initialize(class [mscorlib]System.Type)
    /* 0x00001327 14           */ IL_0073: ldnull
    /* 0x00001328 FE062B000006 */ IL_0074: ldftn     void Eco.Server.Startup::ApplicationThreadException(object, class [System]System.Threading.ThreadExceptionEventArgs)
    /* 0x0000132E 738B00000A   */ IL_007A: newobj    instance void [System]System.Threading.ThreadExceptionEventHandler::.ctor(object, native int)
    /* 0x00001333 288C00000A   */ IL_007F: call      void [System.Windows.Forms]System.Windows.Forms.Application::add_ThreadException(class [System]System.Threading.ThreadExceptionEventHandler)
    /* 0x00001338 287000000A   */ IL_0084: call      class [mscorlib]System.AppDomain [mscorlib]System.AppDomain::get_CurrentDomain()
    /* 0x0000133D 14           */ IL_0089: ldnull
    /* 0x0000133E FE062A000006 */ IL_008A: ldftn     void Eco.Server.Startup::CurrentDomainUnhandledException(object, class [mscorlib]System.UnhandledExceptionEventArgs)
    /* 0x00001344 738D00000A   */ IL_0090: newobj    instance void [mscorlib]System.UnhandledExceptionEventHandler::.ctor(object, native int)
    /* 0x00001349 6F8E00000A   */ IL_0095: callvirt  instance void [mscorlib]System.AppDomain::add_UnhandledException(class [mscorlib]System.UnhandledExceptionEventHandler)
    /* 0x0000134E 2828000006   */ IL_009A: call      bool Eco.Server.Startup::CheckWorkingDirectory()
    /* 0x00001353 2D01         */ IL_009F: brtrue.s  IL_00A2

    /* 0x00001355 2A           */ IL_00A1: ret

    /* 0x00001356 2827000006   */ IL_00A2: call      void Eco.Server.Startup::RegisterCustomTypes()
    /* 0x0000135B 7304000006   */ IL_00A7: newobj    instance void Eco.Server.PluginManager::.ctor()
    /* 0x00001360 26           */ IL_00AC: pop
    /* 0x00001361 2A           */ IL_00AD: ret
} // end of method Startup::Start

A: Thanks to thehennyy for posting the comment that lead to a solution.
The problem was that I had not cleared the error-handlers after removing the try-catch block.
For anyone else having this obscure problem, add the following to your code to remove the handler before writing the assembly to the disk or a Stream.
var il = ...;
il.Body.ExceptionHandlers.Remove(ExceptionHandler handler);


text:
Q: Resolving bottleneck on database connection in Dataflow pipeline We have a Dataflow streaming job that consumes messages in Pubsub, do some transformations, and perform DML (INSERT, UPDATE, DELETE) on a CloudSQL Postgres instance. We observed that the bottleneck is in the database. The code is written in Python and uses SQLAlchemy as the library to interface with Postgres
Common issues we observed are:

*

*It maxes out the allowed database connections, multiple connection pools are created.

*When there is high-volume data coming in from Pubsub, the DoFn responsible for writing to the database throws these Exceptions:

Task was destroyed but it is pending! task: <Task pending name='Task-194770'...
Task exception was never retrieved future: <Task finished name='Task-196602'...

RuntimeError: aiohttp.client_exceptions.ClientResponseError: 429, message='Too Many Requests', url=URL('https://sqladmin.googleapis.com/sql/v1beta4/projects/.../instances/db-csql:generateEphemeralCert') [while running 'write_data-ptransform-48']

Seems that the Cloud SQL API hits the rate limit here.
These should be our ideal scenario:

*

*Regardless of the volume and the number of workers created by Dataflow, we should only have one ConnectionPool (a singleton) throughout the pipeline, with static number of connections (max of 50 allotted to the Dataflow job, out of 200 max connections configured in the database).

*In moments of high-volume flow from Pubsub, there should be some mechanism to throttle the rate of incoming requests to the database. Or do not scale the number of workers for DoFn responsible for writing to the database.

Can you recommend of a way to accomplish this?
From my experience a single global connection pool is not possible because you cannot pass the connection object to workers (pickle/unpickle). Is this true?

A: You should try to batch the call to your database. The pseudocode would look like this (taken from the beam programming guide)
class BufferDoFn(DoFn):
  BUFFER = BagStateSpec('buffer', EventCoder())
  IS_TIMER_SET = ReadModifyWriteStateSpec('is_timer_set', BooleanCoder())
  OUTPUT = TimerSpec('output', TimeDomain.REAL_TIME)

  def process(self,
              buffer=DoFn.StateParam(BUFFER),
              is_timer_set=DoFn.StateParam(IS_TIMER_SET),
              timer=DoFn.TimerParam(OUTPUT)):
    buffer.add(element)
    if not is_timer_set.read():
      timer.set(Timestamp.now() + Duration(seconds=10))
      is_timer_set.write(True)

  @on_timer(OUTPUT)
  def output_callback(self,
                      buffer=DoFn.StateParam(BUFFER),
                      is_timer_set=DoFn.StateParam(IS_TIMER_SET)):
    send_rpc(list(buffer.read()))
    buffer.clear()
    is_timer_set.clear()

In principle, you would need to write a splittable dofn and use timers and states.


text:
Q: Delete elements of a Dataframe if they are in a list I am asking you help for a part of my Python script I am struggling with:
I have a dataframe with 4 columns :
           keyword  impressions  clicks   ctr
0            About          1.0     0.0    0.000000
1            Achat         12.0     2.0    16.6666667
2           Action          1.0     0.0    0.000000
3            Adele         14.0     1.0    7.14285714

this dataframe contains thousands of lines. I am trying to delete lines from this dataframe if it's 'keyword' is in a list (for ex: list =  {'Action', 'About}
Here is the code line I made :
df.drop( df[ df['keyword'] in list ].index, inplace=True)

but I get this error :
File "/Users/adamn/Desktop/test_lambda.py", line 87, in <module>
 df.drop( df[ df['keyword'] in exc ].index, inplace=True)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-
 packages/pandas/core/generic.py", line 1785, in __hash__
raise TypeError(
TypeError: 'Series' objects are mutable, thus they cannot be hashed

I do not really understand what it stands for ...
How can I resolve it ?or how should I process to get the result I want ?
Thank's for helping.

A: Maybe this is what you want!
df.drop( df[ df['keyword'].apply(lambda x: x in list) ].index, inplace=True)

Why does it work?
You were checking whether the series df['keyword'] was in list list. What you had to do was to check if the element x in the series df['keyword'] was in list list. So, we use the apply function which "applies" a given function to every element in a pandas Series or DataFrame.
What are lambdas?
Lambdas are like inline functions in C. An equivalent code of this using functions would be:
def func(x):
    return x in list

df.drop( df[ df['keyword'].apply(func)].index, inplace=True)

PS: I would suggest not to use 'list' as a variable name as it is a datatype in python.

A: Using boolean indexing is far more efficient than using apply.
df = df.loc[~df.keyword.isin(['About', 'Action'])]

NOTE: reset the index if required.
df = df.loc[~df.keyword.isin(['About', 'Action'])].reset_index()

Documentation link -> isin / indexing/selecting data


text:
Q: TailwindCss Not Responsive to Screen Size App.js
function App() {
  return (

        Hello

  );
}

export default App;

tailwind.js
/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [],
  presets: [],
  darkMode: 'media', // or 'class'
  theme: {
    screens: {
      sm: '640px',
      md: '768px',
      lg: '1024px',
      xl: '1280px',
      '2xl': '1536px',
    },

I'm expecting for the text to be aligned to the left by default and on screens 640px and above text should be centered. However the text stays aligned to the left. I do have the html meta tag for responsiveness on my index.html file '
Any help is appreciated!

A: In this case it only activates when its 640px and below. Plus your small media query should be around 360px

A: The problem is because I left the content array empty. I had to configure the path to any file that contained tailwind class names.
Which is a little weird because other class names seemed to work just not the breakpoints. But that did solve the problem.


text:
Q: How to change one keyword's color in Geany? I use Geany to edit JavaScript files. I have made it highlight "self" as a keyword symply by adding it to filetypes.javascript file.
But i need to make it highlighth "self" word in another color. How can i do this?

A: In Linux, copy the file /usr/share/geany/filedefs/filetypes.javascript to ~/.config/geany/filedefs/filetypes.javascript and edit this copy.
In the section [keywords] add:
secondary=self

Change the colour in section [styling] by editing word2, e.g.:
word2=0x00cccc;0xffffff;true;false

This will make it cyan and bold.

A: You will have to edit your filetypes.javascript file (in folder $/.config/.geany, if you're under linux). But I am not 100% sure you can.


text:
Q: How to do bootstrap validation with using other css frameworks friends am started to doing bootstrap validation by taking reference from http://formvalidation.io/examples/changing-success-error-colors/
At the end of the page there is a download option. When I click download they told use something like foundation, pure, semantic and ui kit.
I want to do exactly what they have done - can anyone explain how to do that?
Here is my fiddle  https://jsfiddle.net/0s9xw5rx/2/
Css:
.field-error .control-label,
.field-error .help-block,
.field-error .form-control-feedback {
    color: #ff0039;
}

.field-success .control-label,
.field-success .help-block,
.field-success .form-control-feedback {
    color: #2780e3;
}

HTML
<form id="loginForm" method="post" class="form-horizontal">

        Username

            <input type="text" class="form-control" name="username" />

        Password

            <input type="password" class="form-control" name="password" />

            <button type="submit" class="btn btn-primary">Sign in</button>

</form>

Script
$(document).ready(function() {
    $('#loginForm').formValidation({
        framework: 'bootstrap',
        icon: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        row: {
            valid: 'field-success',
            invalid: 'field-error'
        },
        fields: {
            username: {
                validators: {
                    notEmpty: {
                        message: 'The username is required'
                    },
                    stringLength: {
                        min: 6,
                        max: 30,
                        message: 'The username must be more than 6 and less than 30 characters long'
                    },
                    regexp: {
                        regexp: /^[a-zA-Z0-9_\.]+$/,
                        message: 'The username can only consist of alphabetical, number, dot and underscore'
                    }
                }
            },
            password: {
                validators: {
                    notEmpty: {
                        message: 'The password is required'
                    }
                }
            }
        }
    });
});

A: your question is too open and unclear.
Formvalidtion.io is a library to validate forms for framework users. it means if I'm using Bootstrap/Foundation... i can use the framework's Forms design and behavior with this library.
please answer the following question so we can help you:

*

*do you use a framework in your site? if so, which one?

*have you implemented a form?

*have you connected the library to the site as instructed in the docs?


text:
Q: BST - counting nodes with left and right children As stated in the title, I'm trying to solve this problem by only counting nodes in a BST that have both left and right children. I'm struggling to think of the logic to solve this.
I thought of something like this.
First, check if the root is null or if it has any null children. Next, traverse the tree going right and continue to check the children, increment a counter when the conditions are met. But what happens when I reach the end node and need to go back to a node that had a left child to traverse? I had a temp node to keep track of the most previous parent, but what about when I need to go up more than one level? I'm assuming the answer to this problem is to recursively solve it, but I don't even know where to begin.
Here's what I have:
public int fullNodes() {
    int count = 0;
    Node n = root;
    Node temp = null;

    if (n == null || n.left == null && n.right == null) return count;

    count++; //increment count, since the root has children on both sides

    temp = n; //hold the previous place
    n = n.right; //go right

    //Now what?

    return count;
}

I'm still struggling to think recursively when problem solving, in addition to my question, how do you learn to think recursively? Just a ton of practice, or is there some tricks and tips that you use to solve problems?

A: Rather than using a temp variable to hold the previous node -- which would only work for a depth of 1 -- call the same function on the child nodes.
Recursive tree traversal might look something like this:
public int countSomething (Node node) {

    // Self;
    //
    int result = 1;   // use your required logic here

    // Children;
    //
    if (node.left != null)
        result += countSomething( node.left);
    if (node.right != null)
        result += countSomething( node.right);

    // done.
    return result;
}

// example usages
int treeTotal = countSomething( rootNode);
int subtreeTotal = countSomething( subtree);

The execution callstack will then hold recursive invocations of the function, each with their appropriate context. When the top-level call returns, it will have summed the answer for the entire tree/ or subtree it was called on.
Put appropriate logic for your BST "node has both left & right children" in, instead of the constant 1.

A: First let us create representation of your Node class
class Node {
    public Node left;
    public Node right;
    public Node(){}
    public Node(Node left, Node right) {
        this.left = left;
        this.right = right;
    }
}

Then we write our recusrive function and client that uses your function
public class Main {

    public static int countNodes(Node root) {
        if(root!=null && root.left!=null && root.right!=null) {
            return 1+countNodes(root.left)+countNodes(root.right);
        }
        return 0;
    }

    public static void main(String[] args) {
        Node right = new Node();
        Node left = new Node();
        Node root = new Node(left, right);
        root.right = new Node(new Node(), new Node());
        System.out.println(countNodes(root));
    }

}


text:
Q: Unable to make JDialog modal I am trying to open a new JDialog when the "Register" Button is clicked..
But I am unable to make the JDialog modal..
I have tried setModal(true) and also setModalityType(ModalityType.DOCUMENT_MODAL);
But no luck..(I am using Eclipse's WindowBuilder plugin)
P.S: I am new to JAVA..
Here is my code...
import java.awt.BorderLayout;
import java.awt.Dialog.ModalityType;
import java.awt.EventQueue;
import java.awt.FlowLayout;
import java.awt.Frame;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JScrollPane;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JComboBox;
import javax.swing.JButton;
import javax.xml.ws.handler.MessageContext;

public class loginpage extends JFrame {

    private JPanel contentPane;
    private JTextField userid;
    private JPasswordField password;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    loginpage frame = new loginpage();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the frame.
     */
    public loginpage() {
        super("User Login");
        setResizable(false);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setBounds(400, 200, 550, 370);
        contentPane = new JPanel();
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        contentPane.setLayout(null);
        setContentPane(contentPane);

        JLabel label = new JLabel("Please enter your login credentials...");
        label.setFont(new Font("Times New Roman", Font.PLAIN, 25));
        label.setForeground(Color.BLUE);
        label.setBounds(79, 11, 400, 61);
        contentPane.add(label);

        JLabel lblLoginId = new JLabel("User ID :");
        lblLoginId.setFont(new Font("Tahoma", Font.PLAIN, 12));
        lblLoginId.setBounds(159, 142, 71, 17);
        contentPane.add(lblLoginId);

        JLabel lblUserType = new JLabel("User Type :");
        lblUserType.setFont(new Font("Tahoma", Font.PLAIN, 12));
        lblUserType.setBounds(159, 102, 85, 17);
        contentPane.add(lblUserType);

        JLabel lblPassword = new JLabel("Password :");
        lblPassword.setFont(new Font("Tahoma", Font.PLAIN, 12));
        lblPassword.setBounds(159, 188, 96, 14);
        contentPane.add(lblPassword);

        userid = new JTextField();
        userid.setBounds(254, 141, 114, 20);
        contentPane.add(userid);
        userid.setColumns(10);

        password = new JPasswordField();
        password.setBounds(254, 186, 114, 20);
        contentPane.add(password);

        JComboBox usertype = new JComboBox();
        usertype.setBounds(254, 101, 89, 20);
        contentPane.add(usertype);
        usertype.addItem("Admin");
        usertype.addItem("Employee");

        JButton btnLogin = new JButton("Login");
        btnLogin.setBounds(254, 228, 71, 23);
        contentPane.add(btnLogin);

        JLabel lblNewEmployeeRegister = new JLabel("New employee? ");
        lblNewEmployeeRegister.setForeground(Color.RED);
        lblNewEmployeeRegister.setBounds(296, 304, 114, 14);
        contentPane.add(lblNewEmployeeRegister);

        JButton btnRegister = new JButton("Register Here");
        btnRegister.setBounds(398, 301, 126, 20);
        contentPane.add(btnRegister);

        ImageIcon myicon = new ImageIcon("src\\logo.gif");
        JLabel iconlabel = new JLabel(myicon);
        iconlabel.setBounds(0, 233, 103, 99 );
        iconlabel.setIcon(myicon);
        contentPane.add(iconlabel);

        //Adding Listeners to buttons

        //Login Button Listener
        btnLogin.addActionListener(new ActionListener()
        {

            //Making the Connection and registering the Drivers
            @Override
            public void actionPerformed(ActionEvent arg0) {

            }//actionPerformed ends here
        });//Login Button Listener ends here

        //Register Button Listener
        btnRegister.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                JDialog jd=new JDialog(loginpage.this,"User Registration");
                jd.setLayout(null);
                jd.setVisible(true);
                jd.setBounds(400,300, 479, 329);
                jd.setResizable(false);
                setLocationRelativeTo(loginpage.this);
                jd.setModal(true);

                JLabel lblFillUpThe = new JLabel("Fill up the form to register");
                lblFillUpThe.setForeground(Color.BLUE);
                lblFillUpThe.setFont(new Font("Times New Roman", Font.PLAIN, 25));
                lblFillUpThe.setBounds(93, 11, 400, 61);
                jd.add(lblFillUpThe);

                JLabel lblUserId = new JLabel("Type in a User ID :");
                lblUserId.setFont(new Font("Tahoma", Font.PLAIN, 12));
                lblUserId.setBounds(77, 96, 104, 14);
                jd.add(lblUserId);

                JTextField newid = new JTextField();
                newid.setBounds(236, 94, 122, 20);
                jd.add(newid);
                newid.setColumns(10);

                JLabel lblTypeA = new JLabel("Type in a new Password :");
                lblTypeA.setFont(new Font("Tahoma", Font.PLAIN, 12));
                lblTypeA.setBounds(77, 142, 142, 14);
                jd.add(lblTypeA);

                JPasswordField newpass = new JPasswordField();
                newpass.setBounds(236, 140, 122, 20);
                jd.add(newpass);

                JLabel lblConfirmThePassword = new JLabel("Confirm the Password :");
                lblConfirmThePassword.setFont(new Font("Tahoma", Font.PLAIN, 12));
                lblConfirmThePassword.setBounds(77, 189, 130, 14);
                jd.add(lblConfirmThePassword);

                JPasswordField confpass = new JPasswordField();
                confpass.setBounds(236, 187, 122, 20);
                jd.add(confpass);

                JButton reg = new JButton("Register");
                reg.setBounds(239, 237, 89, 23);
                jd.add(reg);

                reg.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent arg0) {
                        JOptionPane.showMessageDialog(getParent(), "User Registered Successfully..!!", "Successful",JOptionPane.INFORMATION_MESSAGE);

                    }
                });
            }
        });//Register Button Listener ends here

    }
}

A: Try making the dialog modal BEFORE you try and make it visible.  You can't change the modal state once the dialog is made visible...
JDialog jd=new JDialog(loginpage.this,"User Registration");
jd.setModal(true);
jd.setLayout(null); // THIS IS A BAD IDEA //
jd.setLocationRelativeTo(null);
// This is somewhat pointless, you've set relative location, but know overridden it...
// You should also be relying on the layout manager and pack to determine the size...
jd.setBounds(400,300, 479, 329);
jd.setResizable(false);
setLocationRelativeTo(loginpage.this);

// Add you other components

jd.setVisible(true);


text:
Q: How to enable an Apple ID login within an app? I'd like the user to do an apple id login before he can access some features. This is mainly for parental controls.
Can this be done?
Thanks!

A: Apple supports OAuth to do this, where it can bring up apple login screen and proceed with valid credentials. Ref link
However I wonder if the use case is not that strong to implement OAuth which is a complex process.
You can have your own server where you can request user to authenticate to access some features but not with apple credentials.


text:
Q: Laravel 9 Update Form Values with controller MVC I want to update my input values in the form in my database by sending them from the route to the controller. What am I doing wrong? Can you help me? I tried the @method('PUT') method before. It's a bit confusing. I am sharing the codes. I will be very happy if you can help, thank you.
...

                                                        <form action="{{ 'edit-name/' . $user->id }}" method="POST"
                                                            enctype="multipart/form-data">
                                                            @csrf

                                                                {{ __('welcome.fullname') }}:
                                                            <input name="name1" type="hidden"
                                                                placeholder="{{ $user->name }}">

                                                    {{-- //Name Edit Button --}}

                                                    <button type="submit"
                                                        class="btn-sm app-btn-secondary">{{ __('welcome.confirm') }}</button>

...
my route and controller
...
Route::get('edit-name/{id}', [HomeController::class, 'editname']);

...
...
  public function editname(Request $request, $id){
         dd(1);
        $user= Auth::user();
        dd($user);
        $id=$request->id;

        $name=$request->input('name1');

        $isUpdateSuccess = User::where('id', $id) ->update(['name1'=>$name,   ]);

        if($isUpdateSuccess)
 echo '
Update Success
';
        else echo '
Update Failed
';

    }

...

A: you are sending the data from modal using POST method but in your route you are using this data by GET method. I will suggest you to use POST method so that user_id will not be append in URL, so try this,
Your blade

<form action="{{ 'edit-name' }}" method="POST"                                                    enctype="multipart/form-data">
@csrf
      <input type="hidden" name="id" placeholder="{{ $user->id }}">

   {{ __('welcome.fullname') }}:
      <input name="name1" type="text" placeholder="{{ $user->name }}">

{{-- //Name Edit Button --}}

<button type="submit" class="btn-sm app-btn-secondary">{{__('welcome.confirm') }}</button>

Your route
Route::post('/edit-name', [HomeController::class, 'editname']);

Your controller
 public function editname(Request $request){
         // dd(1);
        $user= Auth::user();
        // dd($user);
        $id=$request->id;

        $name=$request->input('name1');

        $isUpdateSuccess = User::where('id', $id) ->update(['name1'=>$name,   ]);

        if($isUpdateSuccess)
 echo '
Update Success
';
        else echo '
Update Failed
';

    }

A: Change action
from
action="{{ 'edit-name/'. $user->id }}"

to
action="{{ url('edit-name',$user->id) }}"


text:
Q: Why does Git know it can cherry-pick a reverted commit? In a branch, say, there are 3 commits: A <- B <- C. If I cherry-pick B directly (Test A), Git says:
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

I can understand that because B is already in this branch, it's no-op to cherry-pick it again.
Then I reverted B and C in a batch commit by:
git revert -n B^..C
git commit -a -m "xxx"

This would be a new big commit D which reverts B and C, the branch should be like A <- B <- C <- D.
Then I need to redo B and C due to some reason. I tried:
git cherry-pick B^..C

I see two new commits B' and C' are appended to the branch: A <- B <- C <- D <- B' <- C'.
My first question is, How can Git intelligently knows it should create B' and C'? I thought Git would find B and C are already in branch history, so it may just skip them like when I cherry-pick 'B' directly in Test A.
Then, after that, since the branch is already A <- B <- C <- D <- B' <- C', I run this command again:
git cherry-pick B^..C

I expected Git can recognize this is a no-op operation. But this time Git complains confliction. My second question is, why does Git fail to recognize and skip this operation this time?

A: cherry-pick is a merge, of the diffs from your cherry-pick's parent to the cherry-pick, with the diffs from your cherry-pick's parent to your checked-out tip. That's it. Git doesn't have to know any more than that. It doesn't care "where" any of the commits are, it cares about merging those two sets of diffs.
revert is a merge of the diffs from your revert to its parent with the diffs from your revert to your checked-out tip. That's it. Git doesn't have to know any more.
Here: try this:
git init test; cd $_
printf %s\\n 1 2 3 4 5 >file; git add .; git commit -m1
sed -si 2s,$,x, file; git commit -am2
sed -si 4s,$,x, file; git commit -am3

Run git diff :/1 :/2 and git diff :/1 :/3. Those are the diffs git runs when you say git cherry-pick :/2 here. The first diff changes line 2, and the second commit changes lines 2 and 4; the line 4 change does not abut any changes in the first diff and the line 2 change is identical in both. There's nothing left to do, all the :/1-:/2 changes are also in :/1-:/3.
Now before you start on what follows, let me say this: this is harder to explain in prose than it is to just see. Do the example sequence above and look at the output. It is much, much easier to see what's going on by looking at it than by reading any description of it. Everybody goes through a stretch where this is too new and maybe a little orientation will help, and that's what the paragraphs below are for, but again: the prose, alone, is harder to understand than the diffs. Run the diffs, try to understand what you're looking at, if you need a little help over what I promise is a very small hump follow along in the text below. When it snaps into focus see if you don't at least mentally slap your forehead and think "wow why was that so hard to see?", just like, well, just about everybody.
Git's merge rules are pretty straightforward: identical changes to overlapping or abutting lines are accepted as-is. Changes to lines with no changes in one diff for changed lines, or lines abutting changed lines, in the other, are accepted as is. Different changes to any overlapping or abutting lines, well, there's an awful lot of history to look at and nobody's ever found a rule that will predict what the results of that should be every time, so git declares the changes conflict, dumps both sets of results into the file and lets you decide what the result should be.
So what happens if you now change line 3?
sed -si 3s,$,x, file; git commit -amx

run git diff :/1 :/2 and git diff :/1 :/x, and you'll see that where, relative to the cherry-pick's parent, :/2 changed line 2 and your tip changed lines 2,3 and 4. 2 and 3 abut, that's historically too close for automated genies to handle properly, so yay, you get to do it: git cherry-pick :/2 now will declare a conflict, showing you the change to line 2 and the two different versions of lines 3 and 4 (:/2 changed neither, your tip changed both, in context here it's clear the line 3 and 4 changes are fine as-is but again: nobody's ever figured out an automatic rule for reliably identifying such contexts).
You can ring changes on this setup to test out how reverts work. Also stash pops, and merges, and git checkout -m which runs a quick ad-hoc merge with your index.
Your git cherry-pick B^..C is a cherry-pick of two commits, B and C. It does them one after another, exactly as described above. Since you've reverted B and C, and then cherry-picked them again, this has the exact same effect as applying B and C and then cherry-picking B (with the intent of then cherry-picking C). I conclude that B and C touch overlapping or abutting lines, so git diff B^ B  will show changes that overlap or abut changes in git diff B^ C', and that's what Git's not going to just pick for you, because whatever looks right here, in other circumstances nobody can write a rule for identifying, an identical-looking choice will be wrong. So git says the two sets of changes conflict and you get to sort it out.

A: This expands @jthill's answer.
Consider a regular merge in a history like this:
a--b--c--d--e--f--g--h
       \
        r--s--t

Git performs the merge by looking only at the contents of these commits:
c--h   <-- theirs
 \
  t    <-- ours
^
|
base

and nothing else. Note that at the conceptual level it is completely irrelevant which side is denoted "ours" and which is "theirs"; they are totally interchangeable. (The only time it makes a difference is when there are conflicts and Git has to decide how it marks the sides as "theirs" and "ours" for the user.) (I'll omit the labels "base", "theirs" and "ours" in the following charts.)
In your history
A--B--C

the merge operation behind the first git cherry-pick B looked at the following commits:
A--B
 \
  C

Here, A is chosen because it is the parent of B, a.k.a., B^. Obviously, the changes from A to C also contain the changes from A to B and the merge machinery produces a no-change-merge-result, and that produces the cherry-pick is now empty message.
Then you made this history by reverting both B and C:
A--B--C--R

Then the next git cherry-pick B looked at these commits:
A--B
 \
  R

This time, the changes from A to R do no longer contain the changes from A to B because they have been reverted. Therefore, the merge no longer produces an empty result.
A small detour: When you do git revert B in your history, the merge machinery looks at these commits:
B--A
 \
  C

Note that only B and the parent of B, a.k.a, A are swapped around compared to git cherry-pick B.
(I was describing a single-commit reversal as I am unsure how a multi-commit reversal works.)

A: Let's step back about ten feet here and get a bigger mental picture of what Git is.
A Git commit is a snapshot of all the files. It represents your whole project, basically. It is not about diffs. This is a brilliant architecture because it is extremely fast and effectively infallible. Any commit can absolutely restore that state of your project, kaboom, just by checking it out; there is no need to "think".
However, Git can make diffs between two commits, and that is how it implements what we may call "merge logic". Every merge consists of applying two diffs simultaneously. [Well, it might be more than two, but pretend it isn't.] A merge, a cherry pick, a rebase, a revert are all merges in that sense — they all use "merge logic" to form a commit expressing the result of applying two diffs. The trick is to know who the comparands are in the construction of the two diffs.

*

*When you ask for a true git merge, say of two branches, Git figures out where those branches last diverged. This is called the merge base. The comparands are: the merge base and the tip of branch1, and the merge base and tip of branch2. Both of those two diffs are applied to the merge base and the result is used to form a commit with two parents (the branch tips). The first branch name then slides up one, to point to that new commit.

*When you ask for a cherry-pick, the merge base is the parent of the commit being picked. The comparands are: the merge base and the head, and the merge base and the picked commit. Both of those two diffs are applied to the merge base and the result is used to form a commit with one parent (the head). The head branch name then slides up one, to point to that new commit. [And a rebase is just a series of cherry picks!]

*A revert also uses merge logic. As jthill has explained, it's just a matter of forming one of the diffs backwards. The merge base is the commit that you are trying to reverse. The comparands are: the merge base and its parent (in that direction), and the merge base and the head. These diffs are applied to the merge base and used to form a commit whose parent is the head. The head branch name then slides up one, to point to that new commit. If this suggests to you that a revert is basically a backwards cherry-pick, you are absolutely right.

The cool thing is that once you know this, you can predict what will happen when you give one of these commands, because you can extract those same diffs yourself by saying git diff. Git's merge logic essentially lies open to your gaze. It remains then only to understand the circumstances under which Git stops in the middle of the operation because it cannot proceed without further explicit instructions. That's called (unfortunately) a conflict, and there are two main ways it can arise:

*

*The same line in the same file was changed in two different ways in the two diffs. Git's idea of what constitutes the same line is rather broader than you might expect; this surprises beginners.

*The same file, qua file, was treated in two incompatible ways: for example, one diff deletes it but the other diff keeps and edits it.

I should add one more fact that explains a lot of behavior, including part of what you're asking about. This may seem obvious, but it is worth stating explicitly: in a diff, "nothing" is not a thing. What I mean is this. Supposing one diff changes a line and the other diff does nothing to that line. Then the way to enact both diffs is: change the line. Doing nothing is not a thing: it does not "tussle" against the change.
That is worth mentioning especially because beginners often don't grasp it. The other day there was a question where a user was complaining that in a merge where the second branch deleted a file, the file did indeed end up deleted even though the first branch kept it. That user was thinking of "don't delete the file" as a thing, and indeed as a primary thing. But it isn't. The two diffs are weighed equally by default, so one branch did nothing and one branch deleted the file, and doing nothing is not a thing, so the result is to delete the file.


text:
Q: Automapper ignore object mapping based on condition My problem could be schematized like this :
I have a domain class represented like this
public class DomainClass {

  public DateTime Begin {get; set;}
  public DateTime End {get; set;}
  public int Type {get;set}
}

And I have two distincts tables in database that matches different type :
public class TypeClassOne {
  public DateTime Begin {get; set;}
  public DateTime End {get; set;}
}

and
public class TypeClassTwo {
  public DateTime Begin {get; set;}
  public DateTime End {get; set;}
}

How can I configure AutoMapper to have a mapping like this
 var config = new MapperConfiguration(c =>
 {
    c.CreateMap<DomainClass, TypeClassOne>()
    .??? <= I would like OnlyIf(source => source.Type == 1)
 }

I've tried ForMember, but it doesn't works at class level...
Anyone tried to do this ?


text:
Q: Ruby on Rails Developed Applications I'm looking to develop a desktop (not server) web application and I have been comparing Ruby on Rails vs Django. Question is, with Django the client needs to install Python 2.5, does the client need to install anything to execute a Ruby on Rails application?
Thanks....

A: You can't use Django and neither Ruby on Rails to develop a desktop app. There might be some projects than can turn these projects to a desktop app but neither of them are built for Desktop App development.
These are web frameworks.
You could simply find these facts by some simple searches on the web.


text:
Q: [mysql]: Querying more db data vs loop on large array I need to compare few scenarios, which can be fulfilled either by calling:

*

*an additional timestamp column from mysql database or

*Looping over the resultant array.

Elaborating further:
CASE 1: 144 byte columns + 4 byte timestamp column for 10K rows, then looping on array of size 50.(download size- 1480000 Bytes)
CASE 2: 144 byte columns for 10K rows, looping on array of size 10000. (download size- 1440000 bytes)
Data download roughly 40KB more for Case1 while 10000 more loop iteration for case2.
Which of the 2 scenarios could be faster, downloading 40KB more or 10000 loop iterations?

A: Your first scenario is by far the best. Here is why.
SQL is designed to extract subsets of rows from tables. It's designed to allow your tables to be many orders of magnitude bigger than your RAM. If you use a query like
SELECT *
  FROM mytable
 WHERE mytimestamp >= TODAY() - INTERVAL 1 DAY
   AND mytimestamp < TODAY()

you will get all the rows with timestamps anytime yesterday, for example. If you put an index on the mytimestamp column, SQL will satisfy this query very quickly and only give the rows you need. And it will satisfy any queries looking for a range of timestamps similarly quickly.

A: There are no answers that are true in 100% of situations. For example, I would prefer to do the first query when I use a fast enough network (anything 1Gbps or higher) and data transfer is free. The difference in the example you show is 40,000 bytes, but it's only 2.7% of the total.
On the other hand, if you need to optimize to minimize bandwidth usage, that's a different scenario. Like if you are transmitting data to a satellite over a very slow link. Or you have a lot of competing network traffic (enough to use up all the bandwidth), and saving 2.7% is significant. Or if you are using a cloud vendor that charges for total bytes transferred on the network.
You aren't taking into account the overhead of executing 1000 separate queries. That means 1000x the bytes sent to the database server, as you send queries. That takes some network bandwidth too. Also the database server needs to parse and optimize each query (MySQL does not cache optimization plans as some other RDBMS products do). And then begin executing the query, starting with an index lookup without the context of the previous query result.
"Performance" is a slippery term. You seem to be concerned only with bandwidth use, but there are other ways of measuring performance.

*

*Throughput (bytes per second)

*Latency (seconds per response)

*Wait time (seconds until the request begins)

All of these can be affected by the total load, i.e. number of concurrent requests. A busy system may have traffic congestion or request queueing.
You can see that this isn't a simple problem.


text:
Q: PHP - change first folder in url but keep remaining folders as is using if else statement, I would like php to check if the first folder in the url is (en),
example:
http://www.domain.com/en/newyork/car/
if the first folder is [ en ] as shown above in the example, then I would like to change the ahref of a link that I have on the page
change link from:
En
change link to:
Ru
Looking at the example above, the only thing I want php to change is en or ru but keeps the remaining url of the current page as is
: if the current page url is http://www.domain.com/en/newyork/car/
the link would be Russian

A: <?php
$url = 'www.domain.com/en/newyork/car/';
$url_arr = explode("/en/", $url);
$new_url = implode("/ru/", $url_arr);
?>

A: In order to get the current language of your page, you will first have to get the path of your current URL, and then get the string after the first slash. You could do this as follows:
// Get the current URL
$current_url = $_SERVER['REQUEST_URI'];

// Get the 'path' portion (without things like 'http')
$url = parse_url($current_url);

// Split the String in an array
$parts = explode('/', $url['path']);
$lang = $parts[1];
$prepath = $url['scheme'] . '://' . $url['host'] . $parts[0];

// Array slice to get all remaining parts
$postpath = array_slice($parts, 2);

// Append the first part of your path, the new language, and finally
// the remainder of your URL.
$newurl = $prepath . '/' . ($lang == 'ru'?'':'ru/') . implode('/', $postpath);

After this, you can use an anchor on your page to allow the user to change:
<a href="<?php echo $newurl;?>">Change Language

A: function changeUrlComponent($url, $componentPos, $newVal) {
    $url = parse_url($url);
    $arr = explode('/',$url['path']);
    $arr[$componentPos] = $newVal;
    $url['path'] = implode('/',$arr);
    return $url['scheme'] .'://'. $url['host'] . $url['path'];
}

echo changeUrlComponent('http://www.domain.com/en/newyork/car/', 1, 'ru');

Hope this helps. Also note you can add more to the returned value based on the expected no of url components. Refer to this. Also the componentPos should start from 1 to length of your directories/path. This would be a more generic approach than the ones answered above as they are too coupled with the expectation of a lang being present in the url.