text:
Q: How to use tinysvcmdns I want to use tinysvcmdns (https://bitbucket.org/geekman/tinysvcmdns) for my ARM cortex microcontroller for audio streaming. I am using LWIP as a TCP/IP stack.
I have finished porting it on LWIP and now I want to test it.
According to the documentattion of tinysvcmdns I have to call the following functions.

*

*srv = mdnsd_start() to start the main thread

*mdnsd_set_hostname(svr, hostname, inet_addr("10.157.5.119")) to set the hostname and IP address

*mdnsd_register_svc(svr, "My Website","_http._tcp.local", 8080, NULL, txt) to register a service
and begin an announcement

*mdnsd_stop() when you no longer need to respond to mDNS queries
I am stuck at mdnsd_set_hostname(), which IP should I set. Is it my Apple device (iPhone) or my microcontroller device IP address?.
Another question when I call mdnsd_register_svc() is that a mdns query or answer ? and should I provide the same service published by my apple device (iPhone)?
When I capture the ethernet stream, I see that my iphone is sending a mdns query to address 224.0.0.251. How should I reply to such request ?
Thanks in advance


text:
Q: Local patches repository while switching kernels I'm new to git,
My scenario is as follows:
I have patches made to a linux kernel on a private project.
I want my local repository to hold these patches. Not the entire kernel.
I ain't talking about .patch files but rather hold the files i'm actually changing.
So that when i want to apply them on a different kernel i'll simply pull them into the second kernel folder.
And now for the problem:
I need to be able to switch the base tree once in a while, or, to simplify the scenario, i want to be able to pull a different tree and the pull my patches-repo into it.
But the actual second kernel is a repo, and my patches are a repo as well.
So i cannot combine them both in the same folder while still having source control for both.
Is there a way to glue the repos or tell git one is the parent and one is the child and it will auto-merge and pull everything automatically ?
Regards
David

A:
Is there a way to glue the repos or tell git one is the parent and one is the child and it will auto-merge and pull everything automatically ?

This is basically the purpose of git submodule but they won't auto-merge. A submodule has to be at least in a given subdirectory in the main repo.
However, if your Linux hack is not about patching existing official files, but writing a distinct kernel module that could be loaded with insmod or modprobe, then you don't need at all to develop inside the kernel tree. Just designate a regular directory somewhere in which you'll do all your development, then ask the top-level linux makefile to compile it for you from here :
make -C /lib/modules/`uname -r`/build M=`pwd` modules

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to change right-to-left property of a sheet? I'm trying to create a new sheet using the javascript api.
In some cases this sheet needs to be right-to-left.
I know how to make it right-to-left manually, but cannot find how to do it programatically.
The code that creates the speardsheet is simple:
var sheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet("My new sheet");

A: Unfortunately the right-to-left options for sheets and cells are not exposed in Apps Script. Please file a feature request for this capability so we can track progress on it.


text:
Q: Javascript calling prototype functions in constructor I keep getting an error saying that my functions are not defined when I was trying to call the prototype functions in the constructor and I dont know whats wrong with it.
Here's the code I have:
function Renderer()
{
    initialiseWebGL();
    initialiseShader();
    initialiseBuffer();
}

Renderer.prototype.initialiseWebGL()
{
    //Do stuff.
};

Renderer.prototype.initialiseShader()
{
        //Do Shader's stuff
};

Renderer.prototype.initialiseBuffer()
{
        //Do Buffers
};

What is wrong with it?

A: Your syntax is wrong. Use this:
function Renderer() {
    this.initialiseWebGL();
    this.initialiseShader();
    this.initialiseBuffer();
}

Renderer.prototype.initialiseWebGL = function () {
    //Do stuff.
};

Renderer.prototype.initialiseShader = function () {
        //Do Shader's stuff
};

Renderer.prototype.initialiseBuffer = function () {
        //Do Buffers
};

After that you can create new object and use it by:
var rendererInstance = new Renderer();

A: Since your instances inherit the (method) properties from the prototype objects, you need to access them as properties and not as plain variables:
function Renderer() {
    this.initialiseWebGL();
    this.initialiseShader();
    this.initialiseBuffer();
}

A: There are a few things wrong with your Code
1.initialiseWebGl()  would look for a function declared in the Global scope -> there is no function

*

*You should use this.initialiseWebGl() to access the Objects Method
Note: this refers to the Instance of Renderer in this case
2.You are not assigning a function with Renderer.prototype.initialiseWebGL() instead you try to invoke the Renderers prototype method initialiseWebGl which gives you an error, as its not defined
3.Because the { are moved down a line they get interpreted as a Block -> this code gets executed.
If you'd had them after your () you would get a Syntax Error ->
Renderer.prototype.initialiseWebGL() {... would result in Uncaught SyntaxError: Unexpected token {
Heres an Commented Example
function Renderer() {
    initialiseWebGL(); // I call the global declared function
    this.initialiseShader(); //I call the Prototypes function
    this.initialiseBuffer(); //Me too
}

Renderer.prototype.initialiseWebGL = function (){ //Here a function gets assigned to propertie of `Renderer`s `prototype` Object
    //Do stuff.
};

Renderer.prototype.initialiseShader = function (){
        console.log("Do Shader Stuff");
};

Renderer.prototype.initialiseBuffer = function (){
        console.log("Do initialise stuff");
};
 Renderer.prototype.initialiseBuffer() // I invoke the method above
{
 console.log("I'm a Block statement");
};

function initialiseWebGL () { //I'm the global declared function
  console.log("Global");
}

var ren1 = new Renderer();

/*"Do initialise stuff"
"I'm a Block statement"
"Global"
"Do Shader Stuff"
"Do initialise stuff"*/

As you can see in the consoles Output
Heres a JSBin


text:
Q: Dropdown field in a form to populate a few hidden fields in a form I'm have an registration form for visitors to sign up for talks on my page.
The problem is that I have 4 different talks they can sign up for.
So I would like to have them select the talk they want to attend and store the talk details e.g. Date, Time and Session in separate fields.
The code below show me storing my talk sessions registered as:
 25th Nov 10:00am on EFFECTIVE LEARNING
I would like to have my confirmation email showing :
Date : 25th Nov
Time : 10:00am
Session : EFFECTIVE LEARNING
Would appreciate any help in this matter.
    <select class="validate-required" name="Session" placeholder="Your Session Choice" data-error-text="You need to select a Session to attend">
        <option selected="25th Nov  2:00pm on LEARNING MADE EASY" value="">Select</option>
        <option value="25th Nov 10:00am on EFFECTIVE LEARNING">EFFECTIVE LEARNING</option>
        <option value="25th Nov  2:00pm on LEARNING MADE EASY">LEARNING MADE EASY</option>
        <option value="26th Nov 10:00am on TURNING THE C's & B's into A's">TURNING THE C's & B's into A's</option>
        <option value="26th Nov  2:00pm on DRAWING OUT THE SPECIAL CHILD">DRAWING OUT THE SPECIAL CHILD</option>
    </select>

A: <select class="validate-required" name="Session" id="sessions" placeholder="Your Session Choice" data-error-text="You need to select a Session to attend">
        <option value="0" selected>Select One</option>
        <option data-date="26th Nov" data-time="3:00pm" data-session="EFFECTIVE LEARNING" value="1">EFFECTIVE LEARNING</option>
        <option data-date="27th Nov" data-time="4:00pm" data-session="HTML Learning" value="2">LEARNING MADE EASY</option>
        <option data-date="28th Nov" data-time="5:00pm" data-session="JavaScript Learning" value="3">TURNING THE C's & B's into A's</option>
        <option data-date="29th Nov" data-time="6:00pm" data-session="PHP Learning" value="4">DRAWING OUT THE SPECIAL CHILD</option>
</select>

<script type="text/javascript">
    document.getElementById("sessions").addEventListener("change", function(el){
        var value = document.getElementById('sessions').options[this.selectedIndex].getAttribute('value');
        if (value != "0") {
            var session = document.getElementById('sessions').options[this.selectedIndex].getAttribute('data-session');
            var date = document.getElementById('sessions').options[this.selectedIndex].getAttribute('data-date');
            var time = document.getElementById('sessions').options[this.selectedIndex].getAttribute('data-time');
            alert('Session: '+session);
            alert('Date:'+date);
            alert('Time:'+time);
        } else {
            alert("You must select a valid option.");
        }
        });
</script>


text:
Q: JS as a Single JavaScript File in RequireJS I am using RequireJS, but our project has gotten quite large.
requirejs([
    'util/utils',
    'util/image_store',
    'models/user_model',
    'util/analytics'
    ],function() { /* do start here */ });

I've taken that initial group and I've concatenated together of those files so now I want to do this:
    requirejs([
        'initial_download.js'
        ],function() { /* do start here */ });
Now how do I let the other files know, that say use models/user_model that they don't need to download it themselves that requires already did a define?
Like this in a hypothetical UserView.js:
define(['models/user_model'],function(UserModel) {
   function UserView() { /* */ }
});

A: when you concatenated the files, you needed to wrap each file's contents into a named define call. This way when it loads, the modules resurrect themselves as if they were loaded from individual files:
;(function() {

    define('util/utils',function(){
        return utilsObject
    })

    define('util/image_store',function(){
        return imageStoreObject
    })

    define('models/user_model',function(){
        return userModelObject
    })

    define('util/analytics',function(){
        return analyticsObject
    })

    // you need this to make this an AMD module.
    // it does not matter what it returns, as your
    // main payload is above.
    define(function(){})

})();

A: I believe you can use the Require.js optimizer to do this for you: http://requirejs.org/docs/optimization.html


text:
Q: Gibberish filed values when Loading data with Oracle SQL Loader (sqlldr) Using

sqlldr

to load data in an oracle table doesn't result in any errors but the value of the fields are gibberish.  not all the values of course, only the values which was in persian(arabic) format.
already read many questions here but could not resolve the issue, most relatable topic to this problem were :[Unreadable character in generated sqlplus file
although the values in my case isn't question mark, but something like ,ÑÇå Âåä or äÇ ãÔÎÕ
Also played with the NLS_LANG environment variable but it was to no avail.
Created different oracle databases with different character set's, this also was to no avail.
I'm new to oracle, so it is highly likely that I'm making a rookie mistake while creating database and setting character set or something else, to be honest i have no idea. but  tried many responses from users and here i am.
I Uploaded the table schema and Ctl extension File to replicate the problem, the link to the related files are resided in this link: [https://www.dropbox.com/sh/ejxvast0ruioksk/AABXhjujqzhRpuMVjl7V-zxUa?dl=0][1]

A: In total you have three character sets or encodings.

*

*What is the encoding of your file? Check the save options of the editor or the application which created the file.

*The character set of your command line window cmd.exe, called "codepage". You can interrogate (or change) with command chcp

*The character set of your database.

1) and 2) must be the same. Use command chcp to set them equal (or change settings in your editor)
3) can be different but the character set must support persian/arabic characters, so most likely AL32UTF8 which is the default nowadays.
Use the NLS_LANG value to tell the database which character set is used for 1) and 2), example
C:\>chcp 1256
Aktive Codepage: 1256.

C:\>set NLS_LANG=.AR8MSWIN1256

C:\>sqlldr ...

You can get a list of codepages vs. Oracle character set with this query:
SELECT VALUE AS ORACLE_CHARSET, UTL_I18N.MAP_CHARSET(VALUE) AS IANA_NAME
FROM V$NLS_VALID_VALUES
WHERE PARAMETER = 'CHARACTERSET';

And here a list of Code Page Identifiers
See also OdbcConnection returning Chinese Characters as "?" to get more details.


text:
Q: Trying to connect with test.mosquitto.org:8883/ 8884 (ssl connection) Getting the error as below I am running this in raspberry pi
Firstly I have generated ca.key using
    openssl genrsa -des3 -out ca.key 2048
    openssl req -new -x509 -days 1826 -key ca.key -out ca.crt

created server certificate using
    openssl genrsa -out server.key 2048
       openssl req -new -out server.csr -key server.key
       openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key
       CAcreateserial -out server.crt -days 360

and created client.key and client.crt using same steps as that of server.
     mosquitto_pub --cert client.crt --key client.key -h
     test.mosquitto.org -p 8883 -m "hellohibye"  -i c10dd3be-a258478f-
     b7aa-da9aa734a373 -t ack/c10dd3be-a258-478f-b7aa-da9aa734a373 -d

when I try to run the command in same working directory, this is the error I am getting
     Client c10dd3be-a258-478f-b7aa-da9aa734a373 sending CONNECT OpenSSL
     Error: error:1416F086:SSL
     routines:tls_process_server_certificate:certificate verify failed
     Error: A TLS error occurred.

this is my client.crt looks like:
  openssl x509 -text -noout -in client.crt
  Certificate:
  Data:
    Version: 1 (0x0)
    Serial Number:
        15:d3:db:e7:b0:cc:76:e8:67:01:5c:a0:73:48:85:77:c5:1d:bd:af
    Signature Algorithm: sha256WithRSAEncryption
    Issuer: C = in, ST = ka, O = livn, CN = test.mosquitto.org
    Validity
        Not Before: Jul 29 08:38:24 2021 GMT
        Not After : Jul 24 08:38:24 2022 GMT
    Subject: C = in, ST = ba, L = ka, O = livn, CN =
  test.mosquitto.org
    Subject Public Key Info:
        Public Key Algorithm: rsaEncryption
            RSA Public-Key: (2048 bit)
            Modulus:
                00:9f:bd:44:c0:4c:34:a2:1b:9b:90:b6:ff:7b:41:
                c5:70:9d:34:a0:a9:f5:c6:ee:12:41:07:49:bc:c6:
                fb:2e:74:3c:91:7d:b5:dd:d0:8a:b5:96:ab:fa:32:
                79:15:0c:fb:9a:90:3a:87:68:2a:27:39:67:e8:38:
                6b:46:86:f8:82:18:a2:10:15:3a:cf:e4:61:69:45:
                47:72:67:79:fd:c6:b4:91:79:a8:64:fe:e3:0e:a4:
                34:6f:e6:59:3d:43:33:4d:0b:63:e7:9b:b8:c9:d6:
                85:6b:90:c1:5a:06:ee:07:fb:b9:8f:9c:9f:9b:e7:
                4c:b6:c5:91:4b:d4:da:7c:9a:11:bf:dd:92:7b:33:
                d2:6c:9a:e9:37:9a:62:cf:bc:13:f1:42:b4:b0:3c:
                a1:9d:e5:07:86:43:f4:11:04:1c:59:e2:61:9c:c0:
                47:05:a2:ed:6c:2b:57:69:af:d2:3c:50:e4:39:b2:
                d6:b3:89:55:1e:ba:6d:47:89:7a:b5:38:e5:1b:4a:
                dd:ce:18:13:35:0e:41:f4:5a:ae:e2:52:9e:a6:10:
                af:be:bc:53:e9:4a:6c:4b:34:39:54:2d:45:77:68:
                05:06:5e:8a:5d:98:76:8f:fb:5a:cd:14:b8:ef:74:
                74:8c:8a:60:d0:be:2b:96:37:bd:ce:eb:15:c7:c4:
                00:65
            Exponent: 65537 (0x10001)
    Signature Algorithm: sha256WithRSAEncryption
     54:81:c9:4a:10:6e:2d:be:9a:10:01:60:45:54:3e:50:8a:79:
     15:0a:be:5a:0b:f9:c7:04:39:d8:50:52:a0:85:ba:ad:f7:ac:
     f6:49:d1:70:3f:49:b9:ef:3b:ff:ee:20:48:25:7a:34:b3:f0:
     f8:b8:ca:8d:0d:02:07:cc:ef:22:05:64:96:9a:69:70:14:b2:
     71:ed:96:f1:cf:fc:51:a2:92:c6:3f:03:42:d7:8b:b1:5b:14:
     24:12:fc:96:b8:5f:c2:e8:59:13:f3:6c:39:b2:c5:09:04:00:
     c6:fd:ff:7c:9a:b9:84:d5:0c:ff:db:07:7c:98:ba:e8:dd:c3:
     4e:5d:27:5b:5b:80:22:b0:bb:78:2b:a2:7c:a8:9c:cd:d8:bb:
     c2:be:2c:9f:c1:44:c3:9a:1d:48:3f:66:4d:72:ba:1a:cf:8a:
     3a:fe:a2:85:12:67:2d:a8:ea:a0:e8:5f:cf:10:16:a0:1e:f2:
     2d:db:6c:01:4d:cd:15:11:46:9a:23:e4:9f:ea:1a:23:db:ac:
     2a:e5:9e:37:55:ef:bd:d4:bb:2e:03:78:8e:c0:f2:7d:68:3b:
     c7:91:0e:50:e4:24:30:af:c2:61:93:32:c5:cb:5f:58:19:3a:
     d9:27:a9:b3:44:15:5f:4b:45:be:0f:72:f3:f7:e6:5e:96:35:
     58:03:66:2b

and this is my server.crt
   openssl x509 -text -noout -in server.crt
      Certificate:
     Data:
    Version: 1 (0x0)
    Serial Number:
        15:d3:db:e7:b0:cc:76:e8:67:01:5c:a0:73:48:85:77:c5:1d:bd:ad
    Signature Algorithm: sha256WithRSAEncryption
    Issuer: C = in, ST = ka, O = livn, CN = test.mosquitto.org
    Validity
        Not Before: Jul 29 07:50:34 2021 GMT
        Not After : Jul 24 07:50:34 2022 GMT
      Subject: C = in, ST = ka, O = livn, CN = test.mosquitto.org
      Subject Public Key Info:
        Public Key Algorithm: rsaEncryption
            RSA Public-Key: (2048 bit)
            Modulus:
                00:c6:a3:cb:c0:36:ae:0f:06:c4:d4:d4:0b:2f:c5:
                0f:58:35:98:de:56:fd:67:19:25:f6:eb:a7:e2:7b:
                41:c8:ef:a8:6e:33:61:f7:62:cd:b3:82:49:c1:e6:
                4e:1c:cb:f8:f2:56:c7:b7:fa:af:3e:bd:19:0e:b4:
                32:9f:4f:45:af:95:9f:27:00:56:18:0f:10:58:3c:
                8e:90:f1:2b:e7:9a:8c:07:5b:48:06:7d:70:58:e8:
                ea:38:1d:43:fc:1a:07:58:ee:b5:d3:2e:2f:e7:7d:
                ed:1c:8c:4e:ab:a3:34:3e:9a:49:7d:85:b2:7d:8b:
                c6:b5:90:df:e4:24:5c:78:81:ce:52:be:5f:b9:27:
                5e:19:07:ff:c9:f0:04:0d:73:96:c1:ca:18:58:79:
                6e:0b:ef:cd:ab:9d:00:d4:e9:7e:b4:53:01:72:86:
                ec:e7:87:0d:90:97:df:6f:13:4f:c0:3b:4c:17:7f:
                12:09:08:87:47:75:5a:f6:c8:e6:cc:70:29:47:42:
                53:c6:5f:ff:0b:40:58:06:8d:e3:14:e5:f1:bc:15:
                fa:08:56:1b:c5:13:80:2c:e2:ee:71:c1:2d:c8:3b:
                cf:59:a3:fb:7d:64:32:6e:8f:e9:78:b5:57:9d:24:
                09:fd:bd:33:47:dd:6c:74:1d:90:21:c4:4e:9a:05:
                6a:69
            Exponent: 65537 (0x10001)
      Signature Algorithm: sha256WithRSAEncryption
     c1:8a:8d:87:23:df:8a:30:74:7a:c8:88:b5:a8:88:f9:e3:80:
     c2:c0:10:1d:da:3c:22:d2:fc:88:49:6c:b4:72:6e:07:e4:95:
     01:c7:f4:f0:bc:d6:3f:3d:26:4e:cf:fa:9a:1e:35:e8:e6:bc:
     e6:cc:dd:56:dc:df:65:bf:ab:56:fa:ab:f7:8c:84:17:da:7d:
     c5:01:a3:0f:48:7a:34:14:68:68:00:52:83:d3:8b:5e:9d:8e:
     71:84:17:c7:15:f9:21:de:5f:47:85:44:6e:5b:89:87:50:33:
     3a:a2:43:88:07:6e:cc:b3:bd:07:91:a0:dc:ef:0a:b8:cb:80:
     f3:54:6c:2e:15:13:35:c8:73:f8:8a:1d:84:c8:67:9a:02:9f:
     90:66:18:a6:e6:22:52:f8:d6:3a:b6:87:bc:73:55:e2:69:66:
     03:f2:34:57:af:9c:4b:33:6c:47:f1:d0:1a:ed:9c:53:c3:1a:
     1e:16:21:4e:74:ad:94:a8:a5:f4:3b:da:87:f3:73:02:ec:6f:
     84:eb:a0:16:77:ce:71:0b:89:62:b9:c7:f8:96:a9:83:a7:fe:
     24:4f:2e:a6:95:f7:7c:9d:b3:85:7d:66:50:5c:ad:8a:01:78:
     c0:95:86:2d:05:60:d3:6e:90:19:da:a9:cc:67:94:50:06:94:
     ed:d4:7e:66

Any help would be greatly appreciated.
Tried to connect with 8884 port then also getting this error
mosquitto_pub --cafile ca.crt --cert client.crt --key client.key  -h test.mosquitto.org -p 8884 -t test -m "hello there" -i c1 -d
Client c1 sending CONNECT
OpenSSL Error: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Error: A TLS error occurred.

A: The problem is you have not supplied a valid hostname.
-h test.mosquitto.org:8883

You need to provide the port number separately
 -h test.mosquitto.org -p 8883

You also need to use the correct CA certificate to verify the test.mosquitto.org broker:
From the test.mosquitto.org web page:

The encrypted ports support TLS v1.3, v1.2 or v1.1 with x509
certificates and require client support to connect. For ports 8883 and
8884 you should use the certificate authority file (mosquitto.org.crt
(PEM format), or mosquitto.org.der (DER format)) to verify the server
connection. Port 8081 has a Lets Encrypt certificate, so you should
use your system CA certificates or the appropriate Lets Encrypt CA
certificate for verification.

Also from the website:

*

*1883 : MQTT, unencrypted, unauthenticated

*1884 : MQTT, unencrypted, authenticated

*8883 : MQTT, encrypted, unauthenticated

*8884 : MQTT, encrypted, client certificate required

*8885 : MQTT, encrypted, authenticated

*8887 : MQTT, encrypted, server certificate deliberately expired

*8080 : MQTT over WebSockets, unencrypted, unauthenticated

*8081 : MQTT over WebSockets, encrypted, unauthenticated

*8090 : MQTT over WebSockets, unencrypted, authenticated

*8091 : MQTT over WebSockets, encrypted, authenticated

This clearly states that if you want to use client certificate authentication you need to use port 8884 not 8883.


text:
Q: Stop Animation of Sprites when touched in centre Cocos2d I want to stop all animations running on my CCSprite when the user touches a sprite in the sprite's center.
Can anyone help me come up with the code to do this or provide links to tutorials that might help please.

A: You hadn't really asked a question there, I've edited your question. I think this should give you a good start.
Implement the CCTargetedTouchDelegateProtocol and focus on this method.
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
    if (CGRectContainsPoint(GCRectMake(/*Define a rect to represent the center of your sprite*/), [touch locationInView:/*View where you want the touch to be located, usually linked to the CCDirectors OpenGL view*/])
    {
        [sprite stopAllActions];
    }
}


text:
Q: Incorrect Number of probabilities simulating a Markov chain my transition probability matrix is like this
             BP          IP             SP

BPBP     0.4586757     0.3772354     0.1640889

IPBP     0.3489484     0.4746654     0.1763862

SPBP     0.3756522     0.4162319     0.2081159

BPIP     0.3646061     0.4640000     0.1713939

IPIP     0.2666122     0.5654956     0.1678922

SPIP     0.3054187     0.4860427     0.2085386

BPSP     0.4125561     0.3974215     0.1900224

IPSP     0.2974337     0.5069415     0.1956247

SPSP     0.3576642     0.4333942     0.2089416

and the code to simulate a first order MC from it is
  function(trans,initprob,N)
  {
  BrokerPosition <- c("BP", "IP", "SP")
  mysequence<-character()
  firstposition <- sample(BrokerPosition, 1, rep=TRUE, prob=initprob)
  mysequence[1]   <- firstposition
  for (i in 2:N){
   prevposition <- mysequence[i-1]
   probabilities  <- trans[,prevposition]
   BPosition<- sample(BrokerPosition, 1, rep=TRUE, prob=probabilities)
   mysequence[i]  <- BPosition
                }
  return(mysequence)
  }

but since this is a non square matrix I am getting an error of mismatch of probabilities ,any idea how to solve this

A: You are using your transition matrix in the wrong direction:
try with
trans[ paste( mysequence[c(i-2,i-1)], collapse="" ), ]

An alternative would be to to convert your second order Markov chain into a first order one:
for instance, the states after
IPBP would be BPIP, BPBP, BPSP (and the other ones, IP* and SP*, would have zero probabilities).
The transition matrix is then a 9*9 matrix with a lot of zeroes.


text:
Q: Multidimensional integration using Divergence Theorem Considering the following integral
$$ \delta U = \frac{1}{2}\int_{\Omega} \sigma_{ij}\left( \delta \frac{\partial u_i}{\partial x_j} + \delta \frac{\partial u_j}{\partial x_i} \right) \text{d}\Omega \tag{1}$$
According to the book (Mechanical Vibrations - Michel Géradin and
Daniel J. Rixen) that I'm reading, applying the Divergence Theorem on (1) yields
$$ \delta U = \int_{\Gamma} n_j \sigma_{ij} \delta u_i\ \text{d}\Gamma - \int_{\Omega}\left(\frac{\partial \sigma_{ij}}{\partial x_j}\delta u_i \right) \text{d}\Omega \tag{2} $$
I cannot get it by applying the Divergente Theorem, as the authors said in the book.
Does someone know how I get (2) by applying Divergence Theorem on (1)?
NOTES

*

*$\sigma_{ij}$ is a symmetric tensor;

*$\delta$ is the variation from Calculus of Variations;

*$\Gamma$ is the boundary surface of $\Omega$.


text:
Q: Registration not working in magento magento 1.9X
I am using below ref to create ajax login/reg popup.
Login works fine. but not able to register.
http://fastdivision.com/2012/03/29/diy-magento-create-ajax-login-registration-forms-for-your-magento-theme/
It gives same error popup "Please make sure your passwords match". even if i use existing email.same popup error appears.
config.xml
<?xml version="1.0"?>
<config>
<modules>
    <FastDivision_QuickLogin>
        <version>1.0.0</version>
    </FastDivision_QuickLogin>
</modules>
<frontend>
    <routers>
        <customer>
            <args>
                <modules>
                    <FastDivision_QuickLogin before="Mage_Customer">FastDivision_QuickLogin_Customer</FastDivision_QuickLogin>

                </modules>
            </args>
        </customer>
    </routers>
</frontend>
</config>

AccountController.php
<?php
// Require the core controller file that you're planning to override
require_once('Mage/Customer/controllers/AccountController.php');

// The class name follows this format:
// YOURPACKAGE_YOUREXTENSION_COREMODULEFOLDER_CONTROLLERFILENAME
// We extend the original Mage_Customer_AccountController class to inherit unused actions and override specific actions
class FastDivision_QuickLogin_Customer_AccountController extends Mage_Customer_AccountController
{
// Code referenced from AccountController.php
public function loginPostAction()
{
    if(!$this->getRequest()->isXmlHttpRequest()) {
        if ($this->_getSession()->isLoggedIn()) {
            $this->_redirect('*/*/');
            return;
        }
    }

    $session = $this->_getSession();

    if($this->getRequest()->isXmlHttpRequest()) {
        // Report exceptions via JSON
        $ajaxExceptions = array();
    }

    if ($this->getRequest()->isPost()) {
        $login = $this->getRequest()->getPost('login');
        if (!empty($login['username']) && !empty($login['password'])) {
            try {
                $session->login($login['username'], $login['password']);
                if ($session->getCustomer()->getIsJustConfirmed()) {
                    $this->_welcomeCustomer($session->getCustomer(), true);
                }
            } catch (Mage_Core_Exception $e) {
                if($this->getRequest()->isXmlHttpRequest()) {
                    $messages = array_unique(explode("\n", $e->getMessage()));
                    foreach ($messages as $message) {
                        $ajaxExceptions['exceptions'][] = $message;
                    }
                } else {
                    switch ($e->getCode()) {
                        case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
                            $value = Mage::helper('customer')->getEmailConfirmationUrl($login['username']);
                            $message = Mage::helper('customer')->__('This account is not confirmed. Click here to resend confirmation email.', $value);
                            break;
                        case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
                            $message = $e->getMessage();
                            break;
                        default:
                            $message = $e->getMessage();
                    }
                    $session->addError($message);
                }

                $session->setUsername($login['username']);
            } catch (Exception $e) {
                // Mage::logException($e); // PA DSS violation: this exception log can disclose customer password
            }
        } else {
            if($this->getRequest()->isXmlHttpRequest()) {
                $ajaxExceptions['exceptions'][] = 'Login and password are required.';
            } else {
                $session->addError($this->__('Login and password are required.'));
            }
        }
    }

    if($this->getRequest()->isXmlHttpRequest()) {
        // If errors
        if(count($ajaxExceptions)) {
            echo json_encode($ajaxExceptions);
        } else {
            // No Errors
            echo json_encode(array('success' => 'success'));
        }
    } else {
        // Redirect for non-ajax
        $this->_loginPostRedirect();
    }
}

// Create Account
public function createPostAction()
{
    if($this->getRequest()->isXmlHttpRequest()) {
        // Report exceptions via JSON
        $ajaxExceptions = array();
    }

    $session = $this->_getSession();
    if ($session->isLoggedIn()) {
        $this->_redirect('*/*/');
        return;
    }
    $session->setEscapeMessages(true); // prevent XSS injection in user input
    if ($this->getRequest()->isPost()) {
        $errors = array();

        if (!$customer = Mage::registry('current_customer')) {
            $customer = Mage::getModel('customer/customer')->setId(null);
        }

        /* @var $customerForm Mage_Customer_Model_Form */
        $customerForm = Mage::getModel('customer/form');
        $customerForm->setFormCode('customer_account_create')
            ->setEntity($customer);

        $customerData = $customerForm->extractData($this->getRequest());

        if ($this->getRequest()->getParam('is_subscribed', false)) {
            $customer->setIsSubscribed(1);
        }

        /**
         * Initialize customer group id
         */
        $customer->getGroupId();

        if ($this->getRequest()->getPost('create_address')) {
            /* @var $address Mage_Customer_Model_Address */
            $address = Mage::getModel('customer/address');
            /* @var $addressForm Mage_Customer_Model_Form */
            $addressForm = Mage::getModel('customer/form');
            $addressForm->setFormCode('customer_register_address')
                ->setEntity($address);

            $addressData    = $addressForm->extractData($this->getRequest(), 'address', false);
            $addressErrors  = $addressForm->validateData($addressData);
            if ($addressErrors === true) {
                $address->setId(null)
                    ->setIsDefaultBilling($this->getRequest()->getParam('default_billing', false))
                    ->setIsDefaultShipping($this->getRequest()->getParam('default_shipping', false));
                $addressForm->compactData($addressData);
                $customer->addAddress($address);

                $addressErrors = $address->validate();
                if (is_array($addressErrors)) {
                    $errors = array_merge($errors, $addressErrors);
                }
            } else {
                $errors = array_merge($errors, $addressErrors);
            }
        }

        try {
            $customerErrors = $customerForm->validateData($customerData);
            if ($customerErrors !== true) {
                $errors = array_merge($customerErrors, $errors);
            } else {
                $customerForm->compactData($customerData);
                $customer->setPassword($this->getRequest()->getPost('password'));
                $customer->setConfirmation($this->getRequest()->getPost('confirmation'));
                $customerErrors = $customer->validate();
                if (is_array($customerErrors)) {
                    $errors = array_merge($customerErrors, $errors);
                }
            }

            $validationResult = count($errors) == 0;

            if (true === $validationResult) {
                $customer->save();

                Mage::dispatchEvent('customer_register_success',
                    array('account_controller' => $this, 'customer' => $customer)
                );

                if ($customer->isConfirmationRequired()) {
                    $customer->sendNewAccountEmail(
                        'confirmation',
                        $session->getBeforeAuthUrl(),
                        Mage::app()->getStore()->getId()
                    );
                    $session->addSuccess($this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please click here.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail())));

                    if($this->getRequest()->isXmlHttpRequest()) {
                        echo json_encode(array('success' => $this->__('Account confirmation is required. Please, check your email for the confirmation link. To resend the confirmation email please click here.', Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail()))));
                    } else {
                        $this->_redirectSuccess(Mage::getUrl('*/*/index', array('_secure'=>true)));
                    }

                    return;
                } else {
                    $session->setCustomerAsLoggedIn($customer);
                    $url = $this->_welcomeCustomer($customer);

                    if($this->getRequest()->isXmlHttpRequest()) {
                        echo json_encode(array('success' => 'success'));
                    } else {
                        $this->_redirectSuccess($url);
                    }

                    return;
                }
            } else {
                $session->setCustomerFormData($this->getRequest()->getPost());

                if(!$this->getRequest()->isXmlHttpRequest()) {
                    if (is_array($errors)) {
                        foreach ($errors as $errorMessage) {
                            $session->addError($errorMessage);
                        }
                    } else {
                        $session->addError($this->__('Invalid customer data'));
                    }
                } else {
                    if (is_array($errors)) {
                        foreach ($errors as $errorMessage) {
                            $ajaxExceptions['exceptions'][] = $errorMessage;
                        }
                    } else {
                        $ajaxExceptions['exceptions'][] = 'Invalid customer data';
                    }
                }
            }
        } catch (Mage_Core_Exception $e) {
            $session->setCustomerFormData($this->getRequest()->getPost());
            if ($e->getCode() === Mage_Customer_Model_Customer::EXCEPTION_EMAIL_EXISTS) {
                $url = Mage::getUrl('customer/account/forgotpassword');
                $message = $this->__('There is already an account with this email address. If you are sure that it is your email address, click here to get your password and access your account.', $url);
                $session->setEscapeMessages(false);
            } else {
                $message = $e->getMessage();
            }

            if(!$this->getRequest()->isXmlHttpRequest()) {
                $session->addError($message);
            } else {
                $messages = array_unique(explode("\n", $e->getMessage()));
                foreach ($messages as $message) {
                    $ajaxExceptions['exceptions'][] = $message;
                }
            }
        } catch (Exception $e) {
            if(!$this->getRequest()->isXmlHttpRequest()) {
                $session->setCustomerFormData($this->getRequest()->getPost())
                ->addException($e, $this->__('Cannot save the customer.'));
            } else {
                $ajaxExceptions['exceptions'][] = 'Cannot save the customer.';
            }
        }
    }

    if($this->getRequest()->isXmlHttpRequest()) {
        echo json_encode($ajaxExceptions);
    } else {
        $this->_redirectError(Mage::getUrl('*/*/create', array('_secure' => true)));
    }
}
}

quick_login.phtml

Register

Already registered? Click here to sign in.

  <form action="<?php echo Mage::getBaseUrl() ?>customer/account/createpost/" method="post" id="signup-form" class="site-form" onsubmit="return false">

              <?php echo $this->__('First Name') ?>*

                  <input type="text" name="firstname" id="firstname" class="input-text validate-email required-entry" />

              <?php echo $this->__('Last Name') ?>*

                  <input type="text" name="lastname" id="lastname" class="input-text validate-email required-entry" />

              <?php echo $this->__('Email') ?>*

                  <input type="text" name="email" id="email_address" class="input-text validate-email required-entry" />

              <?php echo $this->__('Password') ?>*

                  <input type="password" name="password" id="password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />

              <?php echo $this->__('Confirm Password') ?>*

                  <input type="password" name="confirmation" title="<?php echo $this->__('Confirm Password') ?>" id="confirmation" class="input-text required-entry validate-cpassword" />

    <button type="submit" title="Submit" class="action-button">Create Account</button>
  </form>

Login

<?php echo $this->__('If you have an account with us, please log in.') ?>

Need an account? Click here to register.

  <form action="<?php echo Mage::getBaseUrl() ?>customer/account/loginPost/" method="post" id="login-form" class="site-form" onsubmit="return false">

             <?php echo $this->__('Email') ?>*

                 <input type="text" name="login[username]" value="<?php echo $this->htmlEscape($this->getUsername()) ?>" id="email" class="input-text" title="<?php echo $this->__('Email Address') ?>" />

             <?php echo $this->__('Password') ?>*

                 <input type="password" name="login[password]" class="input-text" id="pass" title="<?php echo $this->__('Password') ?>" />

      <button type="submit" class="action-button action-button-no-arrow" title="<?php echo $this->__('Login') ?>" name="send" id="send2"><?php echo $this->__('Login') ?></button>
      <a href="<?php echo $this->getForgotPasswordUrl() ?>" class="small"><?php echo $this->__('Forgot Your Password?') ?>
       </form>

A: As I can see from the error you are receiving, the issue is triggered by the missing 'Password Confirmation' form.
Even if you have decided to hide it, you have to use it in order to duplicate the password in the Controller, until user's validation occurs  before saving.
Check data at the exit of the createPostAction method:
var_dump($this->getRequest()->getPost());

or via Debug (if you are using it).
The array should have the following view:
https://gyazo.com/52d5c7fe80316b9f8f3773fcfa1f6462
This is the minimum of the required parameters (those that are filled in).
If the array doesn't contain the element with the confirmation key and the meaning that corresponds to the password, it will be ignored and skipped somewhere at your template (.phtml).
If it still present there, you should check the whole set of implemented actions in createPostAction and find the spot, where it is deleted before calling Mage_Customer_Model_Customer::validate() (the is the place, where the error is generated).
If you are sending the form without using AJAX and using the Submit option, you should delete this form attribute
 onsubmit="return false;"

A: in Magento 1.9 whenever a customer checkouts or registers in storefront, "Please make sure your password match" pop up comes even if your password and confirm password fields are same. In Magento version 1.9, to Validate confirm password values in class "Mage_Customer_Model_Customer" method validate()  was changed a bit.
Before:
 $confirmation = $this->getConfirmation();

After:
$confirmation = $this->getPasswordConfirmation();

So if you are getting the same issue while checkout and registration, change the line to
$confirmation = $this->getConfirmation();


text:
Q: Failed to load viewstate composite control I have a composite control that contains a different set of child controls based on the value of one of it's properties at runtime.
Whenever there is a postback, I get the following error:
Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.

I have been googling this issue and changing the order of my child controls instantiation repeatedly without success.  Can anyone tell me what I am doing wrong here?  The controls within the composite control function correctly by themselves without error.
Here is the composite control:
    [Serializable]
public enum AddEditType
{
    SelectList,
    SelectSingleItem,
    SelectSingleItemWithForm,
    Form
}
[Themeable(true)]
[Serializable]
public class AddEdit<TBO, TCriteria> : CompositeControl
    where TBO : Bll.BOBase
    where TCriteria : Bll.BaseCriteria
{
    #region Constructor
    public AddEdit(ObjectType myObjectType, AddEditType myType, EquatableList<TBO> myDataList, EditPageViewType myViewType)
    {
        this.ObjectType = myObjectType;
        this.Type = myType;
        this.myViewType = myViewType;
        cachedOriginalList = myDataList.Clone();
        cachedCurrentList = myDataList.Clone();
    }
    #endregion

    #region Private Fields
    private EditPageViewType myViewType = EditPageViewType.Read;
    private EquatableList<TBO> cachedOriginalList
    {
        get
        {
            // Get reference to cache
            ICacheManager cache = CacheFactory.GetCacheManager();
            // Look for cached data.
            string cacheKey = GenerateCacheKey("cachedOriginalList");
            EquatableList<TBO> myList = (EquatableList<TBO>)cache.GetData(cacheKey);
            return myList;
        }
        set
        {
            // Get reference to cache
            ICacheManager cache = CacheFactory.GetCacheManager();
            // Store the value in the cache.
            string cacheKey = GenerateCacheKey("cachedOriginalList");
            cache.Add(cacheKey, value);
        }
    }
    private EquatableList<TBO> cachedCurrentList
    {
        get
        {
            // Get reference to cache
            ICacheManager cache = CacheFactory.GetCacheManager();
            // Look for cached data.
            string cacheKey = GenerateCacheKey("cachedCurrentList");
            EquatableList<TBO> myList = (EquatableList<TBO>)cache.GetData(cacheKey);
            return myList;
        }
        set
        {
            // Get reference to cache
            ICacheManager cache = CacheFactory.GetCacheManager();
            // Store the value in the cache.
            string cacheKey = GenerateCacheKey("cachedCurrentList");
            cache.Add(cacheKey, value);
        }
    }
    private Label myTitle;
    private UpdatePanel myCurrentEntriesUpdatePanel;
    private ButtonPanel myButtonPanel;
    private MyCompanygridview myCurrentEntriesGridView;
    private Panel myEditEntriesPanel;
    private HiddenField myModalPopupTargetControl;
    private ModalPopupExtender myEditEntriesPopup;
    private UpdatePanel myEditEntriesUpdatePanel;
    private Label myEditTitle;
    private Panel myEditContentPanel;
    private SearchGrid<TCriteria> mySearchGrid;
    private Button myConfirmEditEntriesChangesButton;
    private Button myCancelEditEntriesChangesButton;
    private TCriteria mySearchCriteria;

    #endregion

    #region Public Properties
    /// <summary>
    /// Gets or sets the type of display that should be shown in the Add/Edit Control.
    /// </summary>
    /// <summary>
    /// Gets or sets the type of display that should be shown in the Add/Edit Control.
    /// </summary>
    [Category("AddEdit"),
    Description("Gets or sets the type of display that should be shown in the Add/Edit Control."),
    DefaultValue(null)]
    public AddEditType Type
    {
        get
        {
            return (AddEditType)ViewState["AddEditType"];
        }
        set
        {
            ViewState["AddEditType"] = value;
        }

    }
    /// <summary>
    /// Gets or sets the type of items that should be shown in the Add/Edit Control.
    /// </summary>
    /// <summary>
    /// Gets or sets the type of items that should be shown in the Add/Edit Control.
    /// </summary>
    [Category("AddEdit"),
    Description("Gets or sets the type of items that should be shown in the Add/Edit Control."),
    DefaultValue(null)]
    public ObjectType ObjectType
    {
        get
        {
            return (ObjectType)ViewState["ObjectType"];
        }
        set
        {
            ViewState["ObjectType"] = value;
        }

    }
    public EquatableList<TBO> DataList
    {
        get
        {
            return cachedCurrentList;
        }
        set
        {
            cachedCurrentList = value;
        }
    }
    /// <summary>
    /// Gets or sets the search criteria.
    /// </summary>
    /// <value>The search criteria.</value>
    public TCriteria SearchCriteria
    {
        get
        {
            return mySearchCriteria;
        }
        set
        {
            mySearchCriteria = value;
        }
    }
    #endregion
    #region Overridden Methods
    protected override void RecreateChildcotrols()
    {
        EnsureChildcontrols();
    }
    protected override void CreateChildControls()
    {
        Controls.Clear();

        ButtonPanelType myButtonPanelType = ButtonPanelType.SelectList;
        string myEditEntriesTitle = "Select " + Enum.GetName(typeof(ObjectType), this.ObjectType) + ":";
        switch (Type)
        {
            case AddEditType.Form:
                myButtonPanelType = ButtonPanelType.SelectList;
                myEditEntriesTitle = "Edit " + Enum.GetName(typeof(ObjectType), this.ObjectType) + ":";
                break;
            case AddEditType.SelectList:
                myButtonPanelType = ButtonPanelType.SelectList;
                myEditEntriesTitle = "Select " + Enum.GetName(typeof(ObjectType), this.ObjectType) + ":";
                mySearchGrid = new SearchGrid<TCriteria>(this.ObjectType);
                break;
            case AddEditType.SelectSingleItem:
                myButtonPanelType = ButtonPanelType.SelectSingleItem;
                myEditEntriesTitle = "Select " + Enum.GetName(typeof(ObjectType), this.ObjectType) + ":";
                mySearchGrid = new SearchGrid<TCriteria>(this.ObjectType);
                break;
            case AddEditType.SelectSingleItemWithForm:
                myButtonPanelType = ButtonPanelType.SelectSingleItem;
                myEditEntriesTitle = "Select/Edit " + Enum.GetName(typeof(ObjectType), this.ObjectType) + ":";
                mySearchGrid = new SearchGrid<TCriteria>(this.ObjectType);
                break;
        }

        AddEditParser parser = AddEditParserFactory.GetParser(this.ObjectType);

        // Define the Title Label
        myTitle = new Label();
        this.Controls.Add(myTitle);
        myTitle.ID = "lblTitle";
        myTitle.Text = Enum.GetName(typeof(ObjectType), this.ObjectType) + ":";

        // Define the Current Entries Update Panel
        myCurrentEntriesUpdatePanel = new UpdatePanel();
        this.Controls.Add(myCurrentEntriesUpdatePanel);
        myCurrentEntriesUpdatePanel.ID = "updpnlCurrentEntries";
        myCurrentEntriesUpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;

        // Define the Button Panel
        myButtonPanel = new ButtonPanel(myButtonPanelType, myViewType);
        myButtonPanel.AddButtonClick += new EventHandler(myButtonPanel_AddButtonClick);
        myButtonPanel.ResetButtonClick += new EventHandler(myButtonPanel_ResetButtonClick);
        myButtonPanel.RemoveSelectedButtonClick += new EventHandler(myButtonPanel_RemoveSelectedButtonClick);
        myCurrentEntriesUpdatePanel.ContentTemplateContainer.Controls.Add(myButtonPanel);

        // Define the Current Entries MyCompanygridView using parser
        // and add it to the content template of the updatepanel.
        myCurrentEntriesGridView = new MyCompanygridview();
        parser.CreateGridViewColumns(ref myCurrentEntriesGridView);
        myCurrentEntriesUpdatePanel.ContentTemplateContainer.Controls.Add(myCurrentEntriesGridView);
        myCurrentEntriesGridView.ID = "gvCurrentEntries";
        myCurrentEntriesGridView.AutoGenerateColumns = false;
        myCurrentEntriesGridView.DataKeyNames = new string[] { "ID" };
        myCurrentEntriesGridView.DataSource = cachedCurrentList;
        myCurrentEntriesGridView.AllowSorting = true;
        myCurrentEntriesGridView.Width = new System.Web.UI.WebControls.Unit("100%");
        myCurrentEntriesGridView.AllowPaging = true;
        myCurrentEntriesGridView.EnableCustomPager = true;
        myCurrentEntriesGridView.SelectionType = MyCompanygridviewSelectionType.Multiple;

        // Define the Edit Entries Panel
        myEditEntriesPanel = new Panel();
        this.Controls.Add(myEditEntriesPanel);
        myEditEntriesPanel.ID = "pnlEditEntries";
        myEditEntriesPanel.CssClass = "modalWindow";

        // Define the HiddenField used as the TargetControlID
        // for the ModalPopupExtender, and add it to the panel.
        myModalPopupTargetControl = new HiddenField();
        myEditEntriesPanel.Controls.Add(myModalPopupTargetControl);
        myModalPopupTargetControl.ID = "hfModalPopupTargetControl";

        // Define the ModalPopupExtender and add it to the panel.
        myEditEntriesPopup = new ModalPopupExtender();
        myEditEntriesPanel.Controls.Add(myEditEntriesPopup);
        myEditEntriesPopup.ID = "mpeEditEntries";
        myEditEntriesPopup.BackgroundCssClass = "modalBackground";
        myEditEntriesPopup.PopupControlID = "pnlEditEntries";
        myEditEntriesPopup.TargetControlID = "hfModalPopupTargetControl";

        // Define the Edit Entries Update Panel
        myEditEntriesUpdatePanel = new UpdatePanel();
        myEditEntriesPanel.Controls.Add(myEditEntriesUpdatePanel);
        myEditEntriesUpdatePanel.ID = "updpnlEditEntries";
        myEditEntriesUpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;

        // Define the Edit Entries Title
        myEditTitle = new Label();
        myEditEntriesUpdatePanel.ContentTemplateContainer.Controls.Add(myEditTitle);
        myEditTitle.ID = "lblEditTitle";
        myEditTitle.Text = myEditEntriesTitle;

        // Define the Edit Entries Content
        myEditContentPanel = new Panel();
        myEditEntriesUpdatePanel.ContentTemplateContainer.Controls.Add(myEditContentPanel);
        myEditContentPanel.ID = "pnlEditContent";
        switch (Type)
        {
            case AddEditType.Form:
                parser.CreateFormControls(ref myEditContentPanel, new Dictionary<SearchPanelControlType, string>());
                break;
            case AddEditType.SelectList:
                mySearchGrid = new SearchGrid<TCriteria>(this.ObjectType);
                mySearchGrid.GridView.SelectionType = MyCompanygridviewSelectionType.Multiple;
                mySearchGrid.SearchCriteria = this.mySearchCriteria;
                myEditContentPanel.Controls.Add(mySearchGrid);
                break;
            case AddEditType.SelectSingleItem:
                mySearchGrid = new SearchGrid<TCriteria>(this.ObjectType);
                mySearchGrid.GridView.SelectionType = MyCompanygridviewSelectionType.Single;
                mySearchGrid.SearchCriteria = this.mySearchCriteria;
                myEditContentPanel.Controls.Add(mySearchGrid);
                break;
            case AddEditType.SelectSingleItemWithForm:
                mySearchGrid = new SearchGrid<TCriteria>(this.ObjectType);
                mySearchGrid.GridView.SelectionType = MyCompanygridviewSelectionType.Single;
                mySearchGrid.SearchCriteria = this.mySearchCriteria;
                myEditContentPanel.Controls.Add(mySearchGrid);
                parser.CreateFormControls(ref myEditContentPanel, new Dictionary<SearchPanelControlType, string>());
                break;
        }

        // Define the Confirm/Cancel buttons
        myConfirmEditEntriesChangesButton = new Button();
        myConfirmEditEntriesChangesButton.Click += new EventHandler(myConfirmEditEntriesChangesButton_Click);
        myEditEntriesUpdatePanel.ContentTemplateContainer.Controls.Add(myConfirmEditEntriesChangesButton);
        myConfirmEditEntriesChangesButton.ID = "btnConfirmEditEntriesChanges";
        myConfirmEditEntriesChangesButton.Text = "Save";
        myConfirmEditEntriesChangesButton.CausesValidation = true;

        myCancelEditEntriesChangesButton = new Button();
        myCancelEditEntriesChangesButton.Click += new EventHandler(myCancelEditEntriesChangesButton_Click);
        myEditEntriesUpdatePanel.ContentTemplateContainer.Controls.Add(myCancelEditEntriesChangesButton);
        myCancelEditEntriesChangesButton.ID = "btnCancelEditEntriesChanges";
        myCancelEditEntriesChangesButton.Text = "Cancel";
        myCancelEditEntriesChangesButton.CausesValidation = true;

        ConfigureDisplay();
    }

    //protected override void Render(HtmlTextWriter writer)
    //{
    //    AddAttributesToRender(writer);

    //    writer.RenderBeginTag(HtmlTextWriterTag.Div);

    //    myTitle.RenderControl(writer);
    //    myCurrentEntriesUpdatePanel.RenderControl(writer);
    //    myEditEntriesPanel.RenderControl(writer);

    //    writer.RenderEndTag();
    //}
    #endregion

    #region Public Event Handlers
    #region Make the OnCancel event of the AddEdit control visible
    private static readonly object EventCancelEditKey = new object();
    public event EventHandler CancelEdit
    {
        add
        {
            Events.AddHandler(EventCancelEditKey, value);
        }
        remove
        {
            Events.RemoveHandler(EventCancelEditKey, value);
        }
    }
    protected virtual void OnCancelEdit(EventArgs e)
    {
        EventHandler CancelEditHandler = (EventHandler)Events[EventCancelEditKey];
        if (CancelEditHandler != null)
        {
            CancelEditHandler(this, e);
        }
    }
    private void myCancelEditEntriesChangesButton_Click(object source, EventArgs e)
    {
        myEditEntriesPopup.Hide();
        ResetEditEntriesControls();
        OnCancelEdit(EventArgs.Empty);
    }
    #endregion
    #region Make the OnConfirmEdit event of the AddEdit control visible
    private static readonly object EventConfirmEditKey = new object();
    public event EventHandler ConfirmEdit
    {
        add
        {
            Events.AddHandler(EventConfirmEditKey, value);
        }
        remove
        {
            Events.RemoveHandler(EventConfirmEditKey, value);
        }
    }
    protected virtual void OnConfirmEdit(EventArgs e)
    {
        EventHandler ConfirmEditHandler = (EventHandler)Events[EventConfirmEditKey];
        if (ConfirmEditHandler != null)
        {
            ConfirmEditHandler(this, e);
        }
    }
    private void myConfirmEditEntriesChangesButton_Click(object source, EventArgs e)
    {

        if (Type != AddEditType.Form)
        {
            EquatableList<TBO> myOldList = cachedCurrentList.Clone();

            try
            {
                List<Guid> mySelectedValues = mySearchGrid.GridView.SelectedValues;

                // Add each item in the SelectedValues list
                // to the cachedCurrentList
                foreach (Guid currentGUID in mySelectedValues)
                {
                    ObjectMetaDataDictionary myOMD = ObjectMetaDataDictionary.Instance;
                    Type _objectType = myOMD[this.ObjectType].BOClass;

                    TBO myObject = (TBO)Activator.CreateInstance(_objectType);

                    // Check to see if it already exists in the
                    // cachedCurrentList. If it doesn't, add it.
                    if (!cachedCurrentList.ExistByID<TBO>(currentGUID))
                    {
                        Type _managerType = myOMD[this.ObjectType].ManagerClass;
                        Object[] myStaticMethodArguments = new Object[1];
                        myStaticMethodArguments.SetValue(currentGUID, 0);
                        MethodInfo myStaticMethodInfo = _managerType.GetMethod("GetItem");
                        myObject = (TBO)myStaticMethodInfo.Invoke(null, myStaticMethodArguments);

                        // If the Object is not null add it to the cachedCurrentList.
                        if (myObject != null)
                        {
                            cachedCurrentList.Add(myObject);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                cachedCurrentList = myOldList.Clone();
                bool rethrow = ExceptionPolicy.HandleException(ex, "Base Policy");
                if (rethrow)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.AppendFormat("Error: {0}", ex.Message);
                }
            }
        }

        myEditEntriesPopup.Hide();
        BindCurrentGrid();
        myCurrentEntriesUpdatePanel.Update();
        ResetEditEntriesControls();
        OnConfirmEdit(EventArgs.Empty);
    }
    #endregion
    #endregion

    #region Private Event Handlers

    #endregion

    #region Private Methods
    /// <summary>
    /// Creates a string used to identify this control in the cache.
    /// </summary>
    private string GenerateCacheKey(string key)
    {
        StringBuilder sb = new StringBuilder();
        sb.AppendFormat("{0}:{1}:{2}:{3}", "AddEditControl", Enum.GetName(typeof(ObjectType), this.Type), this.Context.Session.SessionID, key);
        return sb.ToString();
    }
    private void BindCurrentGrid()
    {
        myCurrentEntriesGridView.DataSource = cachedCurrentList;
        myCurrentEntriesGridView.DataBind();

    }
    protected void myButtonPanel_AddButtonClick(object sender, EventArgs e)
    {
        myEditEntriesPopup.Show();
    }
    protected void myButtonPanel_ResetButtonClick(object sender, EventArgs e)
    {
        cachedCurrentList = cachedOriginalList.Clone();
        BindCurrentGrid();
        myCurrentEntriesUpdatePanel.Update();
        ResetEditEntriesControls();
        myEditEntriesUpdatePanel.Update();
    }
    protected void myButtonPanel_RemoveSelectedButtonClick(object sender, EventArgs e)
    {
        EquatableList<TBO> myOldList = cachedCurrentList.Clone();

        try
        {
            List<Guid> mySelectedValues = mySearchGrid.GridView.SelectedValues;
            // Remove each item in the SelectedValues list from the cachedCurrentList
            foreach (Guid currentGUID in mySelectedValues)
            {
                cachedCurrentList.RemoveAll(delegate(TBO x) { return x.Id == currentGUID; });
            }
            BindCurrentGrid();
            myCurrentEntriesUpdatePanel.Update();
            ResetEditEntriesControls();
        }
        catch (Exception ex)
        {
            cachedCurrentList = myOldList.Clone();
            bool rethrow = ExceptionPolicy.HandleException(ex, "Base Policy");
            if (rethrow)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat("Error: {0}", ex.Message);
            }
        }
    }
    private void ResetEditEntriesControls()
    {
        if (Type != AddEditType.Form)
        {
            // RESET SEARCH GRID
            mySearchGrid.GridView.SelectedValues = cachedOriginalList.ToListOfIDs();
            if (typeof(IDisabledFlg).IsAssignableFrom(typeof(TBO)))
            {
                foreach (TBO item in cachedOriginalList)
                {
                    IDisabledFlg castedItem = (IDisabledFlg)item;
                    if (castedItem.DisabledFlg)
                    {
                        mySearchGrid.GridView.DisabledValues.Add(castedItem.Id);
                    }
                }
            }
            mySearchGrid.GridView.DataBind();
            mySearchGrid.SearchCriteria = this.mySearchCriteria;
        }
        if (Type == AddEditType.Form || Type == AddEditType.SelectSingleItemWithForm)
        {
            // Call parser to reset any other controls
            AddEditParser parser = AddEditParserFactory.GetParser(this.ObjectType);
            parser.SetFormControls<TBO>(null, ref myEditEntriesPanel);
        }
    }
    private void ConfigureDisplay()
    {
        myButtonPanel.ViewType = this.myViewType;
        switch (myViewType)
        {
            case EditPageViewType.Update:
                myCurrentEntriesGridView.Enabled = true;
                break;
            case EditPageViewType.Create:
                myCurrentEntriesGridView.Enabled = true;
                break;
            case EditPageViewType.Read:
                myCurrentEntriesGridView.Enabled = false;
                break;
            case EditPageViewType.Disable:
                myCurrentEntriesGridView.Enabled = false;
                break;
        }
    }
    #endregion
}

A: Error says:

control tree into which viewstate is
  being loaded must match the control
  tree that was used to save viewstate

This means that if you had some control on your page during save of the view state then it must be there during load of the view state after postback. I think you should check how your composite control creates children controls and make sure they are created after postback.

A: At least one problem with your code in CreateChildControls is that it is a mixture of control creation and data binding code. This isn't appropriate, because ViewState is loaded between control creation and data binding!
Split your code in control creation code (CreateChildControls) and data binding code, running later in the page life cycle. The load event is a good place for data binding.
Further make sure that CreateChildControls is really called before your controls are used. I prefer to call EnsureChildControls in page init.


text:
Q: Debugging a console application that crashes from drag-n-drop I built a console application that allows users to drag and drop files on to it and it will process it. However, it crashes while it's processing the file and I don't know what's going on.
How can I debug this? The console closes too fast for me to see what the issue was, and I can't reproduce the error when I call it through command-line and specify some args there.
The procedure is as follows

*

*In windows explorer, I drag my input file (an image) over an exe

*The exe would then read the image and do something with it

*I then save the image in a new file

The crash occurs during the saving, but I am not too interested in where the issue is, but the fact that I can't come up with a way to actually debug this properly.

A: If your app is started automatically by some other program (like explorer) - configure Launch debugger on process start.
Another simple way (when tweaking registry is not an option) is to add Debugger.Break in your code to have chance to attache debugger. Or even Thread.Sleep(10000) to give you chance to catch it.
There is nothing very specific about drag-n-drop (unlike focus issues that often require remote debugging).
Either start application form VS with correct parameter or attach to running appliction. You may want to turn on "Debug->Exception->break when thrown" for CLR exceptions (may need to disable "Tools->Options->Debug->My code only").
Watch output window while attached to the process for any suspicious traces.
If VS is getting in a way you can use WinDbg the same way... But try VS route first before.

A: You can specify you're debugging command lines in the project propertys just like

then you can place your breakpoints like you would do usually and debug your app.

A: First make sure you tried everything Alexei Levenkov mentioned, if that doesn't work to you (which likely will only happen if you are doing things wrong somehow) you could also use a simple logfile to trace the error, but I would always go with the VS debugger, since thats mutch more confortable.


text:
Q: What should an object look like? I am constantly debating how best to create my classes.
By this I mean why dont we always create a class that Implements INotifyPropertyChanged and IDataErrorInfo so that "if" we want to we can bind directly in our forms, and why dont we always decorate them with the  attributes so that if we want to we can use the class in WCF?
I mean apart from the obvious extra code, and more testing wont this give us better flexibility?
I always hear - 'create once' and use 'everywhere' but I am also in tune with 'YAGNI' (you aint going to need it).
I guess my question here is has the idea of 'a business class' than can be re-used dead? and do we say 'create the most basic' that works for now, and build upon it when required?
R

A: I think it's usually better to make your classes more focused to a small set of specific tasks, rather than creating objects that can be used in a variety of scenarios.  For example, you might have data-layer objects that have all the data-layer specific attributes/behaviors, presentation layer objects with all the presentation layer stuff, and service layer objects, etc.
If you make your classes too "all-powerful" you'll end up creating a lot of dependencies in your different layers, which make it much more difficult to change in the future.  Do a google search for "Single Responsibility Principle" - it's one of the "SOLID" principles of OO.

A: I create many, many classes that are very far removed from the UI.  Implementing those interfaces every time would be a heavy burder, with minimal reward.

A: First off, programmers are lazy, our modivation is to automate boring tasks. (no I'm not being negative) We generally write classes to serve a particular purpose which dicates what sort of extra bits go into it. You are asking the basic question that aspect oriented programming attempts to answer. Is my class a serivce? Is my class a data container? Is my class observable? These are aspects your class can be all of these things depending on usage. Or it may only ever be one of them.

A: If you do that, where do you draw the line? Are you going to make all your classes Exceptions because some day you might want to throw them from somewhere? Are you going to make them all serializable?
Another way you can think about it is that the language designers already made that decision for you - all classes automatically inherit from Object, which contains everything a "general" object needs.
Finally, don't confuse code reuse with writing unnecessary code. In general, you should only write the code that you need right now, but design it so that it's easy to use/change in the future.


text:
Q: Is anybody working on a high level standard library for C++ STL/Boost cover all the low level stuff.
But what about the higher level concepts?
Windows: We have multiple windowing libs

*

*KDE(Qt)

*Gnome

*Motif(C but written in OO style)

*MS Windows

*etc

But is anybody working on a unified standard for windowing?
Something that wrapped all the above would be acceptable. (even if it only accessed the common stuff it would be a starting point).
Networking:
There are a couple out there (including the Boost low level stuff).
But is there anybody working on a Service based network layer?
All the other stuff that Java/C# have in their standard libraries.
The stuff that makes it simpler for a beginner to jump in and say Wow done and it works everywhere (nearly).
Anyway. Here hoping there are some cool projects out there.
Edit
Maybe there is not one.
But if there are a couple that could be bundled together as a starting point (and potentially modified over time (where is that deprecated keyword)) into a nice consolidated whole.
Note: Windows is just a small part of what I am looking for. The Java/C# languages consolidate a lot more under the hood than just the GUI. What would be a good set of libraries to get all the functionality in one place.

A: The Poco C++ project aims to deliver all that you ask, except for Windowing:

The POCO C++ Libraries aim to be for
  network-centric, cross-platform C++
  software development what Apple's
  Cocoa is for Mac development, or Ruby
  on Rails is for Web development — a
  powerful, yet easy to use platform to
  build your applications upon.

A: Qt might be the only framework complete enough to be what you suggest.

A: I guess there's some kind of keyword lookup driving the advertising here because I'm seeing a REALbasic ad, which is what I generally use for cross-platform GUI's nowadays.
I have spent a lot of time over the last 15 years working in C++ GUI's including retailing my own portability layer for CodeWarrior PowerPlant and working on the two Macintosh-based GUI code generators, including adding Windows generation to AppMaker. I've worked with wxWidgets, mainly wxPython. So, my opinion on difficulties in cross-platform GUI is fairly well-qualified :-)
Cross-platform GUI frameworks are hard to the point of nearly impossible without significant compromise - the issues come down to subtle matters of behavior which generally bother users at a level where some of them can't quantify but know that the application doesn't feel right. This is a lot harder to fix than just rendering native controls.
I started using REALbasic because their framework does a better job of getting the feel right than anything else I'd tried (I didn't get into Qt because of the expensive commercial license).
The reason it has taken so long for things to evolve is nothing to do with the C++ world moving slowly, it's just an intractable problem. The very best cross-platform Java apps do some stuff conditionally for OS/X and it is still screamingly obvious to an experienced user that they are not a native Mac app, although some are very usable and come pretty close to looking native - Oxygen XML editor and DeltaWalker are two of my favourites.

A: I don't think it is achievable to make a really comprehensive portable GUI library. Operating systems are just too different. Can you imagine a GUI library that would cover everything from iPhone to Windows 7 and wouldn't feel wierd on any of them?

A: A Boost gui library comes up occasionally.
The general opinion seems to be that the problems is too wide (are you targeting cellphones, FPS games or CAD workstations) and that it is too much work - Qt/wxWidgets has taken 10years.
see http://lists.boost.org/Archives/boost/2005/09/94453.php for a discussion.
It would have been nice because GUI usually means cross platform and threads, so all the GUI toolkits have invented their own cross platform,filesystem and thread classes. On the other hand if a standard GUI had been introduced in C++ it would probably look like TK !

A: What's so great about standardization ?  Sure, if novice coders want to download one SDK to build portable apps, let them download Qt (or something similar) and forever remain within it's fine walled environment.  But it'd be a tragedy if the C++ world revolved around that one library and boost and POCO and wxWidgets and clutter and blitz++ and eigen and and 101 other wonderful things (yes, gtkmm and ACE even) were stifled at birth because the gatekeepers of The Standard Library didn't see fit to admit them.
Diversity is good I think (although when dealing with it, it helps to have a good package manager; I've spent hours setting up build dependencies on Windows which just needed a few seconds of apt-getting on Debian).

A: There are too big differences between platforms to get a definitive C++ standard for GUI programming. I think Qt is about as close as you will get in the forseeable future. wxWidgets is another popular choise, but as I understand it, they are using less modern c++ features.
As for networking, I think you are being kind of vague. If you mean web services over HTTP, I would have a look at Pion.

A: Well it is almost 2010 and C++ almost has threads.
I'll probably get slammed for this but C++ moves too slow - to its own detriment and its user base.  I readily acknowledge the difficulty of the technical and political issues involved but that's still the dirty reality of it.  The language can't build in higher level concepts when it takes 5-10 years to agree on and implement the building blocks.
The reasons for this have endlessly debated but the sad truth is that C++ has relegated itself to a niche language.  I like C++ but I look at the progress C#, Java, and even Python and Ruby have made over the last 5 years and I increasingly question whether C++ is worth the effort.

A: ACE is great for concurrent communication and networking.

A: For cross platform windowing, there's wxWidgets. (formerly wxWindows).

A: Only everybody and his brother, but hardly any of them actually get anywhere.


text:
Q: Doing HTTP call from inside forEach and if condition gives 'subscribe' does not exist on type 'void' error Below is my service method:
    public saveCustomFieldsData(customAttributes) {
        // return this.httpc.post(url, customAttributes, {headers: httpOptions.headers})
        //   .pipe(map(res => res));  //Working

        customAttributes.forEach(function (arrayItem) {
          if(arrayItem.action == 'edit') {
            return this.httpc.post(url, customAttributes, {headers: httpOptions.headers})
            .pipe(map(res => res));  //Not working
          }
        });
    }

I am calling this from my component
    this.customFieldsService.saveCustomFieldsData(this.customAttributes).subscribe((res: any[]) => {
        // logic
    });

This is working with commented code which does not have the if condition. But when I try to move this HTTP call inside forEach and if condition, I am getting Property 'subscribe' does not exist on type 'void' error. How do I modify my code to work from inside forEach and if condition?


text:
Q: How to proceed with the differential equation $x^{\left(x\right)}=0$, where $x\in\mathbb{N}$? I was thinking of some differential equation to do and I came up with this equation, parentheses mean how many times the function is derived. The first thing I did was the Laplace transform on both sides. (Here I will use the capital letter L to express the Laplace transform)$$L(x^{\left(x\right)})=L(0)$$Knowing from the Laplace Transform Table, $L(0)=\frac{0}{s}=0$, and that $L(x^{\left(y\right)})=s^yX-\sum _{n=1}^ys^{y-n}x^{\left(n-1\right)}\left(0\right)$, replacing x and y with x and putting it in the equation, we have $$s^xX-\sum _{n=1}^xs^{x-n}x^{\left(n-1\right)}\left(0\right)=0$$Isolating the X we have$$X=\frac{\sum _{n=1}^xs^{x-n}x^{\left(n-1\right)}\left(0\right)}{s^x}$$Cutting the top and bottom $s^x$, we have$$X=\sum _{n=1}^x\frac{x^{\left(n-1\right)}\left(0\right)}{s^n}$$Now doing the Inverse Laplace Transform on both sides we have$$L^{-1}\left(X\right)=L^{-1}\left(\sum _{n=1}^x\frac{x^{\left(n-1\right)}\left(0\right)}{s^n}\right)$$The Laplace Inverse of Laplace Transform is the original function, so $L^{-1}\left(X\right)=x$, and $L^{-1}\left(\sum _{n=1}^x\frac{x^{\left(n-1\right)}\left(0\right)}{s^n}\right)=\sum _{n=1}^xx^{\left(n-1\right)}\left(0\right)L^{-1}\left(\frac{1}{s^n}\right)$, knowing that x is greater than or equal to 0 and n goes from 1 to x, so n is a number that fits the rule $L^{-1}\left(\frac{\left(n-1\right)!}{s^n}\right)=t^{n-1}$, knowing that $L^{-1}\left(\frac{1}{s^n}\right)=\frac{L^{-1}\left(\frac{\left(n-1\right)!}{s^n}\right)}{\left(n-1\right)!}$, finally we have to $L^{-1}\left(\frac{1}{s^n}\right)=\frac{t^{n-1}}{\left(n-1\right)!}$, replacing these transforms in the equation we have$$x=\sum _{n=1}^x\frac{t^{n-1}x^{\left(n-1\right)}\left(0\right)}{\left(n-1\right)!}$$Unfortunately I don't know how to proceed from here, so can someone please help me?

A: If $x$ is a natural valued function, but can take a real valued input, then it should be clear that $x$ is locally constant anywhere it is locally continuous. To see why, consider what a continuous $x$ would look like if it wasn't constant, if it went from $1$ to $2$, it would have to pass through $1.5$ to get there, which isn't allowed because $1.5$ isn't a natural number.
Since the derivative is only defined where the function is continuous, and our function is constant anywhere it is continuous, we only need to consider the derivative of constant valued functions. If $x = 0$ then $x^{(0)} = x = 0$. If $x > 0$ then $x^{(x)} = 0$ because $x$ is a constant being differentiated at least once.
Since every natural number constant satisfies this equation, and every continuous piece of a natural valued function is constant, then every natural valued function satisfies this equation wherever it is continuous. If $x$ is continuous everywhere, it is constant everywhere, and thus is a solution everywhere.


text:
Q: One Program Constantly Crashes Entire Linux Session - How do I Sandbox this Program? Ubuntu 16.04 with GNOME is my setup
I program in the language R using the R Studio IDE. The rsession program in my system monitor consumes ~200 MB of RAM at any given time. Every 30-60 minutes the rsession consumption exponentially increases until it's consuming ~7 GB in the system monitor. I only have 8 GB of RAM. At this point my entire Ubuntu session basically freezes, and I can only move the mouse around.
Why doesn't Linux catch this type of memory leak before it halts my whole system? The same thing happens when I use this program on Windows, but instead of a system freeze, I get an error, I CTRL+ALT+DEL, kill the program and then I restart the program where I left off and am immediately back in the game.
In Ubuntu everything is totally frozen and I have to hard reset. This kills my workflow for 5-10 minutes. If I continuously CTRL+F1 frantically for several straight minutes I can sometimes get to a terminal console, but that's an exercise in madness. How do I get Ubuntu to put the brakes on rogue processes before they freeze my entire GNOME session? I've filed a bug with R and R Studio but that doesn't help me until this issue is fixed (if ever). I'm fine with the program crashing, I'd simply like to kill, restart, and pickup where I left off.


text:
Q: Как вызвать событие кликом по столбцу (BarChart) в PyQt5 Хочу вывести в консоль индекс стобца при нажатии мыши. Для примера скидываю свою реализацию
from PyQt5.QtChart import *
from PyQt5.Qt import *
from PyQt5.QtGui import QPainter
import random

class MainWidow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.resize(800 ,500)
        series = self.append_series()
        self.chart = QChart()
        self.chart.addSeries(series)
        self.chart.setTitle("Simple percentbarchart example")

        chartView = QChartView(self.chart)
        chartView.setRenderHint(QPainter.Antialiasing)

        self.setCentralWidget(chartView)

    def append_series(self):
        set0 = QBarSet("Min")
        set1 = QBarSet("Mid")
        set2 = QBarSet("Max")

        set0.append([random.randint(0, 10) for i in range(5)])
        set1.append([random.randint(0, 10) for i in range(5)])
        set2.append([random.randint(0, 10) for i in range(5)])

        series = QStackedBarSeries()

        series.append(set0)
        series.append(set1)
        series.append(set2)
        series.setBarWidth(1)

        return series

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    window  = MainWidow()
    window.show()
    sys.exit(app.exec_())

A: У QStackedBarSeries есть сигнал clicked, что вернет индекс столбца и по какой части попали при клике.
Добавьте строку series.clicked.connect(self._on_click_series) и метод:
def _on_click_series(self, index, bar_set):
    print(index, bar_set)

Пример:
from PyQt5.QtChart import *
from PyQt5.Qt import *
from PyQt5.QtGui import QPainter
import random

class MainWidow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.resize(800 ,500)
        series = self.append_series()
        self.chart = QChart()
        self.chart.addSeries(series)
        self.chart.setTitle("Simple percentbarchart example")

        chartView = QChartView(self.chart)
        chartView.setRenderHint(QPainter.Antialiasing)

        self.setCentralWidget(chartView)

    def append_series(self):
        set0 = QBarSet("Min")
        set1 = QBarSet("Mid")
        set2 = QBarSet("Max")

        set0.append([random.randint(0, 10) for i in range(5)])
        set1.append([random.randint(0, 10) for i in range(5)])
        set2.append([random.randint(0, 10) for i in range(5)])

        series = QStackedBarSeries()
        series.clicked.connect(self._on_click_series)

        series.append(set0)
        series.append(set1)
        series.append(set2)
        series.setBarWidth(1)

        return series

    def _on_click_series(self, index, bar_set):
        print(index, bar_set.label())

if __name__ == "__main__":
    import sys
    app = QApplication(sys.argv)
    window  = MainWidow()
    window.show()
    sys.exit(app.exec_())


text:
Q: kubernetes volumes not visible I have pod definition file
apiVersion: v1
kind: Pod
metadata:
  name: ubuntu-docker-soc
spec:
  containers:
  - name: ubuntu-docker-soc
    image: rajendarre/ubuntu-docker
    command: [ "/bin/sh", "-c", "--" ]
    args: [ "while true; do sleep 30; done;" ]
    volumeMounts:
    - name: dockersock
      mountPath: "/var/run/docker.sock"

  restartPolicy: Never
  volumes:
  - name: dockersock
    hostPath:
      path: /var/run/docker.sock

I have created pod successfully ,
but command kubectl get pv is not showing any volumes ,
as I have volume  dockersoc , it should come as volume .
please let me know understanding is correct ?

A: PersistentVolume is a provisioned cluster resource, where else local file or directory  that you mount from the underlying node directly in your pod is not a cluster resource that requires provisioning. Therefore in your example, kubectl get pv will not get you anything.
Here's a good discussion about PV/PVC on major cloud providers.


text:
Q: sorting std::vector with numeric data I have a vector<string> container but the strings are all numbers
EDIT: I tried this:
so now the logic seems to be borked
cleaned this up but experimenting with various attempts to cast std::string to an int is tough
lamba was useless and I have run out of ideas for casting std::string without some bug surfacing
template<typename Iterator>void bubbleSort(Iterator first, Iterator last){
    Iterator i, j;
    for (i = first; i != last; i++)
        for (j = first; j < i; j++)
            if (*i < *j)
                std::iter_swap(i, j); // or std::swap(*i, *j);
}

My code to read the source data is
void loadgames(void) { // read the game app id's
ifstream inFile;
ofstream outFile;
string s;
inFile.open("game-list.txt");
if (inFile.is_open()) {
    while (std::getline(inFile, s)) {
        if(s.length() > 0)
            gamelist.push_back(s);
    };
    inFile.close();
}
//  bubbleSort(gamelist.begin(),gamelist.end());
outFile.open("game-list.txt");
if (outFile.is_open()) {
    for (i = gamelist.begin(); i != gamelist.end(); i++) {
        outFile << *i << endl;
    }
}
outFile.close();

}
The call to is the problem of sorting my vector
bubbleSort(gamelist.begin(),gamelist.end());

A: As you already know, you can use std::sort() with a custom comparator.  The problem is your compare is setup wrong.  Its parameters need to be the container's value_type, not the container type.  And you have an erroneous . in it.
Try this instead:
std::vector<std::string> gamelist;
// fill gamelist as needed...

auto compare = [](const std::string &a, const std::string &b){
    return std::stoi(a) < std::stoi(b);
};

std::sort(gamelist.begin(), gamelist.end(), compare);

Online Demo
However, I would suggest using std::vector<int> instead (or appropriate integer type, depending on your string contents), and simply parse the std::strings into integers with std::stoi() (or equivalent) before inserting them into the std::vector, eg:
std::vector<int> gamelist;
// fill gamelist as needed...
gamelist.push_back(std::stoi(someString));
...
std::sort(gamelist.begin(), gamelist.end());

Online Demo
This will consume less memory and sort much faster, and it will reduce the complexity of the sort since you will be incurring the overhead of converting strings to integers only one time up front, not on every iteration of the sort algorithm (potentially parsing the same strings over and over).


text:
Q: MKAnnotationView - hard to drag I have a MKAnnotationView that the user can drag around the map.
It is very difficult for a user to drag the pin.  I've tried increasing the frame size and also using a giant custom image.  But nothing seems to actually change the hit area for the drag to be larger than default.
Consequently, I have to attempt to tap/drag about ten times before anything happens.
MKAnnotationView *annView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"bluedot"] autorelease];

UIImage *image = [UIImage imageNamed:@"blue_dot.png"];

annView.image = image;
annView.draggable = YES;
annView.selected = YES;
return annView;

What am I missing here?
EDIT:
It turns out the problem is that MKAnnotationView needs to be touched before you can drag it.  I was having trouble because there are a lot of pins nearby and my MKAnnotationView is very small.

A: I didn't realise MKAnnotationView needed to be touched before you can drag it.
To get around this, I created a timer that selected that MKAnnotationView regularly.
NSTimer *selectAnnotationTimer = [[NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(selectCenterAnnotation) userInfo:nil repeats:YES] retain];

and the method it calls:
- (void)selectCenterAnnotation {
    [mapView selectAnnotation:centerAnnotation animated:NO];
}

A: Instead of using a timer, you could select the annotation on mouse down. This way you don't mess with the annotation selection, and don't have a timer for each annotation running all the time.
I had the same problem when developing a mac application, and after selecting the annotation on mouse down, the drag works great.

A: Just came here to say this still helped me today, multiple years later.
In my application, the user can place a bounding area down with annotations and (hopefully) move them around freely. This turned out to be a bit of a nightmare with this "select first and then move" behaviour and just plain made it difficult and infuriating.
To solve this, I default annotation views to selected
func mapView(_ mapView: MKMapView,
             viewFor annotation: MKAnnotation) -> MKAnnotationView? {
  let view = MKAnnotationView(annotation: annotation, reuseIdentifier: "annotation")
  view.isDraggable = true
  view.setSelected(true, animated: false)

  return view
}

The problem is that there is an annotation manager that resets all annotations back to deselected, so I get around this in this delegate method
func mapView(_ mapView: MKMapView,
             annotationView view: MKAnnotationView,
             didChange newState: MKAnnotationView.DragState,
             fromOldState oldState: MKAnnotationView.DragState) {

  if newState == .ending {
    mapView.annotations.forEach({
      mapview.view(for: $0)?.setSelected(true, animated: false)
    })
  }

It's a stupid hack for a stupid problem. It does work though.


text:
Q: Prove $e^c>c^e$ if $c>0$ and $e \neq c$ using graph. I am on this question where it tells me to show $e^c>c^e$ if $c>0$ and $e \neq c$ using the graph of $\dfrac{(log(x))}{x}$.

Now it is obvious that the graph reaches a maximum at $x=e$ but how do i use this graph to show the above statement??
Any hints or advice to get me on the right track would be much appreciated.

A: Since the exponential function is increasing, it suffices to show that $\log(e^c) > \log(c^e)$ for $c > 0, c \not= e$. Can you do this?


text:
Q: I wanted to know how to identify the amount of storage an iPhone has in total - not the storage remaining - using Swift UI Thanks! I was not able to find much documentation on this online. I appreciate the help.

A: func deviceRemainingFreeSpaceInBytes() -> NSNumber {
          let documentDirectoryPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
          let systemAttributes = NSFileManager.defaultManager().attributesOfFileSystemForPath(documentDirectoryPath.last as String, error: nil)
          return systemAttributes[NSFileSystemFreeSize] as NSNumber
        }

try this. Hope this helps


text:
Q: How to accelerate ajax http request using Greasemonkey? hey guys well when am gonna take an appointment and send request  to that server https://algeria.blsspainvisa.com/appointment.php its keep loading without giving me any answer
any solutions to speed up that request to server to  get the answer fast

// ==UserScript==
// @name        BLS FAST REQUEST
// @require      https://algeria.blsspainvisa.com/french/js/jquery-1.11.0.min.js
// @include      https://*.blsspainvisa.com/*/appointment.php
// @include      https://*.blsspainvisa.com/appointment.php
// @grant       GM_xmlhttpRequest
// @connect     blsspainvisa.com
// ==/UserScript==

GM_xmlhttpRequest ( {
    method:     'GET',
    url:        'https://Algeria.blsspainvisa.com/appointment.php',
    onload:     function (responseDetails) {


text:
Q: Delete Rows in Qgis using Field Calculator I tried to delete all rows where Field  "Width"  has value 2?

A: You should be able to follow these steps to delete the rows with the value of interest, in your case 2.

*

*You will need to make the layer editable

*Open the attribute table and select the features of interest

*Then click the delete button.

Not sure if you could use the field directly to delete.

A: I don't know, whether you directly can delete rows via the calculator (doubt so strongly), but you can use select by expression, type "width" = 2 and then delete the marked rows manually.


text:
Q: Git cannot lock ref 'HEAD': unable to resolve reference HEAD when i try to commit I have a problem with Github.
Yesterday it was working normally, but today it looks like this:

i clicked the button to stash it but doesn't take me anywhere. I opened vscode, so, look the error file

so I pasted and copied the code saved on Github web, ok, I saved it, I tried to make a commit end it's error.

i don't know what i should do for my github to work normally

A: Run git fsck and post the output.
If that shows errors (and I'm pretty sure it will), try running:
git reflog expire \
    --stale-fix \
    --expire-unreachable=now \
    --all \
    --rewrite &&
for REMOTE in $(git remote); do
    git remote set-head "$REMOTE" --delete
done

Failing that, try a re-clone.


text:
Q: Accidently overwrote /boot folder files I was trying to install a chronOS kernel. But instead of copying vmlinuz-3.19.0-25-chronos, System.map-3.0.24-chronos, config-3.0.24-chronos i overwrote vmlinuz-3.19.0-25-generic, System.map-3.0.24-generic, config-3.0.24-generic. I have not rebooted yet. Can someone tell me how can i get these files back?

A: sudo apt-get install --reinstall linux-image-3.19.0-25-generic

In general, you can find out what package owns a file with dpkg -S /path/to/file and reinstall if needed.


text:
Q: IP address ranges for EC2 Is there any public info on what public IP address ranges Amazon EC2 uses? I would like to be able to lookup an IP and know whether or not it's an EC2 machine. I know that the DNS name given to EC2 machines gives a hint that it's an EC2 account, but I really prefer to just have an IP lookup available.
Tx, Simon @ http://LabSlice.com

A: You can find information on the public IP ranges used by AWS here:
https://ip-ranges.amazonaws.com/ip-ranges.json
See the documentation:
http://docs.aws.amazon.com/general/latest/gr/aws-ip-ranges.html

A: Amazon maintains the list of EC2 IP Ranges here:
https://forums.aws.amazon.com/ann.jspa?annID=1701

A: There are a couple different sources, but none of them are amazing.
BigJoe mentions https://forums.aws.amazon.com/ann.jspa?annID=1701. (If this is broken, try looking for the top sticky in the forum.)
There's also http://ec2-reachability.amazonaws.com/, which is a less concise list since it includes several narrower ranges for testing IP routing.
For a processed version of those two in a more machine readable format, you might try https://github.com/ab/ec2-ip.

A: Here's an other link:
http://www.uncompiled.com/2010/04/current-amazon-ec2-public-ip-ranges/
 US East (Northern Virginia):
 216.182.224.0/20 (216.182.224.0 – 216.182.239.255)
 72.44.32.0/19 (72.44.32.0 – 72.44.63.255)
 67.202.0.0/18 (67.202.0.0 – 67.202.63.255)
 75.101.128.0/17 (75.101.128.0 – 75.101.255.255)
 174.129.0.0/16 (174.129.0.0 – 174.129.255.255)
 204.236.192.0/18 (204.236.192.0 – 204.236.255.255)
 184.73.0.0/16 (184.73.0.0 – 184.73.255.255)
 184.72.128.0/17 (184.72.128.0 – 184.72.255.255)

 US West (Northern California):
 204.236.128.0/18 (216.236.128.0 – 216.236.191.255)
 184.72.0.0/18 (184.72.0.0 – 184.72.63.255)

  EU (Ireland):
  79.125.0.0/17 (79.125.0.0 – 79.125.127.255)

  Asia Pacific (Singapore)
  175.41.128.0/18 (175.41.128.0 – 175.41.191.255)


text:
Q: Create a Blinking and Colour Changing TextView I am creating a basic application where I have a few EditText fields and TextView fields.  I am wanting to create an activity where if I type 'yes' in the EditText field TFusername, I want the EditText field containing the word 'yes' to blink several times and also change to green in colour which can be either the text itself or the EditText field box.  Can someone help me on how the .java code should be written out for this processs?
I have attached the .xml code below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="16dp" >

<TextView
    android:id="@+id/result_text"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:layout_above="@+id/bVoice"
    android:layout_marginBottom="10dp"
    android:layout_centerHorizontal="true" />

<ListView
    android:layout_width="100dip"
    android:layout_height="40dip"
    android:id="@+id/lvVoiceReturn"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/TFusername"
    android:hint="type here"
    android:textColor="#FF7A7A7A"
    android:gravity="center_horizontal"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

<TextView
    android:id="@+id/caption_text"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:typeface="sans" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Speak"
    android:id="@+id/bVoice"
    android:layout_gravity="bottom"
    android:onClick="onButtonClick_1"
    android:layout_alignTop="@+id/Blogin"
    android:layout_toLeftOf="@+id/Blogin"
    android:layout_toStartOf="@+id/Blogin" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Login"
    android:id="@+id/Blogin"
    android:layout_gravity="center_horizontal"
    android:layout_alignParentBottom="true"
    android:layout_alignLeft="@+id/result_text"
    android:layout_alignStart="@+id/result_text" />

<EditText
    android:id="@+id/editText72"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:gravity="center"
    android:inputType="textMultiLine"
    android:text="Test Application"
    android:textSize="30sp"
    android:layout_below="@+id/TFusername"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="67dp" />

<EditText
    android:id="@+id/editText73"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText72"
    android:layout_marginTop="15dp"
    android:layout_toLeftOf="@+id/result_text"
    android:ems="10"
    android:gravity="center"
    android:inputType="textPersonName"
    android:text="YES"
    android:textColor="@android:color/darker_gray" />

<EditText
    android:id="@+id/editText75"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText72"
    android:layout_marginTop="15dp"
    android:layout_toEndOf="@+id/editText73"
    android:layout_toRightOf="@+id/editText73"
    android:ems="10"
    android:gravity="center"
    android:inputType="textPersonName"
    android:text="NO"
    android:textColor="@android:color/darker_gray" />

A: Animation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(50); //You can manage the blinking time with this parameter
anim.setStartOffset(20);
anim.setRepeatMode(Animation.REVERSE);
anim.setRepeatCount(Animation.INFINITE);
anim.setAnimationListener(new AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                // if you want to change color at start of animation
                //textview.settextcolor("your color")
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                // if you want to change color at end of animation
                //textview.settextcolor("your color")
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });
myText.startAnimation(anim);

Use setAnimationListener callback to change color of text in text view.