text:
Q: Determining whether a polynomial is monotonic on a given interval $I$ Consider a regression/data fitting problem with polynomials.
We have an extra constraint that the solution must be monotonic. So I have the following questions:

*

*For a given polynomial, how to efficiently determine if it is monotonic (at least in a given interval)?

*Furthermore, how to impose the monotonic constraint (again at least in a given interval)?

Thanks a lot in advance!

A: A polynomial $p(x)$ is monotonic on an interval $I$ iff its derivative $p'(x)$ is everywhere nonnegative or everywhere nonpositive on $I$, or equivalently if all of the roots of $p'(x)$ in the interior of the interval have even order.
As an manually workable example, consider a generic cubic polynomial $$p(x) := Ax^3 + Bx^2 + Cx + D.$$ Differentiating gives $$p'(x) = 3A x^2 + 2B x + C,$$ and (henceforth provided that $A \neq 0$) this has no real roots if $$\Delta := (2B)^2 - 4(3A)(C) = 4(B^2 - 3 A C)$$ is negative and a real double root if $\Delta = 0$. If $\Delta > 0$ then $p'$ has two single roots.
So, $p$ is monotonic on $\mathbb{R}$ iff $\Delta \leq 0$. On an interval $I$, $p$ is monotonic iff either (1) $\Delta \leq 0$ or (2) $\Delta > 0$ and neither of the roots of $p'$ (which can be computed with the quadratic formula) are contained in the interior of $I$.

A: It looks like someone else had your problem (monotone approximation) and labeled it as "nontrivial" in this paper which proves a theorem related to your problem, but I can't figure out the implications for you.

A: A little late to the party but I'd like to add my answer for anyone who happens to stumble upon this.

*

*To determine if the polynomial $p(x)$ is monotonic on the interval $[a,b]$:

Calculate the derivative $p^{\prime}(x)$ and its real roots in the desired interval, namely the points $x^{*} = \{x \in [a,b]:p^{\prime}(x)=0\}$. If all roots in $x^{*}$ have even multiplicity or $x^{*}$ is empty then the polynomial is monotonic. This also works for monotonicity over the entire real line. You will need to check at least one value of $p^{\prime}(x)$ in $[a,b]$ to determine if it is monotonically increasing or decreasing. I'm currently working on a package for constrained regression (very early stages) and have this coded up in R here.

*There are several methods for fitting monotone polynomials to data:

Currently the best available is an R package called MonoPoly, see here. The MonoPoly package works by using a parameterisation of the polynomial which enforces monotonicity of a region. I'll update this answer with my work when it is more refined.
UPDATE: Fit monotone polynomial (and mixed effects models) with gcreg.

A: Travis is right, hobs is mistaken I'm afraid. When the roots of the derivative have even multiplicity but are real, there exist values of which the derivative is strictly negative and values of which it is strictly positive. So your polynomial is not monotonic. I think hobs thinks about the matrix of which the derivative is the characteristic equation. Then the roots are the eigenvalues, and the matrix is definite.


text:
Q: JQuery UI Autocomplete - hide result list when no matches I have the following problem:
I have a working implementation of JQuery UI Autocomplete that gathers results from MYSQL Database and autotomatically fills some input fields based on user's choice.
What I am currently trying to get working is the situation when you type your search and there are no search results. Right now, the last suggested search items stay visible until you click away with mouse button. I would like to be able to hide it once there are no matching  results. I have read a lot on this topic but nothing seemed to work for me. This is my Javascript part:
function AutoFill(x) {
  var classname = "." + x;

    $(document).on('keydown', classname, function(){

  var id = this.id;
  var splitid = id.split('_');
  var index = splitid[1];

  // Initialize jQuery UI autocomplete
  $( '#'+id ).autocomplete({
   source: function( request, response ) {
    $.ajax({
     url: "get-details.php",
     type: 'post',
     dataType: "json",
     data: {
      search: request.term,request:1
     },

     success: function( data ) {
          response(data);

     }
    });
   },

   select: function (event, ui) {
    $(this).val(ui.item.label); // display the selected text
    var userid = ui.item.value; // selected value

    // AJAX
    $.ajax({
     url: 'get-details.php',
     type: 'post',
     data: {userid:userid,request:2},
     dataType: 'json',
     success:function(response){

      var len = response.length;

      if(len > 0){
       var id = response[0]['id'];
       var name = response[0]['name'];
       var number = response[0]['number'];

       // Set value to textboxes
       document.getElementById('clientname').value = name;
       document.getElementById('clientnumber').value = number;

      }
     }
    });

    return false;
   }

  });
 });
}

And this is my PHP file, that searches through the Database:
<?php
include('includes/dbconnection.php');

$request = $_POST['request']; // request

// Get username list
if($request == 1){
 $search = $_POST['search'];

 $query = "SELECT * FROM tblclients WHERE FullName like'%".$search."%' OR MobileNumber like'%".$search."%'";
 $result = mysqli_query($con,$query);

 while($row = mysqli_fetch_array($result)){

  $response[] = array("value"=>$row['ID'],"label"=>$row['FullName'].' | '.$row['MobileNumber']);
 }

 // encoding array to json format
 echo json_encode($response);
 exit;
}

// Get details
if($request == 2){
 $userid = $_POST['userid'];
 $sql = "SELECT * FROM tblclients WHERE ID=".$userid;

 $result = mysqli_query($con,$sql);

 $users_arr = array();

 while( $row = mysqli_fetch_array($result) ){
  $userid = $row['ID'];
  $fullname = $row['FullName'];
  $number = $row['MobileNumber'];

  $users_arr[] = array("id" => $userid, "name" => $fullname,"number" => $number);
 }

 // encoding array to json format
 echo json_encode($users_arr);
 exit;
}

I don't know what I'm doing wrong...

redpajama_set_name: RedPajamaStackExchange


text:
Q: Sockets in C#, how can I asynchronously read and write data through a NetworkStream [I am limited to Visual Studio 2010, and therefore, C# 4. async and await are not available to me.]
I'm working on network architecture for a project of mine, that sends packets of data over a network between a server and a client, but the client and server must continue running while waiting, so the code has to be non-blocking, so I thought to use the asynchronous methods. However, except for simple synchronous one-time IO, I don't know much about what to do, especially when using a NetworkStream. What I'm trying to do is:
1) Client connects to server
2) Server accepts connection
3) Server waits for data from client
4) Server processes data
5) Server responds to client
6) While connection is open, repeat from 3.
And I would like to use a NetworkStream to wrap the socket. But I am new to asynchronous I/O and i'm not really sure how to do this without blocking other parts of the server/client code when waiting for a response, especially with a NetworkStream. In my research I see examples that use something like this:
while(true){
    socket.BeginAccept(new AsyncCallback(AcceptCallback), socket );
}

But it seems like that loop would still hold up the application. Can anyone give me some pointers (ha) on how exactly to do this? I haven't been able to find many examples that keep the connection open, only Client Connect -> Client Send -> Server Recieve -> Server Send -> Disconnect. I'm not asking for full code, just the general idea with a few snippets.

A: Here is a very simple example of using async/await with a NetworkStream:
SocketServer.cs:
class SocketServer
{
    private readonly Socket _listen;

    public SocketServer(int port)
    {
        IPEndPoint listenEndPoint = new IPEndPoint(IPAddress.Loopback, port);
        _listen = new Socket(SocketType.Stream, ProtocolType.Tcp);
        _listen.Bind(listenEndPoint);
        _listen.Listen(1);
        _listen.BeginAccept(_Accept, null);
    }

    public void Stop()
    {
        _listen.Close();
    }

    private async void _Accept(IAsyncResult result)
    {
        try
        {
            using (Socket client = _listen.EndAccept(result))
            using (NetworkStream stream = new NetworkStream(client))
            using (StreamReader reader = new StreamReader(stream))
            using (StreamWriter writer = new StreamWriter(stream))
            {
                Console.WriteLine("SERVER: accepted new client");

                string text;

                while ((text = await reader.ReadLineAsync()) != null)
                {
                    Console.WriteLine("SERVER: received \"" + text + "\"");
                    writer.WriteLine(text);
                    writer.Flush();
                }
            }

            Console.WriteLine("SERVER: end-of-stream");

            // Don't accept a new client until the previous one is done
            _listen.BeginAccept(_Accept, null);
        }
        catch (ObjectDisposedException)
        {
            Console.WriteLine("SERVER: server was closed");
        }
        catch (SocketException e)
        {
            Console.WriteLine("SERVER: Exception: " + e);
        }
    }
}

Program.cs:
class Program
{
    private const int _kport = 54321;

    static void Main(string[] args)
    {
        SocketServer server = new SocketServer(_kport);
        Socket remote = new Socket(SocketType.Stream, ProtocolType.Tcp);
        IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Loopback, _kport);

        remote.Connect(remoteEndPoint);

        using (NetworkStream stream = new NetworkStream(remote))
        using (StreamReader reader = new StreamReader(stream))
        using (StreamWriter writer = new StreamWriter(stream))
        {
            Task receiveTask = _Receive(reader);
            string text;

            Console.WriteLine("CLIENT: connected. Enter text to send...");

            while ((text = Console.ReadLine()) != "")
            {
                writer.WriteLine(text);
                writer.Flush();
            }

            remote.Shutdown(SocketShutdown.Send);
            receiveTask.Wait();
        }

        server.Stop();
    }

    private static async Task _Receive(StreamReader reader)
    {
        string receiveText;

        while ((receiveText = await reader.ReadLineAsync()) != null)
        {
            Console.WriteLine("CLIENT: received \"" + receiveText + "\"");
        }

        Console.WriteLine("CLIENT: end-of-stream");
    }
}

It's a very simple example, hosting both the server and client in the same process and accepting just one connection at a time. It's really just for illustration purposes. Real-world scenarios will no doubt include other features to suit their needs.
Here, I'm wrapping the NetworkStreams in StreamReaders and StreamWriters. Note that you have to call Flush() to ensure that the data is actually sent. For better control over the I/O, you can of course use the NetworkStream directly. Just use the Stream.ReadAsync() method instead of StreamReader.ReadLineAsync(). Note also that in my example, writing is synchronous. You can make this asynchronous as well if you like, using the same basic technique as shown for reading.
EDIT:
The OP indicates they are unable to use async/await. Here is a version of the client which uses NetworkStream and the old-style Begin/EndXXX() API (similar changes would be made to the server of course):
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;

namespace TestOldSchoolNetworkStream
{
    class Program
    {
        private const int _kport = 54321;

        static void Main(string[] args)
        {
            SocketServer server = new SocketServer(_kport);
            Socket remote = new Socket(SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Loopback, _kport);

            remote.Connect(remoteEndPoint);

            using (NetworkStream stream = new NetworkStream(remote))
            {
                // For convenience, These variables are local and captured by the
                // anonymous method callback. A less-primitive implementation would
                // encapsulate the client state in a separate class, where these objects
                // would be kept. The instance of this object would be then passed to the
                // completion callback, or the receive method itself would contain the
                // completion callback itself.
                ManualResetEvent receiveMonitor = new ManualResetEvent(false);
                byte[] rgbReceive = new byte[8192];
                char[] rgch = new char[Encoding.UTF8.GetMaxCharCount(rgbReceive.Length)];
                Decoder decoder = Encoding.UTF8.GetDecoder();
                StringBuilder receiveBuffer = new StringBuilder();

                stream.BeginRead(rgbReceive, 0, rgbReceive.Length, result =>
                {
                    _Receive(stream, rgbReceive, rgch, decoder, receiveBuffer, receiveMonitor, result);
                }, null);

                string text;

                Console.WriteLine("CLIENT: connected. Enter text to send...");

                while ((text = Console.ReadLine()) != "")
                {
                    byte[] rgbSend = Encoding.UTF8.GetBytes(text + Environment.NewLine);

                    remote.BeginSend(rgbSend, 0, rgbSend.Length, SocketFlags.None, _Send, Tuple.Create(remote, rgbSend.Length));
                }

                remote.Shutdown(SocketShutdown.Send);
                receiveMonitor.WaitOne();
            }

            server.Stop();
        }

        private static void _Receive(NetworkStream stream, byte[] rgb, char[] rgch, Decoder decoder, StringBuilder receiveBuffer, EventWaitHandle monitor, IAsyncResult result)
        {
            try
            {
                int byteCount = stream.EndRead(result);
                string fullLine = null;

                if (byteCount > 0)
                {
                    int charCount = decoder.GetChars(rgb, 0, byteCount, rgch, 0);

                    receiveBuffer.Append(rgch, 0, charCount);

                    int newLineIndex = IndexOf(receiveBuffer, Environment.NewLine);

                    if (newLineIndex >= 0)
                    {
                        fullLine = receiveBuffer.ToString(0, newLineIndex);
                        receiveBuffer.Remove(0, newLineIndex + Environment.NewLine.Length);
                    }

                    stream.BeginRead(rgb, 0, rgb.Length, result1 =>
                    {
                        _Receive(stream, rgb, rgch, decoder, receiveBuffer, monitor, result1);
                    }, null);
                }
                else
                {
                    Console.WriteLine("CLIENT: end-of-stream");
                    fullLine = receiveBuffer.ToString();
                    monitor.Set();
                }

                if (!string.IsNullOrEmpty(fullLine))
                {
                    Console.WriteLine("CLIENT: received \"" + fullLine + "\"");
                }
            }
            catch (IOException e)
            {
                Console.WriteLine("CLIENT: Exception: " + e);
            }
        }

        private static int IndexOf(StringBuilder sb, string text)
        {
            for (int i = 0; i < sb.Length - text.Length + 1; i++)
            {
                bool match = true;

                for (int j = 0; j < text.Length; j++)
                {
                    if (sb[i + j] != text[j])
                    {
                        match = false;
                        break;
                    }
                }

                if (match)
                {
                    return i;
                }
            }

            return -1;
        }

        private static void _Send(IAsyncResult result)
        {
            try
            {
                Tuple<Socket, int> state = (Tuple<Socket, int>)result.AsyncState;
                int actualLength = state.Item1.EndSend(result);

                if (state.Item2 != actualLength)
                {
                    // Should never happen...the async operation should not complete until
                    // the full buffer has been successfully sent,
                    Console.WriteLine("CLIENT: send completed with only partial success");
                }
            }
            catch (IOException e)
            {
                Console.WriteLine("CLIENT: Exception: " + e);
            }
        }
    }
}

Note that this code, even in spite of leaving out a bunch of exception-handling logic, is considerably longer, at least in part due to the fact that TextReader has no built-in asynchronous API, and so the processing of the input data is much more verbose here. Of course, this is for a simple line-based text exchange protocol. Other protocols may be more or less complex in terms of the data-unpacking aspects, but the underlying read and write elements of the NetworkStream would be the same.


text:
Q: NOT ABLE TO SLIDE AS PDF \documentclass[xcolor=dvipsnames,table]{beamer}
\usepackage{latexsym}
\usepackage[utf8]{inputenc}
%\usepackage[brazil]{babel}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{stmaryrd}
\usepackage{fancybox}
\usepackage{datetime}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{url}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{acronym}
\usepackage{array}

\newtheorem{definicao}{Definio}
\newcommand{\tab}{\hspace*{2em}}

\mode<presentation>
{
  \definecolor{colortexto}{RGB}{0,0,0}

  \setbeamertemplate{background canvas}[vertical shading][ bottom=white!10,top=white!10]
  \setbeamercolor{normal text}{fg=colortexto}

  \usetheme{Warsaw}
}

\title{PROBLEMS}

  \author[Mr. K \\ \url{.edu@gmail.com}]{\includegraphics[height=1.5cm,width=1.5cm]{kte.jpg}\\Mr \\ \url{.edu@gmail.com}}
 \institute{
  K \\Ho C}
\date{\textbf{\today}

 }

Hello! Please help me out.
I used the above code for my slide. The problem is when I extracted the file.pdf as a slide, I couldn't show slide by slide smoothly as powerpoint. Please I need it urgently.
Thank You so much!


text:
Q: Run sh file wiith ssh2_exec (PHP) Im trying to run a sh file with ssh2_exec and getting stream data when it's done.
BTW im using CentOS.
But when im using ssh2_exec('./file.sh'); for example nothing happned..
is it possible to get execute output when the file is done running?

A: As per example from PHP manual about ssh2_exec
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$stream = ssh2_exec($connection, '/usr/local/bin/php -i');

ssh2_exec() is used to pass a command to a shell session/connection.
In order to read the stream contents, you may try:
echo "Output: " . stream_get_contents($stream);

On the other hand, if you were looking to run a command on the php/host server, you could try with shell_exec:
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";


text:
Q: IE6 CSS Issue on Visited Link From my investigation, it seems like IE6 considers the following links are the same:
link1: http://www.google.com#/test=1
link2: http://www.google.com#/test=2
Reason being that I have assigned different colors between a:visited and a:link.
After the first click on link1 or link2, both links are rendered with a:visited color.
It does not happen on IE7 onwards though.
Have you guys encountered this issue before? If so, can someone please advise me the best way to resolve this?
Thanks.

A: Since you stated that you cannot avoid IE 6 (sigh), my answer is to avoid the problem entirely by implementing a more modern design without highlighting the visited links...   the unvisited link always looks the same as the visited link.
Has any large, popular or professional website in the last decade differentiated the "visited" links?  Answer: none that I recall.
Why?

*

*People are treated more intelligently.  They already know they visited a link and don't need the site to tell them.

*Websites are better organized.  A site with a clear layout is less confusing and people don't need a visual indication of what they've already clicked.

*Graphics and visual clues.  Websites used to be mostly plain text with maybe a photo here and there.  You needed a visual indicator to help keep track of where you left off with your reading.  Especially since most links took you to a whole new page or website.  These days, content is visually rich with graphical layouts, icons, less text, animations, multimedia, etc... you no longer need to depend on the colored text of the "visited" indicator to help you keep track of where you left off.

*Complexity and Ajax.  With the richly interactive pages available these days, page refreshing is not required to update content.  However, when you do need to refresh a page, people expect that page to return to it's initial "unvisited" state.  With the "visited" link, you cannot "reset" the page with a simple refresh and that will lead to confusion; especially since modern visitors are not expecting to see links change to a different color.

*Confusing and inconsistent experience.  Anyone who started using the Internet within the last 5-10 years is probably not going to readily understand why certain links are suddenly different colors on your site and nobody else's.

*Not all links are pages or sites.  Some links trigger a modal.  Some cause divs to open or slide around.  Some control a slideshow or other interactive object.  A link can trigger any ajax function you can think of.  Once clicked, are those links considered "visited" then too?  Of course not.  To reduce the confusion, the concept of a "visited" link is rendered obsolete.

*Redundancy.  Most people these days use the same website on different computers, handheld devices, etc. therefore, the "visited link" is rendered useless anyway.  Not to mention that people tend to delete their cache and also use multiple browsers on the same machine, again rendering the highlighted color of the "visited link" pointless.

        Link1; Link2;

EDIT:  The recommendations made in my answer above were intended for links primarily used for site navigation, menus, footers, etc.  A valid exception would be links composing a list of search results.

A: This not answer to you question but Stop using IE6 it's out market now and most of the site stopped supporting IE6 its better to move on the next versions
here is link related to IE6 news : http://www.ianhoar.com/2011/06/17/ie6-is-dead-no-really-i-mean-it-this-time/


text:
Q: How can i find data-id if tag A in table? I have a simple table :

        ID
        View

I would like after click get a data-action and data-id i tried
$('#visit-list-table tr').on('click', function() {
    var test = $(this).closest("tr");
    console.log(test[0].data('id'));

    var test = $(this).closest("tr").find('a').attr('id');
    console.log(test);
});

But without result. How can I get this data?

A: Check below snippet.
You should use data attribute like
$(this).closest("tr").find('a').data('id')

Or
$(this).closest("tr").find('a').attr('data-id')

Both will give same result.
And i added id 'visit-list-table' to the table.

$('#visit-list-table tr').on('click', function() {

  var test = $(this).closest("tr").find('a').data('id');
  console.log(test);

});

        ID
        View

A: add id #visit-list-table to element. and you can do $(this).find('a').attr('data-id'); Here attr('data-id') instead of attr('id') because there is no attribute in a tag with id

$('#visit-list-table tr').on('click', function() {
    var test = $(this).find('a').attr('data-id');
    console.log(test);
});

        ID
        View


text:
Q: Is 23,148,855,308,184,500 a magic number, or sheer chance? News reports such as this one indicate that the above number may have arisen as a programming bug.

A man in the United States popped out
  to his local petrol station to buy a
  pack of cigarettes - only to find his
  card charged $23,148,855,308,184,500.
That is $23 quadrillion (£14
  quadrillion) - many times the US
  national debt.*

In hex it's $523DC2E199EBB4 which doesn't appear terribly interesting at first sight.
Anyone have any thoughts about what programming error would have caused this?

A: If you shift left 64-bit representation 8 bits left (multiply by 256)
You will get a well formed credit card number and 3 empty positions for thise 3 secure extra numbers (all zeroes for some reason). There is only 1 out of 10 chance that random number gives a well formed CC number.
5926 1069 5889 5232 000

A: What happens when you make a purchase by card is that the software immediately goes online to ensure you have sufficient funds for the purchase, but only places a hold on the funds for the transaction.  At the end of the working day the software then gathers all the transactions placed in the last 24hrs and submits them to the acquiring bank for processing.
The submission to the bank is known as settlement, and its done by sending a plain text file in a very rigid format. (This was all developed decades ago and the number of systems now using it makes it hard to modernise)
Each transaction appears in the file as a line of text, and part of that is the transaction value. This field should be 11 numeric characters (zero padded on the left hand side) and will always hold the value in lowest common denominator (in this case cents).  11 numeric characters caters well for values in any currency.
Looks like the payment processor in this case had made some changes to their submission software and erroneously replaced the zero padding with space padding.  Quite how this got by a) service provider, b) acquiring bank and c) Visa without being picked up escapes me.  The net value of that settlement file (13,000 high value transactions) would have been astronomical, and maybe that also was a contributing factor somewhere.

A: If you use the binary equivelant (1110101110110100) decode of the number 23148855308184500, you get K鑛, which is the Mandarin character for mining and ore.  Kmine could mean "knowledge mine," or something like kmine Holdings Ltd.  Perhaps there's a correlation between K(mine or ore) and Bank of America or Visa?

A: Hold on a second; there's something fishy going on.
While the space-padded explanation certainly seems good, it may be (at least partly) specious.
VISA said that there were "fewer than 13,000" customers affected by the snafu with the Visa Buxx pre-paid cards. I've found news on several so far. Josh Muszynski in New Hampshire, Jason Bryan in Tennessee, Ron Seale in Texas, Karen Taylor's teenage son in Bethel, and a teenage girl, Elizabeth Lewis in Owatonna .
The thing is that all of them have the exact same charge: $23,148,855,308,184,500.00. If the problem was the space-padding, then how is it that all of them had the exact same $0x1250 ($46.88) charge? Two of them had purchased cigarettes at gas stations, another two had paid at restaurants, Lewis bought eggs and milk, the last one at a drug store. Do all these varied items happen to cost the same? $46.88 for a restaurant bill seems okay, but for a pack of cigarettes? for milk and eggs‽
The space-padding error makes sense, except it does not account for the 0x1250 constant. Why is it that all of them ended up with 0x2020 2020 2020 1250 instead of 0x2020 2020 2020 2020 or different numbers in the last WORD?
Hmmm, if only 13,000 customers were affected, it may be that somehow that exact, specific charge triggered the error. In that case, it is more than just a field error. If it was just the text field being interpreted as a 64-bit integer, then why didn't other amounts cause it, thus affecting everyone, not just <13,000. Still, how is it that 13,000 people could have just happened to charge the exact same amount in the same week?
They say it's a "temporary programming error", and it may well be, but could it be a hacking thing? In that case, it probably would be a magic-number. In fact, it may be a combination of both: some hacker putting a 0x1250 automatic charge, that got combined with the space-padding error, causing one or both errors to be detected.
The Register thinks that the answer is indeed the padded-field error, but does not expand on why they are all the same, although one of the comments mentions the number possibly being rounded to the nearest $100 (unlikely since banks and banking software explicitly go to lengths to ensure precision).
(There is also a report of a similar, earlier error.)

Jason Bryant's bill:

Elizabeth Lewis's bill:

Ron Seale's bill:

Josh Muszynski's bill:

A: If you remove the trailing zero, this validates as a VISA card number. My guess is they swiped the card then manually entered the number, thinking the swipe had failed.

A: Add the cents to the number and you get 2314885530818450000, which in hexadecimal is 2020 2020 2020 1250.
Do you see the pattern? The first six bytes have been overwritten by spaces (hex 20, dec 32).

A: The ultimate mystery is still where 12 50 is coming from.  They are the ASCII codes for Ctrl+R, P.  Which happens to be the secret keystrokes you have to type to enter the validation code for QuickBooks.
Link: Where to enter Validation code
Quite a coincidence.  I wonder what happens when you type these keys in the wrong place...


text:
Q: Spring Data Rest Add All Projections In A Package I am using RepositoryConfig in order to register my projections for Spring Data Rest.
All projections in the same package. Is there an easy way to add all projections to configuration. Instead of addProjection for each class. Is there a Reflection solution or a Spring-based solution to add all Projection in a package?
@Configuration
public class RepositoryConfig implements RepositoryRestConfigurer {
    @Override
    public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
        config.getProjectionConfiguration()
                .addProjection(PurchaseProjection.class)
                .addProjection(OrderProjection.class);

    }
}

A: I found a reflection library from this question.
Via Reflections library here is my solution:
 public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config){
    // Scan all projections and add them in to the configuration.
    Reflections r= new Reflections("com.company.projection");
    for (Class<?> c: r.getTypesAnnotatedWith(Projection.class)) {
      config.getProjectionConfiguration().addProjection(c);
    }
  }


text:
Q: Change Parent Status/Class Based on child status angular I want to change the class of parent if all the child has a status of "fail" i am using angular 5.
MY JSON :
[{"parent":"PARENT 1", "child":[{ "name":"Child 1", "status":"fail" }, { "name":"Child 1", "status":"fail" },{ "name":"Child 1", "status":"fail" }, { "name":"Child 1", "status":"fail" }], "someVal":"SOME VALUE" }, { "parent":"PARENT 2", "child":[{ "name":"Child 1", "status":"pass" }, { "name":"Child 1", "status":"pass" },{ "name":"Child 1", "status":"fail" }, { "name":"Child 1", "status":"fail" }], "someVal":"SOME VALUE" }, { "parent":"PARENT 3", "child":[{ "name":"Child 1", "status":"pass" }, { "name":"Child 1", "status":"pass" },{ "name":"Child 1", "status":"pass" }, { "name":"Child 1", "status":"pass" }], "someVal":"SOME VALUE" }]

my HTML :

{{anyvar.parent}}

{{anyvar.child.name}}

What I am trying to do is Change the "ngClass" to "FAIL" if all the child has "status" as "fail" else "ngClass" to "PASS" in the parent LI.
Is there a way I can do that with angular 5. Thanks.

A: [ngClass]="isFailed(anyvar) ? 'fail' : 'pass'"

isFailed(value: { child: [{ status: string }] }): boolean {
    return value.child.every(c => c.status === 'fail');
}

https://stackblitz.com/edit/angular-lkuthv


text:
Q: Convert multidemensional array to XML with SimpleXML I'm trying to convert a multidimensional array to an XML file with SimpleXML.
I followed instructions from this post: https://stackoverflow.com/a/5965940/3169412 with these edits: http://pastebin.com/pYuXQWee but I can't get a correct result.
array used:
$array =
array(
'name' => 'xxx',
'chapter' => array(
    array(
    'title' => 'yyy',
    'slide' =>
        array(
        'header' => array('zzz','aaa'),
        'paragraph' => array('bbb','ccc')
        ),
        array(
            'header' => array('ddd'),
            'paragraph' => array('eee')
        )
    ),
    array(
        'title' => 'fff',
        'slide' => array(
            'header' => array('ggg'),
            'paragraph' => array('hhh')
        )
    )
    )
);

Preferred (needed) XML output: http://pastebin.com/HWWeDehK
I tried using different approaches to get the right nodes on the right place, but they all seemed to fail. Closest I got was using array_keys($values), but then I got a lot of double nodes, or nodes on the wrong place.
XMLresult right now: http://pastebin.com/L8LL5VVe

A: $array =
array(
'name' => 'xxx',
'chapter' => array(
    array(
    'title' => 'yyy',
    'slide' =>
        array(
        'header' => array('zzz','aaa'),
        'paragraph' => array('bbb','ccc')
        ),
        array(
            'header' => array('ddd'),
            'paragraph' => array('eee')
        )
    ),
    array(
        'title' => 'fff',
        'slide' => array(
            'header' => array('ggg'),
            'paragraph' => array('hhh')
        )
    )
    )
);

$xml = new SimpleXMLElement("<?xml version=\"1.0\"?><course></course>");

function array_to_xml($array, &$xml) {
    foreach($array as $key => $value) {
        if(is_array($value)) {
            if(!is_numeric($key)){
                $subnode = $xml->addChild("$key");
                array_to_xml($value, $subnode);
            }
            else{
                $subnode = $xml->addChild("item$key");
                array_to_xml($value, $subnode);
            }
        }
        else {
            $xml->addChild("$key",htmlspecialchars("$value"));
        }
    }
};

array_to_xml($array, $xml);

$xml->asXML('file.xml');

The content in file.xml is exactly as you requested.

A: With FluidXML you can generate XML from a PHP array and then import it in SimpleXML
$data = [ 'doc' => [
              'fruit' => 'orange',
              'cake'  => [
                   '@id' => '123',
                   '@'   => 'tiramisu' ],
              [ 'pasta' => 'matriciana' ],
              [ 'pasta' => 'boscaiola'  ]
] ];

just like that
$doc       = fluidxml($data);
$simplexml = simplexml_import_dom($doc->dom());

// Done. ;)

https://github.com/servo-php/fluidxml


text:
Q: mongodb localhost replicasetup I want to setup a replicasetup in my local machine,I am using to instances of mongodb(mongod1.conf,mongod2.conf), rs initiated mongo1 on port 27018 and i want to add the members to 27018 , rs.add('ThinkPad-X230:27019') it is throwing an error called
commands :
mongod --replSet Replicaset1 --dbpath home/data --port 27018
mongo --port 27018
>> rs.initiate()
>> rs.add("ThinkPad-X230:27019")

mongod --dbpath home/data2 --port 27019

mongo --port 27019

i have checked the db.serverStatus().host in 27019 port and adding host name "ThinkPad-X230:27019" to rs.add() members it is throwing the error.
{
    "ok" : 0,
    "errmsg" : "Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2",
    "code" : 103,
    "codeName" : "NewReplicaSetConfigurationIncompatible",
    "operationTime" : Timestamp(1568943205, 1),
    "$clusterTime" : {
        "clusterTime" : Timestamp(1568943205, 1),
        "signature" : {
            "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
            "keyId" : NumberLong(0)
        }
    }
}

A: As you started your first instance of mongod with --replSet Replicaset1 option, it is configured to be a part of Replicaset1 replica set.
And when you initialised the replica set, this instance was added to the replica set as a member. Below is the output snippet of rs.status()
{
    "_id" : 0,
    "name" : "localhost:27018",
    "health" : 1,
    "state" : 1,
    "stateStr" : "PRIMARY",
    "uptime" : 228,
    "optime" : {
        "ts" : Timestamp(1569751005, 1),
        "t" : NumberLong(1)
    },
    "optimeDate" : ISODate("2019-09-29T09:56:45Z"),
    "electionTime" : Timestamp(1569750830, 2),
    "electionDate" : ISODate("2019-09-29T09:53:50Z"),
    "configVersion" : 3,
    "self" : true
}

As you can see the name of the member is "localhost:2018".
So, when you try to add another member to this replica set as rs.add('ThinkPad-X230:27019'), it gives you the following error which is a valid error to be thrown, as one member is "localhost:2018" and another which you are trying to add is "ThinkPad-X230:27019" and both must be localhost.
"errmsg" : "Either all host names in a replica set configuration must be localhost references, or none must be; found 1 out of 2"

Try to add the member using the following command,
rs.add("localhost:27019")

And it will be added successfully.


text:
Q: access the contents of a sharepoint list and update it My problem is how to access the contents of a sharepoint list and update
the contents by a button "Save" of another list that it have the same field.
I'm working in sharepoint online using JavaScript.
Thanks in advance.

A: Using the client side object model or CSOM from SharePoint Online, you can retrieve the details of a list item and create a new list item.
Basically, you would use at least two rountrips to the server from. First, you want to use the JavaScript library provided with SharePoint to get the SharePoint context, send an asynchronous query to SharePoint Online Web Services for the list item details, and process the results in a JavaScript callback function. Then you'd basically repeat the same to write the results to another list.
Take a look at the reference code for List Item Tasks in How to: Complete basic operations using SharePoint 2013 client library code.


text:
Q: Google Cloud Platform tutorial Issue - Detecting anomalies in financial transactions by using AI Platform, Dataflow, and BigQuery I tried following the google cloud platform tutorial "Detecting anomalies in financial transactions by using AI Platform, Dataflow, and BigQuery".
I was able to complete most of the steps but was unable to execute the dataflow job using the command in the tutorial. This is the link to the step.

I replaced the "myProject" and was able to submit a job, but it keeps on failing. I get error message as follows.


text:
Q: How to get selected rows text in the specific cell? I have a dataGrid which consists of 3 columns  (ID) (Name) (Surname).
How do I get the text of a specific cell of a selected row?

A: use this code:
private void gridview_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)//Yourcolumindex
            {

                string value = gridview.SelectedCells[0].Value.ToString();

            }
        }

A: SchoolDepartment newPerson = rows[rows.Count - 1];
MessageBox.Show(newPerson.ID.ToString());

if the last row is selected


text:
Q: How to post the data in Node js In my application i need to post the dynamic data into my main page(mani page means if i run my url(localhost:3456) in browser means that will display one page na that page).How can i post that data.I have tried this but i couldn't post the data.Can anyone help me to fix the issue.
app.js
     var http = require('http');
     var server = http.createServer(function(req, res){
                  res.writeHead(200, ['Content-Type', 'text/plain']);
                  res.write('Hello ');
                  res.end('World');
                   });
     server.listen(3456);

postdata.js
 var data={"errorMsg":{"errno":34,"code":"ENOENT","path":"missingFile.txt"},"date":"2013-0402T11:50:22.167Z"}
 var options = {
                host: 'localhost',
                port: 3456,
                path: '/',
                method: 'POST',
                data:data,
                header: {
                           'content-type': 'application/json',
                           'content-length': data.length
                         }
                 };

 var http=require('http');
 var req;
 req = http.request(options, function(res) {
    var body;
    body = '';
    res.on('data', function(chunk) {
    body += chunk;
  });
 return res.on('end', function() {
    console.log('body is '+body);
  });
  });
 req.on('error', function(err) {
    console.log(err);

});

 req.write(data);
 req.end();

A: Do you have express installed along with Node, if so you can set up Rest Api's which you can use them in your jQuery and bind data dynamically. Please try to look into
http://expressjs.com/
Hope this helps.

A: Two things. First:
var data={"errorMsg:{"errno":34,"code":"ENOENT","path":"missingFile.txt"},"date":"2013-0402T11:50:22.167Z"}

is missing a double-quote, so it's invalid syntax... hence why the syntax highlighting is having trouble.
Second:
req.write(data);

should be:
req.write(JSON.stringify(data));

EDIT:
Based on your comment, I think you might be asking how to read from the body of an HTTP POST request (you're question is very ambiguously worded). If so, that's already very well documented in the Node.js API. Something along the lines of:
var server = http.createServer(requestHandler);
server.listen(3456);

function requestHandler (req, res) {
    req.setEncoding('utf8');
    var body = '';
    req.on('data', function (chunk) { body += chunk; });
    req.on('end', function () {
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('The body of your request was: ' + body);
    });
}

If that's not what you're asking, you'll need to clarify your question. Terms like 'main page' have no meaning unless you explicitly define what they are and what the expected outcome is.

A: //this is a string
var jsonString = '{"errorMsg":{"errno":34,"code":"ENOENT","path":"missingFile.txt"},"date":"2013-04-03T05:29:15.521Z"}';

//this is an object
var jsonObj = {"errorMsg":{"errno":34,"code":"ENOENT","path":"missingFile.txt"},"date":"2013-04-03T05:29:15.521Z"};

note the single quotes in for string
request.write(chunk, [encoding]) requires chunk to be either Buffer or string (see: http://nodejs.org/api/http.html#http_request_write_chunk_encoding)


text:
Q: CLLocation distanceFromLocation large value I'm having some issues with CLLocation distanceFromLocation. I have the code below, formatted to help with debugging, explicitly allocating two new locations etc.  Either way, two nearly identical locations result in a huge gap, but only sometimes.
Code:
CLLocation *loc = [LightweightLocationTracker sharedLocationTracker].lastLocation;
if (loc)
{
  CLLocation *myLoc = [[CLLocation alloc] initWithLatitude:loc.coordinate.latitude longitude:loc.coordinate.longitude];
  CLLocation *productLoc = [[CLLocation alloc] initWithLatitude:self.productToView.latitude longitude:self.productToView.longitude];
  CLLocationDistance dist = [myLoc distanceFromLocation:productLoc];

  NSLog(@"myLoc.coordinate.latitude %f", myLoc.coordinate.latitude);
  NSLog(@"myLoc.coordinate.longitude %f", myLoc.coordinate.longitude);
  NSLog(@"productLoc.coordinate.latitude %f", productLoc.coordinate.latitude);
  NSLog(@"productLoc.coordinate.longitude %f", productLoc.coordinate.longitude);
  NSLog(@"dist %f", dist);
  NSLog(@"%1.1f km", dist);
}

One run TTY:
[] tapped main
[] myLoc.coordinate.latitude 52.369200
[] myLoc.coordinate.longitude 13.941100
[] productLoc.coordinate.latitude 52.364400
[] productLoc.coordinate.longitude 13.360600
[] dist 39542.386770
[] 39542.4 km

Another run TTY:
[] myLoc.coordinate.latitude 52.369200
[] myLoc.coordinate.longitude 13.941100
[] productLoc.coordinate.latitude 52.369202
[] productLoc.coordinate.longitude 13.941100
[] dist 0.184915
[] 0.2 km

Not seeing the culprit...

A: Well, distanceFromLocation returns meters. So that 30k thing is just 30km. Sounds perfectly legit to me.


text:
Q: Run script automatically on startup: script doesn't work correctly I want to run a bash script on startup of my Parallella board, which has Ubuntu. I searched in SO, and found the instruction in here:

*

*Run automatically program on startup under linux ubuntu

*Programmatically run at startup on Linux?
My bash script is test.sh, which has only one line:
echo "Hello World" &> /home/qsp/WIP/test/hello.txt

1) The first way I tried is adding to /etc/rc.local the aboslute path to the script:
/home/qsp/WIP/test/test.sh

2) The second way I tried is following the accepted answer above.
sudo mv test.sh /etc/init.d/
sudo update-rc.d test.sh defaults

In both cases, the script was executed after booting, and there was a file hello.txt created in the folder. However, the content of the file is empty (and the owner is root). I wonder if I'm missing anything. Thank you.
======UPDATE=======
Following the answer of Skynet, I change my script to:
echo "Hello World" | tee /home/qsp/WIP/test/hello.txt

and the script writes to the file after booting correctly. I have another question, why my original script with &> didn't work, although it still works if running from command line.

A: You should make it in init script style, as cited by the first SO question. Like so:
case "$1" in
start)
    #startup code
    ;;
stop)
    #stop code
    ;;
restart)
    #restart code
    ;;
esac

Also take a look at https://github.com/fhd/init-script-template/blob/master/template

A: After editing /etc/rc.local and adding your commands,
check your script must always end with exit 0.
Also make it sure you made it executable by using chmod command
chmod 777 test.sh

Change the line of output as
echo "Hello World" | tee /home/qsp/WIP/test/hello.txt

A: Create .desktop file and configure your ystem to auto-start at the time of login
Create .desktop file as below
    $ vim ~/.config/autostart/test_script.desktop

add the below information
   [Desktop Entry]
   Type=Application
   Name=Test script
   Exec=~/test.sh
   X-GNOME-Autostart-enabled=true

Note that ~/test.sh should point to the script you've created. Save it.
Make it executable:
$ chmod o+x ~/.config/autostart/test_script.desktop
Reboot and for the next login your script should run.


text:
Q: How to summarize by an unknown number of columns? I would like to create summaries for the results of a certain type of task across multiple geographic regions. I currently have the following dummy query:
datatable(env_cloud_location : string, result : string )[
    "East Asia", "Passed",
    "East Asia", "Failed",
    "East Asia", "Error",
    "East US", "Passed",
    "East US", "Error",
    "East US", "Passed",
    "North Europe", "Failed",
    "North Europe", "Error",
    "North Europe", "Error",
]
| summarize
    eastAsia = countif(env_cloud_location  == "East Asia"),
    eastUS = countif(env_cloud_location  == "East US"),
    northEurope = countif(env_cloud_location == "North Europe")
    by result

Now, I suppose I don't know all the possible values of "env_cloud_location" and there in fact are anywhere from 5 to 12, how can I summarize such that each of these locations, however many there are, gets their own column? Expected output in the format:

result
eastAsia
eastUS
northEurope

Passed
1
2
0

Failed
1
0
1

Error
1
0
2

A: Yet another pivot question
datatable(env_cloud_location : string, result : string )[
    "East Asia", "Passed",
    "East Asia", "Failed",
    "East Asia", "Error",
    "East US", "Passed",
    "East US", "Error",
    "East US", "Passed",
    "North Europe", "Failed",
    "North Europe", "Error",
    "North Europe", "Error",
]
| evaluate pivot(env_cloud_location)

result
East Asia
East US
North Europe

Passed
1
2
0

Failed
1
0
1

Error
1
1
2

Fiddle


text:
Q: Merge or Group two pie chart into one pie chart JSFIDDLE
How to merge two pie chart into one pie chart using jqplot
var firstv=30;
            var secondv=40;
            var thirdv=30;
            var name1="giri";
            var name2="shiva";
            var name3="nanda";
    var data =  [[name1, firstv],[name2, secondv],[name3,thirdv]];

var plot1 = jQuery.jqplot('chart1', [data],
        {
            grid: {
                shadow: false,
                background: '#FFFFFF',
            },
            seriesDefaults: {
                // Make this a pie chart.
                renderer: jQuery.jqplot.PieRenderer,
                rendererOptions: {
                    showDataLabels: true,
                    padding: 20,
                    startAngle: 270
                }
            },
            legend: {
                show: true,
                location: 'e',
                fontSize: 11,
                marginTop: 10,
            }
        });

A: Still not sure what you are after but taking a guess.
Given this data:
var firstv=10;
var secondv=20;
var thirdv=70;
var name1="ram";
var name2="kumar";
var name3="manju";

var data1 = [[name1, firstv],[name2, secondv],[name3,thirdv]];

and:
var firstv=30;
var secondv=40;
var thirdv=30;
var name1="giri";
var name2="shiva";
var name3="nanda";

var data2 =  [[name1, firstv],[name2, secondv],[name3,thirdv]];

Then merging the two datasets together:
  var plot2 = jQuery.jqplot('chart2', [$.merge(data,data2)], //using jquery to merge the two datasets
  {
      grid: {
          shadow: false,
          background: '#FFFFFF',
      },
      seriesDefaults: {
          // Make this a pie chart.
          renderer: jQuery.jqplot.PieRenderer,
          rendererOptions: {
              showDataLabels: true,
              padding: 20,
              startAngle: 270
          }
      },
      legend: {
          show: true,
          location: 'e',
          fontSize: 11,
          marginTop: 10,
      }
  });

Produces:


text:
Q: Installing Theano with GPU on Windows 8.1 64-bit with Visual Studio 2013 This Theano Installation is making me mad :(
So, I've followed the instructions here on the most voted answer because it seemed like the most similar condiguration from mine and up-to-date version : Installing theano on Windows 8 with GPU enabled
1- I've installed Cuda v6.5, launched deviceQuery and it works fine.
2- I already have Visual Studio 2013 so I haven't installed Visual Studio 2010
3- > At the time of writing, Theano on GPU only allows working with 32-bit floats and is primarily built for 2.7 version of Python.
So i don't know exactly what is the current state now but I have a friend with the same configuration than mine and he managed to make it work so I guess it's possible. I've installed Python through Anaconda.
4- I've installed MinGW and Cygwin
5- I've fixed msvc9compiler.py
6- Here's the bottleneck : the PyCUDA Installation
Here's what I've done:
- I've used cygwin to extract the pycuda tar file
- I've executed python configure.py through VS2013 x64 Native Tools Command Prompt than configured siteconfig.py as followed:
BOOST_INC_DIR = []
BOOST_LIB_DIR = []
BOOST_COMPILER = 'gcc43'
USE_SHIPPED_BOOST = True
BOOST_PYTHON_LIBNAME = ['boost_python']
BOOST_THREAD_LIBNAME = ['boost_thread']
CUDA_TRACE = False
CUDA_ROOT = 'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v6.5'
CUDA_ENABLE_GL = False
CUDA_ENABLE_CURAND = True
CUDADRV_LIB_DIR = ['${CUDA_ROOT}/lib', '${CUDA_ROOT}/lib/x64']
CUDADRV_LIBNAME = ['cuda']
CUDART_LIB_DIR = ['${CUDA_ROOT}/lib', '${CUDA_ROOT}/lib/x64']
CUDART_LIBNAME = ['cudart']
CURAND_LIB_DIR = ['${CUDA_ROOT}/lib', '${CUDA_ROOT}/lib/x64']
CURAND_LIBNAME = ['curand']
CXXFLAGS = ['/EHsc', '-DBOOST_NO_TYPEID']
LDFLAGS = ['/FORCE']

*

*I've executed python setup.py build --compiler="msvc" through VS2013 x64 Native Tools Command Prompt

*I've executed python setup.py install through VS2013 x64 Native Tools Command Prompt

*When I execute the little test in python, here's what's happening:
PS C:\users\jmm\desktop> python test.py

Vendor:  Continuum Analytics, Inc.

Package: mkl

Message: trial mode expires in 29 days

Traceback (most recent call last):

  File "test.py", line 7, in <module>
    a_doubled = (2*a_gpu).get()

  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\gpuarray.py", line 471, in __rm
ul__
    return self._axpbz(scalar, 0, result)

  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\gpuarray.py", line 333, in _axp
bz
    func = elementwise.get_axpbz_kernel(self.dtype, out.dtype)

  File "<string>", line 2, in get_axpbz_kernel

  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\tools.py", line 423, in context
_dependent_memoize
    result = func(*args)

  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\elementwise.py", line 417, in g
et_axpbz_kernel
    "axpb")

  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\elementwise.py", line 157, in g
et_elwise_kernel
    arguments, operation, name, keep, options, **kwargs)

  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\elementwise.py", line 143, in g
et_elwise_kernel_and_types
    keep, options, **kwargs)

  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\elementwise.py", line 71, in ge
t_elwise_module
    options=options, keep=keep)
  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\compiler.py", line 251, in __in
it__
    arch, code, cache_dir, include_dirs)

  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\compiler.py", line 241, in comp
ile
    return compile_plain(source, options, keep, nvcc, cache_dir)

  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\compiler.py", line 73, in compi
le_plain
    checksum.update(preprocess_source(source, options, nvcc).encode("utf-8"))
  File "C:\Users\jmm\Anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg\pycuda\compiler.py", line 52, in prepr
ocess_source
    cmdline, stderr=stderr)

pycuda.driver.CompileError: nvcc preprocessing of c:\users\jmm\appdata\local\temp\tmp32jnzb.cu failed
[command: nvcc --preprocess -arch sm_30 -m64 -Ic:\users\jmm\anaconda\lib\site-packages\pycuda-2014.1-py2.7-win-amd64.egg
\pycuda\cuda c:\users\jmm\appdata\local\temp\tmp32jnzb.cu --compiler-options -EP]
[stderr:
tmp32jnzb.cu
'C:\Program' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
]

Could you please tell me why the hell this doesn't work ?

A: I have written a practical guide for the whole process:
https://my6266blog.wordpress.com/2015/01/21/installing-theano-pylearn2-and-even-gpu-on-windows/
Good luck! It's not that complicated, just follow the steps one by one.

A: You probably need to add the path to the executables for Visual Studio in your nvcc.profile
(you can find it in your CUDA bin folder. On my system: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.5\bin).
In my case, since I have Visual studio 2010, I added at the end of nvcc.profile:
"compiler-bindir =  C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"

A: Actually you don't need to install pycuda to get theano working on your windows machine. I'm not an expert but I have Theano installed on Windows 8.1.
This is my laptop config: 64-bit, nvcc/cuda 6.5, Python 2.7.9, WinPython-64bit-2.7.9.3, Windows 8.1, VS2013 and two graphic units (Intel HD Graphics 4600 and NVIDIA GeForce GT 750M).

A: The process was a pretty big hassle, so here is a tutorial for anyone that is interested:
All of this has been tested using a clean install of Windows 8.1, with nothing else on it, though it should work fine if you don't have a clean install because this will install all the required versions of the software for you.
You need 64-bit windows, 32 bit will not work. You will also need a CUDA compatible graphics card, so if you don't have one you're stuck for now, sadly. This means that you need a relatively modern NVIDIA graphics card, AMD will not work (it can run OpenCL but not CUDA because CUDA is lame and proprietary).
I am installing this on Windows 8.1, but I suspect it should all still work on windows 7 as well.
First download WinPython, (make sure to get python 2.7, version 2.7.10.3, this link points to there) and install it TO A PATH THAT DOES NOT HAVE SPACES IN IT. OTHERWISE THINGS BREAK. I made an Other folder in C:\ (C:\Other) and then made a folder named Python27 (C:\Other\Python27) and tell the installer to install it in there.
Once it is done installing, you will need to add it to your path. Press the windows key and type environment variables, then click "Edit the System Environment Variables", click Environment Variables in the windows that pops up, scroll down to Path, and then append
C:\Other\Python27\python-2.7.10.amd64

Or wherever else you installed WinPython to
Then add a semicolon after it, so you get
C:\Other\Python27\python-2.7.10.amd64;

This is how you add a specific path to the Path variables, in the future, I will just say to add it here and now give specific steps about how to do that. Note that if you update the system path, the current command prompt windows that are open won't get that update, and you will have to open a new command prompt window to actually have it use the new path.
The purpose of a path is so your command prompt window knows where programs are, because if you call, say
python
in the command prompt, it will look through every folder in your path until it finds a python.exe. If it can't find any, it will get angry as it typically would if that program didn't exist.
If you don't want to clutter your path variable/if your path variable is full, I put a tutorial here about how to make it so your path is just appended to when you open a command prompt window via a text file that stores all the paths, instead of having to edit the environment variable itself, if you are interested.
You then need to add
C:\Other\Python27\python-2.7.10.amd64\DLL;
C:\Other\Python27\python-2.7.10.amd64\Scripts;

to your path as well (again, or wherever else you installed python. For later on I will just say where I installed it and if you installed it somewhere else it should be pretty easy to just tweak the commands accordingly)
Next, install visual studio 2015 community and visual studio 2013, making sure to install all the tools related to c++ development as well (using custom installation, then under Programming Languages). These don't need to be in a path without spaces, and they probably won't let you store them anywhere else anyway and that is OK.
Add
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin;

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64;

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib;

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib\amd64;

To your system path.
Install NOT NEWEST DRIVER BECAUSE THEY ARE UNSTABLE, but instead 355.60 because it is known to be very reliable, and new enough. Then install the CUDA toolkit (it's also okay to store this in a path with spaces, it probably won't give you the option either, but even if it does, just let it store it in the default place it wants to store it to). Version 6.5 is needed because version 7 and above aren't supported by pycuda. If you have a GTX 9__ you will need to download CUDA from here instead.
This will probably automatically append
C:\Program Files (x86)\Windows Kits\8.1\Redist\D3D\x64;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\bin;
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\libnvvp;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;

To your path, if not you will need to do so now.
Those are the only three things that can be stored to paths with spaces (these will be in like Program Files or Program Files (x86)), with everything else be very careful to store them to paths that don't have spaces.
Download the boost binaries (1_55_0 for 64 bit which is the version this link points to), and run the installer, then select to store them to a path without spaces (I stored them to C:\Other\boost)
Navigate to that directory in the command line, then run
bootstrap.bat

and then when it is done run
.\b2

This will start building, and take a long time, and use a lot of space (about 6 GB).
It will probably say that 8 targets failed, 8 targets were skipped, and 1075 were updated. This is what one should expect, and is not a problem.
Install Git-2.7.0-64-bit to some path without a space in it
Choose to use Git from the Windows Command Prompt, checkout Windows-style, commit Unix-style endings, use Window's default console window, and do not enable file system caching.
Add
C:\Other\Git\bin;

To your system path
Next, run the installer for VCForPython.
Download pycuda source (pycuda-2015.1.3)
Navigate inside that directory, then run
python configure.py

this will create a file named siteconf.py.
Open this file, and it should look something like
BOOST_INC_DIR = []
BOOST_LIB_DIR = []
BOOST_COMPILER = 'gcc43'
USE_SHIPPED_BOOST = True
BOOST_PYTHON_LIBNAME = ['boost_python-py27']
BOOST_THREAD_LIBNAME = ['boost_thread']
CUDA_TRACE = False
CUDA_ROOT = 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v6.5'
CUDA_INC_DIR = ['${CUDA_ROOT}/include']
CUDA_ENABLE_GL = False
CUDA_ENABLE_CURAND = True
CUDADRV_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CUDADRV_LIBNAME = ['cuda']
CUDART_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CUDART_LIBNAME = ['cudart']
CURAND_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CURAND_LIBNAME = ['curand']
CXXFLAGS = []
LDFLAGS = []

modify it so it looks like:
BOOST_INC_DIR = ['C:/Other/boost']
BOOST_LIB_DIR = ['C:/Other/boost/lib64-msvc-12.0']
BOOST_COMPILER = 'msvc'
USE_SHIPPED_BOOST = True
BOOST_PYTHON_LIBNAME = ['boost_python-vc120-mt-1_55']
BOOST_THREAD_LIBNAME = ['boost_thread-vc110-mt-1_55']
CUDA_TRACE = False
CUDA_ROOT = 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v6.5'
CUDA_ENABLE_GL = False
CUDA_ENABLE_CURAND = True
CUDADRV_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CUDADRV_LIBNAME = ['cuda']
CUDART_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CUDART_LIBNAME = ['cudart']
CURAND_LIB_DIR = ['${CUDA_ROOT}/lib/Win32', '${CUDA_ROOT}/lib/x64']
CURAND_LIBNAME = ['curand']
CXXFLAGS = ['/DBOOST_PYTHON_STATIC_LIB', '/EHsc']
LDFLAGS = ['/LIBPATH:C:\\Other\\boost\\/lib64-msvc-12.0', '/FORCE']

then run
python setup.py build

followed by
python setup.py install

This should install pycuda for you =)
To install Theano (with GPU enabled), download release 0.7, unzip it, navigate inside it using a command prompt, and then type
python setup.py install

then go and edit system environment variables, and create one named
THEANO_FLAGS

and set it's value to
device=gpu,floatX=float32

Then open a new command prompt, and if you have completed all of the steps above, this should work well =) You can run the code here to make sure that you are actually running off the GPU.

A: I was able to get Theano installed on my ASUS K501LX Windows 8.1 laptop, with an NVIDIA GeForce 950M GPU, without any hassle whatsoever. I largely followed Maor's post above from March 29th. I was actually shocked at how easy it was! All I needed was the Community Edition of Visual Studio 2013 and the CUDA 7 Toolkit. I then installed Anaconda 3.4 (I used the latest version that's out there now). The one modification I made to Maor's post was installing mingw, via conda install mingw libpython immediately after installing Anaconda. Also, since I am using Python 3, I had to change the flags parameter in .theanorc.txt to point to C:\Anaconda3\libs.
Upon importing theano, it returned that it was using my GeForce GTX 950M device, and running the theano\misc\check_blas.py check returned no errors and carried out its tests on my GPU.
Happy times!


text:
Q: $(\alpha+\beta)+\gamma=\alpha+(\beta+\gamma)$ for all ordinals $\alpha,\beta,\gamma$ I have come up with a proof of this theorem from my textbook Introduction to Set Theory by Karel Hrbacek and Thomas Jech. Does it look fine or contain gaps? Thank you for your help!

$(\alpha+\beta)+\gamma=\alpha+(\beta+\gamma)$ for all ordinals $\alpha,\beta,\gamma$.

My attempt:
We proceed by transfinite induction on $\gamma$

*

*If $\gamma=0$, then $(\alpha+\beta)+\gamma=\alpha+\beta=\alpha+(\beta)=\alpha+(\beta+\gamma)$.

*If $\gamma=\delta+1$, then by IH $(\alpha+\beta)+\delta=\alpha+(\beta+\delta)$. We have $(\alpha+\beta)+(\delta+1)=((\alpha+\beta)+\delta)+1=(\alpha+(\beta+\delta))+1=\alpha+((\beta+\delta)+1)=\alpha+(\beta+(\delta+1)).$

*If $\gamma$ is a limit ordinal, then $(\alpha+\beta)+\gamma=\sup\{(\alpha+\beta)+\delta\mid\delta<\gamma\}=$ $\sup\{\alpha+(\beta+\delta)\mid\delta<\gamma\}$.
We have 3 observations.
First, $\beta+\gamma=\sup\{\beta+\delta\mid\delta<\gamma\}$.
Second, $\beta+\gamma$ is a limit ordinal. This is because $\xi<\beta+\gamma\implies\xi\le\beta+\delta$ for some $\delta<\gamma\implies\xi+1\le(\beta+\delta)+1=\beta+(\delta+1)<\beta+\gamma$.
Third, $\sup\{\alpha+(\beta+\delta)\mid\delta<\gamma\}=$ $\sup\{\alpha+\xi\mid\xi<\beta+\gamma\}$. This is because $\alpha+\xi$ for some $\xi<\beta+\gamma$ $\iff\alpha+\xi$ for some $\xi=\beta+\delta$ and $\delta<\gamma$ $\iff\alpha+(\beta+\delta)$ for some $\delta<\gamma$.
It follows that $(\alpha+\beta)+\gamma=\alpha+(\beta+\gamma)$.


text:
Q: GIT: remove from 2nd to 5th commits in the remote branch I'd like to fully remove several commits in the remote branch.
Reason: The branch with the only important (and the most recent) commit supposed to be forked from and merged into another branch.
Once I change the branch to a proper branch (via browser) I see several more commits that are not in that proper branch yet. I don't need them.
git reset --hard HEAD~5

and by manually applying and commiting my recent changes didn't get the result. There are even more commits now.
So, what was a proper and clear algorythm?
Thank you.

A: Ahhh... I didn't quite understand what you want. If what you want to do is "remove" a couple of revisions from the history of a branch (either local or remote), what you have to do is this:

*

*Get the (sha1) IDs for both revisions you want to get rid of

*Checkout the revision before the oldest of the couple

*Cherry-pick revisions from the oldest to one revision before the newest of the couple (that will discard the oldest so it won't be applied)

*Cherry-pick revisions from the newest to the tip of the original branch.

So... say the remote branch is foo/bar and revisions are rev1 (oldest) and rev2 (newest).
What you do is:
git checkout rev1~1
git cherry-pick rev1..rev2~1
git cherry-pick rev2..foo/bar

When you reach this point, you could create a local branch on top of it or just push it into foo/bar if you want to replace it:
git push foo -f HEAD:bar


text:
Q: Is there going to be a "MCSD: SharePoint" certificate? Researching it for long now I found no clear answer and found controversial (but mostly old) info about this issue.
I know for a fact that MCPD has evolved to MCSD (Microsoft Certified Solutions Developer); the new certificates of MCSD are nicely listed at this page here: http://www.microsoft.com/learning/en/us/mcsd-certification.aspx#fbid=fpR-o5C3m1R
However in the same previous page I can't see MCSD for SharePoint! This post at StackExchange (When will the SharePoint 2013 exams be available) mentions that this certificate is already set by Microsoft and it even mentions the requirements for this certificate but none of the info is found on Microsoft site (based on my researches though).
The site here: http://www.absolute-sharepoint.com/2012/12/sharepoint-2013-mcsd-developer.html
mentions roughly similar info as the previous one and it even gives an upgrade path from MCPD to MCSD (www.absolute-sharepoint.com/2012/12/sharepoint-2013-mcsd-developer.html)
However as in the first link I mentioned here, there seems to be no offcial "MCSD: SharePoint" (at least not yet)!
So what is the truth about MCSD: SharePoint? Is there going to be a "MCSE: SharePoint" certificate? Any requirements announced yet? Any upgrade path from MCPD to MCSE announced? What is the future of MCPD: SharePoint 2010?
Thanks for viewing and participating : )

A: I think you are confused with out-dated information,
If you want to do certification in SharePoint 2013 as expert then, here's the list of exams,

MCSD SharePoint not available yet as on Microsoft Certification site,

Source & Source2

A: These two exans are out since June 20:

*

*Developing Microsoft SharePoint Server 2013 Core Solutions

*Developing Microsoft SharePoint Server 2013 Advanced Solutions
They are most likely to be part of a future MCSD SharePoint 2013 certificate. They are together with 70-331 and 70-332 part of nine certificates in MCSM (Solution Master) SharePoint 2013. MCSM is the next step from MCSE, and most probably the same next step from MCSD.
However, no official sources have confirmed a MCSD SharePoint 2013 Certificate yet.

A: Here is a discussion of recent information on the 2013 certifications, including the MCSD: http://www.excessivelyproductive.com/sharepoint-2013-certifications-1.aspx


text:
Q: Why ubuntu 15.10 still needs restart to update the kernel? I upgraded my system to ubuntu 15.10 dev a while ago and the kernel was 4.2.0-14.
A new update downloaded kernel 4.2.0-16 but "uname -a" still shows the current running kernel as 4.2.0-14.
Linux gedo 4.2.0-14-generic #16-Ubuntu SMP Fri Oct 2 05:14:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

And I have this in my "/boot"
-rw-r--r-- 1 root root  1311387 Sep 21 17:36 abi-4.2.0-11-generic
-rw-r--r-- 1 root root  1311906 Oct  2 01:49 abi-4.2.0-14-generic
-rw-r--r-- 1 root root  1311978 Oct  8 11:15 abi-4.2.0-16-generic
-rw-r--r-- 1 root root   184735 Sep 21 17:36 config-4.2.0-11-generic
-rw-r--r-- 1 root root   184756 Oct  2 01:49 config-4.2.0-14-generic
-rw-r--r-- 1 root root   184809 Oct  8 11:15 config-4.2.0-16-generic
drwxr-xr-x 5 root root     1024 Oct 17 19:36 grub
-rw-r--r-- 1 root root 33492548 Oct  8 20:03 initrd.img-4.2.0-11-generic
-rw-r--r-- 1 root root 33525010 Oct 16 18:39 initrd.img-4.2.0-14-generic
-rw-r--r-- 1 root root 33673615 Oct 22 00:20 initrd.img-4.2.0-16-generic
drwx------ 2 root root    12288 Jun 30  2014 lost+found
-rw-r--r-- 1 root root   182704 Aug 27 07:04 memtest86+.bin
-rw-r--r-- 1 root root   184380 Aug 27 07:04 memtest86+.elf
-rw-r--r-- 1 root root   184840 Aug 27 07:04 memtest86+_multiboot.bin
-rw------- 1 root root  3739218 Sep 21 17:36 System.map-4.2.0-11-generic
-rw------- 1 root root  3740363 Oct  2 01:49 System.map-4.2.0-14-generic
-rw------- 1 root root  3740437 Oct  8 11:15 System.map-4.2.0-16-generic
-rw------- 1 root root  6720112 Sep 21 17:36 vmlinuz-4.2.0-11-generic
-rw------- 1 root root  6720976 Oct  2 01:49 vmlinuz-4.2.0-14-generic
-rw------- 1 root root  6797680 Oct  8 11:15 vmlinuz-4.2.0-16-generic

A: Although Kernel 4 supported live patching, ubuntu did not provide the necessary updates for live patching of the kernel.
But now on Ubuntu 16.04, canonical has started to provide the live patches through Canonical Livepatch Service, all you need is to register (free for up to 3 systems), install the service
sudo snap install canonical-livepatch

and enable it with your Token
sudo canonical-livepatch enable [Token]

Afterwards, you will no longer need a restart.


text:
Q: Path independence of integral of 1-form implies the form is exact I am trying to prove that path independence of integral of 1-form implies the form is exact.
Suppose we have 1-form $\omega=Pdx+Qdy$.
We need to show that there exist function $F: \mathbb{R}^2 \supset U \rightarrow \mathbb{R}$ such that $\omega=dF$.
I am trying to show that
$$F(x, y) = \int_{(0, 0)}^{(x, y)} Pdx + Qdy$$
satisfies $\omega=dF$.
(since the integral is path-independent, it doesn't matter how we get from $(0, 0)$ to $(x, y)$)
It obviously can be done by calculating $\partial F / \partial x$ and $\partial F / \partial x$.
Ok, now, I am doing the trick. For calculating $\frac{\partial F}{\partial y}$ let's move towards
$(x,y)$ like that:

(path-independence)
It's not hard to parametrize $\gamma_1(t)=\begin{bmatrix} 0 \\ yt \end{bmatrix}$, where $t \in [0, 1]$
Let's denote $\gamma = \gamma_1 \gamma_2$
Evaluating $F(x, y):$
$$
\int_\gamma Pdx + Qdy = \\
 =\int_{\gamma_1} (Pdx + Qdy) + \int_{\gamma_2} (Pdx + Qdy) = \\
 =\int_{\gamma_1} Qdy + \int_{\gamma_2} Pdx
$$
And it looks like if we calculate the derivatives ${\partial}/{\partial y}$ and ${\partial}/{\partial x}$ componentwise we get what we want. But how to show that
$$
\frac{\partial}{\partial y} \int_{\gamma_1} Qdy = Q \quad ?
$$
I've tried this way:
$$
\frac{\partial}{\partial y} \int_{\gamma_1} Qdy = \frac{\partial}{\partial y} \int_0^1 \langle \begin{bmatrix}
           0 \\
           Q(\gamma_1(t)) \\
         \end{bmatrix} , \dot{\gamma_1}(t) \rangle dt = \\
=\frac{\partial}{\partial y} \int_0^1 Q(0, yt) \cdot y dt=\text{but it doesn't seem to help}
$$

A: We see that $\frac{\partial F}{\partial y}|_{(x_0, y_0)} = \frac{d}{dt} G(t)|_{t = 0}$, where $G(t) = F(x_0, y_0 + t)$.
Consider that $F(x_0, y_0 + t) = F(x_0, y_0) + \int\limits_{(x_0, y_0)}^{(x_0, y_0 + t)} \omega$. This follows directly from path independence, since we can get a path from $(0, 0)$ to $(x_0, y_0 + t)$ by a path from $(0, 0)$ to $(x_0, y_0)$ with a path from $(x_0, y_0)$ to $(x_0, y_0 + t)$.
In other words, $G(t) = G(0) + \int\limits_{(x_0, y_0)}^{(x_0, y_0 + t)} \omega$.
Now the path does not matter. So we take the path parametrized by $[0, t]$ which maps $h \mapsto (x_0, y_0 + h)$. Then we see that $\int\limits_{(x_0, y_0)}^{(x_0, y_0 + t)} \omega = \int\limits_0^t Q(x_0, y_0 + h) dh$.
Thus, we see that $G(t) = G(0) + \int\limits_0^t Q(x_0, y_0 + h) dh$.
Now by the fundamental theorem of calculus, we see that $G'(t) = Q(x_0, y_0 + t)$. Thus, $G'(0) = Q(x_0, y_0)$ in particular. So $\frac{\partial F}{\partial y}|_{(x_0, y_0)} = Q(x_0, y_0)$.
The same argument holds for $\frac{\partial F}{\partial x}|_{(x_0, y_0)}$. Thus, we see that $dF = \omega$.
It's not hard to see that this proof generalises fully to 1-forms in $n$ dimensions for all $n$. Any 1-form in $n$-dimensional space which has the path-invariance property is exact.
You were very close to getting the answer. But you parametrized paths on $[0, 1]$ instead of parametrizing the path on $[0, t]$, which was the necessary step to use the fundamental theorem.


text: Q: Ubermenu cant handle my menu, how to deal with large number of menuitems? I have a webpage with a large number of pages, around 250-300, and I output these in Ubermenu at the moment. Needles to say, my menu backend is very slow, and sorting is a pain in the.. well you know. Is there any other good way to deal with such large numbers of menuitems? Any suggestion would be appriciated!


text:
Q: Multiple regression curve fitting I've got some data with 2 independent variables and 1 dependent variable I'm trying to fit a curve to.  I'm really kind of a dummy with Mathematica except for the most basic things, so I looked through the documentation of FindFit and to be honest I'm a little lost.
My data is:
X = {50, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 62, 63, 63,
 64, 65, 66, 67, 67, 68, 69, 69, 70, 70, 70, 71, 72, 72, 72, 73, 73,
 73, 73, 73, 73, 74, 74, 74, 75, 76, 76, 76, 76, 76, 76, 76, 76}

Y = {19.9, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 30.4, 50,
 24.3, 50, 50, 50, 50, 47.1, 50, 50, 32.4, 50, 51.1, 45.3, 50, 50, 51,
 106.5, 50, 39.7, 71.4, 80.2, 89.2, 160.6, 50, 148.9, 36, 50, 50,
 71.4, 97.2, 116.8, 207.6, 224.2, 230.1, 232.6, 50}

Z = {0.199, 0.500, 0.495, 0.490, 0.485, 0.481, 0.476, 0.472, 0.467,
 0.463, 0.459, 0.455, 0.450, 0.272, 0.446, 0.216, 0.442, 0.439, 0.435,
 0.431, 0.402, 0.427, 0.424, 0.272, 0.420, 0.425, 0.377, 0.417, 0.413,
 0.418, 0.874, 0.410, 0.322, 0.580, 0.653, 0.725, 1.306, 0.407, 1.202,
 0.291, 0.403, 0.400, 0.567, 0.771, 0.926, 1.647, 1.780, 1.826, 1.846, 0.397}

I'm looking for a function f such that f(X,Y)=Z.
I know I have to give it a model, but I'm not even sure what a good model to try would be.  I know that for constant X, f is almost linear in Y, so maybe having f be quadratic in terms of Y would be good.  I'm not sure about f's relationship to X, but I suspect it's a similar situation so quadratic in terms of X maybe as well.
How do I set this up and find a good fit?

A: It helps to look at the data..your points fall very nearly on a plane, which can be found readily:
 plane = Last@Minimize[Total[(a X + b Y - Z + c)^2], {a, b, c}]

{a -> -0.00357726, b -> 0.00799625, c -> 0.267096}

poly = (Append[#, a #[[1]] + b #[[2]] + c /. plane] & /@ {{50,
     19}, {76, 19}, {76, 230}, {50, 230}})
g1=Graphics3D[{ {Red, PointSize[.01], Point[Transpose[{X, Y, Z}]] },
  Opacity[.5], Polygon[poly] }, BoxRatios -> 1]

now it looks like the majority of your points are on a near perfect line, with some scatter.. so do a nonlinear fit to a line:
u = {ux, uy, uz};
sol = FindMinimum[
  Total[Norm[ # -  (# - {x0, y0, z0}).u u/Total[u^2]  - {x0, y0,
        z0} ] & /@ Transpose[{X, Y, Z}]], {{x0, 75}, {y0,
    50}, {z0, .37}, {ux, -1}, {uy, 0}, {uz, 0}}]

Show[g1, Graphics3D[
  Line[{{x0, y0, z0}, {x0, y0, z0} + 30 u} /. sol[[2]]],
  BoxRatios -> 1]]

A: As @Bill points out, plotting the data is essential.  (Also "multivariate" is usually reserved for multiple responses rather than multiple predictor variables and what you want to do is called "multiple regression".)  Once you have some idea as to what form the candidate models might take, you can fit those using several fitting functions:
x = {50, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 62, 63,
   63, 64, 65, 66, 67, 67, 68, 69, 69, 70, 70, 70, 71, 72, 72, 72, 73,
    73, 73, 73, 73, 73, 74, 74, 74, 75, 76, 76, 76, 76, 76, 76, 76, - 76};

y = {19.9, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 30.4, 50,
   24.3, 50, 50, 50, 50, 47.1, 50, 50, 32.4, 50, 51.1, 45.3, 50, 50,
   51, 106.5, 50, 39.7, 71.4, 80.2, 89.2, 160.6, 50, 148.9, 36, 50,
   50, 71.4, 97.2, 116.8, 207.6, 224.2, 230.1, 232.6, 50};

z = {0.199, 0.500, 0.495, 0.490, 0.485, 0.481, 0.476, 0.472, 0.467,
   0.463, 0.459, 0.455, 0.450, 0.272, 0.446, 0.216, 0.442, 0.439,
   0.435, 0.431, 0.402, 0.427, 0.424, 0.272, 0.420, 0.425, 0.377,
   0.417, 0.413, 0.418, 0.874, 0.410, 0.322, 0.580, 0.653, 0.725,
   1.306, 0.407, 1.202, 0.291, 0.403, 0.400, 0.567, 0.771, 0.926,
   1.647, 1.780, 1.826, 1.846, 0.397};

data = Transpose[{x, y, z}];

FindFit[data, a + b xx + c yy, {a, b, c}, {xx, yy}]
(* {a -> 0.26709594179703233,b -> -0.0035772589306014156,c -> 0.00799624708810228} *)

LinearModelFit[data, {xx, yy}, {xx, yy}]["BestFitParameters"]
(* {0.26709594179703283,-0.0035772589306014243,0.007996247088102279} *)

NonlinearModelFit[data,
  a + b xx + c yy, {a, b, c}, {xx, yy}]["BestFitParameters"]
(* {a -> 0.26709594179703233,b -> -0.0035772589306014156, c -> 0.00799624708810228} *)

(And using lower case letters for your variables is almost always better in Mathematica.)
When you want to compare several models, I find that NonlinearModelFit even when fitting linear models is more convenient.  Here are a few possibilities:
nlm1 = NonlinearModelFit[data, a + b xx + c yy, {a, b, c}, {xx, yy}]
nlm2 = NonlinearModelFit[data,
  a + b xx + c yy + d xx^2 + e yy^2, {a, b, c, d, e}, {xx, yy}]
nlm3 = NonlinearModelFit[data,
  a + b xx + c yy + d xx yy, {a, b, c, d}, {xx, yy}]
nlm4 = NonlinearModelFit[data,
  a + b xx + c yy + d xx^2 + e yy^2 + f xx yy, {a, b, c, d, e, f}, {xx, yy}]

You can make relative comparisons the models using AIC:
nlm1["AIC"]
(* -315.55322687806864 *)
nlm2["AIC"]
(* -342.34325852838634 *)
nlm3["AIC"]
(* -485.8345586581582 *)
nlm4["AIC"]
(* -569.8967227522896 *)

Here we see that model 4 with the smallest AIC gives the best fit of the 4 models.  That doesn't mean you get a good fit. To get an idea of a more absolute fit one can look at the root mean square error:
nlm1["EstimatedVariance"]^0.5
(* 0.009818046569044022 *)
nlm2["EstimatedVariance"]^0.5
(* 0.007374767809867794 *)
nlm3["EstimatedVariance"]^0.5
(* 0.0017720941160463222 *)
nlm4["EstimatedVariance"]^0.5
(* 0.0007510869942900922 *)

Here model 4 performs best in that it has the smallest root mean square error but only you know if that value is small enough to meet your objective(s).  For more details of model comparisons, Cross Validated is a more appropriate forum.
Update
Once you determine the approach for model fitting, you can use Mathematica to check on the model fit by looking at the residuals as one is assuming independent and normally distributed errors with a constant variance.  Below is a comparison of Model 1 and Model 4 showing the predicted vs residual, histograms of residuals, and a quantile-quantile plot.  Note that Model 4 has better behaved and smaller residuals than Model 1.  (Why you want to use these visuals is better addressed in Cross Validated.)
(* Calclate residuals *)
residuals1 = z - nlm1["PredictedResponse"];
residuals4 = z - nlm4["PredictedResponse"];

(* Plot predicted response vs. residual *)
GraphicsRow[{ListPlot[
   Transpose[{nlm1["PredictedResponse"], residuals1}],
   PlotRange -> {{0, 1.4}, Full},
   PlotLabel -> Style["Model 1", Bold, Large], Frame -> True,
   FrameLabel -> {"Predicted", "Residual"}],
  ListPlot[Transpose[{nlm4["PredictedResponse"], residuals4}],
   PlotRange -> {{0, 1.4}, Full},
   PlotLabel -> Style["Model 4", Bold, Large], Frame -> True,
   FrameLabel -> {"Predicted", "Residual"}]},
 ImageSize -> Full]

(* Histograms of residuals *)
GraphicsRow[{
  Show[Histogram[residuals1, Automatic, "PDF", PlotRange -> Full, Frame -> True,
    FrameLabel -> {"Residual", "Density"}],
   Plot[PDF[NormalDistribution[Mean[residuals1], StandardDeviation[residuals1]], x], {x, -0.05, 0.02},
    PlotStyle -> Thick]],
  Show[Histogram[residuals4, Automatic, "PDF", PlotRange -> Full, Frame -> True,
    FrameLabel -> {"Residual", "Density"}],
   Plot[PDF[NormalDistribution[Mean[residuals4],  StandardDeviation[residuals4]], x], {x, -0.0025, 0.0025}, PlotStyle -> Thick]]},
 ImageSize -> Full]

(* Quantile-quantile plot *)
GraphicsRow[{QuantilePlot[residuals1,
   NormalDistribution[Mean[residuals1],
    StandardDeviation[residuals1]],
   FrameLabel -> {"Normal theoretical quantiles", "Data quantiles"}],
  QuantilePlot[residuals4,
   NormalDistribution[Mean[residuals4], StandardDeviation[residuals4]],
   FrameLabel -> {"Normal theoretical quantiles", "Data quantiles"}]},
  ImageSize -> Full]


text:
Q: php date('d') calculates same output for two consecutive days I'm building a calendar through PHP and the way I'm doing this results on some days being written twice.
I replicated the behaviour in this little script:
<?php
//
// define a date to start from
//
$d = 26;
$m = 10;
$y = 2013;
date_default_timezone_set('CET');
$time = mktime(0, 0, 0, $m, $d, $y);

//
// calculate 10 years
//
for($i=0;$i<3650;$i++){
  $tomorrowTime = $time + (60 * 60 * 24);

  //
  // echo date if the next day has the same date('d') result
  //
  if(date('d',$time)==date('d',$tomorrowTime)){
    echo date('d-m-Y',$time)." was calculated twice... \n";
  }

  $time = $tomorrowTime;
}

?>

This is what I get:
27-10-2013 was calculated twice...
26-10-2014 was calculated twice...
25-10-2015 was calculated twice...
30-10-2016 was calculated twice...
29-10-2017 was calculated twice...
28-10-2018 was calculated twice...
27-10-2019 was calculated twice...
25-10-2020 was calculated twice...
31-10-2021 was calculated twice...
30-10-2022 was calculated twice...

When I define $time as 0 (unix epoch), I don't get the same behaviour.
Is there something wrong with using mktime()?
Or is November just being awkward?
Cheers,
Jeroen

A: Makes sense, these are leap seconds. Not all days take 86400 seconds.
Don't use 12 AM for these calculations, use 12 PM. That'll help a lot.
That said, there are better approaches for date calculations. But your math with 12 PM will work fine for the UTC timezone (or CET).

A: This statement should guard better against leap seconds and such:
$tomorrowTime = strtotime('+1 days', $time);

A: That's exactly why you don't add seconds to calculate times. DST and leap seconds make it so there are not always exactly 60 * 60 * 24 seconds in one day. You can use mktime for the correct calculations:
for ($i = 0; $i < 3650; $i++) {
    $time = mktime(0, 0, 0, $m, $d + $i, $y);
    //                          ^^^^^^^

    ...
}


text:
Q: MalformedStreamException: Stream ended unexpectedly Given:
byteString is
-----------------------------149742642616556
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain

test
-----------------------------149742642616556--

Then this code (not optimized):
Pattern pattern = Pattern.compile(BOUNDARY_PATTERN); // "(?m)\\A-+\\d+$"
Matcher matcher = pattern.matcher(byteString);
String boundary = null;
while (matcher.find()) {
    boundary = matcher.group();
    contentType = "multipart/form-data; boundary=" + boundary;
}
LOG.info("Content Type = " + contentType);

@SuppressWarnings("deprecation")
org.apache.commons.fileupload.MultipartStream multipartStream =
        new org.apache.commons.fileupload.MultipartStream(new ByteArrayInputStream(byteString.getBytes()), boundary.getBytes());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
multipartStream.readBodyData(bos); // throw error
byte[] byteBody = bos.toByteArray();

Throws this error:
org.apache.commons.fileupload.MultipartStream$MalformedStreamException: Stream ended unexpectedly
    at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:1005)
    at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:903)
    at java.io.InputStream.read(InputStream.java:101)
    at org.apache.commons.fileupload.util.Streams.copy(Streams.java:100)
    at org.apache.commons.fileupload.util.Streams.copy(Streams.java:70)
    at org.apache.commons.fileupload.MultipartStream.readBodyData(MultipartStream.java:593)

What could be possibly wrong here? I would appreciate a help here.

A: The issue seems to be due to a bad end of line and the way the boundary is retrieved. According to a RFC2046 quote taken from a SO answer:

The Content-Type field for multipart entities requires one parameter, "boundary". The boundary delimiter line is then defined as a line consisting entirely of two hyphen characters ("-", decimal value 45) followed by the boundary parameter value from the Content-Type header field, optional linear whitespace, and a terminating CRLF.

The problem lies precisely on two points: the end of line type and the two hyphens preceding the boundary parameter value.
End of lines
Since your code doesn't show accurately the value of byteString, I tried both LF (\n) and CRLF (\r\n) end of lines to see what will happen.
It appears the issue is reproduced when a bad end of line - i.e. not CRLF - is right before the last boundary, as shown below:
String byteString=
    "-----------------------------149742642616556\r\n" +
    "Content-Disposition: form-data; name=\"file\"; filename=\"test.txt\"\r\n" +
    "Content-Type: text/plain; charset=UTF-8\r\n" +
    "\r\n" +
    "test\r\n" + // <-- only \n here lead to a MalformedStreamException
    "-----------------------------149742642616556--\r\n";

It sounds like the MultipartStream fails to parse the begin of the boundary, since it doesn't catch a right end of line (CRLF) on the previous line. So, I you used LF terminators, you should replace them by CRLF ones.
Boundary format
The RFC tells that a boundary delimiter is two hyphens + boundary parameter + CRLF. Your regexp doesn't catch only the boundary parameter value, it also includes the two hyphens. So I replaced this part:
// capturing group = boundary parameter value
String regexp="(?m)\\A--(-*\\d+)$";
// [...]
while (matcher.find()) {
    boundary = matcher.group(1);
    // [...]
}

Working code
Runnable as a MCVE
The code you'll find below can be run in a console without Tomcat. Only commons-fileupload-1.3.3-bin.tar.gz and commons-io-2.6-bin.tar.gz are needed.
To view what's parsed by the MultipartStream, I temporarily replaced bos by System.out in the readBodyData() call (as told in the comments).

*

*To compile:
javac Test.java -classpath ./commons-fileupload-1.3.3-bin/commons-fileupload-1.3.3.jar

*To run:
java -classpath ./commons-fileupload-1.3.3-bin/commons-fileupload-1.3.3.jar:./commons-io-2.6/commons-io-2.6.jar:. Test

The code itself
import java.util.regex.*;
import java.io.*;
import org.apache.commons.fileupload.*;

public class Test {
    public final static void main(String[] argv) {
    String byteString=
        "-----------------------------149742642616556\r\n" +
        "Content-Disposition: form-data; name=\"file\"; filename=\"test.txt\"\r\n" +
        "Content-Type: text/plain; charset=UTF-8\r\n" +
        "\r\n" +
        "test\r\n" + // <-- only \n here lead to a MalformedStreamException
        "-----------------------------149742642616556--\r\n";

    String regexp="(?m)\\A--(-*\\d+)$"; // edited regexp to catch the right boundary

    Pattern pattern = Pattern.compile(regexp);
    Matcher matcher = pattern.matcher(byteString);
    String boundary = null;
    String contentType=null;
    while (matcher.find()) {
        boundary = matcher.group(1);
        contentType = "multipart/form-data; boundary=\"" + boundary + "\"";
    }

    System.out.println("boundary = \"" + boundary + "\"");

    @SuppressWarnings("deprecation")
        org.apache.commons.fileupload.MultipartStream multipartStream =
        new org.apache.commons.fileupload.MultipartStream
        (new ByteArrayInputStream(byteString.getBytes()), boundary.getBytes());
     ByteArrayOutputStream bos = new ByteArrayOutputStream();

    try {
        // Use the commented line instead the following one
        // To see what the multipartStream is reading (for debug)
        // multipartStream.readBodyData(System.out);
        multipartStream.readBodyData(bos);
    } catch (MultipartStream.MalformedStreamException e) {
        System.out.println("Malformed Exception " + e.getMessage());
    } catch (IOException e) {
        System.out.println(e.getMessage());
    }
    byte[] byteBody = bos.toByteArray();

    // Displaying the body read
    for(byte c : byteBody) {
        System.out.format("%c", c);
    }
    System.out.println();
    }
}

Output:
boundary = "---------------------------149742642616556"
-----------------------------149742642616556
Content-Disposition: form-data; name="file"; filename="test.txt"
Content-Type: text/plain; charset=UTF-8

test

A: After some debugging, I found that MultipartStream is adding \r\n-- as a prefix to the boundary, because I didn't have a newline at the beginning of the content I got the MultipartStream.MalformedStreamException("Stream ended unexpectedly") exception because the boundary couldn't be found.
Maybe it's because of an older commons-fileupload version or because I was reading the multipart content from an HTTP PUT request sent by curl
tl;dr
add a newline at the beginning of your content if nothing else helped so far.


text:
Q: Parallel writes/reads in a single nio selector I am working on java.nio which mentions that nio is non blocking io as it is mentioned in the below example.
int noOfKeys = selector.select();
System.out.println("Number of selected keys: " + noOfKeys);
Set selectedKeys = selector.selectedKeys();
Iterator iter = selectedKeys.iterator();

while (iter.hasNext()) {
    SelectionKey ky = iter.next();
    if (ky.isAcceptable()) {
        // Accept the new client connection
        SocketChannel client = serverSocket.accept();
        client.configureBlocking(false);
        // Add the new connection to the selector
        client.register(selector, SelectionKey.OP_READ);
        System.out.println("Accepted new connection from client: " + client);
    }
    else if (ky.isReadable()) {
        // Read the data from client

Everywhere i am seeing an loop which checks for readable keys and writable keys condition and continue with non blocking write/read. Is is possible to process two writes/reads simultaneously in a loop with as single selector? Any help or pointers are really helpful. Also For a socket connection first it should accept the connection then it should perform write or read. How come it is non blocking io? Is this sequential right?

A: Non-blocking I/O is not the same parallel I/O.  What non-blocking I/O allows is I/O without blocking the calling thread.  Normally, the thread would wait on the system call to complete, which prevents the calling thread from doing any other work.  With non-blocking I/O, if the operation would block, it's deferred to allow the calling thread to do other work (e.g. other reads/writes/accepts).
You can use actual separate threads for I/O and do more than one I/O operation simultaneously, but typically there are more clients performing I/O than there are CPUs.  As the number of threads for each I/O set increases above the number of CPUs, they start contending for time on a CPU, which the operating system has to schedule.  So, each I/O operation starts to imply a context switch, which is expensive.  This additional cost, as well as other various costs, are the reason why parallel I/O generally doesn't perform well or scale.
Still, non-blocking I/O can conceptually be thought of as asynchronous or parallel since an operation that would normally block doesn't, and allows another I/O operation to run instead.  So, the actual operations overlap.  However, since they run in the same thread, it avoids that context switch costs and other various costs for parallel I/O.
In reality it is sequential though, and time spent executing application code on response to I/O does add to latency.  Generally that amount of time is less than a context switch though, which means non-blocking I/O normally performs and scales vastly better than parallel I/O.
With Java non-blocking I/O, you use the selector to do the multiplexing.  So, selector.select() retrieves all the clients that are ready to do I/O without blocking.  This is why you register the client's channel with the selector.  You're telling the selector that you want to know when it's ready to do I/O without blocking.
Also, just a note but NIO only stands for New I/O.  Non-blocking I/O is only a subset.
The Wikipedia descriptions aren't that good, but they might help...

*

*Non-blocking I/O

*Java Non-blocking I/O


text:
Q: Regexp for match log4net log file I try match to named groups in log(log4net) file. Regexp work good for all groups, but on exception group i have only first line(paragraph).
How to math full exeption if it exists?
Regexp:
^(?P<time_local>[\d\-\s\:\,\.]+)\s(?P<level>[\w]*)\s(?P<logger>[^\s]*)\s\[(?P<line>[\d]*)\]\s\-\sMESSAGE\:\s(?P<message>.*)(?P<exeption>.*)
Log example:
     2020-11-28 20:03:18,462  INFO Microsoft.AspNetCore.Routing.EndpointMiddleware.LogMessage [0] - MESSAGE: Executed endpoint 'mReqProxy.Controllers.UProxyController.proxy2 (mReqProxy)' (null)
 2020-11-28 20:03:18,472 ERROR Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.LogMessage [0] - MESSAGE: An unhandled exception has occurred while executing the request. (null)
 System.NullReferenceException: Object reference not set to an instance of an object.
   at mReqProxy.Models.proxy.SendRequest(proxy2 rawrequest) in D:\All\VC\mReqProxy\Models\proxy2.cs:line 54
   at mReqProxy.Controllers.UProxyController.proxy2(proxy2 indata) in D:\All\VC\mReqProxy\Controllers\UProxyController.cs:line 29
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
2020-11-28 20:03:18,487 DEBUG Microsoft.AspNetCore.Server.Kestrel.LogMessage [0] - MESSAGE: Connection id "0HM4JNTVF8F90" completed keep alive response. (null)
 2020-11-28 20:03:18,497  INFO Microsoft.AspNetCore.Hosting.Diagnostics.LogMessage [0] - MESSAGE: Request finished in 225.906ms 500 text/plain (null)
 2020-11-28 20:03:22,782  INFO Microsoft.AspNetCore.Hosting.Diagnostics.LogMessage [0] - MESSAGE: Request starting HTTP/1.1 POST https://10.47.6.200:8100/api/uproxy/proxy2 application/json 496 (null)

A: You could make the pattern a bit more specific, and optionally match the exception.
In your pattern you use .* and * for fields that seem to be present in all the lines. You can use + to match them at least a single time.
For the (?P<exeption> group you can match all following lines that do not start with a date like pattern, or in this example 4 digits - and a digit for a short check if that will also be ok.
Note that you don't have to escape \:\,\. in the character class and the \- by itself.
^(?P<time_local>\s*\d{4}-\d{2}[\d\s:,.-]+)\s(?P<level>[A-Z]+)\s(?P<logger>\S+)\s\[(?P<line>\d+)\]\s\-\sMESSAGE:\s(?P<message>\S.*)(?P<exeption>(?:\r?\n(?!\s*\d{4}-\d).*)*)

Regex demo