Difference between ArrayIterator, ArrayObject and Array in PHP

Question: Can somebody explain clearly the fundamental differences between ArrayIterator, ArrayObject and Array in PHP in terms of functionality and operation? Thanks!
Comment: Have you read [ArrayIterator](http://www.php.net/ArrayIterator), [ArrayObject](http://www.php.net/ArrayObject) and [Array](http://www.php.net/Array)? That's probably all the information you'll need.
Answer: Array is a native php type. You can create one using the php language construct array(), or as of php 5.4 onwards []
ArrayObject is an object that work exactly like arrays. These can be created using new keyword
ArrayIterator is like ArrayObject but it can iterate on itself. Also created using new

Comparing Array vs (ArrayObject/ArrayIterator)
They both can be used using the php's array syntax, for eg.
$array[] = 'foo';
$object[] = 'foo';
// adds new element with the expected numeric key

$array['bar'] = 'foo';
$object['bar'] = 'foo';
// adds new element with the key "bar"

foreach($array as $value);
foreach($object as $value);
// iterating over the elements

However, they are still objects vs arrays, so you would notice the differences in
is_array($array); // true
is_array($object); // false

is_object($array); // false
is_object($object); // true

Most of the php array functions expect arrays, so using objects there would throw errors. There are many such functions. For eg.
sort($array); // works as expected
sort($object); // Warning: sort() expects parameter 1 to be array, object given in ......

Finally, objects can do what you would expect from a stdClass object, i.e. accessing public properties using the object syntax
$object->foo = 'bar'; // works
$array->foo = 'bar'; // Warning: Attempt to assign property of non-object in ....

Arrays (being the native type) are much faster than objects. On the other side, the ArrayObject & ArrayIterator classes have certain methods defined that you can use, while there is no such thing for arrays

Comparing ArrayObject vs ArrayIterator
The main difference between these 2 is in the methods the classes have.
The ArrayIterator implements Iterator interface which gives it methods related to iteration/looping over the elements. ArrayObject has a method called exchangeArray that swaps it's internal array with another one. Implementing a similar thing in ArrayIterator would mean either creating a new object or looping through the keys & unseting all of them one by one & then setting the elements from new array one-by-one.
Next, since the ArrayObject cannot be iterated, when you use it in foreach it creates an ArrayIterator object internally(same as arrays). This means php creates a copy of the original data & there are now 2 objects with same contents. This will prove to be inefficient for large arrays. However, you can specify which class to use for iterator, so you can have custom iterators in your code.
Comment: @David What is wrong about the information posted?
Comment: The explanation is about the arrayIterator is all wrong. Read my answer.
Answer: ArrayObject and array are somewhat alike. Merely a collection of objects (or native types). They have some different methods that you can call, but it mostly boils down to the same thing.
However, an Iterator is something else completely. The iterator design pattern is a way to secure your array (making it only readable). Lets take the next example:
You have a class that has an array. You can add items to that array by using addSomethingToMyArray. Note however, that we do something to item before we actually add it to the array. This could be anything, but lets for a moment act like it is very important that this method is fired for EVERY item that we want to add to the array.
class A
{
    private $myArray;
    public function returnMyArray()
    {
        return $this->myArray;
    }

    public function addSomethingToMyArray( $item )
    {
        $this->doSomethingToItem( $item );
        array_push( $item );
    }
}

The problem with this, is that you pass the array by reference here. That means that classes that actually use returnMyArray get the real myArray object. That means that classes other than A can add things to that array, and therefor also change the array inside A without having to use the addSOmethingToMyArray. But we needed to doSOmethingToItem, remember? This is an example of a class not in control of its own inner status.
The solution to this is an iterator. Instead of passing the array, we pass the array to a new object, that can only READ things from the array. The most simple Iterator ever is something like this:
<?php

class MyIterator{

    private $array;
    private $index;

    public function __construct( $array )
    {
        $this->array = $array;
    }

    public function hasNext()
    {
        return count( $this->array ) > $this->index;
    }

    public function next()
    {
        $item = $this->array[ $this->index ];
        this->$index++;

        return $item;
    }
}

?>
As you can see, i have no way of adding new items to the given array, but i do have posibilities to read the array like this:
while( $iterator->hasNext() )
    $item = $iterator->next();

Now there is again, only one way to add items to myArray in A, namely via the addSomethingToArray method. So that is what an Iterator is, it is somewhat of a shell around arrays, to provide something called encapsulation.
Comment: `ArrayObject` implements `IteratorAggregate` and is as such itself (external) iterator.
Answer: Array is array type, ArrayObject and ArrayIterator are built-in classes, with their instances being object type, that partially behave like arrays on syntax and usage level.
For the classes I think the quick idea can be gained from the interfaces they implement:
class ArrayObject implements IteratorAggregate, ArrayAccess, Serializable, Countable {

class ArrayIterator implements SeekableIterator, ArrayAccess, Serializable, Countable {

Both classes implement:

ArrayAccess, so they support array syntax to access values
Countable, so they support count of values, like arrays do
Iterator (though in different ways), so they fit iterable type and can be looped over with foreach and such

One way to look at it, is that classes go through a lot of trouble to work like an array. The point is that being classes, they can be extended and customized.
They would also be inherently interoperable with any code that expects Iterator in general, so the basic use case is just that - wrapping to feed array data into iterator code.
So in a nutshell ArrayObject and ArrayIterator are Do It Yourself arrays (with some implementation differences between the two). Their instances (partially) behave like array type, but as classes they are extensible and as Iterator implementers they are interoperable with code that wants that.
Unless you need a deeply custom behavior and/or Iterator interoperability, sticking with array type is probably the way to go between these.
Notably there are also implementations of collections around, that aim to deliver the class benefits with more friendly abstractions.
Answer:
Arrays

An array in PHP is actually an ordered map. A map is a type that
  associates values to keys. This type is optimized for several
  different uses; it can be treated as an array, list (vector), hash
  table (an implementation of a map), dictionary, collection, stack,
  queue, and probably more. As array values can be other arrays, trees
  and multidimensional arrays are also possible.

The ArrayObject class

This class allows objects to work as arrays.

The ArrayIterator class

This iterator allows to unset and modify values and keys while
  iterating over Arrays and Objects.
When you want to iterate over the same array multiple times you need
  to instantiate ArrayObject and let it create ArrayIterator instances
  that refer to it either by using foreach or by calling its
  getIterator() method manually.
Comment: Sorry I didn't make my question clear - Yes I've read the PHP documentation on the three but it seems to me like they do pretty much the same thing. I was wondering if somebody could explain what the actual difference was between them and why you'd choose one over the other. If this isn't a suitable question to post here then I apologise and please feel free to delete this post!
Answer: array is one the eight primitive types in PHP. Allthough it comes with a lot of built-in utility functions, but they are all procedural.
Both the ArrayObject and the ArrayIterator allow us to make arrays first class citizens in an object oriented program (OOP).
Difference between ArrayObject and the ArrayIterator is that, since ArrayIterator implements SeekableIterator interface, you can do $myArray->seek(10); with ArrayIterator.
Answer: An Iterator is an object that enables a programmer to traverse a container, particularly lists. Various types of iterators are often provided via a container's interface.
There is no much difference between ArrayObject and Array as they represent the same things albeit using different object types.
ArrayIterator is an Iterator that iterates over Array-like objects, this includes all objects that implement ArrayAcess and the native Array type.
In fact, when you foreach over an array, PHP internally creates ArrayIterator to do the traversing and transform your code to look as if typed this,
for( $arrayIterator->rewind(); $arrayIterator->valid(); $arrayIterator-
>next())
{    $key = $arrayIteartor->key();
     $value = $arrayIterator->current();
}

So you can see, every collection object has an Iterator except for your defined collections which you need to define your own Iterators for.
Answer: EDIT:forgot to address the normal array in my answer..
Before you read all this, if your new to php and not trying to do anything tricky just storing values to be used later, then just use the array primitive type.
$data = [1,2,3,4,5];
//or
$data = array(1,2,3,4,5);

Array is the entry point and you should get used to using first them before considering using the others. If you do not understand arrays then you will probably will not understand the benefits of using the others.
( See https://www.w3schools.com/php/php_arrays.asp for a tutorial on arrays. )
Otherwise continue reading...
I have the same question and after coming here decided to just spend some time testing them out and here is my findings and conclusions...
First lets clear up some things that were said by others that I immediately tested.
ArrayObject and ArrayItterator do not protect the data. Both can still be passed by reference in a for-each loop (see down he bottom for example).
Both return true for is_object(), both return false for is_array() and both allow direct access to the values as an array without providing protection for adding values etc. and both can be passed by reference allowing the original data to be manipulated during a foreach loop.
$array = new ArrayIterator();
var_dump(is_array($array)); // false
var_dump(is_object($array)); // true
$array[] = 'value one';
var_dump($array[0]);//string(9) "value one"

$array = new ArrayObject();
var_dump(is_array($array)); // false
var_dump(is_object($array)); // true
$array[] = 'value one';
var_dump($array[0]);//string(9) "value one"

The big difference can be seen in the functions that are available for either of them.
ArrayIteroator has all the functions required to traverse the values such as a foreach loop. ( A foreach loop will call rewind(),valid(),current(),key() methods )
see: https://www.php.net/manual/en/class.iterator.php for an excellent example of the concept (lower level class documentation).

While an ArrayObject can still be iterated over and access values the same way, it does not offer public access to pointer functions.

Object is kind of like adding a wrapper arount the ArrayItterator  object and has public getIterator ( void ) : ArrayIterator that will faciliate traversing of the values inside.
You can always get the ArrayItterator From ArrayObject if your really need the added functions.
ArrayItterator is best choice if you have your own pseudo foreach loop for traversing in weird ways and want better control instead of just start to end traversal.
ArrayItterator would also be a good choice for overriding the default array behavior when iterated over by a foreach loop. eg..
//I originally made to this to solve some problem where generic conversion to XML via a foreach loop was used,
//and I had a special case where a particular API wanted each value to have the same name in the XML.
class SameKey extends ArrayIterator{

    public function key()
    {
        return "AlwaysTheSameKey";
    }
}

$extendedArrayIterator =  new SameKey(['value one','value two','value three']);
$extendedArrayIterator[] = 'another item added after construct';
//according to foreach there all the keys are the same
foreach ($extendedArrayIterator as $key => $value){
    echo "$key: ";//key is always the same
    var_dump($value);
}
//can still be access as array with index's if you need to differentiate the values
for ($i = 0; $i < count($extendedArrayIterator); $i++){
    echo "Index [$i]: ";
    var_dump($extendedArrayIterator[$i]);
}

The ArrayObject might be a good choice if you have more high level complexities with itterators going on for example...
//lets pretend I have many custom classes extending ArrayIterator each with a different behavior..
$O = new ArrayObject(['val1','val2','val3']);
//and I want to change the behavior on the fly dynamically by changing the iterator class
if ($some_condition = true) $O->setIteratorClass(SameKey::class);
foreach ($O as $key => $value){
    echo "$key: ";//AlwaysTheSameKey:
    var_dump($value);
}

One example might be changing the output of the same data set  such as having a bunch of custom iterators that will return the values in a different format when traversing the same data set. eg...
class AustralianDates extends ArrayIterator{
    public function current()
    {
        return Date('d/m/Y',parent::current());
    }
}
$O = new ArrayObject([time(),time()+37474,time()+37845678]);
//and I want to change the behaviour on the fly dynamically by changing the iterator class
if ($some_condition = true) $O->setIteratorClass(AustralianDates::class);
foreach ($O as $key => $value){
    echo "$key: ";//AlwaysTheSameKey:
    var_dump($value);
}

Obviously there are probably better ways to do this kind of thing.
In short these are the major major advantages differences I can see.
ArrayItorator
- lower level ability to control or extend & override traversal behaviors.
VS
ArrayObject
- one Container for data but able to change ArrayIterator class.
There are also other differences you might care to inspect but I'd imagine you wont fully grasp them all until you use them extensively.
It appears both objects can be used by reference in a foreach but NOT when using a custom itterator class via an ArrayObject..
//reference test
$I = new ArrayIterator(['mouse','tree','bike']);
foreach ($I as $key => &$value){
    $value = 'dog';
}
var_dump($I);//all values in the original are now 'dog'

$O = new ArrayObject(['mouse','tree','bike']);
foreach ($O as $key => &$value){
    $value = 'dog';
}
var_dump($O);//all values in the original are now 'dog'

$O->setIteratorClass(SameKey::class);
foreach ($O as $key => &$value){//PHP Fatal error:  An iterator cannot be used with foreach by reference
    $value = 'dog';
}
var_dump($O);

Recommendation/Conclusion
Use arrays.
If you want to do something tricky then,
I'd recommend always using ArrayIterator to start off with and only move on to ArrayObject if you want to something specific that only ArrayObject can do.
Considering the ArrayObject can make use of any custom ArrayIterators you have created along the way, id say this is the logical path to take.
Hope this helps you as much as it helped me looking into it.
Comment: Sorry i forgot to address the standard array.... If you only want to use a collection of values/are new to php / don't understand what I have said / do not require any special tricky stuff,  then just use a standard array. The array is where it begins and you need to get used to using them before you will understand the rest.


AngelCode's Bmfont about widths

Question: In AngelCode's Bmfont is there a way to make it so that all of the widths are equal?
Answer: No. You can't do that with AngleCode's Bitmap Font Generator. You could take the resulting image and location information and run it through a separate sprite sheet editor to pull the images out. Then resize them to the widest character and put them back.
Though, you're best bet is to find an alternative font generator. This isn't really the place to ask for that however. Though I recommend your search term be something like "fixed width bmp font generator", which had some results for me.
Answer: Not using BMFont, no.
If you're willing to pay a subscription fee and are on Mac, Glyph Designer does the best job of any tool out there for building bitmap fonts. Though I'm not sure if they still(?) support grid layout.
If you're desperate for a grid layout i.e. equal widths and heights for each cell, LMNOpc Bitmap Font Builder does this. Unfortunately it's over a decade old and doesn't support unicode the way BMFont does... so you're stuck with Western European. But, it may get the job done for you.

AngelCode's Bmfont about widths


Multiple models with devise + omniauth in Rails

Question: I am using devise + omniauth to enable facebook/linkedin/twitter login on my website.
I have multiple models with totally different roles and both need social logins, I have been using devise+omniauth successfully unitl now as I needed that only for one login.
However now devise gives error saying I cant use omniauthable on multiple models.
I looked around and someone was helpful enough to create this wiki explaining how to use omniauth with devise without omniauthable module.
But I think since I would want to use it for different models, I would have to use different paths for signup, which this wiki doesnt explain.
I looked into omniauth and it has some scarce details about options request_path and callback_path which seem to be relevant, but I couldn't figure out what exactly needs to be done.
Any help will be much appreciated.
EDIT
This is what I have done till now.
<code># omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
    FACEBOOK_AUTH_REGEX = /^\/(model1|model2)\/auth\/facebook\/$/
    FACEBOOK_CALLBACK_REGEX = /^\/(model1|model2)\/auth\/facebook\/callback\/$/

    LINKEDIN_AUTH_REGEX = /^\/(model1|model2)\/auth\/linkedin\/$/
    LINKEDIN_CALLBACK_REGEX = /^\/(model1|model2)\/auth\/linkedin\/callback\/$/

    facebook_callback_path = lambda do |env|
        env["PATH_INFO"] =~ FACEBOOK_CALLBACK_REGEX
    end

    linkedin_callback_path = lambda do |env|
        env["PATH_INFO"] =~ LINKEDIN_CALLBACK_REGEX
    end

    facebook_request_path = lambda do |env|
        match_data = FACEBOOK_AUTH_REGEX.match env["PATH_INFO"]
        if match_data
            "/#{match_data[1]}/auth/facebook/callback/"
        end
    end
    linkedin_request_path = lambda do |env|
        match_data = LINKEDIN_AUTH_REGEX.match env["PATH_INFO"]
        if match_data
            "/#{match_data[1]}/auth/linkedin/callback/"
        end
    end
    provider :facebook, FACEBOOK_ID, FACEBOOK_SECRET, :callback_path => facebook_callback_path, :request_path => facebook_request_path
    provider :linkedin, LINKEDIN_ID, LINKEDIN_SECRET, :callback_path => linkedin_callback_path, :request_path => linkedin_request_path
end

#routes.rb
match "/:model_name/auth/:provider/callback/", :to => "recruiter_omniauth_callbacks#sync"
</code>
And it seems to work fine for linkedin but in facebook I get
<code>{"error":{"message":"Error validating verification code. Please make sure your redirect_uri is identical to the one you used in the OAuth dialog request","type":"OAuthException","code":100}}
</code>
Not Sure why I get this, what are the two urls it says should be same, I think I am using :model_name/auth/facebook/callback/ everywhere so not sure what is the problem it has.
Any help?
Answer: I post an example for a similar case here with other perspective of attacking that problem, hope it helps, regards!


UnicodeDecodeError: 'ascii' codec can't decode error when using render_to_response and dajax.assign

Question: I am new at using django and dajax and I'm having a problem using dajax.assign to load a html file into a div in another html when using non-English characters, when I set the site language to English it works fine, but when I switch to Spanish it does not.
Here is what I am doing:
I tried :
dajax.assign('#setttabs-1','innerHTML','abc')

and it works fine. The div shows the text correctly, but when I try (I am trying to do a translation of the site):
dajax.assign('#setttabs-1','innerHTML','ábcñ')

it generates an exception:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 465: ordinal not in range(128)

I went and did some searching on google and found this:
dajax.assign('#setttabs-1','innerHTML','ábcñ'.decode('utf-8'))

Which again makes it work correctly and it shows all the characters correctly, the problem is that I need to load a template in said div, so the following does not work:
dajax.assign('#setttabs-1','innerHTML',render_to_response('./settings/_change_language.html'.decode('utf-8'), context_instance=RequestContext(request)))

It also throws the exception mentioned above when it tries to load the template. The template has the encoding meta:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

My ajax.py also starts with:
# coding: utf-8

How do I tell dajax to treat this file as utf-8 so it can render it correctly?
Is there a more practical way to do what I am trying to do here?
I feel like I'm missing something really simple, but I can't figure it out.
Thanks in advance for any help you can provide.
Answer: I changed:
dajax.assign('#setttabs-1','innerHTML',render_to_response('./settings/_change_language.html'), context_instance=RequestContext(request)))

to:
dajax.assign('#setttabs-1','innerHTML',render_to_string('./settings/_change_language.html'.decode('utf-8'), context_instance=RequestContext(request)))

and now it works perfectly. Don't know why though. Hope this will help someone out there.


Employee share purchase plans,exit options, IRS

Question: I am investigating the options for what to do with an Employee Share Purchase plan upon retirement that do not result in having to pay a big tax to IRS. I understand that I will have a taxable event if I take constructive receipt of the shares but I believe I can also transfer them to a 401k or some other type of arms length plan.....  Looking for some detailed information on choices.
Comment: To my understanding ESPP exist outside of retirement plans. So there isn't a way to avoid the taxable event. If you have access to your plan documentation, you should quote relevant parts, or describe your ESPP in more detail.
Comment: How are you defining "big tax"? Have you already bought shares and just wanting to avoid paying tax on selling them? The only thing you'd pay tax on is the _gain_ from the time you bought them - the discount you received when buying them should have been taxed as income at that time.
Answer: ESPP are typically bought at a discount, the discount is taxed as ordinary income. The remaining gains are taxed as long term cap gains when held for over 2 years. Depending on your income during retirement, that can be 0%, up to 15% maximum. That's not too bad.
Comment: This answer is very incomplete. Shares are taxed as long term capital gains after 1 year, not 2. Two years are the point where sale becomes a qualifying disposition as opposed to a disqualifying disposition (which this answer does not attempt to distinguish between). You also don't mention when the 2 years start (hint: not when the shares are purchased)
Comment: If you post a complete, accurate answer, I'd gladly delete mine. I retired in 2012, and have clearly forgotten the full details of ESPP.


How to render Hair in Renderman

Question: I am new to Renderman and I can't figure out how to render hair. I tried finding info but I can only find how to do it in Maya which doesn't have the same workflow. I found this tutorial https://www.youtube.com/watch?v=Bfbu6IH1XRQ&t=314s but it is in spanish. I tried following along and it seems like I did everything right, but still no luck.
Answer: Ok I guess something was going on with "IT". After restarting it works the same as Cycles.
Just a glitch.

How to render Hair in Renderman


Searching for a phrase in hard-wrapped text

Question: When searching for a phrase in hard-wrapped text, one wants newlines to be treated as spaces.  Can one have that happen?  Saying /the\_sphrase\_sI\_sseek is a bit awkward.
Comment: See this answer: http://unix.stackexchange.com/a/11848 for a custom function (and command) that does what you want. Adjust to your taste.
Comment: The problem with this solution is that it can't make use of incremental search.  But `cmap  \_s\+` works well (in nvim).
Comment: Whatever floats your boat is ok :)
Answer: You can automatically replace a space with \_s when searching with:
cnoremap <expr> <Space> index(['/', '?'], getcmdtype()) > -1 ? '\_s' : ' '

Because cnoremap is applied to all the commandline (and not just search), we need an expression mapping to check if we're searching or in another commandline mode (e.g. :).

Because you probably don't always want to search like this, you can trigger this newline-insensitive mode with something like:
fun! StartNewlineSearch()
    cnoremap <expr> <Space> index(['/', '?'], getcmdtype()) > -1 ? '\_s' : ' '

    " Unmap both <Space> and this same mapping when pressing <CR>
    cnoremap <CR> <CR>:cunmap <lt>Space><CR>:cunmap <lt>CR><CR>:cunmap <lt>Esc><CR>

    " And the same for <Esc>
    cnoremap <Esc> <Esc>:cunmap <lt>Space><CR>:cunmap <lt>CR><CR>:cunmap <lt>Esc><CR>
endfun

nnoremap // :call StartNewlineSearch()<CR>/

When pressing // it maps <Space> to \_s, and it unmaps it when pressing <CR> or <Esc>.

You could also map this to a key to toggle the two "modes":
let g:search_mode = 0
fun! ToggleMode()
    if g:search_mode == 0
        cnoremap <expr> <Space> index(['/', '?'], getcmdtype()) > -1 ? '\_s' : ' '
        let g:search_mode = 1
    else
        cunmap <Space>
        let g:search_mode = 0
    endif
    return getcmdline()
endfun

cnoremap <C-@> <C-\>eToggleMode()<CR>

Answer: The other answser is certainly great.
However, I've found that it has one weakpoint, which is not necessarily negligible: if you abort the special search, i.e. you press //(changed your mind)Escape, you'll get E385: Search hit BOTTOM without match for:    ; afterwards you'll get the same error even for plain /Escape, which is a bit annoying.
Probably the fix is easy, but I wanted to explore other ways of solving the same problem, so I came up with another solution:
fun! EnableAutocmdToUnmapSpace()
  augroup UnmapSpaceAug
    autocmd!
    autocmd CmdLineLeave,CmdWinEnter / cunmap <space>
    autocmd CmdLineLeave,CmdWinEnter \? cunmap <space>
  augroup END
endf
fun! s:ctrlSMakesSpaceEOLFriendly()
  augroup UnmapSpaceAug
    autocmd!
  augroup END
  cnoremap <expr> <silent> <C-S> execute(':cnoremap <lt>space> \_s\+\| call EnableAutocmdToUnmapSpace()')
endf
augroup EOLFriendlySpace
  autocmd!
  autocmd CmdLineEnter,CmdWinLeave / execute(':call s:ctrlSMakesSpaceEOLFriendly()')
  autocmd CmdLineEnter,CmdWinLeave \? execute(':call s:ctrlSMakesSpaceEOLFriendly()')
  autocmd CmdLineLeave,CmdWinEnter / cunmap <C-S>
  autocmd CmdLineLeave,CmdWinEnter \? cunmap <C-S>
augroup END

It is slighly longer, but it doesn't suffer the issue I described above. And it works differently:

when you start your search with /, Space behaves normally,
but if you hit Ctrl-S, then

Space is cnoremapped to \_s\+,
and an autocmd is activated to cunmap it;

quite importantly, before mapping Ctrl-S, we first clear the autocmd of point 2 above, because we don't want to cunmap <space> on subsequent searches where we don't hit Ctrl-S.
leaving the search cunmaps Ctrl-S.
CmdWinEnter is treated as CmdLineLeave and CmdWinLeave as CmdLineEnter, for the reason explained here; it is fundamentally depending on an implementation detail, but that's necessary to deal with the case that you hit / from within the command window, e.g. if you do /Ctrl+F/ from normal mode.
To make things work for ?, the autocmd needs that you write \?, not ?, as explained here.


Exposing SQL Server database to internet

Question: I have a POS application that is used by a business. The application has a SQL Server backend and there's a local machine that acts as a server for the DB. The other computers within the office connect to this server. This happens over TCP/IP. I am wondering if it is possible and/or how difficult it would be to expose this database and allow read access to an offsite application. Essentially I want to be able to pull data from a local database into AWS on a regular automated schedule. If anyone has any ideas that could help point me in the right direction, that would be great. This is not an application I'm a developer of, so I don't have access to the application code or anything like that. I guess what it boils down to would be the equivalent of an off-site backup. Thanks in advance!
Comment: You're trying to have SQL Server push backups to some remote place? Why does a user have to connect to it and intervene? Just schedule the backups, then SQL Server just needs access to that location, instead of giving the entire world access to SQL Server. If you need to interact with it and you can't VPN or add your IP to a firewall's whitelist then put a simple app in front of it (web app or API).
Comment: Don't expose your database to the internet. Put it behind a firewall and set up a VPN which can then be used to connect to it.
Comment: Expose probably was the wrong word. I guess what I'm really looking to do is create offsite backups automatically. I would also need to be able to remotely configure the access. I suppose I could remotely configure a VPN, but I would need to be able to automatically connect to the VPN, access the DB and create the backup on an ongoing basis without any user interaction.
Comment: You could set up a site to site VPN that is always active, that way you don't have to connect/disconnect all of the time.
Answer:
what I'm really looking to do is create offsite backups automatically

SQL Server can natively backup to Azure Blob Storage.  See Backup to URL.
But whatever offsite storage you use, the right solution is for SQL Server (or code running on the local network) to push the data out.  Not have code running elsewhere pull it out.
That way you don't need to open anything to the internet, or use a VPN.  You just need to open outbound ports, to connect to the internet.
Comment: I'm accepting this as the answer because I believe it would be the best option of those offered. I've since learned that I won't be able to get the credentials to access the database. I'm now looking at pushing a bak file that's created up to S3 and using that to populate an RDS instance.


Phase 10 - Who goes first?

Question: I've played Phase 10, the card game, for years, but recently I started playing the android app version. It has always been my understanding that the dealer role rotates to the left after each hand, but, in the app, I can't figure out how they're decided who goes first each round. I've played one-on-one games, and the same player will go first 3 or more times in a row. Anyone have an idea on this?
Answer: In most rules given for the game it is stated that one player is chosen to be the dealer (source 1, source 2, source 3.)
There is no mention of the dealer role going to another player in those.
Wikipedia says:
One player is chosen to be the dealer (alternately, the deal can rotate to the left after each hand).(source)
This seems to indicate that having the deal rotate is an alternate rule or houserule rather than an official rule.

Phase 10 - Who goes first?


What is the difference between `Home page / Archieves` and the page set as homepage?

Question: In the image below, I set the page Welcome! as my homepage. There is no link to that page, and there is only one way to go to the homepage: click on the banner. However, there is two different items referring to the homepage in the stat. Do you know what are the differences between them?
Answer: "Home page / Archives" stat doesn't necessarily represent the number of views of a single page, although it might if your front page is a static page. The meaning of, and reason for, the designation was briefly addressed by staff member macmanx, shortly after WordPress evidently changed this stat from "Home page" to "Home page / Archives," in an April 2012 topic titled "My stats.". macmanx said,

This is an intentional change. Date and category archive listings are actually counted the same as the Home Page when the home page is set to display posts.
Therefore, what you originally saw for your Home Page total was a collection of Home Page views and Archive views, which is why we changed the title to the much more accurate "Home Page / Archives".
Comment: but how can visitors visit the `Welcome` page when the only way to visit it is to click on the logo of the website to visit the homepage?


Raspberry Pi Voltage Input

Question: I know Raspberry Pi can get 4.75-5.25 Volts as input but will it be OK with 5.3V?
Comment: Anything above 6v will destroy it. I think 5.3v should work just fine.
Comment: The voltage may drop on load, ie, when you connect it to the Pi. Anything above may be more dangerous.
Answer: The supply voltage is 5V ±5%. This allows some variation and either extreme is not ideal. 5.3V is +6% (why do you think this is the input) and is unlikely to cause any damage as the Pi has over voltage protection, but is unlikely to be triggered (depending on the tolerance of other components). Potentially this may increase current and increase the risk of the poly fuse opening.
Comment: Thanks a lot.. i bought Samsung OEM charger that supply 5.3V and 2A (that what it's says on it..) should i be afraid to use it?
Comment: Many modern phone chargers may not work! They are not designed to supply a constant voltage, but to rapidly charge batteries, and the voltage can fall as low as 3.6V.
Answer: Your Pi will be perfectly fine.  The Pi itself will be fine up to just less than 6V.
The 5V +/- 5% range is really to protect attached USB devices not the Pi.
I regularly measure 5.7V on my Pi's power supply.
Comment: Thanks a lot!!! .. So ARE U SHURE 5.3V 2A will be good? i have a OEM Samsung charger and cable ( not a cheape chinese replica)
Comment: Absolutely, as long as it is accurately labelled.  When you can measure the voltage at the Pi.

Raspberry Pi Voltage Input


CPU Performance

Question: Please, help me to understand the mathematics behind the following formula of CPI. Why do we calculate CPI the way it's done on the pic?
Comment: What's CPI? Please make your question self-contained by defining the relevant terms, and please replace the image by text so your question is searchable and accessible to partially sighted people.
Comment: What self-study have you done?  CPI is explained in many architecture textbooks.  There is little point in us repeating that explanation here.  We expect you to do a significant amount of self-study before asking, so you can ask a more informed question....
Comment: It looks like it is just the average number of cycles per instruction.
Answer: CPI is the average number of cycles per instruction. The CPI is the expected value of $C(R)$, where $R$ is a random instruction, and for an instruction $r$, $C(r)$ is the number of clock cycles that $r$ takes. The table gives you the distribution of $R$ and the function $C$, from which you can calculate the expectation according to its definition (which matches the intuitive concept of average number of cycles per instruction), namely
$$ \mathbb{E}[C(R)] = \sum_r C(r) \Pr[R = r]. $$
That's the computation detailed in the answer.
Answer: CPI is a statistical calculation used to determine how many cycles some algorithm (series of instructions) will take. It is not really CPU performance by itself. If you take the identical algorithm and calculate it's CPI on multiple CPUs then those values can be used to compare CPUs although it will not be a strong indication of a CPUs performance due to built in optimisations in CPUs which may skew the results and not really show the highest performing CPU.
CPI is better for comparing different algorithms used to work out similar values on the same CPU. Rather than looking directly at an algorithm's complexity one could calculate its CPI which can be useful when only a rough estimate is needed and the algorithms in question are very complex in nature and therefore their complexities and the amount of computational time they take to complete is very difficult to work out.
CPI is however a statistical result on experimental data which within computer science, is quite unreliable. An analytical approach would be much better in determining a much more reliable result although  this may be too complex to figure out or take too much time. A way to make CPI more accurate would be to take multiple CPI values for the same algorithm and use different statistical calculations like the mean to work out a more accurate result.

CPU Performance


CREATE/ALTER INDEX permission

Question: How can I grant a user create/alter index permissions without giving db_ddladmin? I want them to have the minimum permissions possible.
Answer: The minimum permission to create/alter index can be easily found in corresponding BOL articles CREATE INDEX (Transact-SQL) and ALTER INDEX (Transact-SQL):

Requires ALTER permission on the table or view.

This means you can grant alter table on every table of interest that already exists.
If you don't want to grant so granular permissions you can grant alter on schema(s) where your table(s) reside, this will assure that the user would be able to create/alter indexes on any future table/view.

CREATE/ALTER INDEX permission


What is apt-cache used for?

Question: Can anyone please define what exactly the APT cache is?
Comment: [`apt-cache`'s manual](http://manpages.ubuntu.com/manpages/precise/en/man8/apt-cache.8.html), maybe this can help out a bit, while waiting for someone to give you a better answer?
Comment: Are you referring to the terminal command 'apt-cache'?
Comment: The heading says `apt-cache` and not "APT cache", then also there's the `command-line` tag and also the only question to date which describes the command is almost as much upvoted as the question, so I must suppose the question refers to the command. But what is the "APT cache" used for? That's a very legit question. I asked it [here](https://askubuntu.com/questions/1321028/whats-the-point-of-keeping-packages-in-apt-cache).
Answer: apt-cache is a command to manipulate and obtain information from the packages at apt's cache.
It creates a repository of information about the packages that are avaiable from your sources list, so this way you can search packages and information about it.
Let's say you want to install a chat program but you don't know the name of a package for it.
You would open a console and type:
sudo apt-cache search chat
This would return a list of packages available and that refer to the word chat.
Typical operations with apt-cache:
apt-cache add

Adds a package file to the source cache.
apt-cache gencaches

Builds both the package and source cache
apt-cache showpkg

Show some general information for a single package
apt-cache stats

Show some basic statistics
apt-cache dump

Show the entire file in a terse form
apt-cache dumpavail

Print an available file to stdout
apt-cache unmet

Show unmet dependencies
apt-cache check

Check the cache a bit
apt-cache search

Search the package list for a regex pattern
apt-cache show

Show a readable record for the package
apt-cache depends

Show raw dependency information for a package
apt-cache pkgnames

List the names of all packages
apt-cache dotty

Generate package graphs for GraphVis
Don't forget to add package name after the commands listed above.
Source1
Source2

What is apt-cache used for?


How can I eliminate a 4-way switch and still have two 3-way switches operating the lights?

Question: I have two 3-way switches and one 4-way switch. I eliminate the 4 way and want the two 3-way switches to still turn on and off the lights. So I went up in the ceiling and connected the one switch to the other color to color and I have constant power. The lights will not turn off from the switches. What do I do? The one switch has a feed from power and a switch leg going to the light. The other switch that was going to the 4-way I'm using that 3 wire to connect straight to the other switch where the feed comes in. Both 3 way wires red white black ground. So how can I hook them up so both switches operate the lights?
Comment: Since 3-pole switches are used for industrial 3-phase power, and 4-pole switches are used for generator interlocks for same power, I rather strongly suggest you said "pole" when you meant "way".  I have edited accordingly; if I'm wrong feel free to rollback my edit.
Comment: Sounds like *maybe* you removed a 3-way, not a 4-way. Can you upload pictures of each of the switches showing all currently connected wires, *plus* the original (removed) switch and the wires that are currently in that box (however they are currently connected).
Comment: You had 4 wires to the 4 pole switch, how were they connected and how did you connect them without the switch? The other 2 switches were working correctly with the 4 way in both conditions.
Answer: Nothing easier.

You have 2 travelers.  The 4-way either sends them through straight, or exchanges them.
So take 1 traveler off a brass screw, 1 traveler off a black screw, then splice them together to each other.
Repeat with the other traveler.  And done.


Does hyperparameter tuning of Decision Tree then use it in Adaboost individually vs Simultaneously yield the same results?

Question: So, my predicament here is as follows, I performed hyperparameter tuning on a standalone Decision Tree classifier, and I got the best results, now comes the turn of Standalone Adaboost, but here is where my problem lies, if I use the Tuned Decision Tree from earlier as a base_estimator in Adaboost, then I perform hyperparameter tuning on Adaboost only, will it yield the same results as trying to perform hyperparameter tuning on untuned Adaboost and untuned Decision Tree as a base_estimator simultaneously, where I try the hyperparameters of both Adaboost and Decision Tree together.
Answer: No, generally optimizing two parts of a modeling pipeline separately will not work as well as searching over all the parameters simultaneously.
In your particular case, this is easier to see: the optimal single tree will probably be much deeper than the optimal trees in an AdaBoost ensemble.  A single tree (probably) needs to split quite a bit to avoid being dramatically underfit, whereas AdaBoost generally performs best with "weak learners", and in particular often a "decision stump", i.e. a depth-1 tree, is selected.
Comment: When we use another classifier as a base estimator for AdaBoost e.g. `AdaBoostClassifier(base_estimator = dtree_model)`, do we not use AdaBoost's own `n_estimators` and `learning_rate?` params?


Why when opening parachute, the man doesn't go upwards?

Question: If an object is moving at terminal velocity and then opens the parachute, the air resistance is higher than the weight so why doesnt he go upwards.
Comment: You may have seen film or video in which a free-falling sky diver pulls the rip cord and suddenly seems to shoot up into the sky.  But that's only because the one who pulled the rip cord suddenly was falling much more slowly than the skydiver who was holding the camera.  From the camera's point of view, the one who pulled the rip cord seems to be going up, but from the point of view of a person standing on the ground, they're both still falling down.
Comment: This misunderstanding is tightly coupled with that in [your previous question](https://physics.stackexchange.com/questions/404170/why-object-in-terminal-velocity-doesnt-stop). They are both resolved by understanding that force is related to acceleration and not to velocity. So, if you are not clear on the exact relationship between acceleration and velocity it would be worth your time to focus on that difference for a while and then re-visit these force questions after you have mastered the kinematics issue.
Answer: Because force and motion aren't always in the same direction. Suppose you slam on the brakes in your car. Your car doesn't instantly go backwards. Instead, it accelerates backwards.
When a skydiver opens their parachute, they accelerate upwards. This is not the same as saying the move upwards.
Acceleration is a change in the velocity. So the amount of downward velocity the skydiver has gets smaller and smaller, until they reach a new terminal velocity. During this time, the change in their velocity is upwards.
If we illustrate the skydiver's velocity in red and force and acceleration in blue, we might get something like this:

Time goes from left to right. The skydiver opens their parachute and feels and upward force. It pushes upward on them, but isn't enough to completely stop them and make them move upward. Instead, it just slows them down a bit as they continue falling downward. They keep feeling an upward force (while moving downward) that slows them until they get to a new terminal velocity.
Note that this picture shows the velocity arrows next to each other in space; in reality, the skydiver gets lower and lower in space as we move to the right, but that was harder to draw.
Comment: In your diagram, why doesn't the acceleration decrease to zero as the velocity decreases? Instead, it seems to increase.
Comment: That's because it's just a rough sketch; it's not intended to show as much detail as you're asking about.
Answer: Force can oppose motion. Parachutes provide upward acceleration but the acceleration downwards is much larger in the bigger picture. This is not the same as saying the move upwards; parachutists acceleration > acceleration due to parachutes.
Acceleration is a change in the velocity**
downward velocity eventually decreases to match air resistance and they reach a terminal velocity phase where both upward and downward forces are equal and the parachutist will fall at the same rate.
unless there's an upward force that's much larger than the downward force on a stationary object, the object will not move upwards.
x
Answer: Something going forward will have to slow down before going backward. For example a boat driving forward at 15 km/h has to slow down to 0 km/h before it starts going backward. Same thing for the man. However as he slows down the upward force, in this case drag, produced by the chute falls, meaning it will eventually drop to a level where drag = gravity, and the man will fall at a constant rate. Therefore the man will never begin rising, unless there is some external force like an updraft or a gust of wind.
Answer: Summing it up,
It's my conclusion that:
1) If an object is at rest, a car for instance; and a force is applied it will accelerate until the force is applied. Now we stop exerting the force and it will continue its motion with net force but since in our world friction force is there; it's impossible.
2) Secondly, parachutists don't move upwards or backward because the force is not that large enough.
As said earlier by referring to a car, first it decelerates and if the Force is big enough it moves in the opposite direction. That's why the parachutist's speed keeps on decreasing until Weight=Air Resistance.
I came up with this conclusion.
Anyone please check it and rectify if needed.
I want to make sure, it's correct.
Thanks
Comment: Hey Abdullah, welcome to Physics Stackexchange! Please try to re-order your ideas and rephrase them, it is very hard to follow your thoughts...
Comment: In case you are interested if your way of thinking is correct, here is a short video about parachuting and the corresponding forces: https://www.youtube.com/watch?v=BpXlz4XWpKA Note that the forces acting upon the body are only connected by Newton's second law to the acceleration and not the velocity.
Comment: @2b-t Thanks, I really like this forum. Secondly, I've got the answer to my second point for the parachutists.... But about my first point,could you please clarify:
Comment: @2b-t Thanks, I really like this forum. Secondly, I've got the answer to my second point for the parachutists. But about my first point, could you please clarify:  All I'm saying is that, If an object for e.g: a car is at rest and we exert a force on it; it will accelerate until we keep applying that force,10N let's say. But when we stop applying10 N Force, it should continue its motion with zero acceleration such as in Vacuum but since friction Force is there on earth, the car will come to a halt. I hope I was able to make an explicit statement this time!
Comment: You can learn a lot here by reading and contributing, there are a lot of smart people around here. The way you put it now is correct but your initial comment is very hard to understand. Try to rephrase it, add formulas (such as Newton's second law) and format them with MathJax (a special version of Tex very similar to LaTeX) https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference and add links by typing [link description...] (https://mylink.com/) without the space in between. Sometimes a bit of well written math is easier understood than a long text...


Ten types of stamps

Question: The country Dalgonia issues stamps of only ten different denominations: $134$, $135$, $136$, $137$, $138$, $139$, $140$, $141$, $142$, and $143$ cents.
What is the largest amount of cents which cannot be made up with a combination of these stamps?
Comment: @JonMarkPerry if I'm not mistaken 5,2017,2018,2019,2020,2021 is the smallest set of numbers that has 2016 as an answer
Comment: what stamps give 2016 as the answer?
Comment: @Jon Mark Perry: Since 2017 is prime, there is no interval of stamp values that gives 2016 as the answer.
Comment: @Gamow well, one could say that the stamps 2017,2018,...,4032,4033 have 2016 as an answer
Comment: @Ivo Beckers: Yes, you are right. (But this is a degenerate solution, and somewhat boring.)
Answer:
 Answer = 2009

None of the numbers less than 134 can be obtained with this set of stamps.
All of the numbers in the range 134-143 can be obtained with a single stamp.
None of the numbers between 143 and 2 * 134 can be obtained with a combination of these stamps.
More generally, numbers that lie in the range between (n-1)143 and n(134) cannot be obtained.
Because the stamps are in increments of 1, every value between 134n and 143n can be obtained.

 So we need to discover where 134 * n is less than or equal to 143 * (n-1)
 Solving 134n = 143n - 143
 Gives 143 = 9n
 n=15.89
 So , for who number values of n greater than 15, there is no number that exists between the highest number obtainable with a combination of n-1 stamps and the lowest number that can be obtained with n stamps. All values above this can be achieved.
 We need the highest number that exists in the gap below this, i.e. 15 * 134 -1
 Answer = 2009
Answer: What your basically asking is

 What is the Frobenius Number of these numbers: 134,135,136,137,138,139,140,141,142,143

Thankfully, Wolfram Alpha has a built-in function for that

 https://www.wolframalpha.com/input/?i=FrobeniusNumber%5B%7B134,135,136,137,138,139,140,141,142,143%7D%5D

So the answer is

 2009
Answer: I'm not sure if this even qualifies as a puzzle; it's more of a math problem. There's a simple formula given on Wikipedia for finding the Frobenius number for a given arithmetic sequence.

We can now substitute the values $a=134$, $d=1$ and $s=9$. Using it, we get the answer 2009 as already given by @IvoBeckers
Comment: +1. it's better than my answer because you actual use a formula. And I agree that the question might be off-topic
Comment: You can also solve this by using your brain. It is a puzzle for children of age 15, posed in the year 2009.

Ten types of stamps


Are there any video players with commercial skip for Android?

Question: I have a TiVo Series 3 and the TiVo Desktop Plus software, which I use to convert shows for playback on my iPod Touch.  I'd love to find a video player that would have 30 second/commercial skip for an Android phone (future purchase).  It's hard for me to adjust the slider on the video player with that degree of precision.
Answer: It's not an actual 30 second button, but MX Player has a feature to slowly adjust forward and backward (a full screen swipe typically does ~45-60 seconds), making it very easy to precisely navigate a video.


Sinking deep down the ocean in Anno 2070 - Deep Ocean

Question: In Anno 2070 - Deep Ocean, I cannot scroll down to sink under sea level, even though I can see the shadow of an underwater base with submarines hanging around. Do I need to wait for some event to be able to sink underwater? Or do I have a faulty copy of some kind?
Answer: You need to unlock either eco engineers or tycoon engineers before having access to trimaran and SAAT tech. You will also need Deep Ocean DLC to have access to underwater platform. Check this post.


Message queue, c++ multi thread

Question: I looking for cross platform multithread message queue implementation on c++ (not slot/signal) . Better if it based on subject-observer pattern.
Comment: On what platform? What have you tried doing? Help us help you.
Comment: Windows, Linux platform.
I am creating video server(no gui).
Answer: ZeroMQ looks like it may be what you are looking for.
It is well documented with lots of examples, such as this one: http://www.zeromq.org/blog:multithreaded-server , which may be what you are trying to implement.
Answer: Take a look to the "ISL" open source project (stands for an "Internet Server Library", C++), which SVN-repository is located on http://svn.storozhilov.com/isl/ - isl::AbstractMessageBroker class is a good candidate for a basement of your job. This is quite simple but extensible skeleton for any message broker subsystem (DBus, JMS, AMQP, etc.). Each client is served by 2 threads from the pre-started thread's pool: one is for receiving message from the transport and processing message and another is for sending message to transport. So, actually in order to implement your messaging system you have to override at least following three virtual methods:
<code>    isl::AbstractMessageBroker::receiveMessage(...);
    isl::AbstractMessageBroker::processMessage(...);
    isl::AbstractMessageBroker::sendMessage(...);
</code>
Example of use is in trunk/examples/EchoMessageBroker directory. Responses client with echoed message, terminates connection on "bye\r\n" message, terminates itself on SIGINT.
Answer: You can try out Apache ActiveMQ. http://activemq.apache.org. Quite robust.We use it for a FIX messaging platform, quite responsive and easy to configure also.
Answer: Have a look at Intel's Open Source lib Threading Building Blocks. They are cross-platform and last time I looked they had lock-free containers.

Message queue, c++ multi thread


iPad Air 2 microphone not working since iOS 11 update

Question: Is it a common problem for iPad Air 2 microphone to not work? My method of communication is dictation, so the microphone is critical. It works on my synced iPhone 6.
Comment: What indicates it's not working? What steps towards fixing this issue have you tried?
Comment: All of them. The only thing that allows dictation is Siri. Even that is a problem because it flips to Siri keyboard seemingly on its own.
Comment: I tried every possible setting and preference in my disposal through iPhone I normally use.  I'm pretty good at  problem-solving  and I don't know what happened. The iPad is never prompting for permission to use microphone.
Comment: Which application are you using to confirm the mic isn't working?
Comment: BTW  thanks for answering. Didn't expect such a quick response and petering out so may continue tomorrow.  No intention to ignore.
Comment: Problem solved! Tunneled deep into recesses of settings. Toggled potential culprit off/on, careful to tap DONE and SAVE  all the way back to Settings opening screen. Turned phone off/on. Must've fixed a glitch, as I did not change any settings. After reading a  settings comment on a settings conflict, a vague idea occurred to me.  Who knows with the glitch came from? Probably an iOS  came w one of the last 7 or so updates of Apple's iOS. - not an unfounded statement if you read update details & experience the "said update's" effects on your device.
Comment: Cool! Go ahead and add that as an answer!
Comment: BTW  I took screenshots as for visual clarity & will gladly post upon request.  Thought it best to avoid intimidatingly long "solution"  unless  requested.
Comment: Posting solutions is always good if you can!
Answer: Backup the iPhone and then restore to factory. Then as you set up the iPhone restore the backup.
If the issue persists. Restore again and then dont restore the backup, set up the phone as is. If it works then your files have corrupted the audio. If it doesnt work, then it needs to be repaired. Take it to the Apple Store for repairs.
Comment: Thank you. I figured that was next but hated to admit it. Where do you suppose I'd  most likely pick up corrupt files?
Comment: I went ahead and posted the question on protecting my iPhone and iPad separately to avoid confusion.
Comment: Anything can be the culprit. More than likely its a stock OS issue. Backing up and restoring the backup will let you know if it persists.
Answer: My iPad Pro's microphone recently stopped working almost completely – "almost" because you could still recognise loud sounds in a recording, but it was effectively unusable. The "Hey Siri" setup process wouldn't work etc.
The cause turned out to be mechanical: there was dirt stuck in the tiny microphone hole. I carefully dug it out with a needle and the microphone returned to its original performance.
The microphone's location depends on your iPad model. On my 9 inch Pro, it's a tiny (almost invisible) hole exactly in the middle of the top frame (the one with the power button).
Comment: Where'd you get the electron microscope ? lol


Strong Induction on Two Variables

Question: I know that for proving some $P(m,n)$ we can apply induction as follows: prove some base case $P(m_0, n_0)$, an inductive step given $P(m-1,n)$ to show $P(m,n)$, and an inductive step given $P(m,n-1)$ to show $P(m,n)$. However in a proof I am working on I need a stronger hypothesis. In particular, in order to show $P(m,n)$ given $P(m-1,n)$ I also need to assume that $P(m-1,n-k)$ holds for $1\leq k\leq n$ too, a strong induction of sorts. Is this logically sound, and if not what is the issue with it? If it is sound, how much stronger can we get?
Comment: As long as you prove  enough "base cases", this is fine.  If you like, think of it as doing the usual sort of induction on the sum, $S=n+m$.
Answer: One way to do this is to prove $P(1,n)$ for all values of $n\geq1$.  Then make the induction hypothesis that for some $m>1$, $P(m,n)$ is true for all values of $n\geq1$, and prove that $P(m+1,n)$ is true for all values of $n\geq1$.  This proves that that $P(m,n)$ is true for $m\geq1$ and all values of $m$.  In proving that $P(m+1,n)$ is true for all $m,n\geq1$, you are, of course, free to use any sort of induction you choose.
Comment: @ShivashriganeshMahato That isn't what I said, and I think you need to state it more carefully.  Suppose we've proved $P(1,n)$ fot all $n$.  How do you conclude that $P(2,1)$ is true?  There is no $1\leq k\leq 1$ so your proof must include a proof that $Pm,1)$ is true for all $m$.  After that, I think your argument works.  (I still think that the approach I outlined is conceptually simpler).
Comment: Ah so to clarify, by proving $P(1,n)$ for all $n$, then given $P(m-1,n-k)$ for all $1\leq k\leq n-1$ showing $P(m,n)$, we've successfully proven $P(m,n)$ for all $m,n$?
Answer: Given $P(m, n)$ you can treat $P(m-1, 0), P(m-1, 1), \cdots P(m-1, n)$ as accessible to your induction step, but you can also go further and take all pairs of natural numbers that are smaller lexicographically, which includes statements of the form $P(m-1, \cdot)$.
I think it would help to explicitly pick a set, explicitly pick a partial order on that set, prove that that partial order is a well-order, and then proceed from there.

You can perform induction on any set equipped with a well-order.
Let's define $\le$ on pairs of numbers as follows. This is the lexicographic order on $\mathbb{N} \times \mathbb{N}$.
$$ (a, b) \le (c, d) \;\;\text{iff}\;\; a \le c \lor (a = c \land b \le d) $$
This order is kind of interesting. There are no infinite descending chains, but if we start with $(1, 0)$ in our chain, we can make an arbitrarily long descending chain by picking the next element to be $(0, n)$ for some $n$ in $\mathbb{N}$. The next next element to be $(0, n-1)$ and so on.
In order to convince ourselves that there are no infinite descending chains, we notice that if we start on the row $(n, \cdot)$ then we must reach the row $(n-1, \cdot)$ in finitely many steps. And if we are on the row $(0, \cdot)$ we must reach $(0, 0)$ in finitely many steps. The sum of finitely many finite numbers is finite.
The strong induction schema looks like this. Here, $\implies$ is a low-precedence version of $\to$. $\vec{0}$ is the minimum element of $\le$. Here, $a < b$ is an abbreviation for $a \ne b \land a \le b$.
$$ \bigg((\forall u < x \mathop. \varphi(u)) \to \varphi(x)\bigg) \land \varphi\!\left( \vec{0} \right) \implies (\forall u \mathop. \varphi(u))  $$

Strong Induction on Two Variables


Difference between Web API and Web Service?

Question: I have heard a lot about Web Services and Web APIs, is there any difference between them or are they the same?
Comment: See also StackOverflow: [What is the difference between a web API and a web service?](http://stackoverflow.com/questions/19336347)
Answer: Web Services - that's standard defined by W3C, so they can be accessed semi-automatically or automatically (WSDL / UDDI). The whole thing is based on XML, so anyone can call it. And every aspect of the service is very well defined. There's parameters description standard, parameter passing standard, response standard, discovery standard, etc. etc. You could probably write 2000 pages book that'd describe the standard. There are even some "additional" standards for doing "standard" things, like authentication.
Despite the fact that automatic invoking and discovery is barely working because clients are rather poor, and you have no real guarantee that any service can be called from any client.
Web API is typically done as HTTP/REST, nothing is defined, output can be for eg. JSON/XML, input can be XML/JSON/or plain data. There are no standards for anything => no automatic calling and discovery. You can provide some description in text file or PDF, you can return the data in Windows-1250 instead of unicode, etc. For describing the standard it'd be 2 pages brochure with some simple info and you'll define everything else.
Web is switching towards Web API / REST. Web Services are really no better than Web API. Very complicated to develop and they eat much more resources (bandwidth and RAM)... and because of all data conversions (REQUEST->XML->DATA->RESPONSE->XML->VALIDATION->CONVERSION->DATA) are very slow.
Eg. In WebAPI you can pack the data, send it compressed and un-compress+un-pack on the client. In SOAP you could only compress HTML request.
Comment: In reality I hear people refer to both SOAP and REST as "web services". Web API does tend to be REST though.
Comment: thanks @Slawek, u explained it better..and thanks for the example too...
Comment: @Slawek, the way you said it 2000 pages vs couple of pages, itself explains the complexity reduced. Good way to say it simply..
Answer: A web service allows for machine to machine communications over HTTP.  A web API is a subset of web services that use REST conventions (Summarizing the Wikipedia article).  The concepts definitely overlap.  I believe that there is still a link in most people's minds of web service -> SOAP/XML-RPC which can unnecessarily confuse matters.
In the end, you'll have to ask a few questions to clarify what people mean.  Not everyone makes a distinction or uses the terms interchangeably.
Comment: Thank u @Berin Loritsch, yeah thats right it causes confusion between API's and WS..
Answer: Web services is a defined architecture and approach to a problem domain as stated by the W3C.

Web services provide a standard means
  of interoperating between different
  software applications, running on a
  variety of platforms and/or framework

Web API is a concept and abstracts the means on how the concept is implemented.
In layman's terms...web API is to motor whereas WS is to BMW N53.


How would a character jumping off a building and landing work?

Question: In our last session, a character decided that he wanted to run and jump off a 3-story building, land and use might to prevent damage, and then continue running.  I'm not entirely convinced it really should have happen that way.  How should a character jumping off a building be handled?
Comment: I think this is related to your other question, [here](http://rpg.stackexchange.com/q/11463/2788). If so, I think merging them would help give context and suggest a solution to this question.
Comment: @Pureferret although they came up at the same time in the session, i consider them seperate questions.  this question is about a specific instance of a skill use, whereas the other is (essentially) asking for a definition of a game term that i'm not able to figure out
Answer: Rules for handling falling are on page 319 of Dresden Files: Your Story. The short version is that stress is inflicted for hitting the ground and a skill check can provide armour against it.
The rules use Athletics, not Might, and I don't think there is a good case for switching in Might here (not without a Mortal Stunt anyway) as the skill lies in being able to land at the right angle, bend your legs the right way, and so on. Strength is not much of a factor.
I would rule that if the character wants to keep running, then the normal rules for movement apply and each zone inflicts a -1 supplemental action penalty against the Athletics check to reduce damage.
There is also the temptation to compel one of the new consequences the character has, almost certainly, just acquired to leave them flat on their face for a round.
Answer: I guess that just using might to boost athletics as in Combining skills(YS213) isn't cutting it for you.
You can allow the character to maneuver using might and place the aspect Brace for impact on himself. Then he can tag that aspect and get a +2 on his athletics roll to jump off a building and land safely.


Well pump cycles, presure switch on and off ,contacts keep breaking in the pressure switch

Question: My pump is set on 40-60 lbs when the pressure gets to the shut-off pressure the contacts in the pressure switch keep breaking off and on. there are 25 lbs different between the line pressure at the bladder tank and the pressure at the gauge on, should pressure at the pump and the line pressure not be the same
Comment: Your question is very confusing.  Please proofread it and edit it to make the problem more clear.
Comment: Hello, and welcome to Home Improvement. We'll need more info before we can help. That said, props for [taking our tour](//diy.stackexchange.com/tour) before posting; most newbies don't.
Answer: With a rapid on off cycling of the pressure switch the bladder has usually failed or lost its air charge.  (Bladder or diaphragm).
Turn the power to the pump off and drain the water pressure open a spigot.
Now use an air compressor , bicycle tire pump or some method to pump up the tank to ~38 psi.  There is normally a small valve like a tire valve stem on the top of the tank. This is where to add the air. If you leave the spigot open and air starts coming out or you can not pressurize to 38 psi the bladder or diaphragm has failed.
If you stain 38 psi close the spigot and let the tank fill it should now cycle normally.
On older diaphragm tanks that had failed I had charged them and the system will cycle close to normal but the charge will be lost if the water level in the tank gets low and over time the air dissolving in the water will require recharging but this may provide some time to save for a new tank I am not sure if a bladder tank will have enough volume for this to work but may be worth a try.
I would not leave a system with a failed tank powered up as the rapid on off will damage the pump and the switch contacts along with creating a large number of voltage spikes that can damage sensitive electronics in the home.


Is it a good practice to display an overlay tooltip after tapping a disabled button?

Question: I'd like the tooltip to provide extra information as to why the button appears disabled. Is it a good idea to do this? The tooltip may get slightly hidden by the tapping finger...
Comment: A lot of UI toolkits won't even deliver mouse events to disabled widgets! I think you should if you can.
Comment: Thanks for your reply. It's a mobile app, so there won't be any mouse events but rather tap events.
Answer: Yes.  This is a great idea!
Disabled buttons can be very frustrating to users if there is no clear indicator of why they are disabled.  This can result in all kinds of negative behavior including frustration, abandonment, or bad anchoring where the user assumes the button is not a control or doesn't work (a particular risk with flat design where buttons are not always easily distinguished, as in your layout above).
It may be awkward to figure out where to place and style the tooltip, but this is a great example of thoughtful and empathic UX design.  One thing you may consider is an auto-fadeout of the tooltop after a few seconds, so the user doesn't have to actively dismiss it.
Comment: I don't know how I feel about this. If a tool tip comes up for a deactivated button, is it really deactivated?
Comment: @Majo0od absolutely! It's a classic UX case...disabling a control is not the same as disabling feedback. For example, if you try to start a car while in reverse you will get feedback (e.g. beep or flash) showing that start is disabled. If you try to select a lower floor in an elevator that is going up, it may flash the button to acknowledge the press but disallow you from selecting it.  In both these cases, feedback is very helpful because it acknowledges the user's interaction while indicating the control is disabled.


how to trip a MCB without short circuit or over load?

Question: I want trip a MCB whenever I want to trip using some ckt.I have found that there is two mechanism by which mcb trip:
1)Bi Metallica expansion
2)Solenoid effect.
So i think of controlling the solenoid by some external connection.But till now nothing works.
Plz give a way so that i can do it.
Comment: Can you also add purpose too. People can suggest safer ways.
Comment: Let me paraphrase your question: You want to add a remote controlled switch functionality to your circuit breaker which is not tied to overcurrent or other means of overload?
Comment: Yes want a push button outside the MCB to trip it.My plan is to take out the connection of Solenoid(inside MCB) and using a rectifier ckt to control it.But thats not working.
Answer: Anything that you do to the inside of the circuit breaker will either jeopardize or destroy at least some of the normal function of the MCB. Even just opening the case makes the future function of the MCB questionable.
You could conceivably use an external solenoid to push the lever.
You could connect a relay in series with the circuit breaker.
You could buy a circuit breaker with a built-in shunt-trip mechanism, but that would be a molded case circuit breaker that would be larger and more expensive.

can you plz provide a circuit of "shunt trip coil"?

The trip coil shown in the picture could be converted to a shunt trip coil by disconnecting it and providing a new path for current through the thermal trip element. Then the 5 turns of heavy wire would need to be removed and replaced with many more turns of smaller wire. It you want to trip the breaker by supplying 2% of the present magnetic trip current, you would divide the original number of turns by 0.02 and use about 250 turns. The trip current multiplied by the number of turns needs to remain about the same.
Comment: can you plz provide a circuit of "shunt trip coil"?


How great could tides be on Earth (or an Earth-like planet) if you swapped the Moon?

Question: Assuming a planet would have Earth's surface gravity and about the same share of it's surface covered by water, how great could you make tides if you could make the moon bigger, smaller, denser, less dense, closer or farther away as you wished? And would a planet subjected to a bigger pull by it's moon necessarilly be more geologically active or not?
Comment: You're going to need to narrow this down a bit to a specific answerable question, at the moment it's not asking a specific question, more of a bunch really. If you told us what you were trying to achieve, then we maybe can help you get there.
Comment: In your future attempt to simplify the question, you can forget the density of the Moon. At least as long as the distance between the Moon and the Earth is much larger than the spatial dimensions of both.
Comment: According to calculations, backed up by measurements of laser beams bounced off of reflectors left on the Moon by Apollo missions, the moon is slowly receding from the Earth.  .The Moon used to be much closer to Earth billions of years ago, and the tides used to be gigantic. https://skeptoid.com/episodes/4683 Tidal heating of moons of giant planets can cause vulcanic activity,as on Io.  Heller, René; Rory Barnes (2012). "Exomoon habitability constrained by illumination and tidal heating". Astrobiology. 13 (1): 18–46. https://www.liebertpub.com/doi/10.1089/ast.2012.0859
Comment: I liked Slarty's answer. I would like the question to fit that answer. Is there a suggestion for that? Maybe "How great could tides be on Earth if you could make the moon closer or farther away?" Thank you.
Comment: Thank you, Mr. Golding. I think I got everything I will need.
Answer: That's a bit of a general question to which I will attempt a general answer. The closer the Moon gets to Earth the stronger the tidal effects would be. Limit around 11,500 miles – the Roche limit at which point tidal forces would destroy the Moon and it would break up. In reality bad things would start to happen before then but that's an absolute limit.
The greater the mass of the Moon the greater the tidal effects would be, but at some point the Earth Moon system would be better described as a double planet rather than a planet moon system.
Would the planet be more geologically active? Yes It probably would as tidal forces could exert a lot of force in the crust as we see with Jupiter's moon Io.
How big could the tides be? Well firstly I suggest any huge tidal swings would not be stable in the long run as they would create a lot of drag dissipating energy and probably leading to a collision. However assuming the orbit can be varied and the mass increased the tides could be very large indeed.
In the extreme case of a moon the size of the Earth (Roche limit not an issue for similar sized bodies) orbiting just above the atmosphere the surface of the oceans would become almost weightless (perhaps 1/10 or less the weight) and normal meteorological effects could easily turn huge swathes of the ocean surface into an unstable foam of air debris and water droplets. A massive tide operating in that environment might transfer water high up into the atmosphere and given the proximity of the "moon" beyond.


What VPS spec would I require to run WordPress

Question: I am looking to move an existing WordPress website to a virtual private server (VPS). It will be a Debian (minimal install) running ISPConfig3, Squirrel Mail, and Apache2.
The WordPress site currently accepts 40-60 online payments per day and the VPS will need to handle at least 800 incoming emails a day.
Answer: I operate a few VPS servers on various networks such as Rackspace, Amazon, Cloud Shards and UK2 and what I find is it depends really depends on the cloud platform they use. Generally you have their own cloud software or they use some commonly known software such as OpenVZ, Xen and KVM.
You should start looking a the difference between each platforms and see what they offer, for example OpenVZ it is possible to oversell while XEN since it allots each user a SET amount and you can't set share resources you know that your server may be more responsive all the time while OpenVZ may have spikes at time but may offer more proformence at times too.
I have tried many times to get apache2, mysql and various other server related software running on 256mb and it always runs into problems. I would say the bare mininal you should be looking for is 384 to 512mb. It's worth noting that most NON-OpenVZ platforms do not allow use of the SWAP space since constant disk usage has a stain on the network, however on VPS's that allow SWAP you will easierly get away using 256mb or lower depending on the amount of swap they allow (Most companies you need to read the small print on this or contact them. Using swap on some actually breaks the terms and conditions - Rackspace for example).
Recommend Platforms I've First Hand Experience
AWS Amazon
Amazon is really good for affordable VPS solutions and since you only want to run WordPress you might get away running the Micro Instance which is 'FREE' for a whole year as well as using their RDS service which means you can host your SQL on an instance which means the Micro Instance has more free resources. Uses Ubuntu or Amazon Linux - Doesn't allow for Debian as far as a I know.
http://aws.amazon.com/free/
Rackspace
I strongly believe in you get what you pay for and if your not scouting for the cheapest option and want 24/7 support at a few clicks of a button and 1min wait queues without having to submit silly tickets that you just eagely wait for then Rackspace is the best and I've never had a company in web related services offer better customer service. Their cloud VPS is very fast and stable but of course they are not the cheapest bang for buck.
http://www.rackspace.co.uk/cloud-servers/
UK2.NET
Weak Control Panel, But the VPS operates fast and you get a lot of resources for your money, there support is pretty crappy though and the support number can be expensive for long calls.
http://www.uk2.net/vps-cloud-hosting/
CloudShards
Only been with them for a couple of months and its run on a OPENVZ platform and I'm suprised how quick it is, the support they offer is ticket based but I normally get a good response within an hour.. By far the cheapest - I think I pay around $3.5 a month for the same that I pay rackspace at $40 a month but of course Rackspace offers more but as a cheap solution I recommend CloudShards.
http://www.cloudshards.com/budgetvpshosting.php
GoDaddy
Seriously, I believe that GoDaddy should stick to what they are good at 'SELLING DOMAINS' the shared hosting accounts I've had have a lot of downtime as well a the VPS services and even my shared hosting accounts have been hacked a few times while I never get any problems on any other hosting and the fact I host over 50 sites across servers you'd think their support team would kinda relate to their own security being the problem. Performance Wise on Shared Hosting, REALLY POOR and VPS well its a VPS with hardly any perks and weak support.
http://www.godaddy.com/hosting/vps-hosting.aspx?ci=9013
Summary
You should get a VPS that has more than 512mb ram or 384mb using a SWAP. The few I know of and you want max reliability and your pretty new to VPS and will require some support then go Rackspace, if you tight for cash and want to test VPS without paying then Amazon Micro instances are great. If you want max bang for Buck then CloudShards and if your a GoDaddy fan boy then /facepalm.
Hope this helps thanks.


Linux for programming? Which one?

Question: I don't know if this is the correct place to ask but I honestly would love an answer. I am a Software Engineering student and I have the following dilemma. Till now I have used Windows, I like Windows it is simple and well known but I realized something the last weeks. Windows consumes a LOT of memory. Its ok when i want to play games or when i want to do conventional stuff but regarding school work and programming should I switch to Linux? Is it more lightweight in terms of non-gaming, non-photo editing, non-video editing etc. processes? And shall I go with Fedora or Ubuntu? Thanks in advance for all the answers.
Comment: Questions of opinion aren't well suited for a Stack Exchange site (which [softewarerecs.se] is), rather we stick to an objective question/answer format. That said, Linux is a very different world than Windows. There are a lot of advantages, but it takes time to get used to new and different systems. You'll really have to make that decision yourself. That said, it's not hard to set up a dual boot with both Linux and Windows so you can switch between them at will. I would recommend ubuntu over Fedora since it is more beginner friendly.
Comment: Which software do you want to keep for Linux and are you sure that there is particular software for Linux? Sure, Linux has a lot of open source alternatives but they probably don't have nearly as many features as Windows software. Also, are you sure that it's not _your_ script that consumes a good portion of your RAM?
Comment: From what I have seen when I turn on windows it consumes by default around 3gigs of memory at least! Not only on my machine but most of the student's have problems with their memory especially when they want to run docker. While i love windows in terms of gaming performance I really want something more lightweight on my day to day operations.
Comment: OS recommendations are on-topic, but you would need much more precise requirements. There are hundreds of OSes that allow you to do programming and don't consume much memory.
Answer: Once you start programming on the Ubuntu platform you'll probably use it again and again, because Ubuntu is a versatile OS and many programming language compilers and other programming packages can be installed from the default Ubuntu repositories. Compared with Fedora Ubuntu has much more programming packages in its default repositories which translates to much less packages that need to be manually downloaded or installed from third-party sources.
Ubuntu is better supported than Fedora, and the larger number of packages in the default Ubuntu repositories makes a big difference to a programmer. Ubuntu is open source, so you can customize it, and give it whatever interface you want. I like the default Ubuntu interface because it is good for my workflow.
Ubuntu is a bit more lightweight than Windows 10 and it can be customized to be even more lightweight by installing a more lightweight desktop environment, although the default desktop environment is more programmer friendly. If your computer has a lot of memory Ubuntu will make use of it, which I regard as a positive feature because Ubuntu runs faster than Windows on every computer that I have ever tested. LibreOffice (Ubuntu's default office suite) runs much faster than Microsoft Office on every computer that I have ever tested.
Comment: I was leaning toward Ubuntu as it is the one that we are using for our test exams but i fell in love with the fedora interface.
Comment: Ubuntu is better supported than Fedora, and the larger number of packages in the default Ubuntu repositories makes a big difference to a programmer. Ubuntu is open source, so you can customize it, and give it whatever interface you want. I like the default Ubuntu interface because it is good for my workflow.
Answer: If you want consistency, use a Linux that resembles those installed on your university's computer pools, because sooner or later you'll interact with them to submit assignments, run cloud-/cluster-based programs, etc.
Check out which Linux Systems their campus licenses cover for popular third-party software that is important to you.  Have they licensed their backup software, or their antivirus license, that they give to students, for Debian or for Suse, Redhat based Systems, etc.?
If you are into graphics programming, check which platform best supports your GPU driver inside your laptop or PC (NVidia/AMD/Intel...). Things change quickly in this regard, GPU/platform driver support on linux.
Comment: you could upvote or finally accept he question then

Linux for programming? Which one?


Understanding "come back to you on something"

Question: I am learning English, but I am not familiar with idioms. Could somebody explain me in plain English what does it mean "I will need to come back to you on this request."
Answer: I usually hear this as "I will have to get back to you on this" in AmE, although "come back to you" is also used. It means, I will have to do some investigation or work before I can fulfill your request or answer your question. For example,

"Can you tell me the date of my last payment?"
  "Let me check my files and come back to you on that. Is there anything else I can help you with?"
Answer: In my experience, "get back to you" is more common than "come back to you", but the context suggests it's the same meaning.
It means "I cannot answer you right now, but I will answer you later."

Maybe the speaker doesn't know the answer yet, and so plans to go research it, and then tell you the answer based on their research.
Maybe the speaker does know the answer, but doesn't have time to deliver the answer properly right now.  (Because the answer is long and complex, or requires a diagram, or something.)
Maybe the speaker doesn't know if they have permission to answer you - the information may be confidential, so they need to go find out if they're allowed to disclose it to you.


Web browser plugin for jquery performance optimization

Question: Attempting to improve the perforance of my jquery - so step 1 for me is to optimize my selectors. I have been using jsperf.com which has been helpful but is there any web browser plugin that I can use that will do similar as jsperf? ie. I can enter several different selectors and it tell me which is the slowest etc or the timing each selector takes.
Answer: Can you post your jquery? A good place to start is using firebugs console tab and running the profiler, this will point out what functions are taking the longest to run.
In many cases I have found that using plain javascript where possible instead of jquery will improve performance, an example of this is the .each() function in jquery can be written as a for loop in javascript, for large sets of data it can make a big difference.


What benefits are there to peer reviewing papers?

Question: I am a first year PhD student, and have been asked to peer-review a paper.  The paper is not really in my field, so I will not learn anything valuable by reading the paper.  The publishing venue is not open-access, so it is difficult to justify on altruistic grounds.  Also, the reviews are double-blind, so there is no potential for networking.  As I have never been a reviewer, I am wondering: is there any other possible personal benefits that I might realize from performing this task?
Comment: It never ceases to amaze me that, apparently, in some fields, non-specialists are deemed adequate to referee serious papers. In my field, mathematics, this rarely happens. In particular, even after some decades of experience, if someone asked me to referee a paper on a subject I'd never thought about, I would decline, on the grounds of incompetence. Beyond that, not merely in competence, but ignorance of the context.
Comment: "The paper is not really in my field, so I will not learn anything valuable by reading the paper" Say what? You may learn a lot from looking at what people are doing in close fields! One of the (many) reason to peer-review is that you will learn from other fields, on a presentation level, if not at a technical level.
Comment: @Clément, by "not really in my field", I am in computer science, and the paper is an information systems paper, which is college of business.  I estimate my expected learning return on this to be approximately equal to choosing an academic paper at random from all fields and reading that.... which is non-zero, but not by much.  :)
Comment: If reviews are double-blind, you *can* network with the editor. Double blind peer review usually means you don't know who the authors are and they don't know who the reviewer is. Only if they are triple-blind will there be no potential for networking.
Comment: You don't do it (primarily) for personal benefit. You do it because someone has to do it, or no one would get their papers into journals.
Comment: @Scott > Ouch, that's a huge stretch, indeed. How on earth can that happens?
Comment: @paulgarrett in many fields, specialized knowledge of the field is not entirely necessary to evaluate the merits of the paper, and a basic understanding of the scientific process will do.  A great deal of what gets published involves making some kind of hypothesis about something (not generally super important to understand this part) and then gathering data on the matter and analyzing the results (most scientists from nearly any field can evaluate this part).  This is not the case in all fields, and mathematics is certainly an exception.
Answer: One benefit is that you are now part of the academic game and you'll learn how it's working, esp. if you have a chance to see other reviewer's comments (which is not always the case, but sometimes, all comments have to be adressed and then you can see them).
Someone might have proposed you, and this person wants to promote you.
If the paper is clearly off-topic, I would avoid reviewing it, especially if it is your first review. You should thank the editor for the trust in you, but send them a list of topics you would happliy review.
If the publication venue is a conference, you will be listed under "program committee" and gain visibility in the field.
If it is a journal: Is the journal trustworthy? I'm getting two invitations per day by some predatory journals...


Does link/rm/mv sync dentry metadata immediately when finished?

Question: Does link/rm/mv sync dentry metadata to permanent storage immediately when finished? If not, when?
Answer: From https://www.kernel.org/doc/Documentation/sysctl/vm.txt, I get this:

drop_caches
Writing to this will cause the kernel to drop clean caches, as well as
reclaimable slab objects like dentries and inodes.  Once dropped,
their memory becomes free.
To free pagecache:

echo 1 > /proc/sys/vm/drop_caches

To free reclaimable slab objects (includes dentries and inodes):

echo 2 > /proc/sys/vm/drop_caches

To free slab objects and pagecache:

echo 3 > /proc/sys/vm/drop_caches

This is a non-destructive operation and will not free any dirty
objects. To increase the number of objects freed by this operation,
the user may run `sync' prior to writing to /proc/sys/vm/drop_caches.
This will minimize the number of dirty objects on the system and
create more candidates to be dropped.
This file is not a means to control the growth of the various kernel
caches (inodes, dentries, pagecache, etc...)  These objects are
automatically reclaimed by the kernel when memory is needed elsewhere
on the system.
Use of this file can cause performance problems.  Since it discards
cached objects, it may cost a significant amount of I/O and CPU to
recreate the dropped objects, especially if they were under heavy use.
Because of this, use outside of a testing or debugging environment is
not recommended.
You may see informational messages in your kernel log when this file
is used:
cat (1234): drop_caches: 3
These are informational only.  They do not mean that anything is wrong
with your system.  To disable them, echo 4 (bit 3) into drop_caches.


Ampere's law and external currents

Question: In Ampere's law, the current outside the curve taken is not included in the expression. Does it mean that the magnetic field calculated by using the law gives the contribution of only the currents crossing the area bounded by the curve?
Answer: The value of the line integral $\oint_C \vec B \cdot d\vec l$ really does only depend upon the current bounded by the closed path $C$. That's a consequence of Ampere's law. However, the value of the magnetic field $\vec B$ at any point along the path $C$ depends on every current, even those outside.
Knowing the value of the line integral is not the same thing as knowing the value of the magnetic field.
Here's an example that illustrates the difference:

Imagine just a single wire carrying current $I_o$. Take the Amperian to be a circle that encloses the wire but is not centered on it. By Ampere's law, $\oint_C \vec B \cdot d \vec l=\mu_o I_o$. Done and done. However, you can't use this Ampere's law to "factor out" $\vec B$ from the integral, so you can't use it to solve for $\vec B $. Why? Because the magnetic field isn't constant over the path, and since it's not constant, it can't be pulled out of the integral in the manner you normally would. In order to rewrite $\oint \vec B \cdot d\vec l$ as $B \oint dl$, one requirement is that the magnitude of the magnetic is constant over the path.

One more example.

Imagine two wires that each carry current $I_o$, but the Amperian loop is centered around only one of them; the other wire is not bounded by the loop. Alright, here again, $\oint \vec B \cdot d\vec l = \mu_o I_o$. Done. But the magnetic field $\vec B$ in the integral is really the net magnetic field $\vec B_\text{net}$. As mentioned earlier, all currents contribute to the magnetic field $\vec B$ in Ampere's law. But since the net magnetic field isn't constant, you can't factor it out of the integral and solve for it.

So the Ampere's law as you know it is mainly useful when you can factor out the magnetic field and solve for it. In these cases, you typically have highly symmetric situations that allow you to do this. But even in non-symmetric cases, Ampere's law is true, but doesn't allow you to solve for the magnetic field.
Comment: You might be able to say that, but I don't recommend memorizing it as a rule. Instead, write it out the law completely every time and make sure you know what $\vec B$ does and doesn't represent at each step.
Comment: thank you so can i say that we will get magnetic field of inside if we can take B outside i.e when magnetic field is constant
Answer: It would be nice to provide a picture or diagram to make the question a little more clear.
The answer is that the curve of integration (to find the associated magnetic field) should cover the area or loop into which the current flows, as such there is no current outside which is not taken into account. Of course one can divide the calculation in areas and then sum these together (as in integral form).
Since the equations are linear (with respect to both $B$ and $E$, i.e magnetic and electric fields), does not make a difference.
Comment: OK will try to add diagram next time
Comment: @rjmessibarca, no problem, the question is clear, but in general helps to make your point across :)
Answer: No problem - I think this one is clear, rj.  The answer is No: Amperes law is correct and exact irrespective of whatever currents are flowing outside the loop without crossing it.  Of course these currents still affect the total field at any give point - it's just that these contributions sum to zero.
A good example is the field near a long straight wire.  If you draw a loop that doesn't contain the wire, the line integral of the field is zero.  You can choose a loop that is like a slice of pie with a bite taken out of the pointy bit - two circular arcs and two straight radial segments.  The integral along the straight parts is zero by symmetry, and that along the curved parts must cancel - which shows the field $~1/R$.
Amperes law has lots of interesting consequences when symmetry is present.  For example, the field inside a uniform axisymmetric current sheet with toroidal topology is $~I/R$, where $I$ is the current flowing up the centre of the toroid and R the distance from the symmetry axis, independent of z, no matter what the shape of the cross-section.  Best of luck.
Comment: The contribution of external currents to the *field* does not necessarily sum to zero.

Ampere's law and external currents