text:
Q: How can I build multiple configurations in parallel? I have a Visual Studio 2012 Solution with twelve Solution Configurations.  Each Solution Configuration is independent (i.e., the outputs of each configuration are entirely unrelated).
The Question:  How can I build all twelve configurations in one step, i.e. by running a single MSBuild command on the command line, and how can I get the configurations to be built in parallel?
As an example, if there were just two configurations, Release/AnyCPU and Debug/AnyCPU, I would want both of these to build at the same time, in parallel.
For completeness, the following is what I have tried; I don't yet have a solution to this problem.

To build all of the projects at once, I created a new project file with a Build target that runs the MSBuild task on the Solution file for each configuration:
<Target Name="Build">
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Release;Platform=Win32"     Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Release;Platform=x64"       Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Release;Platform=ARM"       Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Release(ZW);Platform=Win32" Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Release(ZW);Platform=x64"   Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Release(ZW);Platform=ARM"   Targets="$(BuildCommand)" />

  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Debug;Platform=Win32"       Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Debug;Platform=x64"         Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Debug;Platform=ARM"         Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Debug(ZW);Platform=Win32"   Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Debug(ZW);Platform=x64"     Targets="$(BuildCommand)" />
  <MSBuild Projects="cxxreflect.sln" Properties="SolutionDir=$(MSBuildProjectDirectory)\;Configuration=Debug(ZW);Platform=ARM"     Targets="$(BuildCommand)" />
</Target>

This works great, except that each MSBuild task is invoked in sequence, so there's no parallelism (yes, there is parallelism within each configuration build, but I'd really like to get parallelism across configuration builds).
In an attempt to get the configurations to build in parallel, I tried to make use of the MSBuild task's BuildInParallel property.  I wrote a pre-build task that generated project files for each configuration, then attempted to build all of these generated projects in parallel:
<Target Name="PreBuild" Outputs="%(ProjectConfiguration.Identity)" Returns="%(BuildProject.Identity)">
  <Message Text="Cloning Solution for Configuration:  %(ProjectConfiguration.Identity)" />
  <PropertyGroup>
    <BuildProjectPath>$(IntPath)\%(ProjectConfiguration.Platform)\%(ProjectConfiguration.Configuration)\build.proj</BuildProjectPath>
  </PropertyGroup>
  <ItemGroup>
    <BuildProject Include="$(BuildProjectPath)" />
  </ItemGroup>
  <MakeDir Directories="$(IntPath)\%(ProjectConfiguration.Platform)\%(ProjectConfiguration.Configuration)" />
  <WriteLinesToFile
    File="$(BuildProjectPath)"
    Lines="<?xml version='1.0' encoding='utf-8'?>
<Project DefaultTargets='Build' ToolsVersion='4.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
  <Target Name='Build'>
    <MSBuild
      Projects='$(SlnPath)'
      Properties='
        SolutionDir=$(MSBuildProjectDirectory)\%3b
        Configuration=%(ProjectConfiguration.Configuration)%3b
        Platform=%(ProjectConfiguration.Platform)
      '
      Targets='$(BuildCommand)'
    />
  </Target>
</Project>"
    Overwrite="true" />

</Target>
<Target Name="Build" DependsOnTargets="PreBuild">
  <Message Text="%(BuildProject.Identity)" />
  <MSBuild Projects="%(BuildProject.Identity)" Properties="BuildCommand=$(BuildCommand)" BuildInParallel="true" />
</Target>

Unfortunately, while this does build all twelve configurations, it builds them serially.  My guess is that when MSBuild performs dependency analysis on the set of projects to be built, it identifies that they all depend on the same Solution file, so it decides they cannot be built in parallel.  (This is just a guess; I could be completely wrong.  I know very little about MSBuild.)
I am also using the /m switch when building.

A: Take advantage of the MSBuild Task's BuildInParallel option, and pass all the projects in a single call. The examples here give the basic approach:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <ProjectToBuild Include="a1.sln">
            <Properties>Configuration=Debug</Properties>
        </ProjectToBuild>
        <ProjectToBuild Include="a1.sln">
            <Properties>Configuration=Release</Properties>
        </ProjectToBuild>
    </ItemGroup>
    <Target Name="Build">
        <MSBuild Projects="@(ProjectToBuild)" BuildInParallel="true" />
    </Target>
</Project>


text:
Q: Custom multiselect gridview breaks on Row Update commands I have an extended GridView class, GridViewEx, which inherits from the basic ASP.NET gridview.  I override the CreateColumns method to intercept the columns collection and inject my own column, containing a modified CheckBoxField.
(Sidenote: I tried looking some other method of storing and updating which rows were selected and just using the checkbox as a display mechanism, but ultimately the checkbox was the easiest method for handling everything.)
The CheckBoxField has its ReadOnly property set to true when it is created (and it remains true when it is added to the columns collection), which should prevent it from being passed along as a parameter for Update requests against the gridview's datasource.
As you may infer, that's not happening.  When I try to perform a row edit and update, I get a "Too many parameters" warning with a single parameter which has no name.  If I turn off the multiselect function, this goes away.  So I know that my checkboxfield is not being treated as a Readonly field.  But I don't know how to fix it!
Any ideas on where, when, or how I need to set up this field so that it won't be passed automatically as a parameter to my updates?

A: Ok, figured it out.
I also had a custom CheckBoxField which overrides InitializeDataCell and writes in my own checkbox.  I needed to add an extra check so that it disables the field during edits if Readonly is set.  That seems to have resolved this issue.  Hope this helps anyone else out who might be doing custom GridView edits.
    internal class InputCheckBoxField : CheckBoxField
    {
        //... Some boilerplate for ID and other properties here

        protected override void InitializeDataCell(DataControlFieldCell cell, DataControlRowState rowState)
        {
            base.InitializeDataCell(cell, rowState);

            if (cell.Controls.Count == 0)
            {
                CheckBox chk = new CheckBox();
                chk.ID = CheckBoxID;
                chk.AutoPostBack = true;
                cell.Controls.Add(chk);

                //This was the needed check
                if(ReadOnly && rowState == DataControlRowState.Edit)
                    chk.Enabled = false;
            }
        }
    }

redpajama_set_name: RedPajamaStackExchange


text:
Q: jquery url path loading not work without page extension i have code jquery code to load the data on scroll here is the function
 function GetRecords() {
    pageIndex++;
    if (pageIndex == 2 || pageIndex <= pageCount) {
        $("#loader").show();
        $.ajax({
            type: "POST",
            url: "Default.aspx/GetCustomers",
            data: '{pageIndex: ' + pageIndex + '}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: OnSuccess,
            failure: function (response) {
                alert(response.d);
            },
            error: function (response) {
                alert(response.d);
            }
        });
    }
}

if you see the url, it works when i write default.aspx/getcustomer but it does not work when i have page path without extension like url:default/getcustomer
Please advice


text:
Q: SQL Syntax Error - JOIN I am attempting to eliminate unwanted duplicate query results. The gist is that the field [CUSIP] exists in all tables in question, however, the field [4DTYR] exists in all tables except [IDX_FS].
I had previously only joined the tables via the [CUSIP] field, and that resulted in the query produced unwanted duplicate results (some sort of a permutation of [4DTYR] from all the tables that contained that field).
Then, I made the modification below. However, now I'm receiving a JOIN syntax error. Can anyone kindly help? I've reposted just in case this Q got a little bit stale. Thanks!
FROM

(((IDX_FS LEFT JOIN DATA_BS
  ON IDX_FS.CUSIP = DATA_BS.CUSIP)

LEFT JOIN DATA_Footnotes
  ON IDX_FS.CUSIP = DATA_Footnotes.CUSIP)

LEFT JOIN DATA_IS
  ON IDX_FS.CUSIP = DATA_IS.CUSIP)

LEFT JOIN DATA_SP
  ON IDX_FS.CUSIP = DATA_SP.CUSIP

AND (((DATA_BS LEFT JOIN DATA_IS
  ON DATA_BS.CUSIP = DATA_IS.CUSIP
     AND DATA_BS.4DTYR = DATA_IS.4DTYR)

LEFT JOIN DATA_SP
  ON DATA_BS.CUSIP = DATA_SP.CUSIP
     AND DATA_BS.4DTYR = DATA_SP.4DTYR)

LEFT JOIN DATA_Footnotes.4DTYR
  ON DATA_BS.CUSIP = DATA_Footnotes.CUSIP
     AND DATA_BS.4DTYR = DATA_Footnotes.4DTYR

A: Looks like your error is here
LEFT JOIN DATA_Footnotes.4DTYR -- this is not a valid table name
  ON DATA_BS.CUSIP = DATA_Footnotes.CUSIP
   AND DATA_BS.4DTYR = DATA_Footnotes.4DTYR

removing the .4DTYR should fix your error
LEFT JOIN DATA_Footnotes
  ON DATA_BS.CUSIP = DATA_Footnotes.CUSIP
   AND DATA_BS.4DTYR = DATA_Footnotes.4DTYR


text:
Q: How to check for a specific value in List foreach loop Need help checking for a specific value in List<T> foreach loop.  If there is specific value then display a specific string value.
For example how do I…
If (value.something_2 == "Null")
{
    value.something_2 == ".";
}
Elseif (value.something_2 == " ")
{
    value.something_2 == "0";
}

How would I incorporate the above example within the "foreach" loop?
See code below.
protected void MyReport(string filename, IMyRepository repository)
{

    using (FileStream fileStream = new FileStream(Server.MapPath(@"~/Includes/") + filename, FileMode.Create))
    {
        using (StreamWriter writer = new StreamWriter(fileStream))
        {
            List<Report> _report = repository.GetMyReport().ToList();
            foreach (var value in _report)
            {
                String row01 = String.Format("{0, -10}{1, 23}{2, 120}{3, 8}",
                      value.somthing_1,
                      values.something_2,
                      value.something_3);

                 String row02 = String.Format("{0, -10}{1, 23}{2, 120}{3, 8}",
                      value.somthing_4,
                      values.something_5,
                      value.something_6);

                Writer.WriteLine(row01);
                Writer.WriteLine(row02);
            }
        }
        writer.Close();
    }
}

A: There is no clever built-in String.Format that you can do for this if that's what you have in mind. However, the compiler has some tricks that can reduce the amount of code you need to write e.g.
// if it's null, assign it to "."
var s2 = value.something_2 ?? ".";
// it can never be null here, so if there is whitespace default to "0"
value.something_2 = String.IsNullOrWhitespace(s2) ? "0" : s2;

A: If I'm understanding what you're saying, it might be easier just to have another function returning the (possibly) modified string and just pass each of your values into it, inline.
Sting row01 = String.Format("{0, -10}{1, 23}{2, 120}{3, 8}", myFunc(value.somthing_1), myFunc(values.something_2), myFunc(value.something_3));

and then have this in the same class
private string myFunc(string something){
    if (something == "Null"){
        return ".";
    } else if (something == " ") {
        return "0";
    } else {
        return something;
    }
}


text:
Q: $this->db->insert_id() not working in mysql codeigniter I am just trying to get the latest auto generated key from the mysql table from codeiginitor. But it is not working some how. I have tried this code
$this->db->insert_id()   as well as

 $this->db->mysql_insert_id()
I am getting the following error

Severity: Notice
Message: Undefined property: CI_DB_mysql_driver::$insert_id

is the insert_id function not supported for mysql? How can we make it work?

A: Use only this syntax
$last_id = $this->db->insert_id();

return $last_id;

A: This is the code I tried to insert the data and get the insert id,
$this->db->insert('table_name',$data);
$id = $this->db->mysql_insert_id();
It is not working for me. I have used DB Driver as "mysql". Then I have installed "mysqli" and changed the DB driver name in database.php like,
$db['default']['dbdriver'] = 'mysqli';

Now it is working fine for me.

A: I had the same problem, and found a solution with this link: http://kedyr.wordpress.com/2012/10/03/codeigniter-insert_id/
The solution is not properly a solution, because it's just a way to get around by using the native sql, with the codeigniter method "Query" and dealing with the native sql callback.
    $this->db->insert('references', $data);
    $query = $this->db->query('SELECT LAST_INSERT_ID()');
    $row = $query->row_array();
    $LastIdInserted = $row['LAST_INSERT_ID()'];

A: Please check if your table don't have auto increment, primary field then $this->db->insert_id(); will not return anything.

A: CodeIgniter's insert_id() will only return an ID of an insert().  Unless you are executing something like $this->db->insert('table', $data); before calling the function it will not be able to return an ID.

A: assuming you are using active record pattern
this should work
$this->db->insert_id()

A: // Store data into array
$data=array('name'=>'Rudra','email'=>'test@gmail.com');

//Insert Data Query
$this->db->insert('tableName',$data);

// Storing id into varialbe
$id = $this->db->insert_id();
return $id;

A: try this:
$id = $this->db->insert_id()

instead of
$id = $this->db->mysql_insert_id();

A: Try this
$this->db->insert('table_name',$data);
$id = $this->db->mysql_insert_id();

A: Your code will work if you have a code like this :
var $table = 'your table name'
$this->db->insert($this->table,$data1);
        return $this->db->insert_id();

CodeIgniter's insert_id() will only return an ID of an insert(), as mention before, and also you dont forget to settings the DB driver name in database.php like
$db['default']['dbdriver'] = 'mysqli';

A: // insert data
$data=array("name"=>"vijay");
$this->db->insert("table_name",$data);
$insert_id= $this->db->insert_id();

A: If you are using ajax to insert data, then print the output you will get the id in response, or if you are using core codeigniter method then use below code.
$last_id = $this->db->insert_id();
return $last_id;


text:
Q: Fastest way to check if the substrings of one string are in another string Lets say we have two strings
    str1 = "021A,775U,000A,021A,1U2,206B,240,249,255B,260,263B,280,294,2U1,306B,336B,345,427,440,442,474,477,4U4,500,508,523,543L,580,584,772,802,P55,VB" ;

    str2 = "772+240+802+P55+263B+1U2+VB";

and want to know if every substring of str2 splitted by "+" is in str1.
Is there something "better" than doing this
    string[] str1Arr = str1.Split(',');
    foreach (var s in str2.Split('+'))
    {
        if (!str1Arr.Contains(s))
        {
             return false;
        }
    }
    return true;

str2 would return true, while
   str3 ="772+240+802+P55+263B+1U2+V";

would return false.
Edit:
Max length of str1 is ~1000 with all delimited strings being unique and sorted.
Max lenght of str2 is ~700 (average 200) with substrings being unique but not sorted.
Here are some more strings:
"200B+201B+202+202B+203B+204B+205+205B+206+206B+207+207B+208+208B+209+209B+210+210B+211B+214B+216B+460+494+498+830+379"//false
"612+637+638+646+649+655+664+678+688+693+694+754+756+758+774+778+780+781+787+99R+B58+RQW+RRG+RTJ+RVI+RVJ+RVU+RVV"//false
"255B+2U1+775U+336B+P55+802"//true
"220+223+224+229+230+233+234+402+537+550+811+863+872+881+889+965+512L+516L+520L+521L+524L+526L+528L+581L+810L+812L+814L+816L+818L+830"//false
"255B"//true

A: tldr;
Do not split str1 into an array, just use String.Contains() to find the match.
string str1Fixed = "," + str1 + ",";
foreach (var s in str2.Split('+'))
{
    if (!str1Fixed.Contains("," + s + ","))
         return false;
}
return true;

For a small number of elements string Contains is going to be more efficient, especially in the case positive matches that are close to the start of the string.

This was my very first thought before I provided my previous answer but it was a gut feeling not supported by any empirical evidence. I also deleted that original answer because it didn't take into account exact matches (I didn't inject the commas into the search args)

Update: .Net 6 - String Interpolation
It turns out that using string interpolation can save a few memory allocations, so it will even further enhance this solution:
string str1Fixed = $",{str1},";
foreach (var s in str2.Split('+'))
{
    if (!str1Fixed.Contains($",{s},"))
         return false;
}
return true;

The difference is marginal, but if you are executing a significant amount of iterations, its all going to add up.

But don't take my word for it, let us prove it!
Firstly, I will introduce you to our test cases, all of which have been tested to ensure compliance:
public bool Arrays(string optionalValuesCSV, string requiredValuesPSV)
{
    string[] str1Arr = optionalValuesCSV.Split(',');
    foreach (var s in requiredValuesPSV.Split('+'))
    {
        if (!str1Arr.Contains(s))
            return false;
    }
    return true;
}

public bool ConcatenatedString(string optionalValuesCSV, string requiredValuesPSV)
{
    string str1Fixed = "," + optionalValuesCSV + ",";
    foreach (var s in requiredValuesPSV.Split('+'))
    {
        if (!str1Fixed.Contains("," + s + ","))
             return false;
    }
    return true;
}

public bool FormattedString(string optionalValuesCSV, string requiredValuesPSV)
{
    string str1Fixed = String.Format(",{0},", optionalValuesCSV);
    foreach (var s in requiredValuesPSV.Split('+'))
    {
        if (!str1Fixed.Contains(String.Format(",{0},", s)))
             return false;
    }
    return true;
}

public bool InterpolatedString(string optionalValuesCSV, string requiredValuesPSV)
{
    string str1Fixed = $",{optionalValuesCSV},";
    foreach (var s in requiredValuesPSV.Split('+'))
    {
        if (!str1Fixed.Contains($",{s},"))
             return false;
    }
    return true;
}

public bool LinqExcept(string optionalValuesCSV, string requiredValuesPSV)
{
    return !requiredValuesPSV.Split('+')
        .Except(optionalValuesCSV.Split(','))
        .Any();
}

public bool LinqHashsetExcept(string optionalValuesCSV, string requiredValuesPSV)
{
    return !requiredValuesPSV.Split('+')
        .Except(new HashSet<string>(optionalValuesCSV.Split(',')))
        .Any();
}

public bool RegexMatchIterator(string optionalValuesCSV, string requiredValuesPSV)
{
    Regex searchPattern = null;
    foreach (var s in requiredValuesPSV.Split('+'))
    {
        searchPattern = new Regex("," + s + ",");
        if (!searchPattern.IsMatch("," + optionalValuesCSV + ","))
             return false;
    }
    return true;
}

public bool RegexMatchAllPattern(string optionalValuesCSV, string requiredValuesPSV)
{
    // note: need to escape \b for word boundary
    var pattern = "(?=.*?\\b" + requiredValuesPSV.Replace("+","\\b)(?=.*?\\b") + "\\b)";
    Regex searchPattern = new Regex(pattern);
    //return searchPattern.IsMatch("," + optionalValuesCSV + ","))
    return searchPattern.IsMatch(optionalValuesCSV);
}

Most of this is from the thought process and comments to my previous answer:

*

*Arrays
The OP logic to test against

*ConcatenatedString
Use String.Contains() on the str1 value instead of splitting it into an array of strings.

*FormattedString
Same logic as ConcatenatedString but uses String.Format instead of concatenating values,

*

*I know from previous experience and analysis that concatenation is more efficient for very small numbers of templated arguments, but it is included here as a proof so you don't have to take my word for it.

*InterpolatedString
Same logic as ConcatenatedString but uses String Interpolation instead of concatenating values,

*

*I've never tested the performance of this, I hope it is faster than String.Format.

*I can't test this on dotNetFiddle for .Net 4.7 because the compiler doesn't support it, we can't test with .Net 6 or & because SQL Server CLR only supports .Net Framework, so this method is excluded from the current tests :(

*LinqExcept
This is the logic explained in my previous answer using arrays and LINQ Except()

*LinqHashsetExcept
Same as LinqExcept but uses a HashSet<string> instead of an array, the purpose of this is to remove duplicates. Its isn't relevant any more as the OP has been updated to state the items in the arrays will already be unique. It is an interesting case to leave in to see what overheads might be involved.

*RegexMatchIterator
Use Regex.IsMatch() instead of String.Contains, other than that, same setup as the ConcatenatedString approach.

*RegexMatchAllPattern
RegEx matching by changing the required string into a regular expression, no array iterations in this solution.
You might find these additional resources helpful regarding RegEx, many of the comments talk through why and when you might choose one over the other.:

*

*Regex.IsMatch vs string.Contains

*RegEx.IsMatch() vs. String.ToUpper().Contains() performance

*How to check if contains all keywords in any order of string? RegExp Javascript

*

*RexEx Explained
Before we get started on some performance metrics, you will notice I have not included any tests relying on sorting the data. My expectation of this test set is that we will prove the effort it takes to split the strings into arrays and then iterating through the array to find the result will take longer than a simple String.Contains or String.IndexOf. There is an interesting discussion on the associated time complexities here.

NOTE: The following tests are executed on https://dotnetfiddle.net/ using the >NET 4.7.2 compiler. The actual numbers will be different in your operating environment but it is probably a good comparison to how CLR UDFs are executed from within SQL Server.

*

*It is a good comparison because the IO load is variable and shared across other isntances, at any point in time in a live SQL database there will be a varying number of other concurrent queries that will affect performance.

*Ignore the specific values, but look at the patterns they form.

The first benchmark test is to run each of these methods once for the original values of str1 and str2, capturing the time it takes to execute a cold start then after executing 10 times we sample the next execution:

Method
Cold Start (ms)
Warm (ms)

Arrays
0.6484
0.0088

ConcatenatedString
0.0069
0.0024

FormattedString
0.1939
0.0029

LinqExcept
0.0104
0.0036

LinqHashsetExcept
0.2009
0.0052

RegexMatchIterator
0.0389
0.0216

RegexMatchAllPattern
0.0929
0.0879

So far Concatenated String wins, but this isn't conclusive yet, I'm only running on dotnetfiddle, and each time I execute the test set the numbers come back different, but with a very similar distribution. We need to validate the test logic and identify base line execution patterns before we start to vary the inputs. We do that by running the same evaluation for different numbers of iterations.
The following data is captured from this fiddle: https://dotnetfiddle.net/QRPRSu

Mean Execution Time (ms)
1
10
100
1000
10000

Arrays
0.0088
0.0036
0.003464
0.0034006
0.00300586

ConcatenatedString
0.0024
0.00256
0.002541
0.0024637
0.00230981

FormattedString
0.0029
0.00309
0.00308
0.0030005
0.00288773

LinqExcept
0.0036
0.00442
0.004649
0.0050969
0.00436625

LinqHashsetExcept
0.0052
0.00605
0.006088
0.0061603
0.00599868

RegexMatchIterator
0.0216
0.02257
0.058507
0.022021
0.02383395

RegexMatchAllPattern
0.0879
0.08973
0.087446
0.0904722
0.08860092

So I didn't expect this, but for the 100 iteration cycle there is a spike, presumably there is a <10:100 event that occurs which causes the execution time to spike, testing in the epochs less than or greater than 100 seem to smooth out this spike. Across all the iterations the values are still relative to each other but also very similar, enough that we don't need to try for a massive number of iterations with the same parameters to obtain consistent results.

On to the actual testing, this time using the new comparison strings:
    string str1 = "021A,775U,000A,021A,1U2,206B,240,249,255B,260,263B,280,294,2U1,306B,336B,345,427,440,442,474,477,4U4,500508,523,543L,580,584,772,802,P55,VB" ;
    string str2 = "772+240+802+P55+263B+1U2+VB";
    string str3 = "772+240+802+P55+263B+508+VB"; // false
    string str4 = "200B+201B+202+202B+203B+204B+205+205B+206+206B+207+207B+208+208B+209+209B+210+210B+211B+214B+216B+460+494+498+830+379";//false
    string str5 = "612+637+638+646+649+655+664+678+688+693+694+754+756+758+774+778+780+781+787+99R+B58+RQW+RRG+RTJ+RVI+RVJ+RVU+RVV";//false
    string str6 = "255B+2U1+775U+336B+P55+802";//true
    string str7 = "220+223+224+229+230+233+234+402+537+550+811+863+872+881+889+965+512L+516L+520L+521L+524L+526L+528L+581L+810L+812L+814L+816L+818L+830";//false
    string str8 = "255B";//true

Run this fiddle: https://dotnetfiddle.net/sFqleR

Method
TestCases
Iterations
TotalTests
Overall
Milliseconds
ColdStart
Mean
StdDev
Variance

Arrays
7
1000
7000
00:00:00.0255972
25.5972
0.8965
0.00356150000000027
0.0495346716008814
0.049538210170847

ConcatenatedString
7
1000
7000
00:00:00.0152603
15.2603
0.1847
0.00208621428571429
0.00935358891914583
0.00935425710423217

FormattedString
7
1000
7000
00:00:00.0161606
16.1606
0.2099
0.00220965714285706
0.0040865872450029
0.00408687917537046

LinqExcept
7
1000
7000
00:00:00.0308686
30.8686
3.8193
0.00430554285714287
0.00879058428853723
0.00879121225469787

LinqHashsetExcept
7
1000
7000
00:00:00.0433723
43.3723
2.821
0.00609560000000002
0.00892103745152035
0.00892167473676254

RegexMatchIterator
7
1000
7000
00:00:00.0816964
81.6964
0.5562
0.0115590857142857
0.0318308417422667
0.0318331156174521

RegexMatchAllPattern
7
1000
7000
00:00:07.0529764
7052.9764
1.0156
1.00735934285714
1.07445298146738
1.07452973633274

ConcatenatedString still wins, but not by much over a String.Format approach.

*

*It is interesting that note that the variance for String.Format is the lowest, that indicates that it is the most consistent over the test cases.

Now lets try a full outer join between the optional and required values for a bit of variation. Then for fun lets reverse the strings and randomise the values to account for any bias in the sequence of the strings.
Fiddle: https://dotnetfiddle.net/m6YQv9

Method
TestCases
Iterations
TotalTests
Overall
Milliseconds
ColdStart
Mean
StdDev
Variance

Arrays
1024
10
10240
00:00:00.0188368
18.8368
0.2294
0.00173652343749998
0.0128300901366091
0.0128307166517418

ConcatenatedString
1024
10
10240
00:00:00.0157159
15.7159
0.2115
0.00143642578125
0.00719377438896546
0.00719412567320958

FormattedString
1024
10
10240
00:00:00.0164970
16.497
0.2815
0.00151858398437492
0.0038494732983341
0.00384966127466541

LinqExcept
1024
10
10240
00:00:00.0239897
23.9897
0.2688
0.00223395507812505
0.00772608535444904
0.00772646263234338

LinqHashsetExcept
1024
10
10240
00:00:00.0292562
29.2562
0.2896
0.00274775390625008
0.00598778336636879
0.0059880757600192

RegexMatchIterator
1024
10
10240
00:00:00.0800746
80.0746
0.4529
0.00772122070312506
0.0508215684930702
0.0508240501967361

RegexMatchAllPattern
1024
10
10240
00:00:03.6379600
3637.96
0.5773
0.355110078125
0.378996464474246
0.379014971516495

Overall ConcatenatedString still wins, but this time the margin is even smaller, and the FormattedString solution is still the most consistent, which might indicate that for a very large set of data, it could be the most reliable.
Also have a look at the original Array based solution, that is only marginally more expensive than the FormattedString but has a comparatively high degree of variance, which means this result set might have been lucky.

*

*The last test only had 10 iterations of each combination due to runtime execution constraints, so it's not the most reliable data.

I had dreams of generating a random set of terms that fit the patterns described and  then injecting a random number of the terms but TBH i'm out of time, it was a fun adventure, but its chewed up my sunday and now its getting late for dinner.
When looking for performance tuning, you need to have some good metrics around what you are currently experiencing and a realistic idea of both what is acceptable and how much time you are willing to pay for this effort. As an example, I bet OP has already spent a number of hours on this task, add my 8 hours today and the collective hours of others who have read this post and considered it, then this solution is well over 12 hours cost to the team.
I always defer back to this xkcd comic: Is It Worth the Time?

Don't forget the time you spend finding the chart to look up what you save. And the time spent reading this reminder about the time spent. And the time trying to figure out if either of those actually make sense. Remember, every second counts toward your life total, including these right now.

The difference between the Array method and the ConcatenatedString is still very marginal, you would need a very large dataset to really observe any difference that this implementation can provide.
We've spent over 12 hours, so if this makes your query run 5 seconds faster, and you run this over 5 times a day, then in 5 years you break even with the time you spend working on this issue vs the cumulative time the user would have spent waiting for the query to complete if you have done nothing.
When working with SQL and CLR functions, there are other optimisations that you can do in the SQL database that can significantly improve the performance, CLR functions are hard for SQL to optimise, generally for a query that involves this sort of data it is easy to assume that improvements in the rest of the structure of the query or evaluating other filtering constraints before this type of lookup would save more time than what we have saved here today.

A Final Thought...
If the str1 value is pretty consistent for all the items in the list, then an XML or JSON comparison inside the SQL can be far more efficient, you can reduce the cycles for each row by half by pre-formatting the str1 value as a constant variable for the query, but you lose any benefit to this if you try to pass that data across the boundary into CLR.
If this is frequently queried data used in search functions, similar to tags in tweets and other social media posts, then there are better architectural solutions to this problem, the simplest of which is to create a table of the individual terms so we can index them. The good news about SQL is that this implementation detail can be entirely managed in the database with triggers, that way the application and business domain logic do not need to be affected by this structural optimisation.
As you are using CLR, you should read over CLR vs. T-SQL: Performance considerations for some useful background. It's an older resource and SQL has evolved, but it's still relevant thinking.

Update: .Net 6
So after dinner, it's time to check out .Net 6. I had started to writeup a great summary, because a couple of test runs showed that the original Arrays implementation was fastest for fixed values over 100K interations, which means all of this was potentially for nothing, but I can't replicate that result now :) Ultimately that means that this comparison is so fast with either of these options that you are better off looking elsewhere for optimisations if you need them.
Fiddle: https://dotnetfiddle.net/VoMeo9

If we graph those numbers, excluding the RegEx results and the HashSet you can see that over time, the average execution time converges to a much smaller range and the LinqExcept implementation even beats the formatted string implementation. This is interesting when you compare this to later results because it probably points to some special optimisations within dot net when we run the same calculation repeatedly.
String Interpolation is consistently close to the Concatenated String approach and even beats it twice in this series.

The final test is to re-visit the random results feed to see if Interpolation can get the win that I was hoping for:
Fiddle: https://dotnetfiddle.net/4N23s5

Method
TestCases
Iterations
TotalTests
Overall
Milliseconds
ColdStart
Mean
StdDev
Variance

Arrays
1024
80
81920
00:00:00.0856801
85.6801
0.2904
0.000990795898437515
0.00214697922130186
0.002146992325543057

ConcatenatedString
1024
80
81920
00:00:00.0637065
63.7065
0.1513
0.0007239416503907266
0.0014517292239806258
0.00145173808471375

FormattedString
1024
80
81920
00:00:00.0732739
73.2739
0.3548
0.0008382824707032207
0.0016765147809772755
0.0016765250137051203

InterpolatedString
1024
80
81920
00:00:00.0614540
61.454
0.2699
0.0006977844238282229
0.0017730743291170337
0.0017730851512029848

LinqExcept
1024
80
81920
00:00:00.1139557
113.9557
0.8458
0.0013408093261717685
0.007293846685190374
0.007293891203705162

LinqHashsetExcept
1024
80
81920
00:00:00.1413452
141.3452
0.349
0.0016796301269533514
0.001957306707138949
0.0019573186537003933

RegexMatchIterator
1024
80
81920
00:00:00.4237531
423.7531
4.8922
0.005117004394530726
0.018711766419816867
0.018711880628421194

RegexMatchAllPattern
1024
80
81920
00:00:08.2265704
8226.5704
1.1987
0.10035106689453285
0.10451169495402168
0.10451233284862492

It's the slimmest of margins... We'd call that a Bee's D!#@ from where I'm from... Except that this time we are measuring, and these numbers a significantly smaller than that (its ~4800um if you were wondering)
I had to try a few times to get the results I was looking for, due to the test cases being randomised, it makes sense that we'd get a different output with different executions. Here's the results from two observations:

Everyone loves a chart, so here's the final one:

A: It depends on the length of the strings, but you could get a minor optimisation by using a HashSet to ensure that there are only unique entries in the first array
HashSet<string> str1Values = new HashSet<string>(str1.Split(','));
foreach (var s in str2.Split('+'))
{
    if (!str1Values.Contains(s))
    {
         return false;
    }
}
return true;

Or we can do the same in LINQ:
HashSet<string> str1Values = new HashSet<string>(str1.Split(','));
return str2.Split('+').All(s => str1Values.Contains(s));

We can also use LINQ Except() to do a similar comparison, with Except() we want no results, this would indicate that all the values matched.
return !str2.Split('+')
            .Except(new HashSet<string>(str1.Split(',')))
            .Any();

You could also package this into an extension method to reduce some of the ambiguity:
public static class StringExtensions
{
    /// <summary>Check if all the elements in this string exist in the comparison</summary>
    /// <param name="listOfAllValues">the CSV string that contains all the possible values</param>
    /// <param name="requriedElements">CSV of the values that all MUST exist in the source list</param>
    /// <param name="requiredElementsDelimiter">[Optional] delimiter to use for the requriedElements string</param>
    public static bool ContainsAll(this string listOfAllValues, string requiredElements, char requiredElementsDelimiter = '+')
    {
        return !requiredElements.Split(requiredElementsDelimiter)
            .Except(new HashSet<string>(listOfAllValues.Split(',')))
            .Any();
    }
}

Execute it like this:
Console.WriteLine(str1.ContainsAll(str2));
Console.WriteLine(str1.ContainsAll(str2, '+'));

See this fiddle: https://dotnetfiddle.net/45tU6z
It is semantically the same as your code and will break on the first non-matching value.

For small lists you could skip the array for the first string, and just use contains, it might not make a measurable difference though:
string str1Fixed = "," + str1 + ",";
foreach (var s in str2.Split('+'))
{
    if (!str1Fixed.Contains("," + s + ","))
    {
         return false;
    }
}
return true;

Or in LINQ
var str1Fixed = "," + str1 + ",";
return str2.Split('+').Select(s => "," + s + ",").All(s => str1Values.Contains(s));

NOTE: I had to add leading and trailing commas to ensure we get exact matches
I wouldn't resort to regular expressions for simple exact matching like this and suspect that we only need to split str1 into an array if there was going to be either a large number of comparisons (many elements in str2) or a very large number of elements in str1, at which point we could sort the first string and do some further optimisations, but you don't need to go that far until you can demonstrate performance issues.
The other consideration is object reuse. If this is in a comparison that is called many times inside another iterative block or loop, then there might be some additional optimisations, especially if one of the comparisons is relatively static.
For significantly large lists you could index the larger array by the first letter and sort lexicographically... But you really need to have a good justification for taking it this far.
Ideally by using the LINQ comparisons like Except we are assuming that someone smarter than us has applied practical optimisations for us so that we can concentrate on expressing our logic and worry less about the performance considerations.


text:
Q: Does Epplus support set sheet data/cell value by office open xml? My question :
If there is a sheet data format with office open xml like below :
        <sheetData>
            <row r="1" spans="1:3" x14ac:dyDescent="0.25">
                <c r="A1" t="s">
                    <v>0</v>
                </c>
                <c r="B1" t="s">
                    <v>1</v>
                </c>
                <c r="C1" t="s">
                    <v>2</v>
                </c>
            </row>
            <row r="2" spans="1:3" x14ac:dyDescent="0.25">
                <c r="A2">
                    <v>1</v>
                </c>
                <c r="B2">
                    <v>2</v>
                </c>
                <c r="C2">
                    <v>3</v>
                </c>
            </row>
            <row r="3" spans="1:3" x14ac:dyDescent="0.25">
                <c r="A3">
                    <v>4</v>
                </c>
                <c r="B3">
                    <v>5</v>
                </c>
                <c r="C3">
                    <v>6</v>
                </c>
            </row>
            <row r="4" spans="1:3" x14ac:dyDescent="0.25">
                <c r="A4">
                    <v>7</v>
                </c>
                <c r="B4">
                    <v>8</v>
                </c>
                <c r="C4">
                    <v>9</v>
                </c>
            </row>
        </sheetData>

how can I set this xml for epplus to change the cells value?
What I tried :
Searching epplus and only Cells[IndexName].Value = "xx" api.
What I expect for :
some epplus method like :
ws.SetSheetDataXml = xml;

A: You can always get to and manipulate the XML for the Worksheet like this:
var fi = new FileInfo(@"c:\temp\SomeExcelFile.xlsx");

using (var pck = new ExcelPackage(fi))
{
    var workbook = pck.Workbook;
    var ws = workbook.Worksheets.Add("Sheet1");
    ws.Cells.LoadFromDataTable(datatable, true);
    var xdoc = ws.WorksheetXml;

    ...
}

Obviously, you will have to be careful what you do with it so Epplus does not get upset when you try to save it.  Generally, messing with the XML directly is a last resort for thing that Epplus cannot do.  Here are a few examples:
How can I turn background error checking off for the Excel app object in EPPlus?
How to stop other conditional formatting from disappearing when hackmodding databars into solid fills?
X-Axis label formatting issue while exporting Chart to Excel using EPPlus


text:
Q: Django Restful_Api post Json for more than one record in a time I use Django Restful Api ,I want to post records(more than one record!) in a time ,Models ,serialize,viewset are as follows
Does anyone has some advice? thanks advcance!
model
class Brand(models.Model):
    Company_Group = models.ManyToManyField(Company)
    Brand_Group = models.CharField(u'Brand Group',max_length=255, default="")
    Pref_Brand_Name_Flg = models.CharField(u'Preferred Brand Name Flag',max_length=255, default="")
    Pref_Brand_Name = models.CharField(u'Preferred Brand Name',max_length=255, default="")
    PrimaryContact = models.ForeignKey(UserRole, null=True, blank=True) #primarybroker
    Protect_period = models.CharField(u'Protect period',max_length=255, default="")
    # Pref_Brand_Name = models.CharField(u'Preferred Brand Name',max_length=255, default="")
    Brand_Name = models.CharField(u'Brand Name',max_length=255, default="")
    Brand_Name_SC = models.CharField(u'Brand Name in Local Language',max_length=255, default="")
    Year_Enter_Market = models.CharField(u'Entered Market in (Year)',max_length=255, default="")
    Category_Display = models.CharField(u'Category Display',max_length=255, default="")
    Category_1_Code = models.CharField(u'Category',max_length=255, default="")
    Category_2_Code = models.CharField(u'Sub Category',max_length=255, default="")
    Price_Low = models.CharField(u'Price Range - Low',max_length=255, default="")
    Price_High = models.CharField(u'Price Range - High',max_length=255, default="")
    Size_Low = models.CharField(u'Typical Store Size - Low',max_length=255, default="")
    Size_High = models.CharField(u'Typical Store Size - High',max_length=255, default="")
    Headerquater = models.CharField(u'Headerquater',max_length=255, default="")
    Status = models.CharField(u'Status',max_length=255, default="")
    Created_On = models.DateField(u'Created On',auto_now_add=True)
    Created_By = models.CharField(u'Created By',max_length=255, default="")
    Modified_On = models.DateField(u'Modified On', auto_now=True)
    Modified_By = models.CharField(u'Modified By',max_length=255, default="")
    Agreement_InPlace_Flg = models.CharField(u'TR Agreement in place?',max_length=20, default="")
    Web_Site = models.CharField(u'Web Site',max_length=20, default="")
    Comment = models.CharField(u'Comment',max_length=20, default="")

viewset
class BrandViewSet(viewsets.ModelViewSet):
    queryset = Brand.objects.all()
    serializer_class = BrandSerializer

Serializer
class BrandSerializer(serializers.HyperlinkedModelSerializer):
    PrimaryContact_id = serializers.ReadOnlyField(source='PrimaryContact.id', read_only=True)
    def __init__(self, *args, **kwargs):
        many = kwargs.pop('many', True)
        super(BrandSerializer, self).__init__(many=many, *args, **kwargs)

    class Meta:
        model = Brand
        fields = data_export_setting.Brand_form_stand # +options ??
        #Brand_detail = serializers

"myTest code" :a.py
item = [{"id":"2","PrimaryContact_id":"00000","Pref_Brand_Name_Flg":"00000","Protect_period":"test_for_Protect_period_1","Pref_Brand_Name":"Test","Brand_Name":"Chanel Group","Brand_Name_SC":"test","Year_Enter_Market":"test","Category_Display":"test","Category_1_Code":"api","Category_2_Code":"api","Price_Low":"test","Price_High":"test","Size_High":"test","Headerquater":"test","Status":"test","Created_On":"2017-06-14","Modified_By":"2017-07-08","Modified_On":"000"},{"id":"3","PrimaryContact_id":"1111","Pref_Brand_Name_Flg":"11111","Protect_period":"ppppp","Pref_Brand_Name":"Test","Brand_Name":"Chanel Group 2","Brand_Name_SC":"test","Year_Enter_Market":"test","Category_Display":"test","Category_1_Code":"api","Category_2_Code":"api","Price_Low":"test","Price_High":"test","Size_High":"test","Headerquater":"test","Status":"test","Created_On":"2017-06-14","Modified_By":"2017-07-08","Modified_On":"000"}]

data=json.dumps(item)
def test_get_user_list_3():
    resp = requests.post(urlname,auth=AUTH,data=data,headers={ "Content-Type":"application/json","Accept": "application/json"})
test_get_user_list_3()

if item as for one record ,it works
item ={"id":"1","PrimaryContact_id":"00000","Pref_Brand_Name_Flg":"00000","Protect_period":"test_for_Protect_period_1","Pref_Brand_Name":"Test","Brand_Name":"Chanel Group","Brand_Name_SC":"test","Year_Enter_Market":"test","Category_Display":"test","Category_1_Code":"api","Category_2_Code":"api","Price_Low":"test","Price_High":"test","Size_High":"test",Headerquater":"test","Status":"test","Created_On":"2017-06-14","Modified_By":"2017-07-08","Modified_On":"000"},

A: As shown in DRF documentation you can utilize the ListSerializer to create multiple instances of the model.
Your best bet is to create a separate serializer(ListSerializer) with an your own custom .create() method for creating multiple instances of your model. Then in your view you write some business logic to check if it's a single object or a list of multiple objects and send them to the appropriate serializer for creation. Make sure you take a look at the ListSerializer and how to use many=True.
You can potentially use the same serializer with your own custom .create() method and have the business logic inside of there but look at the documentation and see the recommended way of creating multiple instances of objects.

A: Ok, i've spent a considerable amount of time trying to get this work. Below is the code that i've used to get this to do bulk creates.
The get_serializer method that's used by default for ModelViewSet passes in the data without many=True so you have to override it and make sure you check the request for a list instead of a dictionary.
That's the only change required to be able to bulk create items from a list.
models.py
class Brand(models.Model):
    # ------------------------------------------
    # Relations
    # ------------------------------------------
    Company_Group = models.ManyToManyField(Company)
    PrimaryContact = models.ForeignKey(User, null=True, blank=True)

    # ------------------------------------------
    # Attributes
    # ------------------------------------------

    # Brand attrs
    Brand_Name = models.CharField(u'Brand Name',max_length=255, blank=True)
    Brand_Group = models.CharField(u'Brand Group',max_length=255, blank=True)
    Pref_Brand_Name = models.CharField(u'Preferred Brand Name',max_length=255, blank=True)
    Brand_Name_SC = models.CharField(u'Brand Name in Local Language',max_length=255, blank=True)
    Pref_Brand_Name_Flg = models.CharField(u'Preferred Brand Name Flag',max_length=255, blank=True)

    # Record management attrs
    Modified_On = models.DateField(u'Modified On', auto_now=True)
    Created_On = models.DateField(u'Created On', auto_now_add=True)
    Created_By = models.CharField(u'Created By', max_length=255, blank=True)
    Modified_By = models.CharField(u'Modified By', max_length=255, blank=True)

    # Category attrs
    Category_1_Code = models.CharField(u'Category', max_length=255, blank=True)
    Category_2_Code = models.CharField(u'Sub Category', max_length=255, blank=True)
    Category_Display = models.CharField(u'Category Display',max_length=255, blank=True)

    # Pricing attrs
    Price_Low = models.CharField(u'Price Range - Low', max_length=255, blank=True)
    Price_High = models.CharField(u'Price Range - High', max_length=255, blank=True)

    # Store attrs
    Size_Low = models.CharField(u'Typical Store Size - Low', max_length=255, blank=True)
    Size_High = models.CharField(u'Typical Store Size - High', max_length=255, blank=True)

    # Company attrs
    Status = models.CharField(u'Status', max_length=255, blank=True)
    Comment = models.CharField(u'Comment', max_length=20, blank=True)
    Web_Site = models.CharField(u'Web Site', max_length=20, blank=True)
    Headerquater = models.CharField(u'Headerquater', max_length=255, blank=True)
    Protect_period = models.CharField(u'Protect period', max_length=255, blank=True)
    Year_Enter_Market = models.CharField(u'Entered Market in (Year)', max_length=255, blank=True)
    Agreement_InPlace_Flg = models.CharField(u'TR Agreement in place?', max_length=20, blank=True)

    def __str__(self):
        return self.Brand_Name

    class Meta:
        db_table = 'brand'

serializers.py
class BrandSerializer(serializers.ModelSerializer):

    class Meta:
        model = Brand
        fields = '__all__'

views.py
class BrandViewSet(viewsets.ModelViewSet):
    model = Brand
    serializer_class = BrandSerializer
    queryset = Brand.objects.all()

    def get_serializer(self, *args, **kwargs):
        if 'data' in kwargs:
            data = kwargs['data']

            if isinstance(data, list):
                kwargs['many'] = True

        return super().get_serializer(*args, **kwargs)

urls.py
from rest_framework.routers import DefaultRouter

from .views import BrandViewSet

router = DefaultRouter()
router.register(r'brand', BrandViewSet)

urlpatterns = router.urls

I sent the data(JSON) using postman in this format:
[
   {
      "Brand_Name":"",
      "Brand_Group":"",
      "Pref_Brand_Name":"",
      "Brand_Name_SC":"",
      "Pref_Brand_Name_Flg":"",
      "Created_By":"",
      "Modified_By":"",
      "Category_1_Code":"",
      "Category_2_Code":"",
      "Category_Display":"",
      "Price_Low":"",
      "Price_High":"",
      "Size_Low":"",
      "Size_High":"",
      "Status":"",
      "Comment":"",
      "Web_Site":"",
      "Headerquater":"",
      "Protect_period":"",
      "Year_Enter_Market":"",
      "Agreement_InPlace_Flg":"",
      "PrimaryContact":null,
      "Company_Group":[
         1
      ]
   },
   {
      "Brand_Name":"",
      "Brand_Group":"",
      "Pref_Brand_Name":"",
      "Brand_Name_SC":"",
      "Pref_Brand_Name_Flg":"",
      "Created_By":"",
      "Modified_By":"",
      "Category_1_Code":"",
      "Category_2_Code":"",
      "Category_Display":"",
      "Price_Low":"",
      "Price_High":"",
      "Size_Low":"",
      "Size_High":"",
      "Status":"",
      "Comment":"",
      "Web_Site":"",
      "Headerquater":"",
      "Protect_period":"",
      "Year_Enter_Market":"",
      "Agreement_InPlace_Flg":"",
      "PrimaryContact":null,
      "Company_Group":[
         1
      ]
   }
]


text:
Q: A photo of an object in an ImageVIew is not displayed I receive an object from another fragment. In that object there is a photo that I can not see in the ImageView. Help?
I have tried changing the string that arrives to me, to bitmap ... but nothing.
```@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable
ViewGroup container, @Nullable Bundle savedInstanceState) {
View RootView = inflater.inflate(R.layout.fragment_outfit_today,
container, false);
imagePartUp = (ImageView) RootView.findViewById(R.id.partUp);
imagePartMiddle = (ImageView) RootView.findViewById(R.id.partMiddle);
imagePartFloor = (ImageView) RootView.findViewById(R.id.partFloor);

for (int i = 0; i <itemsAllPart.size() ; i++) {
itemsPartUp = itemsAllPart.get(0).getImage();
byte[] imageAsBytes = itemsPartUp.getBytes();
Bitmap bp = BitmapFactory.decodeByteArray(imageAsBytes, 0,
imageAsBytes.length);
imagePartUp.setImageBitmap(bp);
}
return RootView;
}
public void recieveItems(ArrayList<Item> items) {
if(itemsAllPart !=null){
        itemsAllPart = items;
}

A: try this
List<String> encode = new ArrayList<>();
String encoded = "";
byte[] byteArray;

for (int i = 0; i < itemsAllPart.size(); i++)
{
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            itemsAllPart.get(i).compress(Bitmap.CompressFormat.PNG, 10,
            byteArrayOutputStream);
            byteArray = byteArrayOutputStream.toByteArray();
            encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
            encode.add(encoded);
 }

I hope it will work with you


text:
Q: Heroku: NodeJS: pip is missing if I use NodeJS app I have a NodeJS app, in which I want to invoke Python interpreter, to run some processing for me.
When I check for "python --version" from NodeJS using exec(...), I get the output as Python 3.8.5. That's good.
I need to install certain packages using pip.
But when I try to invoke pip, it saying command error. So basically pip is not available on that dyno.
My question is if I use a NodeJS app, how can I install pip? So that I can download certain Python packages.

A: I was struggling with the same problem. You can't install pip, but instead what you need to do is install a python buildpack. This buildpack will set your dyno to properly work with python/pip.
Using Heroku CLI:

*

*First install python buildpack at the first position: heroku buildpacks:add --index 1 heroku/python. You should receive the message below:

NOTE: The buildpack for the primary language of your app should always be the last buildpack in the list. This ensures that defaults for that primary language are applied instead of those for another language, and allows Heroku to correctly detect the primary language of your app.

*Second create a commit so you can run git push heroku main.
That's it. Now you have pip in your dyno, and if you have a file requirements.txt with all the python packages it will be automatically downloaded every time you push to heroku main.
Documentation: Using Multiple Buildpacks for an App
Let me know if it worked.


text:
Q: Issue in facebook login in rails I am having both web and api login in my project. But when I check now, I found my facebook login is not working in web. I am getting the following error
Could not find a valid mapping for path "/omniauth/facebook/callback"

I have the following path
user_omniauth_callback   GET|POST /omniauth/:action/callback(.:format)   users/omniauth_callbacks#:action

and also have method facebook in controllers/users/omniauth_callbacks_controller.rb
I have also included the gems devise, omniauth and omniauth-facebook

A: I have found solution for the question. Updating gems to their newest versions (omniauth 1.6.1 and omniauth-facebook 4.0.0) with:
gem 'omniauth', '~> 1.6.1'
gem 'omniauth-facebook', '~> 4.0.0'

solved the issue.


text:
Q: How to toggle icons and class name and click function on click I've searched this answer for 6 hours but couldn't find. Sorry if it is duplicate.
I'm rookie at Jquery.
I want to change star color, div's class name and of course execute new class' process in jquery.
Here is my html code:

This is my jquery code:
  $(document).ready(function(){

     $('.fav').click(function(){
         var haberid = $(this).attr('haberid');
         var habertype = $(this).attr('habertype');
         var fav = "fav";
        $.ajax({
            type:"POST",
            url:"http://www.myurl.com/robot_yeni/inc/pages/islem/fav.php",
            data: {id: haberid, type: habertype, fav: fav},
            success:function(data){
            }
        });
        $(this).html( "");
        $(this).attr('class','fav2');
     });

     $('.fav2').click(function(){
         var haberid = $(this).attr('haberid');
         var habertype = $(this).attr('habertype');
         var fav = "fav2";
        $.ajax({
            type:"POST",
            url:"http://www.myurl.com/robot_yeni/inc/pages/islem/fav.php",
            data: {id: haberid, type: habertype, fav: fav},
            success:function(data){
            }
        });
        $(this).html( "");
        $(this).attr('class','fav2');
     });
 });

When i first click, it changes from fav1.gif to fav2.gif and class name from "fav" to "fav2" and $.ajax post works.
But it does not work back (toogle) when i click new fav2.gif. No icon change, no class change, no ajax post.
What can i do?

A: You need not apply click listener on the same div twice to get toggle effect. Just apply or remove a particular class to identify current toggle state.
EDIT:
Updated Demo
HTML:

Script:
    $(document).ready(function () {

    $('.fav').click(function () {
        var haberid = $(this).attr('haberid');
        var habertype = $(this).attr('habertype');

        if ($(this).hasClass("fav")) {
            var fav = "fav";

            $(this).html("");
            $(this).attr('class', 'fav2');
        } else if ($(this).hasClass("fav2")) {
            var fav = "fav2";
            $(this).html("");
            $(this).attr('class', 'fav');
        }
        $.ajax({
            type: "POST",
            url: "http://www.myurl.com/robot_yeni/inc/pages/islem/fav.php",
            data: {
                id: haberid,
                type: habertype,
                fav: fav
            },
            success: function (data) {}
        });
    });
});

A:  $('[class*=fav]').click(function(){
     var haberid = $(this).attr('haberid');
     var habertype = $(this).attr('habertype');
     var fav = $(this).hasClass('fav') ? 'fav2' : 'fav';
    $.ajax({
        type:"POST",
        url:"http://www.myurl.com/robot_yeni/inc/pages/islem/fav.php",
        data: {id: haberid, type: habertype, fav: fav},
        success:function(data){}
    });
    $(this).html( "");
    $(this).attr('class',fav);
 });


text:
Q: How can I access Indicator data? I wish to access data from an indicator in pine script. In mt4 I can use the function to do this. is there a similar function call in pine script "iCustom".

A: There isn't really a direct equivalent. There are four ways you might accomplish it though.

*

*There exists some built in functions for common indicators that can be referenced under the ta. namespace such as ta.rsi()

*Obtaining a series from another indicator applied to the chart. Your script must use only one input.source() and then it can use one output from another indicator that is applied to the chart as a source series which you can use in your script's calculation. It has to be set manually once both indicators are on your chart by changing your script's input.source() option to use the other indicator's output.

*Create or use a library which performs the desired calculations and reference that from your script.

*Directly include the code to perform the other indicator's calculation in your script.


text:
Q: Python how to include a string with random integer I want to make a random police unit generator and the code is like so:
import random
unitnumbers = ('unit' , random.randint(1,999))
print(unitnumbers)

However, rather than printing "unit 63" , it prints ('unit', 378)
How could I make it print only the unit and random number?

A: You are making the value of unitnumbers a tuple. You should instead make it a string like that:
unitnumbers = "unit " + str(random.randint(1,999))

A: This should do that:
import random
unitnumbers = 'unit %d' % random.randint(1,999)
print(unitnumbers)


text:
Q: Given 5 integers show that you can find two whose sum or difference is divisible by 6.
Given any $5$ integers, prove that you can pick two among them whose sum or difference is divisible by $6$. (You are not allowed to pick the same number twice.)

I'm trying to solve this problem using the pigeon hole principle.
When dividing an integer by 6 there are 6 different remainders, {0, 1, 2, 3, 4, 5}. Seeing as there are the same number of "holes" (remainders of those 5 integers after being divided by 6) as there are "pigeons" I'm not sure how to go about solving this.

A: Simple.
As noted above if you have two different integers which give same remainder when divided by 6, then their difference will be divisible by 6.
Consider case of integers which all have diffrent reminders when divided by 6.
There can only be 6 remainders then - 0,1,2,3,4,5
It is easy to notice that 1+5 = 6 which means that
sum integers which give remainder of 1 and 5 when divided by 6 will be divisible by 6,
and 2+4 = 6, which means that
sum integers which give remainder of 2 and 4 when divided by 6 will be divisible by 6,
Since you need to choose 5 integers from the six possible types of remainders, you cannot elude both pairs.
Therefore at least one sum will be divisible by 6
QED

A: $a\equiv b\pmod{\! m}$ denotes '$a,b$ leave same remainders when divided by $m$', or $m\mid a-b$ (see Modular Arithmetic).
$x^2\equiv \{0,1,3,4\}\pmod{\! 6}$ for any $x\in\Bbb Z$ ($\color{#0af}4$ possible remainders).
To see why, square $6k,\, 6k\pm 1,\, 6k\pm 2,\, 6k+ 3$.
Let your integers be $a_1,a_2,a_3,a_4,a_5$ ($\color{#0af}{4}+1$ integers).
By pigeonhole principle exist $i\neq j$ with $a_i^2\equiv a_j^2\pmod{\! 6}$, or i.e. $6\mid (a_i+a_j)(a_i-a_j)$
Assume for contr. that $6\nmid a_i+a_j, a_i-a_j$. Then WLOG $3\mid a_i+ a_j,\, 2\mid a_i- a_j$
But $a_i+ a_j=a_i- a_j+ 2a_j$, so $a_i+ a_j$ is even too and $6\mid a_i+ a_j$, contr assumption.
This used elementary methods, but it generalizes. $\,x^2\not\equiv 2$, $\,x^2\not\equiv -1$$\pmod{\! 6}$ is a consequence of quadratic reciprocity, because $3$ (a prime divisor of $6$) is of the form $8k+3$. So you did not need to square $0,\pm 1,\pm 2, 3$, which is neat since the $6$ could've been larger.

A: HINT: If two of the numbers have the same remainder on division by $6$, their difference is divisible by $6$, so you can focus on the case in which all five integers have different remainders on division by $6$. Try to show that no matter which of the $6$ possible remainders is missing, you must have two numbers whose sum is a multiple of $6$.

A: Hint:  Instead of using the smallest non-negative remainders mod $6$, use remainders of smallest absolute value (e.g., $-2,-1,0,1,2,3$).  What can you say about two numbers with the same absolute value?


text:
Q: Prove that if $|f(x)| \leq x^2$, then the function is continuous and differentiable at $x=0$. Let $f:\mathbb{R} \to \mathbb{R}$ be a function such that $|f(x)| \leq x^2$ .
Prove whether or not the function is continuous and differentiable at $x=0$.
Please tell me where am i wrong
i have used the sandwich theorem :
$-x^2 \leq f(x) \leq x^2$,
so $\lim_{x \to 0} f(x) = \lim_{x \to 0} x^2 = \lim_{x \to 0}(-x^2) = 0 $
also , $f(0)=0$
hence the function is continuous and differentiable

A: You've proved continuity and that $f(0) = 0$. To prove differentiability, you need to prove that $$\lim_{x\to 0} \frac{f(x) - f(0)}{x-0}$$ exists. However, this simplifies to proving $$\lim_{x\to 0} \frac{f(x)}{x}$$ exists. And by the given condition, we see $$\left | \frac{f(x)}{x} \right| \le \lvert x \rvert .$$ Thus $$\lim_{x\to 0} \frac{f(x)}{x} = 0$$ which shows that $f$ is differentiable at $0$ with $f'(0)=0$.


text:
Q: How to get past cloudflare with Firefox I have to make my testing script visit a website that is protected with cloudflare, but I can't get past.

Needs to review the security of your connection before proceeding

Using:

*

*Browser    : Firefox

*Code       : Python with Selenium

Things which I have tried:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.service import Service

profile=""

option = webdriver.FirefoxOptions()
option.binary_location = r'C:\Program Files\Mozilla Firefox\firefox.exe'

option.set_preference("dom.webdriver.enabled", False)
option.set_preference('useAutomationExtension', False)

browser = webdriver.Firefox(options=option)

browser.get('https://nowsecure.nl/')

But I always get "needs to review the security of your connection before proceeding."
References:
How can I make a Selenium script undetectable using GeckoDriver and Firefox through Python?


text:
Q: Does the app restart after it crashes when in background - Android I am getting the location updates in background (on BroadcastReceiver) using Google API's FusedLocationProvider. When the app is in background, if a crash occurs(let's say a NullPointerException) and the user choses one of the two options displayed(Open the app again or close the app or send feedback).
Will the app restart itself?
If it doesn't start, is it possible to start the background location updates manually without opening the app?

A: After some tests, I found that the app does restart or recover itself after it crashes regardless of clicking any of the three options mentioned in the question.


text:
Q: Optimal way to do linear approximation of function on an interval. Assume that I want to find the line which in squared integral sense ends up being closest to another function on an interval:
$$\min_{k,m}\left\{\int_{a}^{b} |f(x)-(kx+m)|^2dx\right\}$$
Expanding the square:
$$f(x)^2 - 2 f(x)(kx+m) + (kx+m)^2$$
Let's assume we know $$\int_a^b f(x) dx = [F(x)]_a^b\\\int_a^b f(x)^2 dx = [F_2(x)]_a^b$$
How can we derive optimal $k$ and $m$? Is this sufficient information or do we need to know something more?

A: As Damien writes, we will need the expression $$\int_a^b xf(x) dx$$
We can try integration by parts:
$$\int_a^b u(x)v'(x)dx = [u(x)v(x)]_a^b - \int_a^b u'(x)v(x)dx$$
If we set $u(x)=x,v'(x)=f(x)$
$$\int_a^b xf(x)dx = [xF(x)]_a^b - \int_a^b F(x)dx$$
Here we will also need $\int_a^b F(x)dx$.
And since we don't know $F(a),F(b)$ separately we won't be able to calculate $bF(b)-aF(a)$ either.

Another thing we can do is to approximate $f$ by straight line between $f(a)$ and $f(b)$ on $[a,b]$ for only the purpose of approximating the above integral.
$$f_{appr}(x) = f(a) + \frac{(x-a)(f(b)-f(a))}{b-a}$$
Now $\int xf_{appr}(x)dx $ can be easily calculated as a polynomial.
How good this approximation will be, I don't know. Experiments will probably need to be conducted.


text:
Q: WordPress: Paginating a single Page? I was wondering if someone knows about an option to paginate a regular page?
Couldn't find any additional info online.
The thing is I'm looking to create a page (default page template) with the possibility to paginate it.
Am I missing something or is that not possible?!
Edit :
Just a clarification, I'm referring to the page.php template, not any other file such as the index/archive/post etc as those are pretty straight forward.
Thanks!! :-)

A: On most well-coded themes, all you have to do is paste this code: <!––nextpage––> wherever you want the next page to start.
If for some reason, pagination is not showing up after you have pasted the next page tags, then you would need to add the following code in your single.php loop.
<?php wp_link_pages(); ?>

A: OK, the short answer is, you guys are right.
The long answer is that due to a custom post type setting, (has_archive was set to false) the pagination didn't work on the page.php template, but did work on the front page.


text:
Q: PHP Mail() error using fakemail and WAMP im trying to send an email using localhost in a WAMP server and using this fakemail from this tutorial. https://www.youtube.com/watch?v=qXvGKnWXH5A but i got an error.
Here is my error, Warning: mail(): Failed to connect to mailserver at "" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()
How do i fix it? Im really having a hard time sending mails using WAMP and it is because i have no idea how.
here is my mail function in my php.ini
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = smtp.gmail.com
; http://php.net/smtp-port
smtp_port = 465

; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = you@yourdomain

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
;sendmail_path ="C:\wamp\sendmail\sendmail.exe -t -1"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header = On

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log =

and here is my sendmail.ini
; configuration for fake sendmail

; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail

[sendmail]

; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory.  (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
; run quicker, but you won't get error messages back to the calling
; application.

smtp_server=smtp.gmail.com

; smtp port (normally 25)

smtp_port=465

; SMTPS (SSL) support
;   auto = use SSL for port 465, otherwise try to use TLS
;   ssl  = alway use SSL
;   tls  = always use TLS
;   none = never try to use SSL

smtp_ssl=auto

; the default domain for this server will be read from the registry
; this will be appended to email addresses when one isn't provided
; if you want to override the value in the registry, uncomment and modify

;default_domain=mydomain.com

; log smtp errors to error.log (defaults to same directory as sendmail.exe)
; uncomment to enable logging

error_logfile=error.log

; create debug log as debug.log (defaults to same directory as sendmail.exe)
; uncomment to enable debugging

;debug_logfile=debug.log

; if your smtp server requires authentication, modify the following two lines

auth_username=xxxxxxxx@gmail.com
auth_password=xxxxxxxx

; if your smtp server uses pop3 before smtp authentication, modify the
; following three lines.  do not enable unless it is required.

pop3_server=
pop3_username=
pop3_password=

; force the sender to always be the following email address
; this will only affect the "MAIL FROM" command, it won't modify
; the "From: " header of the message content

force_sender=

; force the sender to always be the following email address
; this will only affect the "RCTP TO" command, it won't modify
; the "To: " header of the message content

force_recipient=

; sendmail will use your hostname and your default_domain in the ehlo/helo
; smtp greeting.  you can manually set the ehlo/helo name if required

hostname=localhost

I followed the procedure in the video but i still get this error.
and here is my sendmail.php
<?php
$to = 'xxxxxxxx@live.com';
$subject = 'Testing Sendmail.exe';
$message = 'hahahahahahahhahaxxxxxx';
$headers = 'From HAHAHA';
if(mail($to,$subject,$message,$headers)){
    echo "email sent";
}
else{
    echo "email sending failed";
}
?>

please help me with this email function on php. im really having a hard time making it work, i am using WAMP and i can't host my site yet, so i need to send mails from the localhost.

A: Examining your error:

Warning: mail(): Failed to connect to mailserver at "" port 25, verify
  your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

it seems you didn't restart WAMPP (Apache) after you've changed php.ini file.


text:
Q: Cancel / abort creating a new form in Delphi / C++Builder? Is there any way to cancel or abort form creation from within the form's OnCreate event handler or C++Builder constructor?
Basically, I'd like to be able to call Close() from OnCreate or from the constructor and have it skip showing the form altogether.  I have several forms that as part of their initialization may determine that they shouldn't be shown at all.  (I realize that I could split apart this portion of the initialization or add extra checks from the calling form or similar, but if there's a way to cleanly do all of this from within OnCreate or the constructor, that seems simplest.)
Edit:  In response to a few comments, some of the don't-show-at-all logic is UI logic and not business logic; the form might display a confirmation before showing, or it might use a common dialog box to get input for the form then abort if the user cancels that dialog.  (Some of it is business logic and needs to be refactored, but it's often hard to find the time to refactor everything that needs it.)

A: You can always call Release in the OnCreate handler, but that will lead to the form quickly appearing and then being closed. Not a very professional thing.
So here's another idea. Let the forms have a public function or property to return whether they are in fact to be shown. Then where you would usually have
TheForm := TSomeForm.Create(Self);
TheForm.Show;

you would have
TheForm := TSomeForm.Create(Self);
if TheForm.ShouldAppear then
  TheForm.Show
else
  TheForm.Release;

Having said that - any other way of coding this (so you don't create a form that will be immediately destroyed) is surely better. Especially if you want to maintain a clear separation between UI and business layer it would be much better to have the code that decides whether the form is to be shown outside of the form. Create the form only after you have made the decision.

A: I would think it is much better to not even have to create the form in the first place.  IF you're performing some logic which determines that the form is not even necessary, and that logic contains state which is important to the form, then re-factor the logic into a separate object (or even a data module) and pass the object to the form as a property.  Here is a simple example (using the object approach):
UNIT1
type
  TOFormTests = class
    fStateData : string;
  public
    function IsForm1Needed( someparam : string) : boolean;
    property StateData : string read fStateData write fStateData;
  end;

UNIT2
uses
  :
  UNIT1;

type
  TForm1 = class(tForm)
  :
  procedure SetFormTests(value : tOFormTests);
  property FormTests : TOFormTests read fFormTests write SetFormTests;
end;

procedure SetFormTest(Value:TOFOrmTests);
begin
  fFormTests := Value;
  // perform gui setup logic here.
end;

then someplace in your code, where you are wanting to determine if you should show your gui or not use something like the following:
var
  Tests : TOFormTests;
begin
  tests := tOFormTests.create;
  try
    if Tests.IsForm1Needed('state data goes here') then
      begin
        Form1 := tForm1.create(nil);
        try
          Form1.FormTests := Tests;
          if Form1.ShowModal = mrOk then
            // handle any save state logic here.
          ;
        finally
          FreeAndNil(Form1);
        end;
      end;
  finally
    freeAndNil(Tests);
  end;
end;

This also assumes that the form is NOT in the auto-create list and needs to be shown modal.

A: Use Abort in the constructor.  It raises a silent exception.  If an object has an exception in the constructor, then the destructor is called and the memory released.  The advantage of Abort is then you don't need to worry about an exception dialog being displayed if you don't add exception handling code.

A: Add a class function that returns an instance when needed.  Then the method that determines if the form should be shown is still in that class, but it can determine if it is necessary before the form is actually constructed.  Call it like "CreateIfNeeded" and it will work just like a constructor, but won't actually construct the form if it isn't needed.  Minimal code changes, and maximum flexibility.

A: Just raise an exception in OnCreate.
You'll need also redefine behavior of HandleCreateException method (as default is to display an error message, and not to cancel creation).

A: I would override ShowModal
function TfHtmlEditor.ShowModal: Integer;
begin
  if TabControl1.Tabs.Count=0 then
    Result := mrAbort
  else
    Result := inherited;
end;


text:
Q: jquery: grab the values from multiple select menus each time a new option is chosen I'm building a live price quote form with jQuery, using a series of select menus. I've come up with the code below, which grabs the default values from each select menu and adds them together:
$(document).ready(function(){
 $('select > option:selected').each(function() {
  var value = $(this).attr('label');

  total = parseFloat(total) + parseFloat(value);
  total = total.toFixed(2);
 });
 printTotal(total); // prints the total price
});

The only problem is that this only works when the page loads. I'd like the price to be updated each time a new value is selected in any of the select menus (there are 6).
I tried adding $("select").change(function () { ... } with a trigger (as shown in the example code here) but that adds up all of the values for each of the select menus (i.e., the total is 6x what it should be).
I've searched the docs but can't figure which event to use. Can anyone help?
HTML sample if it helps:
<select id="colors">
 <option label="25.00" value="XYZ">1 color</option>
 <option label="50.50" value="ABC">2 colors</option>
 <option label="75.75" value="MNO">3 colors</option>
</select>

A: Matt, I think you triggered something in my mind, because I figured it out -- at least, it works so far.
Here is the code that does it:
$(document).ready(function(){
    $('select').change(function() {
        var total = 0;
        $('select > option:selected').each(function() {
            var value = $(this).attr('label');

            total = parseFloat(total) + parseFloat(value);
            total = total.toFixed(2);
        });
        printTotal(total);
    });
});

It came down to placement of the var total = 0 piece, which has to be reset each time a new selection is made.

A: When testing within the change call, you need to make sure that you search options within the context of the select element that you clicked on.
$('select').change(function() {
    var total = 0;

    // note the second parameter passed to the $() function below
    $('option:selected', $(this)).each(function() {
        var value = $(this).attr('label');
        total += parseFloat(value).toFixed(2);
    });
    printTotal(total);
});


text:
Q: iptables openvpn forward selectively from eth to tun Simple for those who know, indecipherable for those who don't...
I'm running openVPN on (hypothetical) 66.66.66.66, I want to FORWARD incoming traffic, arriving on interface eth0 to interface tun0.
It would also be nice to filter - based on destination IP address. I'm doing the NAT later on, but like to lock down early wherever possible.
So onto the main course...
This works:
  #Enable forwarding from eth0 to tun0
  iptables -A FORWARD -i eth0 -o tun+ -j ACCEPT

But this doesn't pass any packets whatsoever:
 #Stricter version
 iptables -A FORWARD -i eth0 -o tun+ --dst 66.66.66.66  -j ACCEPT

Am I being unacceptably foolish?

A: The following works quite well for me, I'm not sure if it's perfect but seems sane enough.
iptables -A FORWARD -i eth0 -o tun+ -j ACCEPT
iptables -A FORWARD -i eth0 -o tun+ \! -d 178.79.178.75 -j DROP


text:
Q: Updating Software on Debian to non packaged version The most current xf86-input-wacom version on Debian is 2 years old (0.34.99.1-1) it seems like and there is a bug where the touchscreen would not work spontaneously anymore which is fixed in version 0.36.1. I now obviously want that version on my Debian (currently still Buster, but I could update). Is building the package acceptable and will it be invincible to updates, or will a single update cause the whole thing to break down? In that case, should I just stay at Debian Buster, because its frozen? I know I am creating a "franken Debian" by doing that, so how to do it the correct Debian way without causing to much trouble?
Handy Links I found so far:
https://sourceforge.net/p/linuxwacom/bugs/349/
https://packages.debian.org/source/sid/xf86-input-wacom
https://github.com/linuxwacom/xf86-input-wacom/wiki/Building-The-Driver

A: There are a couple of approaches to upgrade a package to a newer version which isn't packaged yet, without risking the upgraded version being overwritten by a new package:

*

*package the new version yourself, or build an updated source package (in this case, Ubuntu has a package of version 0.36);

*uninstall the package and install from source.

The former is far more "Debian-like".
However, in your particular scenario, the best solution might be to stop using xf86-input-wacom altogether: libinput supports Wacom touchscreens, and has better multitouch support. It will handle the touchscreen automatically once the Wacom driver is removed.
If libinput doesn't work, the best way to get an updated Wacom driver without resorting to a FrankenDebian is to rebuild the driver:

*

*install some tools we'll need
sudo apt install build-essential devscripts

*retrieve the Ubuntu source package
dget -ux https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/xf86-input-wacom/1:0.36.1-0ubuntu2/xf86-input-wacom_0.36.1-0ubuntu2.dsc

*go into the extracted directory
cd xf86-input-wacom*

*create a package to represent the build dependencies (this will make cleanup easier)
mk-build-deps debian/control

*install it
sudo apt install ./*build-deps*.deb

*move it out of the way
mv ./*build-deps*.deb ..

*build the package
dpkg-buildpackage -us -uc

*install the generated packages
sudo debi

*clean up
sudo apt --autoremove purge xf86-input-wacom-build-deps xserver-xorg-input-wacom-dbgsym


text:
Q: how to automatically set value of textbox according to value of another textbox I had textbox1, textbox2, and textbox3 I want to automatically set value of textbox2 and textbox3 according to value of textbox1 which has an auto complete method as below...
what should I do within the while clause to automatically set value of textbox2 and textbox3 after finishing auto complete at textbox1 ??
I am working on these error form two days everything is public within my code... I have one think i am wondering about is that new class should be defined within the namespace scope like namespace { Class class_name} but I am defining the class instead of another class like  name spaces {class Class_name1 {classs Class_name2 } }  but my problem is that when i put my class within the name spaces scope I am getting alot of error and it wont recognize a lot of key words ... so please would tha be the problem ?? and if yes please can you lead me to solve this ???
public class PopulateProduct
        {
            public string ProductDesc { get; set; }
            public decimal UnitPrice { get; set; }
        }
    Dictionary<string, PopulateProduct> dict = new Dictionary<string, PopulateProduct>();

    public void load()
    {
        string connstr = "user id=rawpic;password=admin";
        string cmdtxt = @"select PRODUCT_ID,DESCRIPTION,UNIT_PRICE
                              from products";

        AutoCompleteStringCollection autocom = new AutoCompleteStringCollection();
        TB_PRODUCT_ID.AutoCompleteMode = AutoCompleteMode.Suggest;
        TB_PRODUCT_ID.AutoCompleteSource = AutoCompleteSource.CustomSource;
        TB_PRODUCT_ID.AutoCompleteCustomSource = autocom;

        using (OracleConnection conn = new OracleConnection(connstr))
        using (OracleCommand cmd = new OracleCommand(cmdtxt, conn))
        {
            try
            {
                conn.Open();
                OracleDataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    dict.Add((string)dr["PRODUCT_ID"],
                        new PopulateProduct()
                        {
                            ProductDesc = (string)dr["DESCRIPTION"],
                            UnitPrice = (decimal)dr["UNIT_PRICE"]
                        });
                    autocom.Add(dr["PRODUCT_ID"].ToString());
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,"",MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }
    }

    private void TB_PRODUCT_ID_TextChanged(object sender, EventArgs e)
    {
        if (dict.ContainsKey(TB_PRODUCT_ID.Text))
        {
            TB_PRODUCTS_DESC.Text = dict[TB_PRODUCT_ID.Text].ProductDesc;
            TB_UNIT_PRICE.Text = dict[TB_PRODUCT_ID.Text].UnitPrice.ToString();
        }
    }

A:
"...everything is public within my code..."

Please check again. Properties of your Object model is not public yet (and Object is not a good name for your model ... how about Product ?) :
public class Product
{
    public string ProductDesc { get; set; }
    public decimal UnitPrice { get; set; }
}

Regarding the last part of the error message, that's because DataReader["column_name"] returns object. You need to explicitly cast the result to suitable type :
dict.Add((string)dr["PRODUCT_ID"],
         new Product()
         {
            ProductDesc = (string)dr["DESCRIPTION"],
            UnitPrice = (decimal)dr["UNIT_PRICE"]
         });


text:
Q: Listen to js variable change Let's say there is a code in place 2
var place2IsReady = true;

In place 1 I need to implement the logic below :
Once place2IsReady value was changed (to true) then display alert('ready!');

Notes:

*

*place2IsReady variable is not available in the scope of place 1.

*the code from place 1 gets executed before place 2 gets executed (or there is a race condition).

Solution 1
I believe I can use window.place2IsReady instead and use setTimeout/setInterval in place 1 until I get window.place2IsReady === true.
Any better options? Using Listeners? On the variable change?
P.S. I need to track only first possible change of place2IsReady.
Is there a better way? Thank you.

A: You can create a listener for the variable change using setTimeout, something like:

let place2IsReady = false;

setReadyListener();

// testing wait 2 seconds to set place2IsReady to true
// so: an alert should occur after 2 seconds
setTimeout(() => place2IsReady = true, 2000);

function setReadyListener() {
  const readyListener = () => {
    if (place2IsReady) {
      return alert("Ready!");
    }
    return setTimeout(readyListener, 250);
  };
  readyListener();
}

A more generic listener 'factory' could be:

let place2IsReady = false;
let fromObj = {
  place2IsReady: "busy",
  done() { this.place2IsReady = "done"; },
};
const listen = changeListenerFactory();

listen(
  () => place2IsReady,
  () => console.log("place2IsReady") );
listen(
  () => fromObj.place2IsReady === "done",
  () => console.log("formObj.place2IsReady done!") );

console.log("Listening...");

// test change variables with listeners
setTimeout(() => place2IsReady = true, 1000);
setTimeout(() => fromObj.done(), 3000);

function changeListenerFactory() {
  const readyListener = (condition, callback, delay) => {
    if (!condition || typeof condition !== "function") { return true; }
    if (condition()) {
      return callback();
    }
    setTimeout(() => readyListener(condition, callback, delay), delay);
  };

  return (condition, callback = () => {}, delay = 250) =>
    readyListener(condition, callback, delay);
}

Or maybe using a Proxy (with a set trap) works for you

const readyState = new Proxy({ ready: false }, {
  set (target, prop, val) {
    console.log(`readyState.ready changed from ${target[prop]} to ${val}`);
    target[prop] = val;
  }
});

console.log("Waiting for changes ...");
setTimeout(() => readyState.ready = true, 2000);

A: Assuming you can replace place2IsReady with an object:
place2IsReady = {
  state: false,
  set ready(value) {
      this.state = value
      state && place_1_call()
  },
  get ready() {
    return state
  }
}

place_1_call = () => {
  alert('ready')
}

place2IsReady.ready = true


text:
Q: Как вывести данные одним списком?
if mys6:
    for row in mys6:
        vkk = row['vk']
        fracc = row['ID']
        if fracc == 'test':
            PEER_ID: int = 2000000013
            vk.messages.send(
                random_id=get_random_id(),
                peer_id=PEER_ID,
                message='\n'.join([f"Уважаемые! {vkk}, {qqwe}."])
            )
        else:
            pass
    else:

Мне нужно вывести в одно сообщение:
Уважаемые! @idvk, @idvk2, idvk3 и т.д.

Как это сделать?


text:
Q: Searching always returns empty list in MVC? I'm trying to implement filtering in a page that contains some data, the page shows three different entities: Branches, Items and Categories, so I used a view model:
   public class WarehouseData
    {
        public IEnumerable<Item> Items { get; set; }
        public IEnumerable<Category> Categories { get; set; }
        public IEnumerable<Branch> Branches { get; set; }
    }

in the controller:
public ActionResult Index(string sort, string search)
        {
            var warhouse = new WarehouseData();
            warhouse.Items = db.Items.Include(c => c.Categories).ToList();
            warhouse.Branches = db.Branches;
            ViewBag.Search = search;

            warhouse.Branches = db.Branches.ToList();
            switch (sort)
            {
                case "q_asc":
                    warhouse.Items = warhouse.Items.OrderBy(c => c.Quantity).ToList();
                    ViewBag.Sort = "q_desc";
                    break;
                case "q_desc":
                    warhouse.Items = warhouse.Items.OrderByDescending(c => c.Quantity).ToList();
                    ViewBag.Sort = "q_asc";
                    break;
                default:
                    warhouse.Items = warhouse.Items.OrderBy(c => c.Name).ToList();
                    ViewBag.Sort = "q_asc";
                    break;
            }

            if (!string.IsNullOrEmpty(search))
            {
                warhouse.Items = warhouse.Items.Where(i => i.Name.Contains(search)).ToList();
                ViewBag.Search = search;
            }
            return View(warhouse);
        }

this is the Index view:
@model WarehouseManagementMVC.ViewModels.WarehouseData

@{
    ViewBag.Title = "Index";
}

Registered Branches |
 @Html.ActionLink("Add New Branch", "Create", controllerName: "Branch")
@foreach (var branch in Model.Branches)
{

@Html.ActionLink(branch.Location, "Details", "Branch", routeValues: new { id = branch.Id }, htmlAttributes: null)

}

All Items Available

    @using (@Html.BeginForm("Index", "Warehouse", FormMethod.Get))
    {
        <input type="text" name="search" value="@ViewBag.Search"/>
        <input type="submit" value="Filter" />
    }

        Product
        @Html.ActionLink("Quantity", "Index", new { sort = ViewBag.Sort, search = ViewBag.Search })
        Categories

    @foreach (var item in Model.Items)
    {

                @Html.ActionLink(item.Name, "Details", "Item", routeValues: new { id = item.Id }, htmlAttributes: null)

                @item.Quantity

                @{foreach (var cat in item.Categories)
                    {
                        @cat.Name

                    }
                }

    }

But when I search, the result is always empty list, why?

A: There's only two things that would cause Items to be empty here:

*

*There's no items in the DB.

*None of those items have Name values that contain the search term. Be advised in particular here that Contains is case-sensitive. So if the name is Foo and you searched for foo it will not match. If you want to do case-insensitive search, then you should cast both Name and search to either lowercase or uppercase before comparing:
Where(m => m.Name.ToLower().Contains(search.ToLower()))

While we're here. A search should ideally filter at the database level. Currently, you're selecting all items in the database and then filtering them in-memory, which is highly-inefficient. As soon as you you call ToList() in the second line of the action, the query has been sent, but you have to do so in order to set warhouse.Items. Instead, you should store your items in a temporary variable, i.e. IQueryable items = db.Items.Include(c => c.Categories); and do all your conditional ordering and filtering on that. Then, finally, set warhouse.Items = items.ToList();.

A: I found that the search is case sensitive, this solved it:
    if (!string.IsNullOrEmpty(search))
    {
        warhouse.Items = warhouse.Items.Where(i => i.Name.ToLower().Contains(search.ToLower())).ToList();
        ViewBag.Search = search;
    }

If you have another suggestion for the code , I appreciate sharing it.


text:
Q: Salesforce Guest User failing invokePostMessage Context: I am trying to send a slack message when we receive survey response. A survey link is send to the users, the users can fill up the survey back (no need of login). I created a process builder around the object survey response to send notification  to slack using Apex class Slack Post Message.
I see the Apex job failing with error submitted by Guest user as    First error: Attempt to de-reference a null object   from Apexclass invokePostMessage.


text:
Q: Optmizing r to java call in rserve I am facing a problem while performing optimization using lpSolveAPI in R and Java on a large dataset.
I tried Rserve,RCaller,JRI,Renjin and found that Rserve is what actually suits my need. RCaller has a functionality that has allows to run all the r commands as a batch, but after that the context is lost.In Renjin the lpSolveAPI support is still under development.I also tried Rglpk package in R but the tuning options provided are limited compared to Rglpk.
The loop which is taking a lot of time is as shared below, the eval and assign statements are taking up a majority of run time.
The number of times the loop1 repeats is 300 - more than 3000, similarly loop2 & loop3(depends on input ).
The assign and eval statements cannot be avoided as it is part of the  logic.
Is there something to boost the performance of this loop, or  another library to be used so that the code can be evaluated after the loop is completed(kind of a batch run). Just to get an idea of things – the program with an input of 1000 records completes in 3hrs, and an input of 2000 records is taking more than a day and is getting stuck not sure if it will complete.
for( : loop1){
    for ( : loop2) {
        rconn.assign("constraint");
        if ( condition ){
            rconn.voidEval("constraint");
        }else{
            rconn.assign("constraint");
        }
        if( condition ){
            rconn.voidEval("constraint");
        }else{
            rconn.voidEval("constraint");
        }
    }
    for( : loop3) {
        rconn.assign("constraint");
        if ( condition ){
            rconn.voidEval("constraint");
        }else{
            rconn.assign("constraint");
        }
        if(condition){
            rconn.voidEval("constraint");
        }else{
            rconn.voidEval("constraint");
        }
        rconn.eval("constraint").asStrings();
    }
    for (String[] item : map.values()){
        rconn.assign("constraint",item);
        rconn.voidEval("constraint");
    }
}


text:
Q: What does it mean "Distance between $k$-planes induced by the identification plane-projection matrix"? I'm reading some parts of Functions of bounded variation and free discontinuity problems by Ambrosio, Fusco, Pallara.
At the very beginning of page 82 there's written "Let $G_k$ be the complete metric space of unoriented $k$-planes on $\mathbb R^n$, with the metric $d(\pi,\pi')=|\pi-\pi'|$ coming from the identification plane-projection matrix."
So we want to define a distance between $k$-planes in $\mathbb R^n$, but I don't understand what "metric coming from plane-projection matrix" means.
It is probable that this definition is written somewhere in the book and I've missed it, but I can't find it.
Could it be something like this:
$$d(\pi,\pi')=\inf \{|x-\pi(x)|:x\in \pi'\}$$ (by $\pi(x)$ I mean the orthogonal projection of $x$ on $\pi$)?

A: This is similar to the Grassmann metric, discussed here.  The idea is to define the distance between planes as the distance between the projection operators onto their shifted subspaces, using the operator norm.  Recall that a $k$-plane is just a shifted subspace, i.e. $\pi$ is of the form $W+a$ where $W$ is some $k$-dimensional subspace.  We then define
$$
d(\pi,\pi^\prime) = \|P_W-P_{W^\prime}\|
$$  Here $P_W,\;P_{W^\prime}$ are the projections onto to the $k$-dimensional subspaces $W=\pi-a$ and $W^\prime = \pi^\prime-a^\prime$, respectively.  This isn't particularly clear from their notation.
Here's a bad picture illustrating the idea:

You project points onto the two (shifted) planes, then find the largest that this can be.  This picture isn't quite right because the planes should intersect the sphere, i.e. the projection points should be on the sphere.  You're esstially finding the Hausdorff distance of the intersection of these subspaces with the unit sphere -  see also this mathoverflow post.


text:
Q: ¿Por que obtengo el error NullPointerException en prueba unitaria con Junit? Tengo el siguiente servicio en Java que consulta a una BD a través de dos parémetros (fecha de inicio y final), este servicio manda a llamar al  método validacionCampos() de una clase Util y lo que necesito es crear las pruebas unitarias para cubrir la mayor parte del Código desarrollado.
Clase ServiceImpl
@Override
public ResponseEntity<?> consultarReportes(Integer fechaInicio, Integer fechaFin) throws Exception {
    Map<String, Object> response = new HashMap<>();
    List<EntityDa> consultarReporte = new ArrayList<EntityDa>();
    try {
        consultarReporte = bitacoraRepository
                .consultarBitacoras(fechaInicio, fechaFin);
        reporteUtil.validacionCampos(consultarReporte);

    } catch (Exception e) {
        LOGGER.error("An error ocurred looking for Entity Data");
        response.put("success", false);
        response.put("error", e.getMessage());
        return new ResponseEntity<Map<String, Object>>(response, HttpStatus.INTERNAL_SERVER_ERROR);
    }
    response.put("success", true);
    response.put("data", consultarReporte);
    return new ResponseEntity<>(response, HttpStatus.OK);
}

Clase Util
private static final String DECIMAL = "0.0000";

        public List<EntityDa> validacionCampos(List<EntityDa> lista) {
        for (EntityDa details : lista) {
            if (details.getRango() == null || details.getRango().equals("0")) {
                details.setRango(DECIMAL);
            }
            if (details.getPrima() == null || details.getPrima().equals("0")) {
                details.setPrima(DECIMAL);
            }
        }
        return lista;
        }

Tengo la siguiente prueba para cubrir las validacion de los campos null de la clase util, pero me manda un NullPointerException en la linea claseUtil.validacionCampos(list);
    @AutoConfigureMockMvc
    @SpringBootTest
    public class ClaseTest {

    @Autowired
    ClaseUtil claseUtil;

    @Test
    public void prepare() throws Exception {
        EntityDa entity = new EntityDa();
        entity.setRango(null);
        entity.setPrima(null);

        List<EntityDa> list = new ArrayList<EntityDa>();
        list.add(entity);

        claseUtil.validacionCampos(list);

    }
    }

alguien sabe por que manda en NullPointer?
o como debe ser el método para probar la clase util?