text:
Q: What unit does the docker run "--memory" option expect? I'd like to constrain the memory of a Docker container to 1 GB. According to the documentation, we can specify the desired memory limit using the --memory option:
$ docker run --memory <size> ...

However, the documentation does not describe the format or units for the argument anywhere on the page:

--memory , -m           Memory limit

What units should I supply to --memory and other related options like --memory-reservation and --memory-swap? Just bytes?

A: Taken from the docker documentation:

Limit a container's access to memory Docker can enforce hard memory
  limits, which allow the container to use no more than a given amount
  of user or system memory, or soft limits, which allow the container to
  use as much memory as it needs unless certain conditions are met, such
  as when the kernel detects low memory or contention on the host
  machine. Some of these options have different effects when used alone
  or when more than one option is set.
Most of these options take a positive integer, followed by a suffix of
  b, k, m, g, to indicate bytes, kilobytes, megabytes, or gigabytes.

This page also includes some extra information about memory limits when running docker on Windows.

A: Classic case of RTFM on my part. The --memory option supports a unit suffix so we don't need to calculate the exact byte number:

 -m, --memory=""
      Memory limit (format: <number>[<unit>], where unit = b, k, m or g)

   Allows you to constrain the memory available to a container. If the
   host supports swap memory, then the -m memory setting can be larger
   than physical RAM. If a limit of 0 is specified (not using -m), the
   container's memory is not limited. The actual limit may be rounded up
   to a multiple of the operating system's page size (the value would be
   very large, that's millions of trillions).

So, to start a container with a 1 GB memory limit as described in the question, both of these commands will work:
$ docker run --memory 1g ...
$ docker run --memory 1073741824 ...

The --memory-reservation and --memory-swap options also support this convention.

A: docker run -m 50m <imageId> <command...>

This is how it should be given. This forces the docker container to use 50m of memory. As soon as it tries to use more than that, it will be shut down.
However using free -m you won't be able to see anything related to the container memory usage. you have to go inside it to see allowed memory.


text:
Q: Footer comes up if in a separate column in css This is how it is:

.technology {
  width: 100%;
}

.technology-left {
  width: 15%;
  height: 100%;
  padding-bottom: 8000px;
  margin-bottom: -8000px;
  overflow: hidden;
}

.technology-right {
  width: 85%;
}

    VERY LONG ACCORDION MENU

      CONTENT

      FOOTER

Now if there is no content or very less content in class content or if any main link in my accordion has quite a number of sub-links and when it opens, then footer comes up showing white space below footer.
How can I solve this by keeping the footer at the base, not fixed?
Also one more small thing (not mentioned in the heading though), when I see in Safari that technology-left thing just keeps scrolling down, I assume it does not take -8000px or overflow?
Here is an illustration of the problem:
Screen Shot

A: I think the easiest solution is to go with flex. And in order to make footer at the bottom simply use margin-top:auto.

* {
 box-sizing:border-box;
}
body {
  height: 100vh;
  margin: 0;
}

.technology {
  display: flex;
  height: 100%;
}

.technology-left {
  width: 15%;
  height: 100%;
  border: 1px solid;
}

.technology-right {
  flex: 1;
  border: 1px solid;
  display: flex;
  flex-direction: column;
}

.footer {
  margin-top: auto;
  border: 1px solid red;
}

    VERY LONG ACCORDION MENU

      CONTENT

      FOOTER

A: For your layout I'd use flexbox *:

body {
  margin: 0;
}

.technology {
  width: 100%;
  display: flex;
  min-height: 100vh;
}

.technology>div {
  display: flex;
  flex-direction: column;
}

.technology-left {
  background-color: #f3f3f3;
  flex: 0 0 15%;
}

.technology>div, .technology-right>div {
  padding: .5rem;
}

.technology .technology-right {
  flex: 1 0 auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.footer {
  padding: .5rem;
  background-color: #424242;
  color: white;
}

    VERY LONG ACCORDION MENU

      CONTENT

      FOOTER

* Don't forget to prefix.

A: As I understand you want to achieve full height layout where footer always stays at the bottom and left right portion should be scrollable when overflow. I don't feel any need for that long margin and padding, you can have your layout without that. here i have updated your code

.technology {
  width: 100%;
}

.technology-left {
  width: 15%;
  height: 100vh;
  overflow: auto;
  float:left;
  background: #eee;
}

.technology-right {
  width: 85%;
  float:left;
  height:100vh;
}
.footer{
  height:50px;
  background: #ddd;
}
.content {
  height:calc(100vh - 50px);
}

    VERY LONG ACCORDION MENU

      CONTENT

      FOOTER

this way your footer always stays at the bottom and technology-left is scrollable when overflown.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Does Google Cloud ML only support distributed Tensorflow for Multiple GPU training jobs? I'd like to run a Tensorflow application using multiple GPU's on Cloud ML.
My Tensorflow application is written in the non-distributed paradigm, that is outlined here
From what I understand if I want to use Cloud ML to run this same application, with multiple GPU's then the application must use scale tier CUSTOM and I need to set up parameter servers, worker servers which seem to be a distributed-tensorflow paradigm. Link here
Is this the only way to run multiple GPU training jobs on Cloud ML?
Is there a guide that helps me scope the changes required for my multiGPU (tower based) training application to a distributed tensorflow application?

A: You can use CUSTOM tier with only a single master node, and no workers/parameter servers. Those are optional parameters.
Then complex_model_m_gpu has 4 GPUs, and complex_model_l_gpu has 8.


text:
Q: What happened to more that 110 thousand of closed votes? Few days ago there were more than 120 thousand of Closed Votes in the review section. Today when I checked this section there is only 8 thousand there.
What happened to this votes (I highly doubt that they were reviewed in a few days)? Is it some new change in review process, site design or were they really reviewed?


text:
Q: Where did the "three fingered salute" come from? Where did the phrase "three-fingered salute", meaning to press CTRL-ALT-DELETE on the keyboard, come from?
As the "two-fingered salute" appears to be a mainly British gesture, I suspect the three-fingered variety is British too. But suspicion isn't evidence.

A: Esteemed writer Charles Petzold used the term in a PC Magazine article back in 1986. He suspects he was the first, and I suspect he's right.

A: In the IT world, there are a number of amusing jargon terms for commonly-performed routines.  In this case, the 'salute' is (likely; I have no canonical reference for this, as the Jargon File merely calls it a synonym for the Vulcan Nerve Pinch) intended ironically as a mark of (dis)respect towards Mr. Gates' most well-known products.
The earliest reference I've been able to locate comes from an FAQ from 1994, where the familiarity with the term indicates that it's been in common use for some time.  I suspect that if I had access to usenet archives that the initial usage would be found sometime earlier, probably in the comp.sci newsgroups.
This bit of jargon has held up rather well, as it's still very much in common use today amongst IT professionals; the usage as an authentication prerequisite in windows-environment systems (which I've thought to be a spectacular joke, personally) has only rendered the use of the term more common.

A: To me, that's a euphemism for "flipping someone off". The adaptation to Ctrl-Alt-Del would seem to echo the feelings one may have when having to recover from a hung application. I imagine that this connection may have weakened after Win2k gave Ctrl-Alt-Del a broader application.


text:
Q: Use the comparison test to find whether $\int_0^\infty 1/(x^2+1)^2\,dx$ converges or not I was thinking what function I should compare it to. If I say whether a function is smaller or bigger than this one, then I must prove that. I was thinking of (x+1)^2 but I realized that this converges so that won't prove the integral diverges. So, what function should I use?

A: Hint: we have $(x^2+1)^2\geq (x^2+1)$ so
$$
\int_0^\infty \frac{1}{(1+x^2)^2}\ \text{d}x \leq \int_0^\infty \frac{1}{(1+x^2)}\ \text{d}x
$$
This last integral is a well-known one.

A: Actually, the function you proposed, $ \ \frac{1}{(x+1)^2} \ $ will work, since it is larger than the  integrand $ \ \frac{1}{(x^2+1)^2} \ $ over $ \ ( 1, \ \infty) \ $ and the region bounded by the two functions over $ \ [0, \ 1 ] \ $ is finite.  (You will need to demonstrate both of these statements are true.)  So the given improper integral is convergent.
Brian M. Scott in his comment proposed this fix for the function I was originally going to suggest.  We can show that $ \ \frac{1}{(x^2 + 1)^2} \ $ is smaller than the piecewise-defined function $ \ f(x) \ = \ 1 \ \ \text{for}    \ \ 0 \ \le \ x \ \le \ 1 \ $ , $ \ \frac{1}{x^4} \ \ \text{for} \ \ x \ > \ 1 \ $ .  The integral for $ \ f(x) \ $ is certainly convergent over $ \ [ 0, \ \infty) \ $ (the section over $ \ [ 1, \ \infty) \ $ by " $ \ p-$ test " ).

A: Split the integral into
$\int_0^1 + \int_1^{\infty}
$.
For the first integral,
the function is less than 1,
so the integral is also
less than 1.
For the second integral,
the function is less than
$1/x^2$,
and the integral of this
from 1 to $\infty$
is 1.


text:
Q: Footer Tab Sliding DIV Anyone know a good tutorial or technique on how to achieve the bottom footer tab as found on the below site?  The "More Resources" tab
http://www.washington.edu/maps/

A: The technique is quite easy - There's a div with absolute positioning, with the bottom position set to the negative value of the footer contents height (-188px in their case). When the button is clicked, it animates the bottom of that element to 0. Looks like they've also put a nice easing effect on it too.
You'll be interested in http://api.jquery.com/animate/ and http://gsgd.co.uk/sandbox/jquery/easing/
Also, I googled 'jQuery sliding footer' and the first result looks good ( http://return-true.com/2010/04/jquery-pop-up-footer-version-2/ ). I know it's annoying when people tell you to Google stuff, but seriously, it works :p

A: Here is a simple demo for you with some JavaScript/CSS/HTML (I made a jsfiddle for a demo: http://jsfiddle.net/Xbak7/2/):
HTML --

    Why Hello There
    I wasn't expecting you...

CSS --
#bottom_div {
    position: fixed;
    bottom: -35px;
    height: 55px;
    width: 200px;
    left: 50%;
    margin-left: -100px;
    background-color: #ccc;
    text-align: center;
}
#hidden_span {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 200px;
    margin-left: -100px;
}

JavaScript --
$(document).ready(function () {
    $('#bottom_div').bind('mouseenter', function () {
        $(this).stop().animate({bottom: 0}, 750, 'easeInExpo');
    }).bind('mouseleave', function () {
        $(this).stop().animate({bottom: '-35px'}, 750, 'easeOutBounce');
    });
});

Some Notes:

*

*jQuery animate (http://api.jquery.com/animate/) can be given an easing parameter which can be set to make the animation bounce like the one in your example website. Here is where you get the easing plugin with lots of easing types: http://gsgd.co.uk/sandbox/jquery/easing/

*The left and margin-left assignments in CSS are to center the divs.

*The .stop() function stops the animation if another animation is called. Effectively making the animation appear smooth is you mouse over and mouse out the div several times very quickly. If you don't set .stop() this mouse over/out'ing very quickly will lead to many animations playing in order and the div won't stop moving for a long time.


text:
Q: Should we answer the question being asked, or be as helpful as possible? So I was reading this question and there are two answers there that I like

*

*jlordo's answer succinctly and clearly answers the question that is being asked

*RobHruska's answer doesn't exactly answer the question that is being asked, but, rather, answers the real question that a new programmer would be asking if they knew how to ask it
So I guess what I'm saying is, is it preferable in the StackExchange paradigm to answer what the question asker is saying exactly or to be as helpful as possible, to teach what the questioner really needs to learn.

A: It is preferable to help the question asker as best you can.
If that means reading between the lines and suggesting a different approach, then please do so! If you can address both the original question and teach the asker about better methods, so much the better. You have helped the question asker just that little bit more.
In your specific example, the answer that addressed what you call the real question, was awarded the 'helpful answer' flag; the question asker felt that answer helped him most. And that's the whole point of Stack Overflow.

A: Being helpful is good, but remember that the purpose is to make a resource for future visitors as well, not just to help the asker.
Even if there may be a much better solution for the asker's specific problem, there may be future visitors who are looking for exactly what was requested. (Or, more annoyingly, future questions may be closed as a duplicate of the question that was literally asked, even if the answers aren't applicable because nobody answered the literal question.) For their sake, we should try to make sure that there is at least one answer that addresses the question that was asked.
If somebody else has already posted such an answer, then you can just post an alternative. If not, then even if you're suggesting an alternative you should try to also address the literal question in your answer.


text:
Q: Sending API request through on public ip only We are working on a third party api integration.
Due to security reasons the API hosting company has asked us to give one public ip to whitelist and all the requests will be allowed through this IP only.
But our users are sitting in remote locations with VPN connection so I don't know how to send the request from one public ip which is available at Head office only.
I have read one thread to achieve this through proxy server on Linux platform. I would really appreciate if someone can provide me steps to do the same in windows platform as I m completely new to proxies and Linux is not available with us at all.
Thanks in advance for your help

A: I think what you can do is to build a service API on top of this 3rd Party API and let your users connect to your Service API instead.
Then you can provide the public IP of your service API to 3rd party to white list and also if in the future they implement extra security feature such as different types of token you need to change in only one place.
However, with this approach, you are responsible for the security of your service API.


text:
Q: jquery ui dialog, having multiple dialogs affects position As I am making multiple dialogs, I am faced with difficulties. Here is my code:
var dialog_count = 3;

$(function() {

    var left_value = 0;
    var top_value = 0;
    for(var i = 1; i < dialog_count+1; i++) {
        $('.dialog_' + i).dialog({ width: 263, position: [800 - left_value, 800 - top_value] });
        left_value = left_value + 40;
        top_value = top_value + 140;
    }
});

what it should do: neatly stack each dialog on given position
what it does: somehow re-positions each dialog as new ones gets added.
I tried playing around with it, here's what I did, in 3 steps
$('.dialog_1').dialog({ width: 263, position: [300, 700] });

this is correctly positioned, now i am going to add 2nd one.
$('.dialog_1').dialog({ width: 263, position: [300, 700] });
$('.dialog_2').dialog({ width: 263, position: [250, 550] });

da heck? it moved the other one by itself... now both of them are not correctly positioned.
$('.dialog_1').dialog({ width: 263, position: [300, 700] });
$('.dialog_2').dialog({ width: 263, position: [250, 550] });
$('.dialog_3').dialog({ width: 263, position: [200, 400] });

alright, now things look funky. you really have to try it yourself to understand what I am talking about... ;(
thank you advance!

A: Running the sample code, I'm not seeing the original one move. I do notice they don't stack correctly, but I think that's because you're adding 140 to one and 40 to the other. That may have been a typo though.
top_value = top_value + 140; // Try + 40 instead

A: After disabling autoOpen, and having to set positions through options, and calling open method, successfully has worked.
Turns out, the autoOpen feature doesn't let dialogs to be positioned exactly on top of each other, so it moves them around accordingly.
var dialog_count = 3;

$(function() {

    var left_value = 0;
    var top_value = 0;
    for(var i = 1; i < dialog_count+1; i++) {
        $('.dialog_' + i).dialog({ width: 263, position: [500, 500], autoOpen: false });
    }
    for(var i = 1; i < dialog_count+1; i++) {
        $('.dialog_' + i).dialog("option", "position", [500,500]);
        $('.dialog_' + i).dialog("open");
    }
});


text:
Q: A method inside a class that calls another method I need help with the below code. I want to use the get_skies, get_high, and get_low method to call the set_skies, set_high, and set_low methods, respectively, and then return the value for init_skies, init_high, and init_low, respectively.
This is what I have got so far:
class WeatherForecast():
  def set_skies(self, init_skies):
     return init_skies

  def set_high(self, init_high):
     return init_high

  def set_low(self, init_low):
     return init_low

  def get_skies(self):
    self.set_skies()

  def get_high(self):
    self.set_high()

  def get_low(self):
    self.set_low()

A: In python attributes of class are publically accessible.
You don't need to use getter or setters for attributes unless you want to perform some kind of preprocessing or mutation of the attribute
In your case, you can try this,
class WeatherForecast():
    def __init__(self, init_skies, init_low, init_high):
        self._init_skies = init_skies
        self._init_low = init_low
        self._init_high = init_high

    @property
    def skies(self):
        return self._init_skies

    @property
    def high(self):
        return self._init_high

    @property
    def low(self):
        return self._init_low

    @skies.setter
    def skies(self, value):
        self._init_skies = value

    @high.setter
    def high(self, value):
        self._init_high = value

    @low.setter
    def low(self, value):
        self._init_low = value

w = WeatherForecast(1, 2, 3)
print(w.skies, w.low, w.high) # --> print the values

# Set the values
w.skies = 10
w.low = 20
w.high = 30

print(w.skies, w.low, w.high) # -->  print the updated values


text:
Q: Regex Match End of Line Unless it Ends with a Closed Bracket I'm trying to write a JavaScript Regex that will grab the end of a line unless said line ends with a closing bracket, example:
[word]
lengthy text line

[other word]
even lengthier text line! Whoo!

That part I have down pat writing up this Regex new RegExp(/[\n]\n|(?![^\]])$/gm)
But I also need to be able to grab the end of the line even where there isn't a double space, and that is proving to be SUPER difficult since I don't really know a ton about Regex.
                                        --   [word]
These two lines need to be grouped      --   lengthy text line

                                        --   [other word]
These two lines need to be grouped      --   even lengthier text line! Whoo!
This needs to be it's own group         --   This text line is the longest of them all!
                                        --   [more words]
These two lines need to be grouped      --   The last guy can win...

What's annoying is that there is a very simple Regex that accomplishes this goal, but it's not currently supported in FireFox, and that's a problem. (?<!])\n Negative Look Behind Assertion
EDIT: The method used for the information is splitting, it splits the value placed into a textarea and matches it to array[i].match(/^\[(.*?)\]\n/).  It'd look something like this:
var regex = new RegExp(/[\n]\n|(?![^\]])$/gm);
var array = $('#textar').val().split(regex);

for (var i = 0; i < array.length; i++) {
    var match = array[i].match(/^\[(.*?)\]\n/)
}

but with a lot more code taking those variables and using them.
SOLUTION:
Wiktor Stribiżew had the solution. Changing .split(regex) to .match(regex) and adding their regex fixed the problem
var regex = new RegExp(/^.*[^\]\n](?:\]\n.*[^\]\n])*$/gm);
var array = $('#textar').val().match(regex);

for (var i = 0; i < array.length; i++) {
    var match = array[i].match(/^\[(.*?)\]\n/)
}

A: You may use String#match:
text.match(/^.*[^\]\n](?:\]\n.*[^\]\n])*$/gm)

Regex details

*

*^  - start of a line

*.*[^\]\n] - 0 or more chars other than line break chars, as many as possible and then a char other than a newline and ]

*(?:\]\n.*[^\]\n])* - 0 or more repetitions of

*

*\]\n - ] and a newline, LF, char

*.*[^\]\n] - 0 or more chars other than line break chars, as many as possible and then a char other than a newline and ]

*$  - end of a line.

See the JS demo:

var text = "[word]\nlengthy text line\n\n[other word]\neven lengthier text line! Whoo!\nThis text is the longest of them all!\n[more words]\nThe last gyu can win...";
console.log(text.match(/^.*[^\]\n](?:\]\n.*[^\]\n])*$/gm));

A: You are looking for a regex like this:
/^\[.+(\n+[^\[]+)/gm

*

*^ at the begining of the string,

*look for [

*.+ followed by any character

*(\n+[^\[]+) an enter any number of times or any character as long as it is not [
Demo: https://regex101.com/r/c1giqu/3
For your convenience, the full match keeps the text between brackets. The first group includes only the text without the brackets.


text:
Q: Distance and open sets in a metric I am hoping to prove the following:

$A \subset X$ is such that if for any $x ∈ X$ and $\epsilon > 0$
  there exists $y ∈ A$ such that $d(x, y) < \epsilon$
is equivalent to saying for any $B \subset X, B$ nonempty and open,
  then $B \cap A$ is nonempty.

I have proved the reverse, but having some trouble with this direction. I think I need to use open balls and show that their intersection contains a point, but I'm confused by the specifics.

A: Suppose $B$ is open and non empty, choose $x \in B$ then $B(x,\epsilon) \subset B$ for some $\epsilon>0$ since $B$ is open. By hypothesis, there is some
$y \in A $ such that $d(y,x) < \epsilon$ and hence $y \in B$. So $A \cap B $ is non empty.


text:
Q: Fix moving files into year folder if exist a matching in .txt file I have files like this
Taxi driver.torrent
Tabu - Gohatto.txt
Troll 2 (1990)..zip

Inside my filelist.txt file I have files named like so
Troll 2 (1990) [BDrip 1080p - H264 - Ita Ac3] Horror, Commedia
Troll 2 (1990) [XviD - Ita Mp3]
Taxi Driver (1976) Mastered..
Tabù - Gohatto (N. Oshima, 1999)

I have just folders like
1976
1990
1999

I want to move files into correct year folder in this way
1976
  |__ Taxi driver.torrent

1990
  |__ Troll 2 (1990)..zip

1999
  |__ Tabu - Gohatto.txt

I use this path, folders
C:\Path
Test4.txt
script_powershell.ps1

I actually test with powershell 5 to move
$movies = @()
(get-content C:\Path\Test4.txt) | foreach($_){
$properties = @{
date = $_.substring($_.IndexOf("(")+1,4)
name = $_.substring(0,$_.IndexOf("("))
}
write-host $date
write-host $name

$movies += New-Object PSObject -Property $properties
}

$torrentFiles = dir $torrentPath

foreach($movie in $movies){
$datePath = "C:\Path\$($movie.date)"
if(-not(test-path $datePath)) {
new-item $datePath -ItemType "directory"
}
$words = ($movie.name -split '\s') | ?{ $_.Length -gt 1}
$significant = $words.Count
 foreach($torrentFile in $torrentFiles){
 $matchingWords = 0
  foreach($word in $words){
   if($torrentFile.BaseName -match $word){
    $matchingWords += 1
   }
  }
  if($matchingWords -ge $significant){
  Move-Item -path $torrentfile -Destination $datePath
 }
 }
}

EDIT:
This poweshell has many problems. For examples
Caccia al delitto

is moved in 1990 folder...but..Caccia al delitto is 1986..
Inside file text I have
Caccia a Ottobre Rosso (1990) [DivX - Ita Mp3] Guerra [CURA] Russia
Caccia a Ottobre Rosso (1990) [VP9 - Ita Eng Opus] Thriller

I have not a text string for Caccia al delitto (I remove it for test)

A: $movies = @()
$movieLocation = 'C:\Path'
$torrentPath = '.'

(get-content "$movieLocation\Test4.txt") | foreach($_) {

 # Check for braces.
 if (-not($_ -match ".*\(.*\).*")) {return}

 $properties = @{
  date = ($_ -replace ".+?\(.*?(\d{4}).*?\).*", '$1')
  name = $_.substring(0, $_.IndexOf("(")).Trim()
 }

 # Add items that have a 4 digit date.
 if ($properties.date -match "^\d{4}$") {
  'Name: "' + $properties.name + '" Date: "' + $properties.date + '"'

  $movies += New-Object PSObject -Property $properties
 }
}

$torrentFiles = dir $torrentPath

foreach ($movie in $movies) {
 $datePath = "$movieLocation\$($movie.date)"

 if (-not(test-path "$datePath")) {
  new-item "$datePath" -ItemType "directory"
 }

 foreach ($torrentFile in $torrentFiles) {
  # Get percentage based on length.
  $pc = [int]($movie.name.length / $torrentFile.basename.length * 100)

  # Only between 80% and 100% in length.
  if ($pc -gt 100) {continue}
  if ($pc -lt 80) {continue}

  if ($torrentFile.basename -match $movie.name) {
   # Items that match.
   'Torrent: {0,-40} Date: {1,-5} Match: {2}' -f $torrentFile.basename, $movie.date, $movie.name

   if (-not(test-path "$datePath\$torrentfile")) {
    Move-Item -LiteralPath "$torrentPath\$torrentfile" -Destination "$datePath"
   }
  }
 }
}

A modest fix with the date using regex.
The name required a trim to remove trailing space.
I added a test-path before move-item in case the file is not found.
Long time since last used Powershell so could be perhaps improved more.
I tested in path . so hope C:\Path works just as well.


text:
Q: PHP Curl/file_get_contents inconsistent response time in Chrome I'm on Windows 7 (using a VirtualBox VM) to do some development. I have PHP/5.5.13, Apache 2.4.9, Chrome 35.0.1916.153. I'm seeing some very inconsistent behavior when I run the following code :
index2.php
<?php
echo "Load time before 'file_get_contents': ".(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'])."
\r\n";
echo file_get_contents('http://custom.local/index3.php');
echo "Load time after 'file_get_contents': ".(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'])."
\r\n";
exit;
?>

index3.php
<?php
echo "Load time inside 'index3.php': ".(microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'])."
\r\n";
exit;
?>

Here is the results in Chrome (I get consistent response time between 8 and 28 seconds after curl_exec). Response time fluctuates a lot as well:
Load time before 'file_get_contents': 0.002000093460083
Load time inside 'index3.php': 0.0026569366455078
Load time after 'file_get_contents': 15.411452054977

A: It seems that after all it was an Apache issue.
Chrome's advanced options "Predict network actions to improve page load performance" would use more threads than provisioned by the default Apache config (Windows 2.4.9 Windows build).
The fix is simple in httpd.conf :
AcceptFilter http none
More details here:
http://www.apachelounge.com/viewtopic.php?p=28142#28142


text:
Q: Jquery Complex wrap around uncontained group of items I'm trying to take group of headers and lists, and contain them individually so I can style them. ie:

Title 1

Item 1

Item 2

Item 3

Title 2

Item 1

Item 2

Item 3

I attempted this by using .before() and .after to add a div before the h2 tag, and close it after each ul however I found out that jquery cleans and closes the tag automatically. So I'm guessing I need to use wrap() just not sure how to group the title and list together.

A: Use
$('h2').each(function(){
   var self = $(this);
   self.add( self.next() ).wrapAll('
');
});

demo at http://jsfiddle.net/gaby/e4f9h/

A: You want to create a jQuery collection that contains both elements. For this you would select the h2 elements. You than would need to find the next() element that is a ul. After you get both of them linked, you would wrapAll() with your containing div.
$("h2").each( function(){
   var h2 = $(this);
   h2.add(h2.next("ul")).wrapAll('

');
});

jsFiddle


text:
Q: Why is this numba code to store and process pointcloud data slower than the pure Python version? I need to store some data structure like that:
{'x1,y1,z1': [[p11_x,p11_y,p11_z], [p12_x,p12_y,p12_z], ..., [p1n_x,p1n_y,p1n_z]],
 'x2,y2,z2': [[p21_x,p21_y,p21_z], [p22_x,p22_y,p22_z], ..., [p2n_x,p2n_y,p2n_z]],
 ...
 'xn,yn,zn': [[pn1_x,pn1_y,pn1_z], [pn2_x,pn2_y,pn2_z], ..., [pnm_x,pnm_y,pnm_z]]}

Every key is a grid cell index and the value is a list of classified points. The list can be variable length but I can set it static, for example 1000 elements.
For now I tried something like this:
np.zeros(shape=(100,100,100,50,3))

But if I use numba.jit with that function the execution time is few times worse than with pure Python.
Simple Python example of what I want to do:
def split_into_grid_py(points: np.array):
    grid = {}
    for point in points:
        r_x = round(point[0])
        r_y = round(point[1])
        r_z = round(point[2])
        try:
            grid[(r_x, r_y, r_z)].append(point)
        except KeyError:
            grid[(r_x, r_y, r_z)] = [point]
    return grid

Is there any efficient way of doing that with numba?
Per 10 execution in loop times are like:

*

*numba: 7.050494909286499

*pure Python: 1.0014197826385498

With the same data set, so it's crap optimization.
My numba code:
@numba.jit(nopython=True)
def split_into_grid(points: np.array):
    grid = np.zeros(shape=(100,100,100,50,3))
    for point in points:
        r_x = round(point[0])
        r_y = round(point[1])
        r_z = round(point[2])
        i = 0
        for cell in grid[r_x][r_y][r_z]:
            if not np.sum(cell):
               grid[r_x][r_y][r_z][i] = point
               break
            i += 1
    return grid

A: The pure Python version append items in O(1) time thanks to the dictionary container while the Numba version use a O(n) array search (bounded by 50). Moreover, np.zeros(shape=(100,100,100,50,3)) allocate an array of about 1 GiB which resulting in many cache misses during the computation which will be done in RAM. Meanwhile, the pure Python version may fit in the CPU caches. There are two strategies to solve that.
The first strategy is to use 3 containers. An array keyGrid mapping each grid cell to an offset in a second array valueGrid or -1 if there is no point associated to this cell. valueGrid contains all the points for a given grid cell. Finally, countingGrid count the number of points per grid cell. Here is an untested example:
@numba.jit(nopython=True)
def split_into_grid(points: np.array):
    # Note: use np.uint16 if the actual number of filled grid cell is less than 65536
    keyGrid = np.full(shape=(100,100,100), -1, dtype=np.uint32)
    i = 0
    for point in points:
        r_x = round(point[0])
        r_y = round(point[1])
        r_z = round(point[2])
        if keyGrid[r_x,r_y,r_z] < 0:
            keyGrid[r_x,r_y,r_z] = i
            i += 1
    uniqueCloundPointCount = i
    # Note the number of points per grid cell is also bounded by the type
    countingGrid = np.zeros(uniqueCloundPointCount, dtype=np.uint8)
    valueGrid = np.full((uniqueCloundPointCount, 50, 3), -1, dtype=np.int32)
    for point in points:
        r_x = round(point[0])
        r_y = round(point[1])
        r_z = round(point[2])
        key = keyGrid[r_x,r_y,r_z]
        addingPos = countingGrid[key]
        valueGrid[key, addingPos] = point
        countingGrid[key] += 1
    return (keyGrid, valueGrid, countingGrid)

Note that the arrays are quite small as long as not all grid cells contains points resulting in less cache misses. Moreover the mapping of each point is done in (small) constant time resulting in a much faster code.
The second strategy is to use the same method than in the pure Python implementation, but with Numba types. Indeed, Numba experimentally supports dictionaries. You can replace the exception with a dictionary check ((r_x, r_y, r_z) in grid) which will cause less compilation issues and likely speed up resulting code. Note that Numba dict are often as fast as CPython ones (if not slower). So the resulting code may not be much much faster.


text:
Q: angular translate using useStaticFilesLoader to load nested json I have a nested json structure like this
    {
        "module1": {
            "component1": "text1",
            "component2": "text2"
        }
    }

So inside my code I am using {"module1.component1" | translate} which never get resolved whereas if I do
    {
        "component1": "text1",
        "component2": "text2"
    }

{"component1" | translate} works . Is there a way to resolve nested JSON data using useStaticFilesLoader
edit 1:
here is my useStaticFilesLoader config looks like :
$translateProvider.useStaticFilesLoader({
        prefix: './langfiles/',
        suffix: '.json'
      });
    $translate.use(lang);//lang is derived from header

langfiles contains :
  en_US.json etc

A: Check out this post: Accessing nested JSON objects and see if that helps. Their JSFiddle show how it can be done: http://jsfiddle.net/z1uLjg89/

// Including ngTranslate
angular.module("ngTranslate", ["ng"]).config(["$provide", function (n) {
    $TranslateProvider = function () {
        var n, t = {};
        this.translations = function (n, r) {
            if (!n && !r) return t;
            if (n && !r) {
                if (angular.isString(n)) return t[n];
                t = n
            } else t[n] = r
        }, this.uses = function (r) {
            if (!r) return n;
            if (!t[r]) throw Error("$translateProvider couldn't find translationTable for langKey: '" + r + "'");
            n = r
        }, this.$get = ["$interpolate", "$log", function (r, a) {
            return $translate = function (e, i) {
                var l = n ? t[n][e] : t[e];
                return l ? r(l)(i) : (a.warn("Translation for " + e + " doesn't exist"), e)
            }
        }]
    }, n.provider("$translate", $TranslateProvider)
}]), angular.module("ngTranslate").directive("translate", ["$filter", "$interpolate", function (n, t) {
    var r = n("translate");
    return {
        restrict: "A",
        scope: !0,
        link: function (n, a, e) {
            e.$observe("translate", function (r) {
                n.translationId = angular.equals(r, "") ? t(a.text())(n.$parent) : r
            }), e.$observe("values", function (t) {
                n.interpolateParams = t
            }), n.$watch("translationId + interpolateParams", function () {
                a.html(r(n.translationId, n.interpolateParams))
            })
        }
    }
}]), angular.module("ngTranslate").filter("translate", ["$parse", "$translate", function (n, t) {
    return function (r, a) {
        return angular.isObject(a) || (a = n(a)()), t(r, a)
    }
}]);

// Configuring your module, asking for ngTranslate as dependency
var app = angular.module('myApp', ['ngTranslate']);

// Configuring $translateProvider
app.config(['$translateProvider', function ($translateProvider) {

    // Simply register translation table as object hash
    $translateProvider.translations('en', {
        "SEARCH": {
            "SEARCH": "Recherce",
                "ABILITY": "Abilities",
                "MANAGEMENT": "Management Competencies",
                "PERSONAL": "Personal Suitability"
        },

            "ABILITIES": {
            "TITLE": "Test Title here",
                "ADVISORY": {
                "TITLE": "Advisory Skills",
                    "QUESTIONS": [{
                    "TYPE": "A",
                        "LEVEL": "45",
                        "DESCRIPTION": "Can you tell me how awesome you are"
                }, {
                    "TYPE": "B",
                        "LEVEL": "100",
                        "DESCRIPTION": "Tell me about your wicked project"
                }]
            }
        },

            "HEADLINE": "Oh No!",
            "SUB_HEADLINE": "Looks like you are not amazing"
    });

    var list = $translateProvider.translations('en');
    console.log(list);
    var getTitle = list.HEADLINE;
    var getSearch = list.SEARCH.ABILITY;
    console.log(getSearch);
    console.log(getTitle);
}]);

A possible work around is to flatten your json file.
Fastest way to flatten / un-flatten nested JSON objects or
Convert complex JavaScript object to dot notation object
This fiddle shows you how what it will look like: http://fiddle.jshell.net/blowsie/S2hsS/show/light/


text:
Q: How to put every three images in one div? I have a slideshow with jQuery Cycle Plugin from Malsup and I don't know php at all.
I want to have a dynamically generated slideshow on my website.
Here's the markup:

The problem is that image1 is static, while the other 5 images are fetched dynamically in php:
                      <?php foreach ($images as $image) { ?>
                      <a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>"><img src="<?php echo $image['thumb_tiny']; ?>" alt="<?php echo $heading_title; ?>"/>
                      <?php } ?>

How can I wrap every three images in one div with .slide class with help of php, so that the first slide contains one static image plus two dynamin ones, and the other slides (infinite number) contain the next three dynamically fetched imaged?
Thank you and hope my description is not hard to get :)

A: Use a for loop so you have an index and then just check if the modulo 3 of that index is 0 to do something every three images.
<?php
for ($i = 0; $i < count($images); $i++)
{
    if ($i % 3 == 0) { // Do something every 3 images }
    echo "

Since your first image is static, and this is the only special case, you can explicitly just check for that case and alter the values accordingly,
if ($i == 2) { // Force a div }
// You then need to offset the value for the modulo check,
if ($i > 2 && $i+2 % 3 == 0) { // Do something every 3 images after first 2 }

A: The modulo operator is really handy in this kind of situation:
if (!empty($images)) {
    echo '
';

    for ($i = 0; $i < count($images); $i++) {
        $image = $images[$i];

        // check if we need to start a new div
        if ($i > 0 && $i % 3 === 0) {
            echo '

';
        }

        echo '';
    }

    echo '
';
}

A:

<?
$n_images = 3;
$i = 0;
while ($i < count($images)) {
?>

<?
    if ($i == 0) {
?>

<?
    }
    for ($j = 0; $j < ($i > 0 ? $n_images : $n_images - 1); $j++) {
?>
        <a href="<? echo $images[$i + $j]['popup']?>" title="<? echo $heading_title?>"><img src="<? echo $images[$i + $j]['thumb_tiny']?>" alt="<? echo $heading_title?>" />
<?
    }
?>

<?
    $i += $n_images;
}
?>


text:
Q: On scroll ,capture the last text in the screen? I have a requirement where i need to display 1000 images which will take lot of time if i need to display all at once . So each time the user scrolls , i want to know the last element or first element in the viewport .Is that possible using jquery ?How can i achieve it .
Thanks in advance

A: Taken from this: Check if element is visible after scrolling
function isScrolledIntoView(elem)
{
    var docViewTop = $(window).scrollTop();
    var docViewBottom = docViewTop + $(window).height();

    var elemTop = $(elem).offset().top;
    var elemBottom = elemTop + $(elem).height();

    return ((elemBottom >= docViewTop) && (elemTop <= docViewBottom));
}

Now simply loop through your elements and test them each to see if they are visible and take the last one.
For a lot of elements this will be slow. I recommend doing some kind of sorting when the page loads and then doing a binary search instead.


text:
Q: Benefits of using Springs Transaction management vs using hibernate I've been trying to learn spring and hibernate, and I've used a lot of examples around the net to put together a nice application. However, I realized now that Spring supports transaction management. In my spring app I just simply made whatever calls I wanted to, directly to hibernate. Is there a reason/benefit as to why people would use Spring's transaction management/db stuff?

A: The real advantages are:

*

*Lightweight declarative syntax. Compare:
public void saveEmployee(Employee e) {
    Session s = sf.getCurrentSession();
    s.getTransaction().begin();
    s.save(e);
    s.getTransaction().commit();
}

and
@Transactional
public void saveEmployee(Employee e) {
    sf.getCurrentSession().save(e);
}

*Flexible transaction propagation. Imagine that now you need to execute this saveEmployee() method as a part of a complex transaction. With manual transaction management, you need to change the method since transaction management is hard-coded. With Spring, transaction propagation works smoothly:
@Transactional
public void hireEmployee(Employee e) {
    dao.saveEmployee(e);
    doOtherStuffInTheSameTransaction(e);
}

*Automatic rollback in the case of exceptions

A: The spring's reference doc mentions it very clear

The Spring Framework provides a
  consistent abstraction for transaction
  management that delivers the following
  benefits:

*

*Provides a consistent programming model across different transaction
  APIs such as JTA, JDBC, Hibernate,
  JPA, and JDO.

*Supports declarative transaction management.

*Provides a simpler API for programmatic transaction management
  than a number of complex transaction
  APIs such as JTA.

*Integrates very well with Spring's various data access abstractions.

Provides a consistent programming model across different transaction
 APIs such as JTA, JDBC, Hibernate,
 JPA, and JDO.
Let us say you are currently using hibernate api for transaction management and sometime down the road you would want to switch to JDO. This requires the change of transaction management code. If you use Spring then there is no change.
Supports declarative transaction management.
Similar to EJB
Provides a simpler API for programmatic transaction management
than a number of complex transactions
APIs such as JTA.
JTA and JDBC have different APIs for transaction management. Spring abstracts that out by providing a uniform API.


text: Q: Aurora mysql select to s3 hangs after completing I'm running a large extract to an s3 bucket from an AWS Aurora cluster that uses the 5.6.mysql_aurora.1.22.2 engine. The query returns ~4.5 million rows of about 30 characters each, so it's not ginormous, but pretty big. I'm running it from a terminal on my Macbook by connecting via the mysql command line client and feeding it the query. By monitoring the s3 bucket, I see that it finishes the extract in about 20 minutes, but the mysql command in my terminal window never completes. After a couple of hours it finally just times out. Do I need to configure timeouts differently? Is there a better way to kick this off than the CLI?


text:
Q: Google Colab API Is there a Google Colab API? I'm looking to accomplish things like:

*

*Create users

*Create notebooks

*Share notebooks with users

*Retrieve the contents of a notebook

A: Google Colab Notebooks are just like a normal file in Google Drive.
So, you can use Drive API to manage them just like any Drive files.
For example, you can share notebooks with Drive REST API as documented here
https://developers.google.com/drive/api/v3/manage-sharing

A: As pointed out in the other answer, Colab Notebooks are files on your Google Drive. Hence, sharing them or retrieving their contents can be done via the Google Drive API (from what I understand you can use the webContentLink to download it).
However, your first question is:
Where is the Google Colab API?
For anyone coming here from Google trying to find the official Google Colab API (because it's one of the top results when googling for now), here is the answer:
[As of summer 2020] Since this is merely a research project, there is no official API documentation and very limited documentation.
Official Documentation (very limited)

*

*Google Colab: Official FAQ

*The Google Colab: Official Feature Demo exemplifies most features. Use it to learn many of its capabilities.

The API in code
Beyond those resources, your best bet would be going to the Official Github Repository. Here are some highlights from the code:

*

*Github: google.colab

*Github: google.colab.drive

*Github: google.colab.drive.mount (used in quite a few snippets)

*Github: google.colab.files (provides download and upload utilities)

*Github: google.colab.snippets (add snippets to the snippets list programmatically; FYI: you can  find all snippets by going to Insert -> Snippets)

*Github: all packages
More Notes
The FAQ explains many important mechanics. Highlights include:

It's a Jupyter notebook environment that requires no setup to use.

Convinient!
I heartly recommend checking out the Official Feature Demo; it's how I found out that it even supports LaTeX and MathJax! (but then again that might not come as news to someone with experience in Jupyter)
Virtual Machine
The FAQ also mentions...

Code is executed in a virtual machine dedicated to your account. Virtual machines are recycled when idle for a while, and have a maximum lifetime enforced by the system.

That is why you can execute all kinds of the usual system calls (e.g. !pip install, open etc.) and it just works.
However that is also why when you come back the next day...

*

*drive.mount asks for your permission again

*you have to re-install all packages

*any newly created files are all gone (unless you put em in a drive-mounted folder)


text:
Q: Prove that the Euclidean Norm of any vector in $\mathbb{R}^2$ is the same for any orthonormal basis Consider the standard basis of $\mathbb{R}^2$, $W$, and another basis $V = \{(a_1,a_2),(b_1,b_2)\}$ (written in coordinates of $W$). Show that the euclidean norm of any vector $(x,y)$ is the same for both bases.
So far, I have the following:
Let $x,y \in \mathbb{R}^2.$ $\exists \alpha,\beta \in \mathbb{R}$ s.t. $x = \alpha a_1 + \beta b_1, y = \alpha a_2 + \beta b_2.$ Then we can solve for $\alpha$ an $\beta$ as follows:
\begin{align*}
x &= \alpha a_1 + \beta b_1 \Rightarrow \alpha = \frac{x - \beta b_1}{a_1} \\
y &= \alpha a_2 + \beta b_2 \Rightarrow  \alpha = \frac{y - \beta b_2}{a_2}  = \frac{x - \beta b_1}{a_1}\\
\Rightarrow \beta &= \frac{a_1y - a_2x }{a_1 b_2 - a_2 b_1}, \alpha = \frac{b_2 x - b_1 y}{a_1 b_2 - a_2 b_1}.
\end{align*}
From here we plug into our euclidean norm:
\begin{align*}
\sqrt{\alpha^2 + \beta^2} &= \sqrt{\left(  \frac{b_2 x - b_1 y}{a_1 b_2 - a_2 b_1}\right)^{2} + \left( \frac{a_1y - a_2x }{a_1 b_2 - a_2 b_1}  \right)^{2}} \\
&= \sqrt{\frac{b_{2}^{2} x^2 - 2 b_1 y b_2 x + b_{1}^{2} y^{2} + a_{1}^{2} y^2 -2 a_{2} x a_1 y + a_{2}^{2} x^2}{\left( a_1 b_2 - a_2 b_1\right)^2}} \\
&= \sqrt{\frac{(b_{2}^{2} + a_{2}^{2}) x^2 -2 (b_1b_2 + a_1a_2) xy + (b_{1}^{2} + a_{1}^{2}) y^2}{\left( a_1 b_2 - a_2 b_1\right)^2}}
\end{align*}
Unfortunately, I am stuck here. I know that I am meant to somehow use the properties of orthonormality (i.e. $ a_{1}^{2} + a_{2}^{2} = b_{1}^{2} + b_{2}^{2} = 1, a_1b_1 + a_2b_2 = 0$), and I am supposed to show that the above expression is equal to $\sqrt{x^2 + y^2}$, but I am not sure how to get to that point using the information I have.

A: Here is a less computational strategy. $\lVert \:\cdot\:\rVert$ is independent of choice of basis if and only if $\lVert\:\cdot \:\rVert^2$ is, so we may as well use that. Now, if $(e_1,e_2)$ is one orthonormal basis for $\Bbb{R}^2$ and $(f_1,f_2)$ is another, then the change of basis matrix $P$ is orthogonal so that $PP^T=I_2.$ If $f_1=ae_1+be_2$ and $f_2=ce_1+de_2$, and $v=m_1f_1+m_2f_2,$ then $Pv$ expresses $v$ in terms of $(e_1,e_2)$. So,
$$ \lVert v\rVert^2=\langle v,v\rangle=v^Tv=v^TP^TPv=\langle Pv,Pv\rangle=\lVert Pv\rVert^2.$$


text:
Q: How to monitor long running jobs in hadoop cluster ? How to monitor long running jobs in hadoop cluster ? which all possibilities are there for long running job? and how to overcome that?

A: You can monitor all the jobs that are running on a YARN cluster by tracking the job URL that you will get after submitting the job.
You can monitor your Hive job status also using resource manager web UI. Visit localhost:8088, here you can see the list of all jobs that are submitted to the YARN cluster in that session.
There are some tips that can be followed to optimize your Hive queries. You can refer to this blog for more details on optimizing your hive queries.


text:
Q: MYSQL innodb variable innodb_log_file_size value is not accepting more than 2GB in 5.6.32 I tried to increase the innodb_log_file_size to 10G in mysql 5.6.32. After shutting down the server and moved the innodb files to another location. then changed the variable size to 10G. And started the server but mysql server is not started. so tried with 2G its working fine. It is not accepting more than that. I dont the reason behind this. can anyone help me on this?
Please find the error log details below.

A: innodb_log_file_size, as of 5.6.3 can be up to 512GB / innodb_log_files_in_group.
What value do you have for innodb_log_files_in_group?  There is no good reason to have a value other than 2.
Is this a 32-bit build?  Or on a 32-bit OS?
Anyway...  Since your innodb_buffer_pool_size is only 1.0GB, there is no need to make the total log_file_sizes bigger than that.


text:
Q: How should I handle package-lock.json when I deploy from git via ssh? I have a deployment process where I check code into a git repository, and via web hooks a deployment script is run on the production server. On that server, I connect to git using ssh and a .pem key, pull from git, npm install, build webpack and restart the service process.
I never intend to commit anything from the prod servers - they should be able to deploy automatically. However, this does not work, because the package-lock.json file is frequently updated when I run npm install, and so the next time I deploy, the git pull step fails, saying that I conflict with existing package-lock.json file because it has changes that are not committed.
My current solution is to .gitignore the package-lock.json file. But that defeats its purpose, to provide builds that are identical to the ones on my dev machine.
What would be the right way to handle package-lock.json?

A: There's a helpful StackOverflow Question/Answer about why your package.lock is changing. The closest most useful answer seems to reference an NPM bug that's seeing much activity here in October 2017.
But currently, package.json overrides package-lock.json, meaning if you use ~2.1 and there's a 2.2 version of that package, your production deploy will get upgraded.
Assuming you're not from the future, there's two different ideas here:

*

*Use only non-prefixed, specific version numbers (2.1 vs ~2.0) in your package.json. (This is not great)

*npm install --no-save... which doesn't solve the underlaying issue of lock files getting ignored, but I think will keep the package-lock.json from being updated.


text:
Q: Only update added javascript elements on second click I have some Javascript code that gets values from an array that processes a http response from a server and adds buttons to a modal window. So the ids for the buttons come from the array.
On second click everything is fine and my buttons are added to the modal window. But when I call the function the next time it adds the buttons again, but it should only update the buttons.
How can I handle it that the function will only update the buttons on second and further clicks?
buttonContainer = document.getElementById('modal1');
        for (i = 0; i < resultContainers.length; i++) {
            newButton = document.createElement('input');
            newButton.type = 'button';
            newButton.value = resultContainers[i];
            newButton.id = resultContainerValues[i];
            newButton.class = 'buttonContainer';
                if (newButton.id == 'true') {
                    newButton.style.backgroundColor = '#8cff1a';
                };
            newButton.onclick = function () {
                alert('You pressed '+this.id);
            };
            buttonContainer.appendChild(newButton);

A: You need to check if the button already exists before you add it in that case.  Since you know the id of the button you're about to create, you can see if there's already a button with that id and just update it instead.
var newButton = document.getElementById(resultContainerValues[i]);
if(newButton!=null) {
    newButton.value = resultContainers[i];
} else {
    newButton = document.createElement('input');
    newButton.type = 'button';
    newButton.value = resultContainers[i];
    newButton.id = resultContainerValues[i];
    newButton.class = 'buttonContainer';
    if (newButton.id == 'true') {
        newButton.style.backgroundColor = '#8cff1a';
    }
    newButton.onclick = function () {
        alert('You pressed '+this.id);
    };
    buttonContainer.appendChild(newButton);
}


text:
Q: IE8 is breaking my AJAX... FF is fine Feeling very proud of myself after creating a form with an AJAX submit, I test it in IE8 and get "Message: 'quantity' is undefined". I've read that it could be something to do with the fact that earlier versions of IE used ActiveX for AJAX requests, but I'm very new to JS and have no real understanding of the problem, let alone the ability to implement a fix.
Here's my code:
var time_variable;

function getXMLObject()  //XML OBJECT
{
  var xmlHttp = false;
   try {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  // For Old Microsoft Browsers
   }
   catch (e) {
     try {
       xmlHttp = new ActiveXObject("Microsoft.XMLHTTP")  // For Microsoft IE 6.0+
     }
     catch (e2) {
       xmlHttp = false   // No Browser accepts the XMLHTTP Object then false
     }
   }
   if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
     xmlHttp = new XMLHttpRequest();        //For Mozilla, Opera Browsers
   }
   return xmlHttp;  // Mandatory Statement returning the ajax object created
}

var xmlhttp = new getXMLObject();   //xmlhttp holds the ajax object

function ajaxFunction() {
  var getdate = new Date();  //Used to prevent caching during ajax call
  if(xmlhttp) {
    var txtname = document.getElementById("txtname");
    xmlhttp.open("POST","slots.php",true); //calling     testing.php using POST method
    xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send("quantity=" + quantity.value + "&price=" + price.value + "&slot=" +         slot.value + "&store=" + store.value); //Posting txtname to PHP File

  }
}

function handleServerResponse() {
   if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {
       document.getElementById("message").innerHTML=xmlhttp.responseText; //Update the     HTML Form element
     }
     else {
        alert("Error during AJAX call. Please try again");
     }
   }
}

A: If quantity is a form field you need to get it using getElementById before using it just like you did with txtname:

var quantity = document.getElementById("quantity");

You cant use it directly from the form.

A: From your last comment on your question, I suspect you are not defining 'quantity' anywhere and assuming that it will reference the form field. Try this:
if(xmlhttp) {
    var txtname = document.getElementById("txtname");
    var quantity = document.getElementById("quantity");
    var price = document.getElementById("price");
    var store = document.getElementById("store");
    xmlhttp.open("POST","slots.php",true); //calling     testing.php using POST method
    xmlhttp.onreadystatechange  = handleServerResponse;
    xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlhttp.send("quantity=" + quantity.value + "&price=" + price.value + "&slot=" +               slot.value + "&store=" + store.value); //Posting txtname to PHP File
}


text:
Q: Find the indices of elements greater than x Given the following vector,
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

I need to identify the indices of "a" whose elements are >= than 4, like this:
idx = [3, 4, 5, 6, 7, 8]

The info in "idx" will be used to delete the elements from another list X (X has the same number of elements that "a"):
del X[idx] #idx is used to delete these elements in X. But so far isn't working.

I heard that numpy might help. Any ideas?
Thanks!

A: The simplest in my eyes would be to use numpy
X[np.array(a)>4]#X needs to be np.array as well

Explanation:
np.array converts a to an array.
np.array(a)>4 gives a bool array with all the elements that should be kept
And X is filtered by the bool array so only the elements where a is greater than 4 are selected (and the rest discarded)

A: >>> import numpy as np
>>> a = np.array(range(1,10))
>>> indices = [i for i,v in enumerate(a >= 4) if v]
>>> indices
[3, 4, 5, 6, 7, 8]

>>> mask = a >= 4
>>> mask
array([False, False, False,  True,  True,  True,  True,  True,  True], dtype=boo
l)
>>> a[mask]
array([4, 5, 6, 7, 8, 9])
>>> np.setdiff1d(a,a[mask])
array([1, 2, 3])

A: I guess I came here a bit late (while things got easier using Numpy)..
import numpy as np

# Create your array
a = np.arange(1, 10)
# a = array([1, 2, 3, 4, 5, 6, 7, 8, 9])

# Get the indexes/indices of elements greater than 4
idx = np.where(a > 4)[0]
# idx = array([4, 5, 6, 7, 8])

# Get the elements of the array that are greater than 4
elts = a[a > 4]
# elts = array([5, 6, 7, 8, 9])

# Convert idx(or elts) to a list
idx = list(idx)
#idx = [4, 5, 6, 7, 8]

A: >>> [i for i,v in enumerate(a) if v > 4]
[4, 5, 6, 7, 8]

enumerate returns the index and value of each item in an array. So if the value v is greater than 4, include the index i in the new array.
Or you can just modify your list in place and exclude all values above 4.
>>> a[:] = [x for x in a if x<=4]
>>> a
[1, 2, 3, 4]

A: OK, I understand what you mean and a Single line of Python will be enough:
using list comprehension
[ j for (i,j) in zip(a,x) if i >= 4 ]
# a will be the list compare to 4
# x another list with same length

Explanation:
>>> a
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> x
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j']

Zip function will return a list of tuples
>>> zip(a,x)
[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f'), (7, 'g'), (8, 'h'), (9, 'j')]

List comprehension is a shortcut to loop an element over list which after "in", and evaluate the element with expression, then return the result to a list, also you can add condition on which result you want to return
>>> [expression(element) for **element** in **list** if condition ]

This code does nothing but return all pairs that zipped up.
>>> [(i,j) for (i,j) in zip(a,x)]
[(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f'), (7, 'g'), (8, 'h'), (9, 'j')]

What we do is to add a condition on it by specify "if" follow by a boolean expression
>>> [(i,j) for (i,j) in zip(a,x) if i >= 4]
[(4, 'd'), (5, 'e'), (6, 'f'), (7, 'g'), (8, 'h'), (9, 'j')]

using Itertools
>>> [ _ for _ in itertools.compress(d, map(lambda x: x>=4,a)) ]
# a will be the list compare to 4
# d another list with same length

Use itertools.compress with single line in Python to finish close this task
>>> a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> d = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j'] # another list with same length
>>> map(lambda x: x>=4, a)  # this will return a boolean list
[False, False, False, True, True, True, True, True, True]

>>> import itertools
>>> itertools.compress(d, map(lambda x: x>4, a)) # magic here !
<itertools.compress object at 0xa1a764c>     # compress will match pair from list a and the boolean list, if item in boolean list is true, then item in list a will be remain ,else will be dropped
#below single line is enough to solve your problem
>>> [ _ for _ in itertools.compress(d, map(lambda x: x>=4,a)) ] # iterate the result.
['d', 'e', 'f', 'g', 'h', 'j']

Explanation for itertools.compress, I think this will be clear for your understanding:
>>> [ _ for _ in itertools.compress([1,2,3,4,5],[False,True,True,False,True]) ]
[2, 3, 5]

A: using filter built-in function is fine
>>>a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>>filter(lambda x : x < 4, a)
[1, 2, 3]

Explanation
filter(FUN, Iterable)
this expression will iterate all element from Iterable and supply to FUN function as argument, if return is True ,then the arugment will be append to a internal list
lambda x: x > 4
this means a anonymous function that will take a argument and test it if bigger than 4, and return True of False value
Your solution
if you are try to delete all elements larger than 4 ,then try blow
>>> a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> filter(lambda x: x<4 ,a)
[1, 2, 3]

A: looping is slow, using divide and conquer method. code in C++
// find index whose value is equal to or greater than "key" in an ordered vector.
// note: index may be equal to indices.size()
size_t StartIndex(const std::vector<int>& indices, int key)
{
    if (indices.empty() || key <= indices[0])
        return 0;

    if (key > indices.back())
        return indices.size();

    size_t st = 0;
    size_t end = indices.size() - 1;

    while (true)
    {
        if ((end - st) < 2)
            return (indices[st] < key) ? end : st;

        size_t mid = ((st + end) >> 1);  // (st + end) / 2

        if (indices[mid] == key)
            return mid;

        (indices[mid] < key ? st : end) = mid;
    }
}


text:
Q: Webhooks for Event start on Google Calendar API Is there a way to get a webhook when an event starts or slightly before an event starts?
Google Calendar API allows to create reminders on events. Is it possible to get a webhook when an  event is activated or started?
For e.g., if I create an event for "Dec 15 2020 15:45 +0530", can I get a webhook at exactly that time, or a few minutes before?
Google may be using such a webhook to send out reminder emails or alarms. I want to use that to send notifications within my app.

A: There is currently an open Feature Request on Google Issue Tracker to add an API for reminders for Calendar.
What you can do in this situation is to star the issue here and eventually add a comment.
Workaround
You can create a script using Apps Script that will get all the events from a particular day and check their starting times.
function getEvents() {
    let today = new Date();
    let calendar = CalendarApp.getCalendarById(id);
    let events = calendar.getEventsForDay(today);
    let startTime = today.getHours();
    for (let i = 0; i < events.length; i++) {
        if (events[0].getStartTime() <= startTime) {
            // send email, notification etc;
        }
    }
}

Afterwards, you can add an installable time-driven trigger which can run every 15 minutes for example to trigger the execution of the above function.
function createTrigger() {
  ScriptApp.newTrigger('getEvents')
      .timeBased()
      .everyMinutes(15)
      .create();
}

Note
Please bear in mind that you can customize the script and the trigger in such a way that it suits your needs accordingly.
Reference

*

*Apps Script CalendarApp Class;

*Apps Script Installable Triggers.

A: You can do this easily with IPaaS
With IFTTT's Google Calendar & Webhook applet,
IF=> Any Event Starts(You can set how many minutes/hours )
Then=> Post Webhooks
You can set its;

*

*title

*Description

*Location

*Start Time

*End Time

*EventURL

*VideoCallURl
in additional headers, URL parameter and/or JSON body.

The timing of the trigger is not that accurate though.
Alternatively, you can use Integromat's Mailhook to work with the reminder notification.

*

*Set forward setting in your gmail client for reminder notification to forward it to email address provided by Integromat

*According to the contents of the email, make HTTP request to your endpoint.

You also have such services like;
https://mailhook.app/
for converting emails to webhooks.
https://cronhooks.io/
for creating a schedule to post webhooks.


text:
Q: Why there is proxy in front of Router (or between PC and Router)? Our company's router is 192.168.135.254
with traceroute, I got this:
traceroute to 8.8.8.8 (8.8.8.8), 64 hops max, 52 byte packets
 1  192.168.0.162 (192.168.0.162)  1.903 ms  0.839 ms  0.699 ms
 2  192.168.135.254 (192.168.135.254)  308.121 ms  6.839 ms  4.661 ms

SO router is 2, before router there's a 192.168.0.162, which by nmap, I know its a squid proxy,
Why there is a proxy before router?
Is my understanding right? packet from my PC SHOULD first go to router, then go to outside?

A: Squid proxies serve a couple of purposes, typically.
One is (with SquidGuard) web filtering/blocking, if any. If this is causing you a problem at work, bring it up with IT if it's a legitimate work-related thing it's causing a problem with, and otherwise stop trying to go places that are banned at work if you know what's good for you - they have a little list, and you'll be on it, along with there you were trying to go.
Another is the basic web cache function to reduce load on the outside line and load things that have already been downloaded quickly on the internal network without wasting time & data downloading them again from the external network. With a large cache, this can make a HUGE difference for big repetitive stuff like software updates.


text:
Q: HTML external link working but image src not I am using external links for some images in my app. Links are ok, anchor tag works and it moves me to the exact raw image. The issue is that src of the image display broken image link icon;/

Image Original Link

Could someone help me?


text:
Q: Compact formula for the $n$th derivative of $f\left(\sqrt{x+1}\right)$? I'm interested in a general formula for
$$\frac{d^n}{dx^n}\Big[f\left(\sqrt{x+1}\right)\Big].$$
In particular, Fàa di Bruno's formula gives
$$\frac{d^n}{dx^n}\Big[f\left(\sqrt{x+1}\right)\Big]=\sum_{k=1}^n f^{(k)}\left(\sqrt{x+1}\right)B_{n,k}\big(g'(x),g''(x),\dots,g^{(n-k+1)}(x)\big),$$
where $g(x)=\sqrt{x+1}$ and $B_{n,k}$ denote Bell polynomials.
I suspect we can do better than this, using the identities
$$\frac{d^k}{dx^k}\Big[\sqrt{x+1}\Big]=\left(\frac{1}{2}\right)^\underline{k}x^{1/2-k}=-\frac{(2k-3)!!}{(-2)^k}x^{1/2-k}=\frac{\sqrt{\pi}}{2\Gamma(3/2-k)}x^{1/2-k}.$$
In particular, every term in $B_{n,k}$ for fixed $n$ and $k$ will be some numerical factor times $(x+1)^{k/2-n}$ (see notes below), so the result is always of the form
$$\frac{d^n}{dx^n}\Big[f\left(\sqrt{x+1}\right)\Big]
=\sum_{k=1}^n a_{n,k} \frac{f^{(k)}\left(\sqrt{x+1}\right)}{(x+1)^{n-k/2}}$$
for some constants $a_{n,k}.$ Is there an explicit expression for the $a_{n,k}$ above? For example, it seems likely that there is some expression using Stirling numbers, factorials, binomial coefficients, etc., given the combinatorial nature of the problem.

Current progress:
Using the first identity above for derivatives of $\sqrt{x+1}$ [where $(\cdot)^\underline{k}$ denotes the $k$th falling factorial], we have
$$B_{n,k}\big(g'(x),g''(x),\dots,g^{(n-k+1)}(x)\big)
=B_{n,k}\left[\left(\frac{1}{2}\right)^\underline{1}x^{1/2-1},\left(\frac{1}{2}\right)^\underline{2}x^{1/2-2},\dots,\left(\frac{1}{2}\right)^\underline{n-k+1}x^{1/2-(n-k+1)}\right].$$
The definition of the Bell polynomials guarantees that the power of $x$ in every term of $B_{n,k}(\cdots)$ comes out to $x^{k/2-n}$, with pre-factor given by
$$a_{n,k}=B_{n,k}\left[\left(\frac{1}{2}\right)^\underline{1},\left(\frac{1}{2}\right)^\underline{2},\dots,\left(\frac{1}{2}\right)^\underline{n-k+1}\right],$$
so the remaining task is to simplify the above expression, if possible.

A: Heuristic
By analyzing the matrix of the first values for $a_{n,m}$ it is possible to
deduce that
$$ \bbox[lightyellow] {
a_{\,n,\,m}  =\frac{ \left( { - 1} \right)^{n - m} }{2^n} \left( \matrix{  2n - 1 - m \cr   2n - 2m \cr}  \right)
\left( {2n - 2m - 1} \right)!!\quad \left| {\,0 \le m \le n} \right.
} \tag{1}$$
which can be further simplified in terms of Gamma or other, and which can be
of help for a rigorous demonstration.
Demonstration
We put
$$
{{d^{\,n} } \over {dx^{\,n} }}f\left( {\sqrt {x + 1} } \right)
 = \sum\limits_{0\, \le \,k} {a_{\,n,\,k} {{f^{\,\left( k \right)} \left( {\sqrt {x + 1} } \right)}
 \over {\left( {x + 1} \right)^{\,n - k/2} }}}
$$
The $a_{\,n,\,k} $ are supposed to be constant, independent from $f$.
Then they shall be valid for any infinitely differentiable function, in particular
for analytic functions, and thus in particular for
$$
f(x) = x^{\,2m} \quad \left| {\,0 \le m \in Z} \right.
$$
For this we have
$$
\left\{ \matrix{
  f\left( {\sqrt {x + 1} } \right) = \left( {x + 1} \right)^{\,m}  \hfill \cr
  {{d^{\,n} } \over {dx^{\,n} }}f\left( {\sqrt {x + 1} } \right)
 = m^{\,\underline {\,n\,} } \left( {x + 1} \right)^{\,m - n}  \hfill \cr
  f^{\,\left( n \right)} \left( {\sqrt {x + 1} } \right)
 = \left( {2m} \right)^{\,\underline {\,n\,} } \left( {\sqrt {x + 1} } \right)^{\,2m - n}  \hfill \cr}  \right.
$$
and therefore
$$
\eqalign{
  & m^{\,\underline {\,n\,} } \left( {x + 1} \right)^{\,m - n}  =   \cr
  &  = \sum\limits_{0\, \le \,k} {a_{\,n,\,k} {{\left( {2m} \right)^{\,\underline {\,k\,} }
 \left( {x + 1} \right)^{\,m - k/2} } \over {\left( {x + 1} \right)^{\,n - k/2} }}}
  = \sum\limits_{0\, \le \,k} {a_{\,n,\,k} \left( {2m} \right)^{\,\underline {\,k\,} }
 \left( {x + 1} \right)^{\,m - n} }   \cr
  & \quad \quad  \Downarrow   \cr
  & m^{\,\underline {\,n\,} }
  = \sum\limits_{0\, \le \,k} {a_{\,n,\,k} \left( {2m} \right)^{\,\underline {\,k\,} } }
 \quad  \Leftrightarrow \quad \left( {{m \over 2}} \right)^{\,\underline {\,n\,} }
  = \sum\limits_{0\, \le \,k} {a_{\,n,\,k} m^{\,\underline {\,k\,} } }  \cr}
$$
Since
$$
\eqalign{
  & \left( {{m \over 2}} \right)^{\,\underline {\,n\,} }
  = \sum\limits_{\left( {0\, \le } \right)\,j\,\left( { \le \,n} \right)}
 {\left( { - 1} \right)^{\,n - j} \left[ \matrix{  n \cr   j \cr}  \right]\left( {{m \over 2}} \right)^{\,j} }
  = \sum\limits_{\left( {0\, \le } \right)\,j\,\left( { \le \,n} \right)}
 {{{\left( { - 1} \right)^{\,n - j} } \over {2^{\,j} }}\left[ \matrix{ n \cr  j \cr} \right]m^{\,j} }   \cr
  & \sum\limits_{0\, \le \,k} {a_{\,n,\,k} m^{\,\underline {\,k\,} } }
  = \sum\limits_{0\, \le \,k} {a_{\,n,\,k} \sum\limits_{\left( {0\, \le } \right)\,j\,\left( { \le \,k} \right)}
 {\left( { - 1} \right)^{\,k - j} \left[ \matrix{k \cr  j \cr}  \right]m^{\,j} } }  =   \cr
  &  = \sum\limits_{\left( {0\, \le } \right)\,j\,} {\left( {\sum\limits_{0\, \le \,k}
 {\left( { - 1} \right)^{\,k - j} a_{\,n,\,k} \left[ \matrix{ k \cr  j \cr}  \right]} } \right)m^{\,j} }  \cr}
$$
i.e.
$$
{{\left( { - 1} \right)^{\,n - j} } \over {2^{\,j} }}\left[ \matrix{  n \cr  j \cr}  \right]
 = \sum\limits_{0\, \le \,k} {\left( { - 1} \right)^{\,k - j} a_{\,n,\,k}
 \left[ \matrix{  k \cr   j \cr}  \right]}
$$
which can be viewed as a matrix relation involving the matrix $A:\; A_{\,n,\,k} = a_{\,n,\,k}$
multiplied by the matrix of the signed Stirling N. of 1st kind, which is well known to be
the inverse of the Stirling N. of 2nd kind, so:
$$ \bbox[lightyellow] {
a_{\,n,\,m}  = \sum\limits_{0\, \le \,k}
 {{{\left( { - 1} \right)^{\,n - k} } \over {2^{\,k} }}
\left[ \matrix{  n \cr   k \cr}  \right]\left\{ \matrix{  k \cr  m \cr}  \right\}}
}\tag{2}$$
The computation of the above checks with the heuristic formula:
it remains to demonstrate this fact analytically.

A: Thanks to G Cab's inference of the correct answer and Gary's comment on the recursive formula for the $a_{n,k}$'s, I have now found a proof by induction of the result. I'll post it here for posterity.

Define $a_{n,k}=0$ if $k=0$ or $k>n$, and otherwise let it be defined as in the original post. Then we can write
$$\frac{d^n}{dx^n}\Big[f\left(\sqrt{x+1}\right)\Big]
=\sum_{k=0}^\infty a_{n,k} \frac{f^{(k)}\left(\sqrt{x+1}\right)}{(x+1)^{n-k/2}},$$
and differentiating both sides gives the recurrence relation $a_{n+1,k}=\frac{1}{2}a_{n,k-1}+(k/2-n)a_{n,k}$ for all $n,k≥1.$ This is equivalent to
$$a_{n+1,k+1}=\frac{1}{2}a_{n,k}+\left(\frac{k+1}{2}-n\right)a_{n,k+1}\qquad\Bigg|\qquad n≥1,k≥0.$$
Now define
$$c_{n,k}:=\frac{(-1)^{n-k}}{2^n}\frac{(2n-1-k)!}{(2n-2k)!!(k-1)!}$$
for $n≥1,1≤k≤n$, and $c_{n,k}=0$ otherwise. (In fact, the first expression also works for these cases if we interpret negative factorials as $\infty$ and $1/\infty$ as zero.) It is straightforward to check that this formula for $c_{n,k}$ is equivalent to $(1)$ in G Cab's answer.
Induction Part 1
It is quick to check that $c_{n,k}=0=a_{n,k}$ for $k=0$ or $k>n$, and that $c_{1,1}=1/2=a_{1,1}.$
Induction Part 2
Let $n≥1,k≥0$ be fixed, and assume that $c_{n,k}=a_{n,k}$ and $c_{n,k+1}=a_{n,k+1}$ for these particular values. We will show that $c_{n+1,k+1}=a_{n+1,k+1},$ which proves the desired result by induction.
$\begin{align*}
a_{n+1,k+1}&=\frac{1}{2}a_{n,k}+\left(\frac{k+1}{2}-n\right)a_{n,k+1}
\\\\
&=\frac{1}{2}c_{n,k}+\left(\frac{k+1}{2}-n\right)c_{n,k+1}
\\\\
&=\frac{1}{2}\frac{(-1)^{n-k}}{2^n}\frac{(2n-1-k)!}{(2n-2k)!!(k-1)!}
+\left(\frac{k+1}{2}-n\right)\frac{(-1)^{n-k-1}}{2^n}\frac{(2n-2-k)!}{(2n-2k-2)!!k!}
\\\\
&=\left[
\frac{k}{2n-k}+(2n-k-1)\frac{2n-2k}{(2n-k)(2n-k-1)}
\right]
\frac{(-1)^{n-k}}{2^{n+1}}\frac{(2n-k)!}{(2n-2k)!!k!}
\\\\
&=\left[
\frac{k}{2n-k}+\frac{2n-2k}{2n-k}
\right]
c_{n+1,k+1}
\\\\
&=c_{n+1,k+1}
\end{align*}$

A: A formula to calculate the $n$-th derivative of composite functions is stated as identity (3.56) in H.W. Gould's Tables of Combinatorial Identities, Vol. I and called:

*

*Hoppe Form of Generalized Chain Rule
Let $D_g$ represent differentiation with respect to $g$ and $g=g(x)$. Hence $D^n_x f(g)$ is the $n$-th derivative of $f$ with respect to $x$.  The following is valid for $n\geq 1$:
\begin{align*}
D_x^n f(g)=\sum_{k=1}^nD_g^kf(g)\frac{(-1)^k}{k!}\sum_{j=1}^k(-1)^j\binom{k}{j}g^{k-j}D_x^ng^j\tag{1}
\end{align*}

Here we have $g(x)=\sqrt{1+x}$. The right-most part of (1) is
\begin{align*}
g(x)^{k-j}D_x^ng(x)^j&=(1+x)^{\frac{k-j}{2}}D_x^n(1+x)^{\frac{j}{2}}\\
&=(1+x)^{\frac{k-j}{2}}\left(\frac{j}{2}\right)^{\underline{n}}(1+x)^{\frac{j}{2}-n}\\
&=(1+x)^{\frac{k}{2}-n}\left(\frac{j}{2}\right)^{\underline{n}}\tag{2}\\
\end{align*}
We obtain with $g(x)=\sqrt{1+x}$ from (1) and (2):
\begin{align*}
\color{blue}{D_x^n f\left(\sqrt{1+x}\right)
=\sum_{k=1}^n(1+x)^{\frac{k}{2}-n}D_g^kf(g)\frac{(-1)^k}{k!}\sum_{j=1}^k(-1)^j\binom{k}{j}\left(\frac{j}{2}\right)^{\underline{n}}}
\end{align*}


text:
Q: Can a Linux server serve as a Domain Controller for Windows Machines? In a small office setup (5-6 employees) we have seven Windows XP and Windows Vista clients, as well as a couple of linux servers.
Is it possible to set up a linux machine to act as the domain controller to provide single signon and AD-like capabilities for the network?

A: Samba4 is going to be able to do that, but it's still in alpha.  If you're adventurous you can play with the latest releases.

A: My answer is going to be "why would you want to?"  You're probably far better off implementing a Windows DC; it won't cost you that much, and you'll be on a supported and more predictable environment.  AD isn't difficult - there's a lot in it, but it's not difficult.  So long as you don't do bizarre or wacky stuff with it, it's incredibly robust and has low maintenance overhead.  If you want the Linux boxes to authenticate against it, you can set it up in Mixed Mode and it will present itself as an NT4-like DC where appropriate.

A: With the versions of Samba found in current versions of common distributions you can certainly have a Linux machine act as an NT-style domain controller (this has been the case for some time).
I believe that taking part in an AD based domain is being actively worked on but not yet ready for production use, though it isn't something I've looked at recently so the support may have moved on.

A: Of course you can!
Just read a bit some tutorials at samba.org
Samba by example is great for a start

A: If you don't mind commercial linux software, Novell's Open Enterprise Server 2 (SP1 and later) has a component called Domain Services for Windows that'll do exactly that. Cost-wise, however, it'd probably be cheaper to purchase a Windows 2003 server and create your own AD tree. But if you really want a Microsoft-free solution OES2 will do it for you.

A: If the "AD-like capabilities" you want are basically group policies, I recommend looking into Nitrobit Group Policy, which allow to simulate this function in a samba domain.
I have running this in my network and it's a great piece of software, although not free.

A: Until Samba 4 arrives, you can use Likewise Open.  We have had a great experience with this on Ubuntu.  Another option that provides a lot of the advantages of AD is Novell's eDirectory.  I have zero direct experience with it so I can't personally vouch, but it's something more than one of my sysadmin friends have raved about -- one using with Linux servers and an all-WindowsXP client base.


text:
Q: SSLError when install gcloud CLI I was going to install gcloud cli on my macbook running on macOS.
I run ./google-cloud-sdk/install.sh and met the following error:
requests.exceptions.SSLError: HTTPSConnectionPool(host='dl.google.com', port=443): Max retries exceeded with url: /dl/cloudsdk/channels/rapid/components-2.json (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))

I can access "dl.google.com" with my local browser.
When I run other gcloud commands, there is also this issue.
How to solve this problem?

A: In accordance with @mxjecho, it works when running the below command to disable ssl verification:
gcloud config set auth/disable_ssl_validation True


text:
Q: Is there an efficient way to create a lot of GMSMarker objects? I used an overlay on the google maps as shown:

I have a UIButton button at the top right corner that filters markers using a UIPickerView.
Depending on the selection, I'm creating an X number of markers and placing it at the appropriate spots on the map.
The issue I have is having to manually do this:
GMSMarker *marker1 = [ [GMSMarker alloc] init];
GMSMarker *marker2 = [ [GMSMarker alloc] init];
GMSMarker *marker3 = [ [GMSMarker alloc] init];
GMSMarker *marker4 = [ [GMSMarker alloc] init];

....

Is there a quicker and more efficient way to create an X number of GMSMarker without repetitive code, ideally a for loop?

A: Add all the markers in an array(coordinatesArray).
NSArray *coordinatesArray = ......;

then
for(int counter=0; counter<[coordinatesArray count]; counter++)
{
    GMSMarker *marker = [[GMSMarker alloc] init];

    //----Below line is just an example, you'll get lat , lng from the array like the way.
    marker.position=CLLocationCoordinate2DMake([coordinatesArray objectAtIndex:counter]);

    marker.map = mapView_;
}

Hope this will help you.


text:
Q: Open a file from crystal report export to stream function How can i open a file directly from stream which is exported through crystal report export to stream function? I am using vs2010 and sap crystal report.
MemoryStream m = (MemoryStream)(PReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
FileStream f = new FileStream(purchaseCombo.SelectedItem.ToString(),FileMode.Create,System.IO.FileAccess.Write);
byte[] bytes = new byte[m.Length];
m.Read(bytes, 0, (int)m.Length);
f.Write(bytes, 0, bytes.Length);
f.Close();
m.Close();

A: It depends on the file that you are exporting. Since Crystal Reports can export a number of different file types and each of them has a specific program that can handle it, you will need to search for the exact file type that you're interested. For example with a quick search on the internet, I found that a stream of an html file can be directly previewed inside a WebBrowser component (in a WPF app) by using the NavigateToStream method. Maybe there are some 3rd party components that expose methods for directly opening files from memory.
Though, the easiest way would be to export a temporary file to disk instead of memory by using the ExportToDisk method and delete it after its usage, since many components read from paths rather than memory. Before exporting the file, you can use the GetTempFileName method which creates and names a temporary file.


text:
Q: Behavior of FOR XML AUTO SQL SERVER I was fiddling with XML AUTO and XML RAW to see how they behave. The test db is AdventureWorks2012.
SELECT TOP 20  Cust.CustomerID AS C1,
        Cust.TerritoryID,
        OrderHeader.CustomerID AS C2,
        OrderHeader.SalesOrderID,
        OrderHeader.Status

FROM Sales.Customer Cust
INNER JOIN Sales.SalesOrderHeader OrderHeader
ON Cust.CustomerID = OrderHeader.CustomerID
FOR XML RAW('MyRow'), ELEMENTS

XML RAW's simplicity just puts every element in the same level
<MyRow>
<C1>29825</C1>
<TerritoryID>5</TerritoryID>
<C2>29825</C2>
<SalesOrderID>43659</SalesOrderID>
<Status>5</Status>

While for XML AUTO
SELECT TOP 20  Cust.CustomerID,
        Cust.TerritoryID,
        OrderHeader.CustomerID,
        OrderHeader.SalesOrderID,
        OrderHeader.Status
FROM Sales.Customer Cust
INNER JOIN Sales.SalesOrderHeader OrderHeader
ON Cust.CustomerID = OrderHeader.CustomerID
FOR XML AUTO, ELEMENTS

I have
<Cust>
<CustomerID>29825</CustomerID>
<TerritoryID>5</TerritoryID>
<OrderHeader>
    <CustomerID>29825</CustomerID>
    <SalesOrderID>43659</SalesOrderID>
    <Status>5</Status>
</OrderHeader>
</Cust>

XML AUTO decides to group all under Cust tag. How does it come to this conclusion that Cust somehow encloses and "at a higher level" than OrderHeader. Why does it decide to group all OrderHeader's columns under OrderHeader tag and not the same for Cust ? Before executing I thought that it would be
<Cust>
    <CustomerID>29825</CustomerID>
    <TerritoryID>5</TerritoryID>
</Cust>
<OrderHeader>
    <CustomerID>29825</CustomerID>
    <SalesOrderID>43659</SalesOrderID>
    <Status>5</Status>
</OrderHeader>

Update
It's a hunch but I start to think SQL Server will take the table of the column first mentioned to be the outer tag,
For example,
SELECT TOP 20  OrderHeader.CustomerID,,
               Cust.CustomerID,
               Cust.TerritoryID,
               OrderHeader.SalesOrderID,
               OrderHeader.Status

Even when I mix the column order, it will still group columns of OrderHeader together, and Cust is a subgroup
<OrderHeader>
<CustomerID>29825</CustomerID>
<SalesOrderID>43659</SalesOrderID>
<Status>5</Status>
<Cust>
<CustomerID>29825</CustomerID>
<TerritoryID>5</TerritoryID>
</Cust>
</OrderHeader>


text:
Q: how to check for duplicates and rename file if there are any while copying them from another source It's a script in bash, it copies files from one directory into another but there may be duplicates in a sub-directory. So while copying, it should recognize if a another file has the same name and if so - change the name of the file that is being copied.
I tried this
for i in $1; do
    find $i -type f -name img*.jpg -exec cp {} $2 \;
    for j in $2; do
        find $j -type f -name $i | while read filename; do if test "$i"="$j"; then mv $i new_filename; fi done
    done
done

but I get a error message saying a filename should not contain slashes which is a bit weird... am a complete beginner, please do comment if you put any code. thanks.

A: Your $1 should be a directory list, because it is the first parameter after find. OK?
In your first find you must quote the asterisk: -name 'img*.jpg'
Then you copy into directory $2.
Therefore, $2 in your second for is a directory, and only one.
If your intention is to look at every file in $2, use for j in $2/* And then, find $2 -type f -name $i | while ...
BTW, if chance is that names may contain spaces, use double quotes around parameters.


text:
Q: Remove default user registration, login and subscriber profiles My website has recently come under attack by a wave of spam user accounts. My website uses a custom login that forces users to use their email address as their username, however the spam users all have regular usernames so I am assuming they are running a script which sends POST requests to /wp-login.php.
It is not enough to remove this page I need to disable the ability to make user accounts via POST requests to this page as I'm pretty sure the spammers are using software and not hand crafting these accounts.
Lastly I need to disable /wp-admin/profile.php as I believe they are creating accounts to insert back-links into their profiles.
How would I go about doing this?

A: I realised this is probably better dealt by the server, I ended up putting the following in a .htaccess:
# Block regular login/registration and profile pages
<Files wp-login.php>
    Order Deny,Allow
    Deny from All
</Files>
<Files profile.php>
    Order Deny,Allow
    Deny from All
</Files>

This prevents any requests to those pages and forces users to use my custom login and registration pages.
Edit: I don't think I made this clear and I do not recommend this solution to most WordPress users.
I have a custom user registration, login and profile system. These do not extend the default WordPress ones but are completely stand-alone and do not require access to these pages as all logic and requests are handled by the system itself and not passed on (However they do use WordPress functions and the default user table in the WordPress database).
This is not the same as say a plugin which provides a custom login page just to change the theme but actually sends POST requests back to wp-login.php as this would break under my solution.


text:
Q: Different customer login form than administrator login form? I've recently installed Woocommerce. I have realized that the administrator can access the back-end through the same login form presented to the customers. This, to me, presents a huge security risk.
I thought of a couple of solutions, but I do not know the code that would help me implement them:

*

*How can I prevent the administrators from logging in through the customer
login page? (if statement on login from the customer login form that would check the role of the user and prevent login if the user is an admin)

*How can I present a login form so that only the customers can login through? (use a default or native login form set only for customers)

A: Although users have access to go to /wp-admin/, they will not have access to do anything on there. There is no security risk involved to being able to have access /wp-admin/ for WooCommerce users.
If you'd like however, you can setup an Apache protected directory with a password to /wp-admin/ that requires an additional user and pass to get to that URL.


text:
Q: JavaScript .focus() function not working in a text field I'm trying to use .focus() on the following form field without success. The tabindex of the div this element is in is 0.
<input class="form-control ng-pristine ng-valid ng-empty ng-touched" id="accessionNumber" type="text" name="filter.accessionNumber" ng-model="selectFields.accessionNumber" style="">

I'm using the following:
document.getElementsByName("filter.accessionNumber")[0].focus()

I've also tried document.getElementById using the "accessionNumber" ID as well as the .click() function instead of the .focus() function but none have worked so far
Thanks!

A: Short answer: Maybe have a look at this post
Longer answer: Since you are using Angular you should use the features of the framework that enable this: ViewChild
Steps to make it work:

*

*In your component create a variable with the ViewChild annotation

*Mark the element with the ViewChild id in the Components Template

*Access your element in ngAfterViewInitlike

this.myElement.nativeElement.focus();


text:
Q: Proving the formula of function graph i have to prove the following statement:
$\mathbb \forall a \in A, \exists ! b \in B : (a,b) \in \Gamma $
where Gamma is the graph of a function. I proceeded in this direction (first time using absurd proof):
Lets say that a function is not a unique correspondence between elements of the domain and co-domain. Then, i can write:
$\mathbb \forall a \in A, \exists  b \in B : (a,b) \in \Gamma $
This implies that there's atleast one correspondence. Atleast means that there can be $\ge$ 1 correspondence between a and b.
If this is true, then the circle and the ellipse are functions (there are more drawings). If it is a function, then the following statement is true:
$\mathbb \Gamma = \{(a,b) \in AxB: b=f(a)\} $
which is the correct definition of a function. In the case of the ''functions'' like ellipse and the circle though, the definition falls since it changes to:
$\mathbb \Gamma = \{(a,b) \in AxB: b=f(a)=f(c)\} $
Not only this, but this last statement does not have the unique correspondance that defines a function.
Conclusion: if there's a graph of a function, then the correspondance between elements of domain and codomain is unique.


text:
Q: SwiPlCs throws 'Precondition Failed' when trying to get list as result from swi-prolog I'm having a problem trying to call SWI-Prolog from C#, it gives me a message 'Precondition failed' in my PlTerm variable. The program is for a school project and I'm running out of time and ideas on how to solve this. It is supposed to show me all the available flights from one airport to another.
Let me show you my code for you to better understand what I'm trying to say:
aeropuerto(a).
aeropuerto(b).
aeropuerto(c).
aeropuerto(d).
aeropuerto(m).

vuelo(1,b,a,1000).
vuelo(2,a,b,900).
vuelo(3,c,a,1200).
vuelo(4,a,c,1400).
vuelo(5,d,c,500).
vuelo(6,b,d,800).
vuelo(7,d,m,600).
vuelo(8,m,d,700).

vDirecto(A,X,Y,B):-vuelo(A,X,Y,B).

vEscalaSimple([T,M],X,Y,Z):-vDirecto(T,X,C,B),vDirecto(M,C,Y,P),suma(B,P,Z),X\=Y.

suma(B,P,Z):-Z is B + P.

reversa(X,A,B):-vuelo(X,B,A,C).

vuelos([A|_],X,Y,B):-vDirecto(A,X,Y,B).
vuelos([A|T],X,Y,B):-vEscalaSimple([A|T],X,Y,B).
vuelos([A|T],X,Y,B):-vDirecto(A,X,Z,D),vEscalaSimple(T,Z,Y,C),suma(D,C,B),reversa(J,X,Z),X\=Y,not(member(A,T)),not(member(J,T)).

misVuelos([A|T],X,Y,B):-vuelos([A|T],X,Y,B).
misVuelos([A|T],X,Y,B):-vDirecto(A,X,Z,D),vuelos(T,Z,Y,C),suma(D,C,B),reversa(J,X,Z),X\=Y,not(member(A,T)),not(member(J,T)),not(length([A|T],3)).

So this is my code in SWI-Prolog. When I call for "misVuelos(A,B,C,D)" Prolog shows me all the available flights as a list. Everything works perfect, the problem comes when trying to retrieve the answer in C#.
Environment.SetEnvironmentVariable("SWI_HOME_DIR", @"C:\Program Files\swipl");
Environment.SetEnvironmentVariable("Path", @"C:\Program Files\swipl\bin");
            List<string[]> temp = new List<string[]>();
            string[] _params = { "-q", "-f", _path };
            if (!PlEngine.IsInitialized)
            {
                try
                {
                    PlEngine.Initialize(_params);

                    PlTerm t1 = new PlTerm("A"), t2 = new PlTerm("B"), t3 = new PlTerm("C"), t4 = new PlTerm("D");
                    PlTermV termV = new PlTermV(new PlTerm[] { t1, t2, t3, t4 });

                    using (PlQuery q = new PlQuery("misVuelos", termV))
                    {
                        foreach (PlQueryVariables v in q.SolutionVariables)
                        {
                            Console.WriteLine(t1.ToString());
                            /*temp.Add(new string[] {
                                v["A"].ToString(),
                                v["B"].ToString(),
                                v["C"].ToString(),
                                v["D"].ToString()
                            });*/
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    PlEngine.PlCleanup();
                }
            }
            return temp;

When trying to get the value of variable t1 and print it to the console it throws me an error saying (again) 'Precondition failed'. The other variables work well (t2, t3 and t4), it's just t1 that's giving me problems. I have read the documentation but no luck on finding the solution.
Someone care to explain why isn't working and how to solve this? What am I missing?

A: Solution was found 4 months ago
NVM, I found the solution. I still don't understand, I will read carefully later but for now, it works! ^^
Source:
http://www-users.york.ac.uk/~sjh1/courses/L334css/complete/complete2su6.html
Prolog code changes:
vuelos([A|[]],X,Y,B):-vDirecto(A,X,Y,B).
vuelos([A|[]],X,Y,B):-vEscalaSimple([A|[]],X,Y,B).
vuelos([A|T],X,Y,B):-vDirecto(A,X,Z,D),vEscalaSimple(T,Z,Y,C),suma(D,C,B),reversa(J,X,Z),X\=Y,not(member(A,T)),not(member(J,T)).

Now I can print the solutions to the C# console without problems.


text:
Q: Graph View- X axis not ral-time Refresh - Android studio I'm using Graph View to track and display some numbers in real time.
The problem is that after 80 seconds the x axis is not updated and the size change is performed after 40 seconds from [0-80] to [0-200].
Is there a way to change Xaxis every time a new number after 80 seconds will be tracked?
this is my code:
private Handler mHandler = new Handler();
private LineGraphSeries<DataPoint> series;
private double LastXPoint=2;

@SuppressLint("ClickableViewAccessibility")
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        GraphView graph= (GraphView) findViewById(R.id.graph);
        series = new LineGraphSeries<>(new DataPoint[] {

        });
    graph.addSeries(series);
    graph.getViewport().setMaxX(400);

    DatiRealTime();
}

private final void DatiRealTime() {
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            LastXPoint++;
            series.appendData(new DataPoint(LastXPoint,plotRRG), false, 300);
            DatiRealTime();

        }
    }, 500);

}

How could I achive it?
thanks in andvance

A: I have a feeling your issue is because of calling DatiRealTime inside the run method. Change the method and use the handler instead:
private void DatiRealTime() {
    mHandler.post(new Runnable() {
        @Override
        public void run() {
            LastXPoint++;
            series.appendData(new DataPoint(LastXPoint, plotRRG), false, 300);
            mHandler.postDelayed(this, 500);
        }
    });
}

Hope that helped you.