text:
Q: OCI runtime exec failed: exec failed: unable to start container process: open /dev/pts/0: operation not permitted: unknown I have read many links similar to my issue, but none of them were helping me to resolve the issue.
Similar Links:

*

*Failed to exec into the container due to permission issue after executing 'systemctl daemon-reload'

*OCI runtime exec failed: exec failed: unable to start container process: open /dev/pts/0: operation not permitted: unknown

*CI runtime exec failed: exec failed: unable to start container process: open /dev/pts/0: operation not permitted: unknown

*OCI runtime exec failed: exec failed: unable to start container process: open /dev/pts/0: operation not permitted: unknown

*Fail to execute docker exec

*OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "open /proc/self/fd: no such file or directory": unknown
Problem Description:
I have created a new Kubernetes cluster using Kubespray. When I wanted to execute some commands in one of containers I faced to the following error:
Executed Command
kubectl exec -it -n rook-ceph rook-ceph-tools-68d847b88d-7kw2v -- sh

Error:

OCI runtime exec failed: exec failed: unable to start container process: open /dev/pts/1: operation not permitted: unknown
command terminated with exit code 126

I have also logged in to the node, which runs the pod, and try executing the container using docker exec command, but the error was not changed.
Workarounds:

*

*As I have found, the error code (126) implies that the permissions are insufficient, but I haven't faced this kind of error (like executing sh) in Docker or Kubernetes.

*I have also checked whether SELinux is enabled or not (as it has been said in the 3rd link).
apt install policycoreutils
sestatus
# Output
SELinux status:                 disabled

*In the 5th link, it was said to check whether you have updated the kernel, and I didn't upgrade anything on the nodes.
id; stat /dev/pts/0
# output
uid=0(root) gid=0(root) groups=0(root)
  File: /dev/pts/0
  Size: 0               Blocks: 0          IO Block: 1024   character special file
Device: 18h/24d Inode: 3           Links: 1     Device type: 88,0
Access: (0600/crw-------)  Uid: (    0/    root)   Gid: (    5/     tty)
Access: 2022-08-21 12:01:25.409456443 +0000
Modify: 2022-08-21 12:01:25.409456443 +0000
Change: 2022-08-21 11:54:47.474457646 +0000
 Birth: -

*Also tried /bin/sh instead of sh or /bin/bash, but not worked and the same error occurred.
Can anyone help me to find the root cause of this problem and then solve it?

A: This issue may relate to docker, first drain your node.
kubectl drain <node-name>

Second, SSH to the node and restart docker service.
systemctl restart docker.service

At the end try to execute your command.

A: I have found the root cause after about 3 months. Kubespray has been used to install the cluster. Kubespray has a strange bug when installing OCI (in my case Docker). The configuration for Docker is not applied, and the changes are not applied properly. @xirehat suggested restarting Docker as a solution to the Kubespray problem.


text:
Q: What does "to stub" mean in programming? For example, what does it mean in this quote?

Integrating with an external API is almost a guarantee in any modern web app. To effectively test such integration, you need to stub it out. A good stub should be easy to create and consistently up-to-date with actual, current API responses. In this post, we'll outline a testing strategy using stubs for an external API.

A: Layman's terms, it's dummy data (or fake data, test data...etc.) that you can use to test or develop your code against until you (or the other party) is ready to present/receive real data. It's a programmer's "Lorem Ipsum".
Employee database not ready? Make up a simple one with Jane Doe, John Doe...etc.
API not ready? Make up a fake one by creating a static .json file containing fake data.

A: This phrase is almost certainly an analogy with a phase in house construction — "stubbing out" plumbing. During construction, while the walls are still open, the rough plumbing is put in. This is necessary for the construction to continue. Then, when everything around it is ready enough, one comes back and adds faucets and toilets and the actual end-product stuff. (See for example How to Install a Plumbing Stub-Out.)
When you "stub out" a function in programming, you build enough of it to work around (for testing or for writing other code). Then, you come back later and replace it with the full implementation.

A: You have also a very good testing frameworks to create such a stub.
One of my preferrable is Mockito There is also EasyMock and others... But Mockito is great you should read it - very elegant and powerfull package

A: RPC Stubs

*

*Basically, a client-side stub is a procedure that looks to the client as if it were a callable server procedure.

*A server-side stub looks to the server as if it's a calling client.

*The client program thinks it is calling the server; in fact, it's calling the client stub.

*The server program thinks it's called by the client; in fact, it's called by the server stub.

*The stubs send messages to each other to make the RPC happen.

Source

A: "Stubbing-out a function means you'll write only enough to show that the function was called, leaving the details for later when you have more time."
From: SAMS Teach yourself C++, Jesse Liberty and Bradley Jones

A: In this context, the word "stub" is used in place of "mock", but for the sake of clarity and precision, the author should have used "mock", because "mock" is a sort of stub, but for testing. To avoid further confusion, we need to define what a stub is.
In the general context, a stub is a piece of program (typically a function or an object) that encapsulates the complexity of invoking another program (usually located on another machine, VM, or process - but not always, it can also be a local object). Because the actual program to invoke is usually not located on the same memory space, invoking it requires many operations such as addressing, performing the actual remote invocation, marshalling/serializing the data/arguments to be passed (and same with the potential result), maybe even dealing with authentication/security, and so on. Note that in some contexts, stubs are also called proxies (such as dynamic proxies in Java).
A mock is a very specific and restrictive kind of stub, because a mock is a replacement of another function or object for testing. In practice we often use mocks as local programs (functions or objects) to replace a remote program in the test environment. In any case, the mock may simulate the actual behaviour of the replaced program in a restricted context.
Most famous kinds of stubs are obviously for distributed programming, when needing to invoke remote procedures (RPC) or remote objects (RMI, CORBA). Most distributed programming frameworks/libraries automate the generation of stubs so that you don't have to write them manually. Stubs can be generated from an interface definition, written with IDL for instance (but you can also use any language to define interfaces).
Typically, in RPC, RMI, CORBA, and so on, one distinguishes client-side stubs, which mostly take care of marshaling/serializing the arguments and performing the remote invocation, and server-side stubs, which mostly take care of  unmarshaling/deserializing the arguments and actually execute the remote function/method. Obviously, client stubs are located on the client side, while sever stubs (often called skeletons) are located on the server side.
Writing good efficient and generic stubs becomes quite challenging when dealing with object references. Most distributed object frameworks such as RMI and CORBA deal with distributed objects references, but that's something most programmers avoid in REST environments for instance. Typically, in REST environments, JavaScript programmers make simple stub functions to encapsulate the AJAX invocations (object serialization being supported by JSON.parse and JSON.stringify). The Swagger Codegen project provides an extensive support for automatically generating REST stubs in various languages.

A: A stub is a controllable replacement for an Existing Dependency (or collaborator)
in the system. By using a stub, you can test your code without
dealing with the dependency directly.
External Dependency - Existing Dependency:
It is an object in your system that your code
under test interacts with and over which you have no control. (Common
examples are filesystems, threads, memory, time, and so on.)
Forexample in below code:
public void Analyze(string filename)
    {
        if(filename.Length>8)
        {
            try
            {
                errorService.LogError("long file entered named:" + filename);
            }
            catch (Exception e)
            {
                mailService.SendEMail("admin@hotmail.com", "ErrorOnWebService", "someerror");
            }
        }
    }

You want to test mailService.SendEMail() method, but to do that you need to simulate an Exception in your test method, so you just need to create a Fake Stub errorService object to simulate the result you want, then your test code will be able to test mailService.SendEMail() method. As you see you need to simulate a result which is from an another Dependency which is ErrorService class object (Existing Dependency object).

A: A stub, in this context, means a mock implementation.
That is, a simple, fake implementation that conforms to the interface and is to be used for testing.

A: Stub is a function definition that has correct function name, the correct number of parameters and produces dummy result of the correct type.
It helps to write the test and serves as a kind of scaffolding to make it possible to run the examples even before the function design is complete

A: Stub is a piece of code which converts the parameters during RPC (Remote procedure call).The parameters of RPC have to be converted because both client and server use different address space. Stub performs this conversion so that server perceive the RPC as a local function call.

A: A stub can be said as a fake substitute of the original function, which gives output, which is not accessible right now because of reasons:

*

*It is not developed right now

*It is not callable from the current environment (maybe testing)

A stub has :

*

*Exact number of parameters

*Exact output format (not necessarily correct output)

Why a stub is used?
When function is not accessible in an environment such as testing, or when its implementation is not available.
Example:
let's say you want to test a function in which there's a network call. While testing the code, you cannot wait for a network call's result for your test. so you write a mock output of the network call and proceed with your test.
TestFunction(){
  // Some things here

  // Some things here

  var result = networkCall(param)

  // something depending on the result
}

This networkCall gives out lets say a string, so you have to create a function with exact same parameters and it should give string output.
String fakeNetworkCall(int param){
  if(param == 1) return "OK";
  else return "NOT OK";
}

Now you have written a fake function, use this as replacement in your code
TestFunction(){
  // Some things here

  // Some things here

  var result = fakeNetworkCall(param)

  // something depending on the result
}

This fakeNetworkCall is a stub.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Superscripts in Chat? Can there be support for superscripting in SO chat? Possibly with a syntax such as:
^^text^^

For example:
My birthday is On the 27^^th^^ of February

or
Teh Internetz^^TM^^

It will be quite awesome. Thanks.

A: Just use the well-known Unicode transforms:
tr[+−=()0123456789AaÆᴂɐɑɒBbcɕDdðEeƎəɛɜɜfGgɡɣhHɦIiɪɨᵻɩjJʝɟKklLʟᶅɭMmɱNnɴɲɳŋOoɔᴖᴗɵȢPpɸrRɹɻʁsʂʃTtƫUuᴜᴝʉɥɯɰʊvVʋʌwWxyzʐʑʒꝯᴥβγδθφχнნʕⵡ]
  [⁺⁻⁼⁽⁾⁰¹²³⁴⁵⁶⁷⁸⁹ᴬᵃᴭᵆᵄᵅᶛᴮᵇᶜᶝᴰᵈᶞᴱᵉᴲᵊᵋᶟᵌᶠᴳᵍᶢˠʰᴴʱᴵⁱᶦᶤᶧᶥʲᴶᶨᶡᴷᵏˡᴸᶫᶪᶩᴹᵐᶬᴺⁿᶰᶮᶯᵑᴼᵒᵓᵔᵕᶱᴽᴾᵖᶲʳᴿʴʵʶˢᶳᶴᵀᵗᶵᵁᵘᶸᵙᶶᶣᵚᶭᶷᵛⱽᶹᶺʷᵂˣʸᶻᶼᶽᶾꝰᵜᵝᵞᵟᶿᵠᵡᵸჼˤⵯ];

That way you can have 1ˢᵗ 2ⁿᵈ 3ʳᵈ 4ᵗʰ without needing HTML's clumsy 1st 2nd 3rd 4th.
Wouldn't you rather enter 1ˢᵗ 2ⁿᵈ 3ʳᵈ 4ᵗʰ than 1st 2nd 3rd 4th? I know I sure would. Even my eyes hurt looking at all the typing needed for the HTML tag-in tag-out sequences.
Plus the font's superiors always look better than the HTML jiggery. HTML superscripts usually screw up the linespacing, but the font's superiors are guaranteed to never do that.


text:
Q: JSONB performance degrades as number of keys increase I am testing the performance of jsonb datatype in postgresql. Each document will have about 1500 keys that are NOT hierarchical. The document is flattened. Here is what the table and document looks like.
create table ztable0
(
   id serial primary key,
   data jsonb
)

Here is a sample document:
{ "0": 301, "90": 23, "61": 4001, "11": 929} ...

As you can see the document does not contain hierarchies and all values are integers. However, Some will be text in the future.

*

*Rows: 86,000

*Columns: 2

*Keys in document: 1500+

When searching for a particular value of a key or performing a group by the performance is very noticeably slow. This query:
select (data ->> '1')::integer, count(*) from ztable0
group by (data ->> '1')::integer
limit 100

took about 2 seconds to complete. Is there any way to improve performance of jsonb documents.

A: This is a known issue in 9.4beta2, please, have a look at this blog post, it contains some details and pointers to the mail threads.
About the issue.
PostgreSQL is using TOAST to store data values, this means that big values (typically round 2kB and more) are stored in the separate special kind of table. And PostgreSQL also tries to compress the data, using it's pglz method (been there for ages). By "tries" it means that before deciding to compress data, first 1k bytes are probed. And if results are not satisfactory, i.e. compression gives no benefits on the probed data, decision is made not to compress.
So, initial JSONB format stored a table of offsets in the beginning of it's value. And for values with high number of root keys in JSON this resulted in first 1kB (and more) being occupied by offsets. This was a series of distinct data, i.e. it was not possible to find two adjacent 4-byte sequences that'd be equal. Thus no compression.
Note, that if one would pass over the offset table, the rest of the value is perfectly compressable.
So one of the options would be to tell to the pglz code explicitly wether compression is applicable and where to probe for it (especially for the newly introduced data types), but existing infrastructure doesn't supports this.
The fix
So decision was made to change the way data is stored inside the JSONB value, making it more suitable for pglz to compress. Here's a commit message by Tom Lane with the change that implements a new JSONB on-disk format. And despite the format changes, lookup of a random element is still O(1).
It took around a month to be fixed though. As I can see, 9.4beta3 had been already tagged, so you'll be able to re-test this soon, after the official announcement.
Important Note: you'll have to do pg_dump/pg_restore exercise or utilize pg_upgrade tool to switch to 9.4beta3, as fix for the issue you've identified required changes in the way data is stored, so beta3 is not binary compatible with beta2.


text:
Q: MySQL polymorphic join condition with OR not using index I have tables departments, employees, and emails in MySQL 5.6.17 (for a Rails app). Each department has many employees, and both departments and employees have many emails. I want to sort departments by the number of emails to the entire department and individual employees within the department. My attempt:
SELECT departments.*, COUNT(DISTINCT employees.id) AS employees_count, COUNT(DISTINCT emails.id) AS emails_count
    FROM departments
    LEFT OUTER JOIN employees
        ON employees.department_id = departments.id AND employees.is_employed = true
    LEFT OUTER JOIN emails
        ON (emails.emailable_id = departments.id AND emails.emailable_type = 'department')
            OR (emails.emailable_id = employees.id AND emails.emailable_type = 'employee')
    GROUP BY departments.id
    ORDER BY emails_count DESC
    LIMIT 20;

Unfortunately, this query takes over 3 minutes to complete. Since this query will be used in a web interface, that's not a workable timeframe. An EXPLAIN gives:
+----+-------------+-------------+-------+-------------------------------------------------+----------------------------------+---------+-------------------------------+-------+------------------------------------------------+
| id | select_type | table       | type  | possible_keys                                   | key                              | key_len | ref                           | rows  | Extra                                          |
+----+-------------+-------------+-------+-------------------------------------------------+----------------------------------+---------+-------------------------------+-------+------------------------------------------------+
|  1 | SIMPLE      | departments | index | PRIMARY                                         | PRIMARY                          | 4       | NULL                          | 37468 | Using where; Using temporary; Using filesort   |
|  1 | SIMPLE      | employees   | ref   | index_employees_on_department_id                | index_employees_on_department_id | 5       | development_db.departments.id |     5 | Using where                                    |
|  1 | SIMPLE      | emails      | ALL   | index_emails_on_emailable_id_and_emailable_type | NULL                             | NULL    | NULL                          | 10278 | Range checked for each record (index map: 0x2) |
+----+-------------+-------------+-------+-------------------------------------------------+----------------------------------+---------+-------------------------------+-------+------------------------------------------------+

The index on emails is, then, not being used. This index is used successfully when I join emails only to departments or only to employees, but not with both at once.
Why is this? What can I do about this? Is there a more efficient way to query the desired data?

A: It might help to do the aggregation first before the joins:
SELECT d.*, e.employees_count, em.emails_count
FROM d LEFT OUTER JOIN
     (SELECT e.department_id, count(*) as employees_count
      FROM employees e
      WHERE e.is_employed = true
      GROUP BY e.department_id
     ) e
     ON e.department_id = d.id LEFT OUTER JOIN
     (SELECT department_id, count(distinct id) as emails_count
      FROM (SELECT em.emailable_id as department_id, em.id
            FROM emails em
            WHERE em.emailable_type = 'department'
            UNION ALL
            SELECT e.department_id, em.id
            FROM emails em JOIN
                 employees e
                 ON em.emailable_id = e.id AND em.emailable_type = 'employee'
           ) ee
      GROUP BY department_id
     ) em
     ON em.department_id = d.id LEFT OUTER JOIN
ORDER BY emails_count DESC
LIMIT 20;

You also want an index on emails(emailable_id, emailable_type, id) and on emails(emailable_type, emailable_id, id).


text:
Q: Exempt several site folders from forced https:// A year ago I managed to figure out what to add to .htaccess to force https:// on my site.  I thought it was working. (Green code)
Last week, however, I noticed that some pages were still coming up as http://
I had someone "fix" it.  They added the blue code. And, yes, all pages are now coming up as https://. BUT, the four URLs in the original code that we don't want to be forced to https are now being forced to https://
Is there a simple way to modify the blue code so that the four folders are not forced to https// ??[
I tried moving the four RewriteCond {REQUEST_URI} lines from the green to blue section, but that didn't help.
And, I can safely remove the original code now, right?

A: RewriteCond rules are processed as a conjunction (a set of and expressions) up to the RewriteRule directive.

The RewriteCond directive defines a rule condition. One or more RewriteCond can precede a RewriteRule  directive. The following rule is then only used if both the current state of the URI matches its pattern, and if these conditions are met.

Therefore, they need to be placed before the RewriteRule:
RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond ...
RewriteCond ...
RewriteCond ...
RewriteCond ...
RewriteRule ^(.*)$ https://example.com%{REQUEST_URI} [E=UPGRADE,L,R=301]


text:
Q: Is there an issue with this RTF sample? I am doing an override of RichTextBox to tell it to use the newest RTF assembly available.  I have RTF which displays well in MS word.  The same RTF is mal-aligned in a table when viewed in my custom RichTextBox.
Example

Is there any issue with this RTF formatting that will cause this to occur?
{\rtf1\ansi\deff0{\fonttbl{\f0 Arial;}{\f1 Courier New;}}\viewkind4\uc1\pard\lang1033\f0\fs20
{\pard\f0\ul\b Fingerstick Glucose\b0 : Collected: 8/29/2012 5:44:00 AM\ulnon\f0\par}
\par\pard\lang1033\f0\fs20
{\trowd
\cellx4000
\cellx9500
 Fingerstick Glucose\intbl\cell
 125 mg/dL\intbl\cell
\row}

}
UPDATE
This greatly simplified RTF has the same issue.  "cell 1" floats above and out of the table.
{\rtf1\ansi\deff0
\trowd
\cellx1000
\cellx2000
\cellx3000
cell 1\intbl\cell
cell 2\intbl\cell
cell 3\intbl\cell
\row
}

A: \intbl needs to come before the text.
{\rtf1\ansi\deff0
\trowd
\cellx1000
\cellx2000
\cellx3000
\intbl cell 1\cell
\intbl cell 2\cell
\intbl cell 3\cell
\row
}


text:
Q: Посадка на bitrix нестандартных сайтов Нашёл следующий нестандартный шаблон
Как осуществить вёрстку этой темы с учётом того, что хэдер и футер разделены на несколько частей и идут вперемешку с контентом (это не как обычный шаблон в виде простой последовательности хедер - контент - футер, а перемешанный). CMS будет либо WordPress, либо 1С Битрикс.
Хедер и футер статические, а контент динамический.


text:
Q: AWS Aurora - adding error logs to Cloudwatch? (errorlog) I know you can export Aurora's audit logs to Cloudwatch, but I don't see any way to do that for the error logs/errorlog. That would enable us to set up a Cloudwatch alarm for failed scheduled events, etc. Am I just missing it?
It looks like they support it for MySQL RDS, but not Aurora.
I already have code that will query the error log files, but being able to set up an alert would make more sense (plus I wouldn't scan the logs every x minutes).

A: The AWS doc does not provide any info about this in the English page but it does in the French page.
Please see the link here.
Then you could translate thanks to Chrome.

*

*Publication logs of Aurora MySQL in CloudWatch Logs with AWS management Consoles.
You can publish logs of Aurora MySQL in CloudWatch Logs by the way of the console. To publish newspapers Aurora MySQL from the console :

*

*Open the console Amazon RDS to the address https://console.aws.amazon.com/rds/

*In the shutter of navigation, choose Clusters.

*Choose the cluster of database Aurora MySQL whose data of logs you want to publish.

*For Actions, choose  Modify the cluster.

*In the section Exports of logs, choose the logs which you want to begin to publish into CloudWatch Logs.

*Choose Continue, then Modify DB Cluster on the recapitulative page.


text:
Q: Iphone Coreplot I am new to the iPhone development can anybody help me to draw curve chart in iPhone using only three values
-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot
{
    NSLog(@"Array1-->%@",Array1);
    return [Array1 count];
}

-(NSNumber *)numberForPlot:(CPPlot *)plot
                     field:(NSUInteger)fieldEnum
               recordIndex:(NSUInteger)index
{
    NSLog(@"Array1-->%@",Array1);
    NSLog(@"marks1-->%@",marks1);

    if(fieldEnum == CPScatterPlotFieldX)
    {
        return [Array1 objectAtIndex:index];
    }
    else
    {
        if(plot.identifier == @"X Squared Plot")
        {
            return [marks1 objectAtIndex:index];
        }
    }
}

iploted curve chart using above code but i have many values in each array.. but i want plot using only three values in each array.

A: Replace the following code:
-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot{
    NSLog(@"Array1-->%@",Array1);
    return [Array1 count];
    //return 50;
}

with the following one:
-(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot{
    NSLog(@"Array1-->%@",Array1);
    return 3;
}

Hope this helps!


text:
Q: Optimal data structure for binary data/Java I have several input formats mostly restricted to geotiff and some proprietary binary formats. I import them into my program and then need to export them into various other data formats (also binary) but as two dimensional arrays.
Currently I hold the data after importing them into my program as a byte array. I also need to perform search and replace on element of this data. Is the byte array the best data structure  for this sort of application ?
Summary - all of my input formats are binary(geotiff and proprietary) and all of my export formats are binary(two dimensional arrays). In between import and export I need to do some search and replace. Is byte array the best data structure for this sort of application ?


text: Q: How to make pdf show current date? Is there a way to make a pdf show the current date (not the date when it was compiled, but when it was opened/printed)? I'm making some sign sheets and it would be great if I could put the date in there instead of requiring people to fill it in manually -- but recompiling the file every time just to get the date in there is absolutely stupid. I've been trying to use JavaScript for this (with AcroTeX), but I wasn't successful; clearly my JS skills have got somewhat rusty since I last used it (12 years ago).


text:
Q: Print function in my DoublyLinkedList creates duplicates. C++ basically my print function will print out the contents when i only have one Player object inserted into my list.  But when i insert another object, it adds it but the first element inserted has been overwritten.  I have tested my insert and append functions and i dont believe it is to do with these functions.  I think the print function is printing the last entered firstName,lastName,level and exp by the number of nodes in the list.
Here is my code:
Stats.cpp
#include "Stats.h"
#include <iostream>
#include "Validators.h"
using namespace std;

Validators validators2;

Stats::Stats()
{
    firstName = "";
    secondName = "";
    level = 0;
    experience = 0;
}
Stats::Stats(string firstName,string secondName, int level, int experience)
{
    firstName = firstName;
    secondName = secondName;
    level = level;
    experience = experience;

}
    string Stats :: getFirstName()
    {
        return firstName;
    }
    string Stats :: getSecondName()
    {
        return secondName;
    }
    int Stats :: getLevel()
    {
        return level;
    }
    int Stats :: getExperience()
    {
        return experience;
    }
    Stats Stats :: input()
    {
        string inputfirstName = "Please enter the First Name: ";
        firstName = validators2.getString(inputfirstName);
        string inputSecondName = "Please enter the Second Name: ";
        secondName = validators2.getString(inputSecondName);
        cout<< "Please enter the level: ";
        level = validators2.getNum();
        cout<< "Please enter the experience: ";
        experience = validators2.getNum();

        Stats s1(firstName,secondName,level,experience);
        return s1;

    }

Main
int main ()
{
//-------------------------------------------------------------------------------------------
//  Set up a linkedList and a iterator.
//-------------------------------------------------------------------------------------------
    DoublyLinkedList<Stats> list;
    DoublyLinkedListIterator<Stats> itr = list.getIterator();
        list.Insert(itr,stats.input());
        list.print(itr);
}
//--------------------------------------------------------------------------------------------
//  Name:           DoublyLinkedList.h.
//  Description:    Header file for the use in DoublyLinkedList.cpp.
//                  A DoublyLinkedList is a dynamically growing datastructure and use's
//                  nodes and pointers in its structure.
//--------------------------------------------------------------------------------------------
#ifndef DOUBLYLINKEDLIST_H
#define DOUBLYLINKEDLIST_H

#include <iostream>
#include "Validators.h"
#include "Stats.h"

using namespace std;

Validators validators;
Stats stats;

//-------------------------------------------------------------------------------------------
//  Class Declarations.
//-------------------------------------------------------------------------------------------
template<class Datatype> class DoublyLinkedList;
template<class Datatype> class DoublyLinkedListNode;
template<class Datatype> class DoublyLinkedListIterator;
//-------------------------------------------------------------------------------------------
//  Class:  DoublyLinkedList.
//-------------------------------------------------------------------------------------------
template <class Datatype>
class DoublyLinkedList
{
public:
//-------------------------------------------------------------------------------------------
//  Member Vairables.
//-------------------------------------------------------------------------------------------
DoublyLinkedListNode<Datatype>* m_head;
DoublyLinkedListNode<Datatype>* m_tail;
int m_count;
//-------------------------------------------------------------------------------------------
//  Name:           Constructor.
//  Description:    Constructs the DoublyLinkedList.
//-------------------------------------------------------------------------------------------
DoublyLinkedList()
{
    //Sets m_head to a default value of 0.  m_head is the first node in the linkedList.
    m_head = 0;
    //Sets m_tail to a default value of 0.  m_tail is the last node in the linkedList.
    m_tail = 0;
    //Sets m_count to a default value of 0.  m_count is to count the elements in the linkedList.
    m_count = 0;
}
//-------------------------------------------------------------------------------------------
//  Name:           Destructor.
//  Description:    Deletes the DoublyLinkedList.
//-------------------------------------------------------------------------------------------
~DoublyLinkedList()
{
    //Temporary node pointer.
    DoublyLinkedListNode<Datatype>* itr = m_head;
    DoublyLinkedListNode<Datatype>* next = 0;

    while(itr != 0)
    {
        //Save the pointer to next node.
        next = itr->m_next;
        //Delete the current node.
        delete itr;
        //Make the next node the current node.
        itr = next;
    }
}
int getCount()
{
return m_count;
}
// -------------------------------------------------------------------------------------
//  Name:           Append
//  Description:    This adds a node to the end of the list, then points to the newNode
//  Arguments:      p_data - The data to store in the new node.
//                  m_count is increased.
//  Return Value:   None.
// -------------------------------------------------------------------------------------
    void Append(Datatype p_data)
    {
        if(m_head == 0)
        {
            // create a new head node.
            m_head= m_tail= new DoublyLinkedListNode<Datatype>;
            m_head->m_data= p_data;
            m_head->m_next= 0;
            m_head->m_prev= 0;
        }
        else
        {
            // insert a new node after the tail and reset the tail.
            m_tail->InsertAfter(p_data);
            m_tail= m_tail->m_next;
        }
        m_count++;
    }

//-------------------------------------------------------------------------------------------
//  Name:           Print.
//  Description:    Prints the elements from the list along with its index.
//-------------------------------------------------------------------------------------------
    void Print(DoublyLinkedListIterator<Datatype> m_itr)
    {
        for(m_itr.Start();m_itr.Valid();m_itr.Forth())
        {
            cout << "------------------Player------------------\n";
            cout << "First Name:\t\t" << stats.getFirstName() << "\n";
            cout << "Second Name:\t\t" << stats.getSecondName() << "\n";
            cout << "Level:\t\t\t" << stats.getLevel() << "\n";
            cout << "Experience:\t\t" << stats.getExperience() << "\n";
            cout << "------------------------------------------\n";
        }
    }
// ----------------------------------------------------------------------------------------------------------------
//  Name:           Insert
//  Description:    Inserts data before the iterator, this works whether the iterator is backwards of forwards
//                  through the list.Inserts at the end of the list if iterator is invalid.
//  Arguments:      p_iterator: The iterator to insert before
//                  p_data: the data to insert
//  Return Value:   None.
// ----------------------------------------------------------------------------------------------------------------
    void Insert(DoublyLinkedListIterator<Datatype>& p_itr, Datatype p_data)
    {
        if(p_itr.m_node != 0)
        {
            // insert the data before the iterator
            p_itr.m_node->InsertBefore(p_data);

            //if the iterator was at the head of the list,
            //reset the head pointer
            if(p_itr.m_node == m_head)
            {
                m_head = m_head->m_prev;
            }
            // increment the count
            m_count++;
        }
        else
        {
            Append(p_data);
        }
    }

//-------------------------------------------------------------------------------------------
//  Name:           GetIterator
//  Description:    Generates an iterator pointing towards the current head node
//  Arguments:      None.
//  Return Value:   <Datatype> Iterator
//-------------------------------------------------------------------------------------------
    DoublyLinkedListIterator<Datatype> getIterator()
    {
        return DoublyLinkedListIterator<Datatype>(this, m_head);
    }
};
//-------------------------------------------------------------------------------------------
//  Class:  DoublyLinkedNode.
//-------------------------------------------------------------------------------------------
template<class Datatype>
class DoublyLinkedListNode
{
public:
//-------------------------------------------------------------------------------------------
//  Member Vairables.
//-------------------------------------------------------------------------------------------
    DoublyLinkedListNode<Datatype>* m_next;
    DoublyLinkedListNode<Datatype>* m_prev;
    Datatype m_data;

// ----------------------------------------------------------------
//  Name:           InsertAfter
//  Description:    This adds a node after the current node.
//  Arguments:      p_data - The data to store in the new node.
//  Return Value:   None.
// ----------------------------------------------------------------
    void InsertAfter(Datatype p_data)
    {
        //Create the new node.
        DoublyLinkedListNode<Datatype>* newNode= new DoublyLinkedListNode<Datatype>;
        newNode->m_data = p_data;
        // make the new node point to the next node.
        newNode->m_next = m_next;
        newNode->m_prev = this;

        // make the node before it, point to the new node.
        //if(m_next != 0)
        //m_next->m_prev= newNode;
        m_next = newNode;
    }
// ----------------------------------------------------------------
//  Name:           InsertBefore
//  Description:    This adds a node before the current node.
//  Arguments:      p_data - The data to store in the new node.
//  Return Value:   None.
// ----------------------------------------------------------------
    void InsertBefore(Datatype p_data)
    {
        //Create new Node
        DoublyLinkedListNode<Datatype>* newNode = new DoublyLinkedListNode<Datatype>;
        newNode->m_data = p_data;
        //Set up new Node Pointers
        newNode->m_next = this;
        newNode->m_prev = m_prev;
        //if theres a node before it, make it point to new node
        if(m_prev != 0)
        m_prev = newNode;
    }
};
//-------------------------------------------------------------------------------------------
//  Class:  DoublyLinkedIterator.
//-------------------------------------------------------------------------------------------
template <class Datatype>
class DoublyLinkedListIterator
{
public:
//-------------------------------------------------------------------------------------------
//  Member Vairables.
//-------------------------------------------------------------------------------------------
    DoublyLinkedListNode<Datatype>* m_node;
    DoublyLinkedList<Datatype>* m_list;
    DoublyLinkedListIterator(DoublyLinkedList<Datatype>* p_list= 0, DoublyLinkedListNode<Datatype>* p_node= 0)
    {
        m_list= p_list;
        m_node= p_node;
    }

// ------------------------------------------------------------------
//  Name:           Start
//  Description:    Resets the iterator to the beginning of the list.
//  Arguments:      None.
//  Return Value:   None.
// ------------------------------------------------------------------
    void Start()
    {
        if(m_list!= 0)
            m_node= m_list -> m_head;
    }

// ----------------------------------------------------------------
//  Name:           End
//  Description:    Resets the iterator to the end of the list
//  Arguments:      None.
//  Return Value:   None.
// ----------------------------------------------------------------
    void End()
    {
        if(m_list!= 0)
            m_node = m_list->m_tail;
    }

// ----------------------------------------------------------------
//  Name:           Forth
//  Description:    Moves the iterator forward by one position
//  Arguments:      None.
//  Return Value:   None.
// ----------------------------------------------------------------
    void Forth()
    {
        if(m_node != 0)
        {
        m_node = m_node ->m_next;
        }
    }

// ----------------------------------------------------------------
//  Name:           Back
//  Description:    Moves the iterator backward by one position.
//  Arguments:      None.
//  Return Value:   None.
// ----------------------------------------------------------------
    void Back()
    {
        if(m_node!= 0)
            m_node = m_node->m_prev;
    }

// ----------------------------------------------------------------
//  Name:           Item
//  Description:    Gets the item that the iterator is pointing to.
//  Arguments:      None.
//  Return Value:   Reference to the data in the node.
// ----------------------------------------------------------------
    Datatype& Item()
    {
        return m_node->m_data;
    }
//-----------------------------------------------------------------
//  Name:           Valid
//  Description:    Determines if the node is valid.
//  Arguments:      None.
//  Return Value:   true if valid
// ----------------------------------------------------------------
    bool Valid()
    {
        return (m_node!= 0);
    }
};

#endif

A: Is this really the code?
Stats::Stats(string firstName,string secondName, int level, int experience)
{
    firstName = firstName;
    secondName = secondName;
    level = level;
    experience = experience;
}

That's just horribly, horribly wrong. You are assigning variables to themselves! Nothing happens to the object you are trying to construct!
This would work
Stats::Stats(string firstName,string secondName, int level, int experience)
{
    this->firstName = firstName;
    this->secondName = secondName;
    this->level = level;
    this->experience = experience;
}

but usually you choose parameter names that are different from your member variable names, e.g.
Stats::Stats(string fn, string sn, int lvl, int ex)
{
    firstName = fn;
    secondName = sn;
    level = lvl;
    experience = ex;
}

I'm not surprised you're getting weirdness, you've written a constructor that doesn't work, it's a pretty fundamental thing to be wrong.

A: Your print loop should look something like this
   for(m_itr.Start();m_itr.Valid();m_itr.Forth())
    {
        cout << "------------------Player------------------\n";
        cout << "First Name:\t\t" << m_itr.Item().getFirstName() << "\n";
        cout << "Second Name:\t\t" << m_itr.Item().getSecondName() << "\n";
        cout << "Level:\t\t\t" << m_itr.Item().getLevel() << "\n";
        cout << "Experience:\t\t" << m_itr.Item().getExperience() << "\n";
        cout << "------------------------------------------\n";
    }

See how it uses the iterator to get the values to print.


text:
Q: String length error - saving to database I encountered this weird error while trying to save data to database on MS Azure.

the field must be a string or array type with a maximum length of '1'

I am quite certain that I cant fix this on Azure side because I have tried all string data types (char, varchar, nchar, nvarchar, text with values like 255 or max). The string with 1 character really worked and got saved to DB.
I managed to avoid this error by setting context.Configuration.ValidateOnSaveEnabled = false; but that in not the desired solution.
I suppose that it must be specified somewhere in the code but I have no idea where the length of this string is specified and therefore how to edit it. Any help would be appreciated!


text:
Q: Vue 3 with Vuex 4 I'm using Vue 3 with the composition API and trying to understand how I can map my state from Vuex directly so the template can use it and update it on the fly with the v-model.
Does mapState works or something else to solve this issue? Right no I need to get my state by a getter, print it out in the template, and then do a manual commit for each field in my state... In Vue 2 with Vuex, I had this 100% dynamic

A: To make two-way binding between your input and store state  you could use a writable computed property using set/get methods :
setup(){
  const store=useStore()

   const username=computed({
       get:()=>store.getters.getUsername,
       set:(newVal)=>store.dispatch('changeUsername',newVal)
    })

return {username}
}

template :
<input v-model="username" />

A: I've solved it!
Helper function:
import { useStore } from 'vuex'
import { computed } from 'vue'

const useMapFields = (namespace, options) => {
const store = useStore()
const object = {}

if (!namespace) {
    console.error('Please pass the namespace for your store.')
}

for (let x = 0; x < options.fields.length; x++) {
    const field = [options.fields[x]]

    object[field] = computed({
        get() {
            return store.state[namespace][options.base][field]
        },
        set(value) {
            store.commit(options.mutation, { [field]: value })
        }
    })
}

return object
}

export default useMapFields

And in setup()
       const {FIELD1, FIELD2}  = useMapFields('MODULE_NAME', {
            fields: [
                'FIELD1',
                 etc…
            ],
            base: 'form', // Deep as next level state.form
            mutation: 'ModuleName/YOUR_COMMIT'
        })

Vuex Mutation:
    MUTATION(state, obj) {
        const key = Object.keys(obj)[0]
        state.form[key] = obj[key]
    }


text:
Q: How to make splot from Gnuplot understand that the X axis data is not in the data file? I am trying to use splot from Gnuplot to create a 3D chart. My data file has only the X (time) and Y (throughput) values but I will use multiple data files in the same splot to create it in a 3D fashion. So, in the end, X would be datafile-1, datafile-2, datafile-3, etc. Y would be the time, and Z would be the throughput.
The problem is that the X axis is not in the files. It is actually a different file. And I think that splot is understanding that the data is placed on the file. How should I configure splot to understand that I want the X axis fixed for different files? Here is my current plot with a minimal running script and files:
#!/usr/bin/gnuplot

reset session

set style line 1 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # auto-combiner input    throughput - 8combines.8reducers

set style line 9 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # auto-combiner input    throughput - 16combines.16reducers

set term pdfcairo size 5.0in,3.5in
set pointintervalbox 0
set datafile separator ','
set output "efficiency-throughput-networkbuffer-TaxiRideNYC-500K-merged-3D.pdf"
set grid
myTimeFmt = "%Y-%m-%d %H:%M:%S"
set key under center maxrows 1 horizontal
set key font ",9"

set xlabel "different topologies" font ",9" rotate by -8 right offset 10,-1,0
set xrange [0:3]
set xtics 0, 1 font ",8"
x0 = 0
x1 = 1
x3 = 2
x4 = 3

set ylabel "time (hour:minute)" font ",9" offset 1,0,0
set format y "%tH:%tM" time
set ytics font ",8" offset 0,0,0
set yrange [0:5400]

set zlabel "Throughput (K rec/sec)" font ",9" rotate by 90 right offset 3,0,0
set zrange [0:7]
set ztics nomirror font ",10"

splot t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv" u x0:(column(2)/1000):(t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0) skip 2 title "auto-combiner input throughput (8:8)" with linespoints ls 1 \
, t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-all.csv" u x1:(column(2)/1000):(t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0) skip 2 title "auto-combiner input throughput (16:16)" with linespoints ls 9 \

the data file throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv:
time,throughputINmean,throughputINstddev,throughputOUTmean,throughputOUTstddev,outPoolAvgMean,outPoolAvgStddev,outPool99thMean,outPool99thStddev
,0,0,0,0,0,0,0,0
"2020-06-07 23:45:00",1040.88,283.444,1040.88,283.439,79.1667,14.7314,77,16.2635
"2020-06-07 23:45:15",1578.69,108.016,1578.69,108.02,100,0,100,0
"2020-06-07 23:45:30",1853.13,296.748,1853.13,296.756,100,0,100,0
"2020-06-07 23:45:45",2094.84,470.787,2094.84,470.796,100,0,100,0
"2020-06-07 23:46:00",1775.97,249.804,1775.95,249.833,99.8264,0.245523,100,0
"2020-06-07 23:46:15",1459.78,24.1722,1459.76,24.2096,100,0,100,0
"2020-06-07 23:46:30",1429.39,7.10249,1429.37,7.12607,100,0,100,0
"2020-06-07 23:46:45",1425.87,18.5822,1425.84,18.6244,100,0,100,0
"2020-06-07 23:47:00",1415.67,0.0658002,1415.64,0.0481225,100,0,100,0
"2020-06-07 23:47:15",1443.3,3.15546,1443.29,3.15743,100,0,100,0
"2020-06-07 23:47:30",1439.04,0.594166,1439.02,0.60988,100,0,100,0
"2020-06-07 23:47:45",1441.54,13.7807,1441.52,13.7788,100,0,100,0
"2020-06-07 23:48:00",1433.19,12.0817,1433.16,12.1092,100,0,100,0
"2020-06-07 23:48:15",1425.33,0.860313,1425.29,0.897633,100,0,100,0
"2020-06-07 23:48:30",1419.75,19.4022,1419.71,19.4307,100,0,100,0
"2020-06-07 23:48:45",1406.29,32.193,1406.24,32.2313,100,0,100,0
"2020-06-07 23:49:00",1423.24,0.771925,1423.19,0.78371,99.6528,0.245523,100,0
"2020-06-07 23:49:15",1420.64,7.01607,1420.56,7.0092,100,0,100,0
"2020-06-07 23:49:30",1411.63,10.9091,1411.56,10.9287,100,0,100,0
"2020-06-07 23:49:45",1411.94,17.4695,1411.86,17.4822,100,0,100,0
"2020-06-07 23:50:00",1408.83,9.79343,1408.75,9.84253,100,0,100,0
"2020-06-07 23:50:15",1413.76,35.4693,1413.69,35.5449,100,0,100,0
"2020-06-07 23:50:30",1432.11,8.61099,1431.98,8.73375,100,0,100,0
"2020-06-07 23:50:45",1436.48,34.7072,1436.34,34.881,100,0,100,0

and the data file throughput-vs-networkbuffer-500K-16combiners-16reducers-all.csv:
time,throughputINmean,throughputINstddev,throughputOUTmean,throughputOUTstddev,outPoolAvgMean,outPoolAvgStddev,outPool99thMean,outPool99thStddev
,0,0,0,0,0,0,0,0
"2020-05-28 21:59:00",636.815,544.766,636.815,544.766,60,28.2843,60,28.2843
"2020-05-28 21:59:15",1021.11,247.18,1021.13,247.162,78.8542,14.9524,83.6667,11.5494
"2020-05-28 21:59:30",1415.11,41.2229,1415.1,41.2258,69.6875,21.4342,84.3333,11.078
"2020-05-28 21:59:45",1815.02,324.306,1815.02,324.306,90.4167,6.77644,91.0417,6.3345
"2020-05-28 22:00:00",2051.02,481.214,2051.02,481.218,92.2917,5.45062,97.5,1.76777
"2020-05-28 22:00:15",2003.74,446.739,2003.73,446.748,100,0,100,0
"2020-05-28 22:00:30",1844.27,342.101,1844.26,342.104,100,0,100,0
"2020-05-28 22:00:45",1672.59,222.094,1672.56,222.091,100,0,100,0
"2020-05-28 22:01:00",1489.64,98.2898,1489.64,98.2967,100,0,100,0
"2020-05-28 22:01:15",1396.23,0.577471,1396.21,0.560284,100,0,100,0
"2020-05-28 22:01:30",1379.1,1.3823,1379.09,1.37542,100,0,100,0
"2020-05-28 22:01:45",1374.07,17.6728,1374.08,17.6885,100,0,100,0
"2020-05-28 22:02:00",1383.45,33.6386,1383.44,33.647,100,0,100,0
"2020-05-28 22:02:15",1357.17,19.0992,1357.16,19.1115,100,0,100,0
"2020-05-28 22:02:30",1360.52,5.2483,1360.5,5.23259,100,0,100,0
"2020-05-28 22:02:45",1372.18,22.3451,1372.17,22.3279,100,0,100,0
"2020-05-28 22:03:00",1374.21,5.27384,1374.2,5.26009,100,0,100,0
"2020-05-28 22:03:15",1365.91,8.53979,1365.89,8.54322,100,0,100,0

A: I could make it using functions in Gnuplot. I am using the same data files above, this Gnuplot script, and the function P(x)=x for the X axis:
#!/usr/bin/gnuplot

reset session

set style line 1 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 2 pi 15 # auto-combiner input    throughput - 8combines.8reducers

set style line 9 lc rgb '#3274D9' lt 1 lw 1.0 ps 0.4 pt 1 pi 15 # auto-combiner input    throughput - 16combines.16reducers

set term pdfcairo size 5.0in,3.5in
set pointintervalbox 0
set datafile separator ','
set output "efficiency-throughput-networkbuffer-TaxiRideNYC-500K-merged-3D.pdf"
set border 127

set xyplane at 1
set grid
#set grid x y z vertical
#set grid lt 1 lw 0.75 lc "grey"
myTimeFmt = "%Y-%m-%d %H:%M:%S"
set key under center maxrows 1 horizontal
set key font ",9"

set xlabel "different topologies" font ",9" rotate by -8 right offset 10,-1,0
set xrange [0:3]
set xtics 0, 1 mirror font ",8"
P(x)=x

set ylabel "time (hour:minute)" font ",9" offset 1,0,0
set format y "%tH:%tM" time
set ytics mirror font ",8" offset 0,0,0
set yrange [0:5400]

set zlabel "Throughput (K rec/sec)" font ",9" rotate by 90 right offset 3,0,0
set zrange [0:7]
set ztics mirror font ",9"
set ticslevel 0 # We need this, in order to shift the 0 of the z axis

splot t=0 "throughput-vs-networkbuffer-500K-8combiners-8reducers-all.csv" u (P(0)):(t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 title "auto-combiner input throughput (8:8)" with linespoints ls 1 \
, t=0 "throughput-vs-networkbuffer-500K-16combiners-16reducers-all.csv" u (P(1)):(t==0?(t0=timecolumn(1,myTimeFmt),t=1):NaN, timecolumn(1,myTimeFmt)-t0):(column(2)/1000) skip 2 title "auto-combiner input throughput (16:16)" with linespoints ls 9 \


text:
Q: Протопотоки. Как использовать в обычном C99 Требуется решить проблему многозадачности.
Т.к. времени в обрез и писать что-то на asm особо не хочется...
Короче, прочитал, что псевдомногопоточность можно реализовать протопотоками.
Но примеры там не то что для чайников, а для прожженых самоваров)
Никак не пойму как сделать следующее:
Имеется структура:
struct SimpleProcess{   // Одиночный процесс

        unsigned char Priority;         // Приоритет
        unsigned char SecurityLevel;    // Уровень безопасности
        unsigned char Status;           // Статус процесса
        void(*Function)();              // Функция

    };

Так вот, нужно Function выполнить в отдельном протопотоке. Как это сделать?
Т.е. есть функции
void PrintHello(){
  while (true) printf("BEEP!\n");
}

void PrintBuy(){
      while (true) printf("OOOP!\n");
    }

Есть маин:
int main(){
  struct SimpleProcess SP[2];
  ...
  SP[1].Function = PrintHello;
  ...
  SP[2].Function = PrintBuy;
  ...
  // Запуск протопотоков
}

Сорри за примеры, пытался написать простые, чтоб разобраться проще было.
Так вот, как запихнуть первые 2е функции в протопотоки для одновременного выполнения?
И что там пишут про локальные переменные?
Возможно не смог самостоятельно разобраться из-за гугл транслейта )

A: #include <stdio.h>
#include "pt.h"

#define true    1

struct SimpleProcess
{
    unsigned char Priority;
    unsigned char SecurityLevel;
    unsigned char Status;
    struct pt Context; // Переменная для хранения контекста протопотока
    char (*Function)(struct pt *Context); // Для протопотока необходим указатель на
                                          // контекст
};

PT_THREAD(PrintHello(struct pt *Context)) // Объявление протопотока
{
    PT_BEGIN(Context);

    while (true)
    {
        printf("BEEP!\n");

        // Передача управления в main.
        // При следующем вызове этого протопотока выполнение продолжится после
        // макроса PT_YIELD.
        PT_YIELD(Context);
    }

    PT_END(Context);
}

PT_THREAD(PrintBuy(struct pt *Context)) // Объявление протопотока
{
    PT_BEGIN(Context);

    while (true)
    {
        printf("OOOP!\n");

        // Передача управления в main.
        // При следующем вызове этого протопотока выполнение продолжится после
        // макроса PT_YIELD.
        PT_YIELD(Context);
    }

    PT_END(Context);
}

int main(void)
{
    struct SimpleProcess SP[2];

    SP[0].Function = PrintHello;
    SP[1].Function = PrintBuy;

    // Инициализация контекстов
    PT_INIT(&SP[0].Context);
    PT_INIT(&SP[1].Context);

    // В бесконечном цикле вызываем протопотоки
    while (true)
    {
        for (int i = 0; i < 2; i++)
        {
            SP[i].Function(&SP[i].Context);
        }
    }

    return 1;
}

По поводу локальных переменных ничего особенного нет.
Нужно помнить, что после передачи управления с помощъю
макросов PT_... локальные переменные, расположенные в стеке
теряются. Если необходимо, чтобы локальные переменные
сохраняли свои значения между вызовами протопотока
их необходимо объявлять с использованием ключевого слова
static или использовать глобальные переменные.


text:
Q: What is an efficient BASH one-liner for adding line every 130 characters to a file without lines? I am trying to process some largish files which lack line separators.  I would like to process them with line-oriented tools like grep and sed.
I'd like to put something on the front of my pipeline that will insert a newline every 130 characters.  I'm not interested in modifying the input files.
What is an efficient BASH one-liner for adding line every 130 characters to a file without lines?

A: If you really want efficient, there is special command (part of coreutils) for this:
fold -w130 file | ...

A: I discovered the answer in the asking.  Another way to phrase this question to understand this answer is: What is an efficient BASH one-liner for reading a file without lines 130 characters at a time?
The answer is the BASH builtin read.  It is a powerful tool that is well-suited to this purpose.
cat unlined_data.txt | while read -n130 record ; do echo $record ; done # | rest of pipeline

There may be a more elegant solution and I'd be happy to see one.


text:
Q: Find guids between strings Problem:
Trying to get all matches where guid = guid. I'm expecting to receive a collection of matches where one match looks like:
{9659BAE5-632F-4195-BD5D-414C1F2C1066} = {6E298F2A-129A-4491-B053-F12D67561572}

I'm trying to match all of the guid = guid between GlobalSection(NestedProjects) = preSolution and EndGlobalSection specifically. There are other places in the file where guid = guid exists.
Here is a data snippet:
    Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Applications\", "{297BE1A3-A6A3-4835-BB87-63B4B4E2AE0D}"
        ProjectSection(ProjectDependencies) = postProject
            {A459406A-94FF-4CA9-8183-C7472419CC7D} = {A459406A-94FF-4CA9-8183-C7472419CC7D}
        EndProjectSection
    EndProject

    GlobalSection(NestedProjects) = preSolution
        {3D84A2B1-536D-4953-B331-D86E421905E7} = {AF46FD2E-710D-49CD-A203-CB0F8B7EF415}
        {02CB05EC-6902-417E-AD50-B3910B245B22} = {2F54A6F1-5D32-4673-8AEE-B845CC622D64}
        {DE303EF0-E3B1-4BA9-8CB3-544D37D29576} = {2F54A6F1-5D32-4673-8AEE-B845CC622D64}
        {5A095236-0EE1-4480-B7A6-833ECCFE4257} = {AF070137-227F-42F7-9487-00CB26C46E04}
        {6CCA189C-0D45-4E80-8486-38AB3E625E69} = {AF070137-227F-42F7-9487-00CB26C46E04}
        {EAE3152A-C003-4E39-BFB7-B4F7CACE1606} = {AF070137-227F-42F7-9487-00CB26C46E04}
        {9659BAE5-632F-4195-BD5D-414C1F2C1066} = {6E298F2A-129A-4491-B053-F12D67561572}
    EndGlobalSection
EndGlobal

What I've Tried:
Here's what I'm using to match guid = guid
{[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}} = {[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}}

This works fine except it doesn't discriminate against the location of the match, obviously. So I receive other matches from other parts of the file.
I've been trying to use a positive look behind like so (with many variations):
(?<=GlobalSection\(NestedProjects\) = preSolution(\r\n|.)+?)

Am I misusing the lookbehind or something else?

A: I tried the following regex and got correct results using your example.
(?<= GlobalSection\(NestedProjects\) = preSolution(\r\n|.)+?){[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}} = {[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}}

You may need to use RegexOptions.Multiline as an option in your regex since it is C# (if you're not already).
EDIT
I wrote a little test program with your data snippet.  I doubled it to make sure it did not just match the first group after GlobalSection(NestedProjects) = preSolution
matches only returned the GUIDs between GlobalSection(NestedProjects) = preSolution and EndGlobalSection for both sections.
The line {A459406A-94FF-4CA9-8183-C7472419CC7D} = {A459406A-94FF-4CA9-8183-C7472419CC7D} was not in the matched results as I would expect.  I hope something in this code helps you out.
    static void Main(string[] args)
    {
        string input = System.IO.File.ReadAllText(@"c:\test\directory\test.txt");

        string pattern =
            @"(?<=GlobalSection\(NestedProjects\) = preSolution(\r\n|.)+?){[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}} = {[A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12}}";
        Regex re = new Regex(pattern, RegexOptions.Multiline);

        MatchCollection matches = re.Matches(input);

        foreach (var match in matches)
        {
            Console.Write(match);
        }

    }


text:
Q: How to add dependant libraries when creating an executable file from executable jar? I created an executable jar (system.jar) which added lib folder.
How can you add the lib folder (contains datepicker.jar)  to  the system.jar when creating .exe file?
Using Launch4j and I wasn't able to add the lib folder.

A: If you are using Apache Maven you can use Maven Shade Plugin. This is explained in Selecting Contents for Uber JAR usage page.
Other build systems will have their own plugins e.g. there is shadow plugin for Gradle.

A: You can add required external jars from "classpath" tab in Launch4j.
In Main class select the executable jar (system.jar).
In class path add required jar i.e. lib\datepicker.jar


text:
Q: How to loop through full API collection by changing one number in URL I am using this API ('https://api.opensea.io/asset/0x5d00d312e171be5342067c09bae883f9bcb2003b/1/') to collect information about individual digital assets within a certain game. The '1' at the end of the URL represents the asset with token_id = 1. I am trying to get my code to collect the variables that I need for each asset and then cycle to the next - token_id = 2 which would be a '2' at the end of the URL, token_id = 3, and so on. The final asset would be token_id = 51,450.
I would like to print the results and then somehow export to excel if possible, been trying to figure that out as well. All help is appreciated, thanks!
import json
import requests

r = requests.get('https://api.opensea.io/asset/0x5d00d312e171be5342067c09bae883f9bcb2003b/1/')
EMONA_json = r.json()
EMONA_str = json.dumps(EMONA_json, indent=2)

token_id = EMONA_json['token_id']
traits = EMONA_json['traits']
owner_address = EMONA_json['owner']['address']

print(token_id, traits, owner_address)

Best case scenario - the code would print all the results into excel. Each column would include 'token_id', 'traits' (will eventually extract trait_type: class_name, level & catch_number values) and owner_address.

A: Assuming that your question is how to handle 50000+ api calls, well here goes:
Use a queue (RabbitMQ for example) which retries an event in case it fails. Create 50000 events (or maybe use batches) and sent them to the queue. A services will subscribe to this queue which will do the actual API call. This can be made in parallel. I would store resulting data in a NoSQL (key value or document), with the token_id as a hash key. Once all are done, scan that table and create the excel/csv file.

A: Here's a very simple example that will hopefully guide you to a more refined and better solution.
In order to keep things easy I output results into a csv file that you can easily import in Excel.
import json
import requests
import csv

result = {}
max_id_to_get = 3

for token_id in range(1,max_id_to_get):
    r = requests.get('https://api.opensea.io/asset/0x5d00d312e171be5342067c09bae883f9bcb2003b/{}'.format(token_id))
    EMONA_json = r.json()
    EMONA_str = json.dumps(EMONA_json, indent=2)
    token_id = EMONA_json['token_id']
    traits = EMONA_json['traits']
    owner_address = EMONA_json['owner']['address']
    result[token_id] = {"traits":traits, "owner_address":owner_address}

with open('output.csv', 'w') as csvFile:
    writer = csv.writer(csvFile)
    writer.writerow(["token_id", "traits", "owner_address"])
    for id in result:
        writer.writerow([id, result[id]['traits'], result[id]['owner_address']])
csvFile.close()


text:
Q: ETPUSH addAttributes not working I'm using SDK in my android app, and I'm trying to set attributes (already created in MC) but MC never shows me value I set in my android app.
etPush.addAttribute("MunicipioResidencia","MunicipioResidencia");
etPush.addAttribute("TipoFamNumerosa","TipoFamNumerosa");
etPush.addAttribute("NumDocumentoFN","NumDocumentoFN");

I am currently doing that, however, in contact detail never is set this values:

How this is really working? What am i doing wrong?


text:
Q: At what point are hard drive bad sectors actually bad? I'm kind of freaking out here, so I'm sorry if this question may be panicked.
So, today, when I started my system up, I took a look at one of the drives in my Raid 0 setup. It showed 7 bad sectors. Alright. That's fair. Several hours later, I took another look. 10 bad sectors!
Now, I've been doing a LOT of copying and downloading onto that drive (Maybe, around 100GB transfers), so is it possible that those sectors were there, but just not recorded as being bad? None of the bad sectors have been irrecoverable yet, but at what point should I start considering options for replacement?
Even a little bit of help would be greatly appreciated! Thank you!

A: RAID 0 is striping and if you have a back up then don't panic.  The bigger issue is the rate of increase.  I would definitely start planning to replace the drive.  However, to detect how bad the drive is really I would use mhdd or spinrite.  Spinrite may not like drives over 1tb and mhdd is free anyway.  However spinrite is the better tool.


text:
Q: Create a shortcut using batch with quotes in the Target Based on: How to create a shortcut using a batch script?
I can't figure out how to write this batch so all the quotes are in the right place and create the shortcut file. I used the above info as reference.
My final target should be
Target: %COMSPEC% /c start "" "E:\PinballEmporium\Core\RetroFE.exe"

This is the batch I've wrote, if I remove everything after the word 'start' it will write the shortcut file, but obviously that's not all I need. (This is being launched from 'E:\PinballEmporium')
@echo off

set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs"
echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT%
echo sLinkFile = "%USERPROFILE%\Desktop\Pinball Emporium.lnk" >> %SCRIPT%
echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT%

REM %COMSPEC% /c start "" "E:\PinballEmporium\Core\RetroFE.exe"
echo oLink.TargetPath = "%%COMSPEC%% /c start "" "%cd%\Core\RetroFE.exe"" >> %SCRIPT%
REM echo oLink.Arguments="%cd%\Core\RetroFE.exe" >> %SCRIPT%

echo oLink.IconLocation="%cd%\PEICON.ico" >> %SCRIPT%
echo oLink.WorkingDirectory="%cd%" >> %SCRIPT%
echo oLink.WindowStyle="0" >> %SCRIPT%
echo oLink.Description="Shortcut for Pinball Emporium"
echo oLink.Save >> %SCRIPT%
cscript /nologo %SCRIPT%
del %SCRIPT%

A: You can give a try for this batch file :
@echo off
Title Batch Shortcut Creator
Set "ShortcutName=Pinball Emporium"
Set "TargetPath=E:\PinballEmporium\Core\RetroFE.exe"
Set "IconLocation=%cd%\PEICON.ico"
Call :Create_Shortcut "%ShortcutName%" "%TargetPath%" "%IconLocation%"
EXIT
REM -----------------------------------------------------------------------------
:Create_Shortcut
Set "VBS_Shortcut=%temp%\%~n0.vbs"
>"%VBS_Shortcut%" (
    echo    Call Create_Shortcut("%~1","%~2","%~3"^)
    echo    Sub Create_Shortcut(ShortcutName,TargetPath,IconLocation^)
    echo        Dim objShell,DesktopPath,objShortCut
    echo        Set objShell = CreateObject("WScript.Shell"^)
    echo        DesktopPath = objShell.SpecialFolders("Desktop"^)
    echo        Set objShortCut = objShell.CreateShortcut(DesktopPath ^& "\" ^& ShortcutName ^& ".lnk"^)
    echo        objShortCut.TargetPath = chr(34^) ^& TargetPath ^& chr(34^)
    echo        objShortCut.IconLocation="%~3"
    echo        objShortCut.Save
    echo    End Sub
)
cscript //nologo "%VBS_Shortcut%" "%~1" "%~2" "%~3"
If Exist "%VBS_Shortcut%" Del "%VBS_Shortcut%"
Exit /B
REM ------------------------------------------------------------------------------


text:
Q: Calling jQuery function in php (or modifying javascript so php runs the remaining code) I was having difficulty calling the necessary jQuery functions in php so I added them to the javascript, but the method I'm familiar with (the success function) prevents the php from performing anything other than the INSERT INTO  and SELECT queries.  How would I change this script so that it completes the php, and/or how would I combine the code so that the following can be accomplished?
Validates form (with separate rules for Men and Women)
If validation is successful: Both Genders: parent.close_field('notice'); (currently only works in javascript)
If Gender is Female:

*

*INSERT information into customer_info table

*Identifies user_id assigned to this account

*Redirects user to the next page (currently in both php & javascript)

If Gender is Male:

*

*Generates email notifying me of the request

*INSERT information into invite_requests table

*Echo message to Men (currently in both; Preferred method is in php)

*Close Fancybox iframe (currently only works in javascript)

I am using fancybox2 and this jQuery validation plugin http://bassistance.de/jquery-plugins/jquery-plugin-validation/
Javascript
var $custInfo = $("#customer_info");
$(document).ready(function () {
  var validator = $custInfo.validate({
    rules: {...},
    messages: {...},
    errorLabelContainer: "#messageBox",
    submitHandler: function () {
        $custInfo.ajaxSubmit({
            success: function () {
                if ($('input[name=gender][value=female]').is(':checked')) {
                    parent.close_field('notice');
                    window.location.href = "page1.html";
                } else if ($('input[name=gender][value=male]').is(':checked')) {
                    parent.close_field('notice');
                    parent.$.fancybox.close();
                    alert("This isn't available yet for men, but we'll send you an invitation as soon as it is");
                }
            }
        });
    }
  });
  $custInfo.find("input[name=gender]").change(function () {
    if ($(this).val() == "male") {
        $custInfo.submit();
    }
  });
});

PHP
<?php
//Start session and connection to database goes here
//Function to sanitize values received from the form goes here
$gender = $_POST['gender'];
if ($gender==="female" ) {
    // INSERT information into customer_info table
   $qry = "INSERT INTO customer_info(fname, lname, gender, zip, email, phone, terms, security_question, security_answer, participating_retailers, notify_new_items, notify_promotions, priority1, priority2, priority3, priority4, priority5, gift_privacy, user_name, password, Quickfill)      VALUES('$_POST[fname]','$_POST[lname]','$_POST[gender]','$_POST[zip]','$_POST[email]','$_POST[phone]','$_POST[terms]','$_POST[security_question]','$_POST[security_answer]','$_POST[participating_retailers]','$_POST[notify_new_items]','$_POST[notify_promotions]','$_POST[priority1]','$_POST[priority2]','$_POST[priority3]','$_POST[priority4]','$_POST[priority5]','$_POST[gift_privacy]','$user_name','".md5($_POST['password'])."','$_POST[Quickfill]')";
       $result = @mysql_query($qry);
    if($result) {

// Identifies user_id assigned to this account
          $qry="SELECT * FROM customer_info WHERE user_name='$user_name' AND password='".md5($_POST['password'])."'";
          $result=mysql_query($qry);
    if($result) {
        if(mysql_num_rows($result) == 1) {
            session_regenerate_id();
            $member = mysql_fetch_assoc($result);
            $_SESSION['SESS_USER_ID'] = $member['user_id'];
            $_SESSION['SESS_USER_NAME'] = $member['user_name'];
            session_write_close();
// Redirects user to the next page
            header("location: page1.html");
            exit();
        }else {  //user_name failed
            header("location: login_failed.html");
            exit();  }
    }else { die("Unable to access your account (Error Message 1)");   }
    }else { die("Unable to access your account (Error Message 2)");   }
  }
// If Gender is Male
  else {
// Notify us of request via email
$sendto  = "info@click2fit.com";$userfname = $_POST['fname'];$userlname = $_POST['lname'];$usermail = $_POST['email'];$gender = $_POST['gender'];$subject  = "Invite Request - " . ($gender) . " ";
// INSERT information into invite_requests table
   $qry = "INSERT INTO invite_requests(fname, lname, gender, zip, email, phone, terms, participating_retailers, notify_new_items, notify_promotions, priority1, priority2, priority3, priority4, priority5, gift_privacy, user_name, password, Quickfill)         VALUES('$_POST[fname]','$_POST[lname]','$_POST[gender]','$_POST[zip]','$_POST[email]','$_POST[phone]','$_POST[terms]','$_POST[participating_retailers]','$_POST[notify_new_items]','$_POST[notify_promotions]','$_POST[priority1]','$_POST[priority2]','$_POST[priority3]','$_POST[priority4]','$_POST[priority5]','$_POST[gift_privacy]','$user_name','".md5($_POST['password'])."','$_POST[Quickfill]')";
    $result = @mysql_query($qry);
 // Echo message to Men
  echo "
Click2Fit is not yet available for men, but we'll be sure to send an invitation as soon as it is
";
// Redirects user - This should be replaced with the function which closes the fancybox iframe
  header("location: home.html");
exit();
    }
?>

A: It's important to understand that javascript is a client-side language(meaning it runs in the user's browser) and php is a server-side language(meaning that it runs on your server).  In order to get javascript and php to interact with each other, you're going to need to use AJAX.
since you're already using jQuery, I would suggest you check out their AJAX api.  Essentially, every time you want to call a php function from within your javascript code, you're going to have something along the lines of this:
$.ajax({
  type: "POST", /*usually POST, but it can also be GET and some other HTTP requests in certain browsers*/
  url: "some.php", /*the url of the php which processes your data*/
  data: { name: "John", location: "Boston" } /*the data you want to pass to the server.  It will be contained in the $_POST array because of the 'type: "POST"' line above*/
}).done(function( msg ) {
  alert( "Data Saved: " + msg ); /*'msg' is what server send back to you while the contents of the function are what you do once the server finishes.  You can change the variable name, msg, as well as the function contents to suit your needs */
});


text:
Q: Why can't download video title when to set proxy argument with youtube-dl? The command can get video title without proxy argument,run on my vps.
url="https://www.youtube.com/watch?v=znmQ7oMiQrM&list=PLUkh9m2BorqnKWu0g5ZUps_CbQ-JGtbI9&index=1"
youtube-dl -o "/tmp/%(title)s.%(ext)s" --write-auto-sub --yes-playlist  $url

The output info for above command.
[info] Writing video subtitles to: /tmp/Session 1 - Introduction to Valuation.en.vtt
[download] Destination: /tmp/Session 1 - Introduction to Valuation.mp4

It can get video subtitles,now to add proxy argument,run on my local pc.
url="https://www.youtube.com/watch?v=znmQ7oMiQrM&list=PLUkh9m2BorqnKWu0g5ZUps_CbQ-JGtbI9&index=1"
youtube-dl -o "/tmp/%(title)s.%(ext)s" --proxy "socks5://127.0.0.1:1080/" --write-auto-sub --yes-playlist  $url

I only add proxy argument, keep all other unchanged,it get the following output:
WARNING: Unable to extract video title
[youtube] znmQ7oMiQrM: Looking for automatic captions
[info] Writing video subtitles to: /tmp/_.en.vtt
[download] Destination: /tmp/_.f248.webm

It can download video without title as the downloaded video,Whe the action is different for the argument proxy ,why to run on my vps do matter?
To add a v argument to show all info in detail.
youtube-dl -v --write-pages  -o "/tmp/%(title)s.%(ext)s" --proxy "socks5://127.0.0.1:1080/" --write-auto-sub --yes-playlist  $url
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--write-pages', '-o', '/tmp/%(title)s.%(ext)s', '--proxy', 'socks5://127.0.0.1:1080/', '--write-auto-sub', '--yes-playlist', 'https://www.youtube.com/watch?v=znmQ7oMiQrM&list=PLUkh9m2BorqnKWu0g5ZUps_CbQ-JGtbI9&index=1']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2019.07.16
[debug] Python version 3.5.3 (CPython) - Linux-4.9.0-9-amd64-x86_64-with-debian-9.9
[debug] exe versions: ffmpeg 3.2.14-1, ffprobe 3.2.14-1
[debug] Proxy map: {'https': 'socks5://127.0.0.1:1080/', 'http': 'socks5://127.0.0.1:1080/'}
[youtube:playlist] Downloading playlist PLUkh9m2BorqnKWu0g5ZUps_CbQ-JGtbI9 - add --no-playlist to just download video znmQ7oMiQrM
[youtube:playlist] PLUkh9m2BorqnKWu0g5ZUps_CbQ-JGtbI9: Downloading webpage
[youtube:playlist] Saving request to PLUkh9m2BorqnKWu0g5ZUps_CbQ-JGtbI9_https_-_www.youtube.com_playlistlist=PLUkh9m2BorqnKWu0g5ZUps_CbQ-JGtbI9_disable_polymer=true.dump
[download] Downloading playlist: Valuation
[youtube:playlist] playlist Valuation: Downloading 25 videos
[download] Downloading video 1 of 25
[youtube] znmQ7oMiQrM: Downloading webpage
[youtube] Saving request to znmQ7oMiQrM_https_-_www.youtube.com_watchhas_verified=1_bpctr=9999999999_v=znmQ7oMiQrM_disable_polymer=true_hl=en_gl=US.dump
[youtube] znmQ7oMiQrM: Downloading video info webpage
[youtube] Saving request to znmQ7oMiQrM_https_-_www.youtube.com_get_video_infohl=en_gl=US_video_id=znmQ7oMiQrM_disable_polymer=true_eurl=_ps=default_el=embedded.dump
WARNING: Unable to extract video title
[youtube] znmQ7oMiQrM: Looking for automatic captions
[debug] Default format spec: bestvideo+bestaudio/best
[info] Writing video subtitles to: /tmp/_.en.vtt
[debug] Invoking downloader on 'https://r4---sn-a5msen7l.googlevideo.com/videoplayback?expire=1565674517&ei=tPdRXZy-MND8kgbJ7JrwCQ&ip=65.49.218.106&id=o-APXnQrHHHHttAI0VI1FjI3xIZNQKXoAcTffCZvbDaowF&itag=248&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-a5msen7l%2Csn-a5mekne7&ms=au%2Crdu&mv=m&mvi=3&pl=20&initcwndbps=1261250&mime=video%2Fwebm&gir=yes&clen=123038403&dur=974.431&lmt=1540749282657199&mt=1565652704&fvip=1&keepalive=yes&c=WEB&txp=5432432&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRQIgWW_UbLJqGcCIkKNgYhCKSWEDpC_ND_4c-_e9LSbAMkACIQDKZNf_b01YjtrNllZFNq_dL7GX5bX6CM5jsgiaqw0JZQ%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRQIgFkroUYnazUgzoaBbuU1Ot4vu81LmQex7WfJoNhsNx6kCIQCCIeMh_wo0F2bUysi0P9yJCZBh9g9XfxKQpZMGvYKw6A%3D%3D&ratebypass=yes'
[download] Destination: /tmp/_.f248.webm

A: An update to youtube-dl was recently made to address similar issues; try the new version:
$ youtube-dl --update
$ youtube-dl --version
2019.08.13

If that doesn't resolve your problem you could try the geo-restriction
  options, or file a bug report with the developers and
  provide access to your vpn, vps, proxy, etc. so they can debug it.

↳ see: How can I speed up my issue?

A: sudo pip3 install --upgrade youtube-dl


text:
Q: Select Table A minus Table B where condition consists of two columns I have two tables. Table A and table B.
I would like to select everything from table A which is NOT in table B.
Sounds easy the catch is I need to select it based on two values (two columns)
revision AND casetype. Something like this.
select a.revision, a.casetype from A a
minus
select b.revision, b.casetype from B b;

The problem is I won't get back ID from table A.
Is it possible to select whole table A minus table B where conditions consist of two columns ? I would like to stick to SQL (no PL/SQL)
I also tried to write something like query below but I guess I can't do it since I need to check revision AND casetype altogether
select * from A a where a.casetype IN (select...) and a.revision IN (select...)

Any idea how to work around ? Thanks

A: Sure, I believe a basic not exists check should work.
select a.id, a.revision, a.casetype
from A a
where not exists (
    select 1
    from B
    where revision = a.revision and casetype = a.casetype
);

A: Oracle supports tuples, so if you wanted you could do:
select a.*
from a
where (a.revision, a.casetype) in (select a.revision, a.casetype from A a
                                   minus
                                   select b.revision, b.casetype from B b
                                  );

I would normally go for not exists, but this is the solution that builds on what you have already done.

A: except should work
select a.revision, a.casetype from A a
except
select b.revision, b.casetype from B b;


text:
Q: JQ: A list with multiple values for one key Using jq, I want to get a list of application names, all versions and server name. The list should not contain information about the latest version.
Input:
{
  "software": {
    "app_1": {
      "0.0.1": {
        "properties_1": {
          "lang": "en"
        },
        "server": "vm123-4.domain.com"
      },
      "0.0.2": {
        "properties_2": {
          "arch": "x86"
        },
        "server": "vm123-5.comain.com"
      },
      "latest_version": "0.0.2"
    },
    "app_2": {
      "1.0.1": {
        "properties_2": {
          "arch": "x86"
        },
        "server": "vm333-1.domain.com"
      },
      "latest_version": "1.0.1"
    },
    "app_33": {
      "0.44.1": {
        "properties_1": {
          "lang": "en"
        },
        "properties_2": {
          "arch": "x86"
        },
        "properties_3": {
          "boot": "true"
        },
        "server": "vm888-9.domain.com"
      },
      "1.2.2": {
        "properties_3": {
          "boot": "yes"
        },
        "server": "vm123-4.domain.com"
      },
      "latest_version": "1.2.2"
    }
  }
}

Desired output:
"app_1,  0.0.1,  vm123-4.domain.com"
"app_1,  0.0.2,  vm123-5.comain.com"
"app_2,  1.0.1,  vm333-1.comain.com"
"app_33, 0.44.1, vm888-9.comain.com"
"app_33, 1.2.2,  vm123-4.comain.com"

My request will only list one version of the app, but not all. I do not know how to do this.
.software | to_entries[] | [(.key), (.value | to_entries[] | select(.key | IN("latest_version") | not))] | "\(.[0]) \(.[1].key) \(.[1].value.server)"

My output:
"app_1  0.0.1  vm123-4.domain.com"
"app_2  1.0.1  vm333-1.domain.com"
"app_33 0.44.1 vm888-9.domain.com"

A: jq -r '.software | to_entries[] | .key as $app | .value | to_entries[] | select((.value | objects)) |  [$app, .key, .value.server] | @csv'

A: .software | to_entries[] | "\(.key) \(.value | to_entries[] | select(.key != "latest_version") | "\(.key) \(.value.server)")"

Will produce
"app_1 0.0.1 vm123-4.domain.com"
"app_1 0.0.2 vm123-5.comain.com"
"app_2 1.0.1 vm333-1.domain.com"
"app_33 0.44.1 vm888-9.domain.com"
"app_33 1.2.2 vm123-4.domain.com"

As you can test in this online demo.

Using --raw-output with tabs \t, we can create a column like output:
app_1   0.0.1   vm123-4.domain.com
app_1   0.0.2   vm123-5.comain.com
app_2   1.0.1   vm333-1.domain.com
app_33  0.44.1  vm888-9.domain.com
app_33  1.2.2   vm123-4.domain.com

Demo


text:
Q: JBoss 5 Backward compatibility with Java 6 I just need clarifications related to JBoss Application Server. I've developed a project which is compiled in Java 6. And it is deployed in Jboss 5 version. Till now I didn't find any problem with the application. But I want to know will there be any possibility that Jboss will have any backward compatibility problem. Or does Jboss needed upgradation with respect to Java version. Any suggestion would be appreciable.
Thanks,
Marshal.

A: Even if JBoss 5 is compiled with Java 5 there shouldn't be compatibility problems at a language level.
As for the libraries there might be a problem but those that JBoss requires should have been taken care of. This leaves you with core libraries that JBoss might have replaced in its class loader hiearchy and thus might have an older version. In that case you could put those libraries into your application and effectively override the JBoss versions on a per-application basis. We did that with some XML libs (IIRC JAXB was one of them).
As an alternative - as suggested by @Geziefer - use a JBoss 5 version specifically compiled for Java 6.


text:
Q: Summation Rules Mistake? I'm looking at a solution for a stats problem and I think there is a mistake. The solution is as follows:
$$m_i^{-1} \sum_{e=1}^{m_i} u_{i,e} = m_i^{-1}\sum_{e=1}^{m_i}(f_i + u_{i,e}) = f_i + m_{i}^{-1}\sum_{e=1}^{m_i}v_{i,e}$$
I believe there was a mistake where they wrote $u$ instead of $v$ but aside from that I don't believe the last part makes sense. Am I misunderstanding or is this a mistake?
They show that $u_{i,e} = f_i + v_{i,e}$
Edit: I am of the opinion that $f$ should can't be added to the second term. I believe it needs to still multiply by everything and the value $m_i$.

A: It is actually right like this $-$ beside the $u$-$v$-typo of course. A sum where every element is independent of the index is similiar to adding up ones $($in case of definite sums$)$. I.e. we got that
$$\sum_{e=1}^{m_i}1=\underbrace{1+1+\dots+1}_{m_i~\text{times}}=m_i$$
Since we can simply pull out constants in such sums we may conclude that
$$m_i^{-1}\sum_{e=1}^{m_i}f_i=m_i^{-1}f_i\sum_{e=1}^{m_i}1=f_im_i^{-1}(m_i)=f_i$$

$$\therefore~m_i^{-1}\sum_{e=1}^{m_i}(f_i + v_{i,e})=m_i^{-1}\sum_{e=1}^{m_i}f_i+m_i^{-1}\sum_{e=1}^{m_i}v_{i,e} = f_i + m_{i}^{-1}\sum_{e=1}^{m_i}v_{i,e}$$


text:
Q: timestamp to php from timestamp array Hi guys i am really new to php and i am trying to convert the timestamp from an xml array but with no sucess , i read everything i found but still can find the way can you please help ?
I am using this code to decode an xml api output
$mysongs = simplexml_load_file('http://example.com/test/xml/');
$timestamp = $mysongs->item->timestamp;
$playtime = date("Y-d-m G-i-s",$timestamp);

If i echo $timestamp it works fine, $playtime doesn't...
Tried with :
echo gmdate("Y-m-d", $timestamp);

&
echo date('Y-m-d H:i:s', $wra);

&
echo '<timeplayed>' . date('Y-m-d G:i:s', $mysongs->item->timestamp) . '</timeplayed>';

Still no luck.. Time is not showing.. If i use this example
echo '<timeplayed>' . date('Y-m-d G:i:s', (1365532902)) . '</timeplayed>';

it works fine.. What am i doing wrong here ?
Update
Finally i found it.. it needed to cast the $timestamp as integer for the date to decode properly as euxneks sugested..
So right code should be
$timestamp = intVal ($mysongs->item->timestamp);

and then
    $playtime = date("Y-d-m H-i-s",($timestamp));

& finally echo ($playtime); and it works fine...
Thanks everyone for your replys problem solved

A: It's likely that you need to cast your result as an integer (it's been a while since I've used simplexml but I'm pretty sure it doesn't automatically type the values received):
http://php.net/intval
Also, strtotime might work too :)
http://php.net/strtotime

A: You are definitely missing strtotime function, here is an example:
$str = '04/09/2013';
$date = date('Y-m-d H:i:s',strtotime($str));

echo $date;

This will output:
2013-04-09 00:00:00

Updated
Since strtotime is alread used, what about using:
$date = date('Y-m-d H:i:s', ($timestamp));


text:
Q: Optimal merging of triplets I'm trying to come up with an algorithm for the following problem :
I've got a collection of triplets of integers - let's call these integers A, B, C. The value stored inside can be big, so generally it's impossible to create an array of size A, B, or C. The goal is to minimize the size of the collection. To do this, we're provided a simple rule that allows us to merge the triplets :

*

*For two triplets (A, B, C) and (A', B', C'), remove the original triplets and place the triplet (A | A', B, C) if B == B' and C = C', where | is bitwise OR. Similar rules hold for B and C also.

In other words, if two values of two triplets are equal, remove these two triplets, bitwise OR the third values and place the result to the collection.
The greedy approach is usually misleading in similar cases and so it is for this problem, but I can't find a simple counterexample that'd lead to a correct solution. For a list with 250 items where the correct solution is 14, the average size computed by greedy merging is about 30 (varies from 20 to 70). The sub-optimal overhead gets bigger as the list size increases.
I've also tried playing around with set bit counts, but I've found no meaningful results. Just the obvious fact that if the records are unique (which is safe to assume), the set bit count always increases.
Here's the stupid greedy implementation (it's just a conceptual thing, please don't regard the code style) :
public class Record {
    long A;
    long B;
    long C;

    public static void main(String[] args) {
        List<Record> data = new ArrayList<>();
        // Fill it with some data

        boolean found;

        do {
            found = false;
            outer:
            for (int i = 0; i < data.size(); ++i) {
                for (int j = i+1; j < data.size(); ++j) {
                    try {
                        Record r = merge(data.get(i), data.get(j));
                        found = true;
                        data.remove(j);
                        data.remove(i);
                        data.add(r);
                        break outer;
                    } catch (IllegalArgumentException ignored) {
                    }
                }
            }
        } while (found);
    }

    public static Record merge(Record r1, Record r2) {
        if (r1.A == r2.A && r1.B == r2.B) {
            Record r = new Record();
            r.A = r1.A;
            r.B = r1.B;
            r.C = r1.C | r2.C;
            return r;
        }
        if (r1.A == r2.A && r1.C == r2.C) {
            Record r = new Record();
            r.A = r1.A;
            r.B = r1.B | r2.B;
            r.C = r1.C;
            return r;
        }
        if (r1.B == r2.B && r1.C == r2.C) {
            Record r = new Record();
            r.A = r1.A | r2.A;
            r.B = r1.B;
            r.C = r1.C;
            return r;
        }
        throw new IllegalArgumentException("Unable to merge these two records!");
    }

Do you have any idea how to solve this problem?

A: This is going to be a very long answer, sadly without an optimal solution (sorry). It is however a serious attempt at applying greedy problem solving to your problem, so it may be useful in principle. I didn't implement the last approach discussed, perhaps that approach can yield the optimal solution -- I can't guarantee that though.
Level 0: Not really greedy
By definition, a greedy algorithm has a heuristic for choosing the next step in a way that is locally optimal, i.e. optimal right now, hoping to reach the global optimum which may or may not be possible always.
Your algorithm chooses any mergable pair and merges them and then moves on. It does no evaluation of what this merge implies and whether there is a better local solution. Because of this I wouldn't call your approach greedy at all. It is just a solution, an approach. I will call it the blind algorithm just so that I can succinctly refer to it in my answer. I will also use a slightly modified version of your algorithm, which, instead of removing two triplets and appending the merged triplet, removes only the second triplet and replaces the first one with the merged one. The order of the resulting triplets is different and thus the final result possibly too. Let me run this modified algorithm over a representative data set, marking to-be-merged triplets with a *:
0: 3 2 3   3 2 3   3 2 3
1: 0 1 0*  0 1 2   0 1 2
2: 1 2 0   1 2 0*  1 2 1
3: 0 1 2*
4: 1 2 1   1 2 1*
5: 0 2 0   0 2 0   0 2 0

Result: 4

Level 1: Greedy
To have a greedy algorithm, you need to formulate the merging decision in a way that allows for comparison of options, when multiple are available. For me, the intuitive formulation of the merging decision was:

If I merge these two triplets, will the resulting set have the maximum possible number of mergable triplets, when compared to the result of merging any other two triplets from the current set?

I repeat, this is intuitive for me. I have no proof that this leads to the globally optimal solution, not even that it will lead to a better-or-equal solution than the blind algorithm -- but it fits the definition of greedy (and is very easy to implement). Let's try it on the above data set, showing between each step, the possible merges (by indicating the indices of triplet pairs) and resulting number of mergables for each possible merge:
          mergables
0: 3 2 3  (1,3)->2
1: 0 1 0  (1,5)->1
2: 1 2 0  (2,4)->2
3: 0 1 2  (2,5)->2
4: 1 2 1
5: 0 2 0

Any choice except merging triplets 1 and 5 is fine, if we take the first pair, we get the same interim set as with the blind algorithm (I will this time collapse indices to remove gaps):
          mergables
0: 3 2 3  (2,3)->0
1: 0 1 2  (2,4)->1
2: 1 2 0
3: 1 2 1
4: 0 2 0

This is where this algorithm gets it differently: it chooses the triplets 2 and 4 because there is still one merge possible after merging them in contrast to the choice made by the blind algorithm:
          mergables
0: 3 2 3  (2,3)->0   3 2 3
1: 0 1 2             0 1 2
2: 1 2 0             1 2 1
3: 1 2 1

Result: 3

Level 2: Very greedy
Now, a second step from this intuitive heuristic is to look ahead one merge further and to ask the heuristic question then. Generalized, you would look ahead k merges further and apply the above heuristic, backtrack and decide the best option. This gets very verbose by now, so to exemplify, I will only perform one step of this new heuristic with lookahead 1:
          mergables
0: 3 2 3  (1,3)->(2,3)->0
1: 0 1 0         (2,4)->1*
2: 1 2 0  (1,5)->(2,4)->0
3: 0 1 2  (2,4)->(1,3)->0
4: 1 2 1         (1,4)->0
5: 0 2 0  (2,5)->(1,3)->1*
                 (2,4)->1*

Merge sequences marked with an asterisk are the best options when this new heuristic is applied.
In case a verbal explanation is necessary:

Instead of checking how many merges are possible after each possible merge for the starting set; this time we check how many merges are possible after each possible merge for each resulting set after each possible merge for the starting set. And this is for lookahead 1. For lookahead n, you'd be seeing a very long sentence repeating the part after each possible merge for each resulting set n times.

Level 3: Let's cut the greed
If you look closely, the previous approach has a disastrous perfomance for even moderate inputs and lookaheads(*). For inputs beyond 20 triplets anything beyond 4-merge-lookahead takes unreasonably long. The idea here is to cut out merge paths that seem to be worse than an existing solution. If we want to perform lookahead 10, and a specific merge path yields less mergables after three merges, than another path after 5 merges, we may just as well cut the current merge path and try another one. This should save a lot of time and allow large lookaheads which would get us closer to the globally optimal solution, hopefully. I haven't implemented this one for testing though.

 (*): Assuming a large reduction of input sets is possible, the number of merges is
  proportional to input size, and
  lookahead approximately indicates how much you permute those merges.
  So you have choose lookahead from |input|, which is
  the binomial coefficient that for lookahead ≪ |input| can be approximated as
  O(|input|^lookahead) -- which is also (rightfully) written as you are thoroughly screwed.

Putting it all together
I was intrigued enough by this problem that I sat and coded this down in Python. Sadly, I was able to prove that different lookaheads yield possibly different results, and that even the blind algorithm occasionally gets it better than lookahead 1 or 2. This is a direct proof that the solution is not optimal (at least for lookahead ≪ |input|). See the source code and helper scripts, as well as proof-triplets on github. Be warned that, apart from memoization of merge results, I made no attempt at optimizing the code CPU-cycle-wise.

A: I don't have the solution, but I have some ideas.
Representation
A helpful visual representation of the problem is to consider the triplets as points of the 3D space. You have integers, so the records will be nodes of a grid. And two records are mergeable if and only if the nodes representing them sit on the same axis.
Counter-example
I found an (minimal) example where a greedy algorithm may fail. Consider the following records:
(1, 1, 1)   \
(2, 1, 1)   |     (3, 1, 1)  \
(1, 2, 1)   |==>  (3, 2, 1)  |==> (3, 3, 1)
(2, 2, 1)   |     (2, 2, 2)  /    (2, 2, 2)
(2, 2, 2)   /

But by choosing the wrong way, it might get stuck at three records:
(1, 1, 1)   \
(2, 1, 1)   |     (3, 1, 1)
(1, 2, 1)   |==>  (1, 2, 1)
(2, 2, 1)   |     (2, 2, 3)
(2, 2, 2)   /

Intuition
I feel that this problem is somehow similar to finding the maximal matching in a graph. Most of those algorithms finds the optimal solution by begining with an arbitrary, suboptimal solution, and making it 'more optimal' in each iteration by searching augmenting paths, which have the following properties:

*

*they are easy to find (polynomial time in the number of nodes),

*an augmenting path and the current solution can be crafted to a new solution, which is strictly better than the current one,

*if no augmenting path is found, the current solution is optimal.

I think that the optimal solution in your problem can be found in the similar spirit.

A: Based on your problem description:

I'm given a bunch of events in time that's usually got some pattern.
  The goal is to find the pattern. Each of the bits in the integer
  represents "the event occurred in this particular year/month/day". For
  example, the representation of March 7, 2014 would be [1 <<
  (2014-1970), 1 << 3, 1 << 7]. The pattern described above allows us to
  compress these events so that we can say 'the event occurred every 1st
  in years 2000-2010'. –  Danstahr Mar 7 at 10:56

I'd like to encourage you with the answers that MicSim has pointed at, specifically

Based on your problem description, you should check out this SO
  answers (if you didn't do it already):
  stackoverflow.com/a/4202095/44522 and
  stackoverflow.com/a/3251229/44522 –  MicSim Mar 7 at 15:31

The description of your goal is much more clear than the approach you are using. I'm scared that you won't get anywhere with the idea of merging. Sounds scary. The answer you get depends upon the order that you manipulate your data. You don't want that.
It seems you need to keep data and summarize. So, you might try counting those bits instead of merging them. Try clustering algorithms, sure, but more specifically try regression analysis. I should think you would get great results using a correlation analysis if you create some auxiliary data. For example, if you create data for "Monday", "Tuesday", "first Monday of the month", "first Tuesday of the month", ... "second Monday of the month", ... "even years", "every four years", "leap years", "years without leap days", ... "years ending in 3", ...
What you have right now is "1st day of the month", "2nd day of the month", ... "1st month of the year", "2nd month of the year", ... These don't sound like sophisticated enough descriptions to find the pattern.
If you feel it is necessary to continue the approach you have started, then you might treat it more as a search than a merge. What I mean is that you're going to need a criteria/measure for success. You can do the merge on the original data while requiring strictly that A==A'. Then repeat the merge on the original data while requiring B==B'. Likewise C==C'. Finally compare the results (using the criteria/measure). Do you see where this is going? Your idea of bit counting could be used as a measure.
Another point, you could do better at performance. Instead of double-looping through all your data and matching up pairs, I'd encourage you to do single passes through the data and sort it into bins. The HashMap is your friend. Make sure to implement both hashCode() and equals(). Using a Map you can sort data by a key (say where month and day both match) and then accumulate the years in the value. Oh, man, this could be a lot of coding.
Finally, if the execution time isn't an issue and you don't need performance, then here's something to try. Your algorithm is dependent on the ordering of the data. You get different answers based on different sorting. Your criteria for success is the answer with the smallest size after merging. So, repeatedly loop though this algorithm: shuffle the original data, do your merge, save the result. Now, every time through the loop keep the result which is the smallest so far. Whenever you get a result smaller than the previous minimum, print out the number of iterations, and the size. This is a very simplistic algorithm, but given enough time it will find small solutions. Based on your data size, it might take too long ...
Kind Regards,
-JohnStosh