## minimax – Understanding deep cutoff in Alpha–beta pruning algorithm

I am studying the Alpha Beta pruning algorithm here.

function alphabeta(node, depth, α, β, maximizingPlayer) is
if depth = 0 or node is a terminal node then
return the heuristic value of node
if maximizingPlayer then
value := −∞
for each child of node do
value := max(value, alphabeta(child, depth − 1, α, β, FALSE))
α := max(α, value)
if α ≥ β then
break (* β cutoff *)
return value
else
value := +∞
for each child of node do
value := min(value, alphabeta(child, depth − 1, α, β, TRUE))
β := min(β, value)
if β ≤ α then
break (* α cutoff *)
return value


In this slide (pg. 13) I read:

Deep alpha cut-off: . Def: For a node u in a tree and a positive
integer g, Ancestor(g, u) is the direct ancestor of u by tracing the
parent’s link g times. . When the lower bound Vl is produced at and
propagated from u’s great grand parent, i.e., Ancestor(3,u), or any
Ancestor(2i + 1,u), i ≥ 1. . When an upper bound Vu is returned from
the a branch of u and Vl ≥ Vu, then there is no need to evaluate all
later branches of u.

Also here the difference bteween shallow and deep cutoff.

I understand shallow alpha cutoff but I don’t understand why deep alpha cutoff works.

## htaccess – Understanding mod_expires apache module

Working with htaccess is a new capitol for me. I have already read about mod_expires here https://httpd.apache.org/docs/current/mod/mod_expires.htm, but I’m stil confused.

I have the next code from stack overflow:

ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access plus 2 months"


My questions are:

1. I suppose the line ExpiresByType image/jpg "access 1 year" tells the client (browser) to download the file and keep it for one year. And when the client accesses the same page from my website, the jpg image won’t be downloaded from my website. It will be read from his computer (where the browser saved first time). After one year, the browser automatically deletes the file and, once the client access my website, it will download again, for another year. If the client cleans his browser history after 2 months, then the browser will download it again even if a year hasn’t passed. Do I miss something ?

2. What cache availability should I set for each file type ? It depends on the file ? What should I consider when set the expiration time ?

3. What’s the difference between "access 1 year" and "access plus 1 year" ?

4. Does ExpiresDefault rule works for php files too ? I mean, if I have a contact.php file with some content and I modify the content of contact.php, because of ExpiresDefault rule, the content won’t change to the user ?

5. Do search engine spiders listen for this cache rules or they download the files each time they crawling my website ?

6. Is it true that ExpiresDefault is for the files I don’t set using ExpiresByType ? If the answer is yes, what are the other types ? What types of files are included here ?

7. Do I understand correct that Header set Cache-Control "max-age=290304000, public" is the maximum time allowed for a file to be cached ? If the answer is yes, then means that "access 999 years" will take no effect as long 290304000 is the limit. True or false ?

## Understanding htaccess cache rules – Webmasters Stack Exchange

Ok.

I’ve read a lot and I understand almost nothing.

I talk about cache, and I don’t know any cache system that is interested in keeping my files, for me, and for free. And, as I read, there are almost 5 other cache systems triggered when a user/client access let’s say www.webmasters.stackexchange.com

Ok, I know one cache. My visitor browser’s cache, which, once he accesses my website, he (the browser) may save the resources into his system (where the browser set it). The next time when the user navigates to the same page, the resources are loaded from his system and not from my website.

Further, I want to take advantage of the most important cache methods for my website. So I use some rules. The problem is that it doesn’t help me just to have them. I also want to understand them.

The code I found from stack overflow and other sites is (which I will modify further):

# Block 1 #
<ifModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access plus 2 months"
Header set Cache-Control "max-age=290304000, public"
</ifModule>

# Block 2 #
<FilesMatch ".(js|css|xml|svg|gz)$"> Header append Vary Accept-Encoding </FilesMatch> </IfModule> # Block 3 # <IfModule mod_deflate.c> <filesMatch ".(js|css|html|php|txt|svg|otf|ttf|woff2|xml)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>


In the first block, I have some instructions but ONLY if mod_expires module is available. Anyway, inside the block 2, I also have at the last line:

    Header set Cache-Control "max-age=290304000, public"


Is it true that this line doesn’t belong to this block as instructions will be loaded only if mod_expires is available ? If mod_headers is disabled, then I will probably get a 500 error. So this line should better be in the <IfModule mod_headers.c> block. Isn’t it ?

So, the code looks now like this:

# Block 1 #
<ifModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access plus 2 months"
</ifModule>

# Block 2 #
<FilesMatch ".(js|css|xml|svg|gz)$"> Header append Vary Accept-Encoding </FilesMatch> # Line from block 1 # Header set Cache-Control "max-age=290304000, public" </IfModule> # Block 3 # <IfModule mod_deflate.c> <filesMatch ".(js|css|html|php|txt|svg|otf|ttf|woff2|xml)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>


I’m not interested in checking if module xyz is available. It must be. So I will remove IF conditions. If, for some reason, one module won’t be available in the future, then I’ll probably get a 500 error, which is fine for me. I want to take advantage of the cache methods for true, not if whatever. It’s something wrong here ?

So, the code looks now like this:

# Block 1 #
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access plus 2 months"

# Block 2 #
Header set Cache-Control "max-age=290304000, public"
<FilesMatch ".(js|css|xml|svg|gz)$"> Header append Vary Accept-Encoding </FilesMatch> # Block 3 # <filesMatch ".(js|css|html|php|txt|svg|otf|ttf|woff2|xml)$">
SetOutputFilter DEFLATE
</filesMatch>


Inside block 1 I have the first line which sets “ExpiresActive on”, which is clear. I activate the module even if it is available.

Next, on second line I set ExpiresByType image/jpg “access 1 year”

Is this the cache system for the user’s browser (I talked above) ? I understand well ?

What cache availability should I set here ? It depends on the file ? I see 1 year for some files and one month for others. What should I consider when set the expiration time ?

Why:

ExpiresByType image/jpg "access 1 year"


And not:

ExpiresByType image/jpg "1 year"


What’s access keyword doing here ?

A user access my website which contains one jpg image. Next, the browser loads and save that image and keeps it for one year. After one year, the browser automatically delete this image and the next time the user access my website, the browser will save the jpg image again for another year. If the user cleans his browser cache after let’s say 2 months, the next time when the user access my website, the browser saves the image again, even if a year hasn’t passed. Do I understand ok ?

What types of files should I put here ?

I know that images, css files and javascript files are almost required. Do I need to put other files here ?

Does ExpiresDefault rule works for php files too ? I mean, if I have a contact.php file with some content and I modify the content of contact.php, because of ExpiresDefault rule, the content won’t change to the user ?

If one image file was changed, how would I force the browser to re-download the file ? I understand that the recommendation would be to set another link for that image, but let’s say I want to use the same url. The name of that image may be good for optimization and I may not want to change his name or even his directory. So, if the image was already saved to the user, how can I force a re-download ?

Now, last line of block 1 is:

ExpiresDefault "access plus 2 months"


I understand that this is the default expiration time, but for what type of files ?

In the block 2 I have now:

Header set Cache-Control "max-age=290304000, public"


Does this has something to do with block 1 ? If the answer is yes, then means that a file saved in the user’s browser won’t exceed the time set in max-age even if I set ExpiresByType image/jpg "access 999 years" ?

What files are included in Header set Cache-Control "max-age=290304000, public" ? For what types of files is this max-age cache available ?

Can someone give me an example of what are the benefits of Header append Vary Accept-Encoding rule ? And an example of what happens if I don’t use it ?

In the block 2, the Header append Vary Accept-Encoding is available only for js, css, xml, svg, gz files. There are other files should I put here ? What should I consider when I set those file types ?

Can someone explain what does SetOutputFilter DEFLATE with an example ? And what happens if I don’t use this ?

Here, almost like in block 2, the line SetOutputFilter DEFLATE is available for js, css, html, php, txt, svg, otf, ttf, woff2 and xml files. Should the php files be here ? Should I put other file types here too ?

That’s all. Please, be kind and don’t condemn my questions. I just try to understand what I’m doing…

## graphs and networks – Trouble Understanding PageRankCentrality function

I’m doing a project in which I want to rank the nodes of a graph using page-rank centrality. The Mathematica documentation for PageRankCentrality is:

PageRankCentrality[g, α], gives a list of page-rank centralities for the vertices in the graph g and weight α.

The function would then return the page-rank centralities of all nodes in the graph. My question is, is there a version of this such that I can apply it to an unweighted graph? This function requires a parameter “α” for the weight. If I put the weight to 1 or 0 for example, would that make the graph essentially unweighted? If not, what could be a possible solution to find the page-rank centrality of all nodes?

## calculus – not understanding a question about IVT

Thanks for contributing an answer to Mathematics Stack Exchange!

• Please be sure to answer the question. Provide details and share your research!

But avoid

• Asking for help, clarification, or responding to other answers.
• Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

## security – Am I really understanding how the “Trezor Model T”, and hardware wallets in general, work?

Getting increasingly paranoid about losing my coins, I’ve yet again (for probably the 20th time by now) went looking for hardware wallets. The only semi-reasonable one seems to be the two Trezors. All the others seem fishy/unreliable to me.

But as I read and watch and listen, it seems like even the “premium” Trezor Model T requires “OS support” and even to go to a webpage (not hosted on the device itself) to actually use it. Its operations are not at all self-contained in the device itself.

Up until now, I always had the idea that the Trezors (even the first model) is entirely self-contained, and only plugs into a computer in order to use its network capabilities to be able to send coins and update its data. (Of course, doing all the validations and verifications on the device, so it doesn’t have to trust the network or the computer it’s plugged in to.)

Actually, I vaguely had the idea that I would be able to buy one and then physically take it with me somewhere, without any computer around, and sort of “beam” any amount of my coins into another person’s Trezor or even other hardware wallet…

None of this seems to be the case. Even the expensive model with the touch screen appears to be entirely reliant on the “host computer” to do anything besides storing the coins. I bet the special Trezor “coin control panel” webpage doesn’t even support my browser (I don’t run spyware), and who knows how long that will stay online? I don’t want to rely on some company’s website, or require special “OS support” for my hardware wallet. That’s why it’s a hardware wallet! For it to be stand-alone.

Am I missing something fundamental? Are there no “actual” hardware Bitcoin wallets which can do everything by themselves: send and receive coins without any computer? I don’t even have wireless Internet at home, but most people apparently have, so I definitely expected it to be using “wifi” on its own, but this doesn’t seem to be the case?!

I really tried to find this out by myself before asking.

## unity – I’m failed to understanding array coordinate

I’m totally lost in understanding the arrays’ coordinates. Below is the code I use to generate an one dimensional array(10). I attached the console result and the generated result.

Please explain why array(0) (the cube at the bottom) does not match the gizmos color? It looks like array(0) actually refers to the 2nd cube (counting from bottom) while array(10) has gone missing from the display. The lowest cube looks like an extra generated cube which is irrelevant to the gizmos color.

using UnityEngine;

public class NewBehaviourScript : MonoBehaviour

{
int y;
int() array1 = new int(10);
int temp;
void Start()
{

for (y = 0; y < 10; y++)
{
array1( y) = Random.Range(0, 2);

Debug.Log(string.Format("{0},{1}", y, array1( y)));

}
}

void OnDrawGizmos()
{

for (y = 0; y < 10; y++)
{
Vector2 pos1 = new Vector2(0,  y );
Gizmos.DrawCube(pos1,new Vector3(0.5f,0.5f,0.5f) );
Gizmos.color = (array1( y) == 1) ? Color.black : Color.white;
}

}
}


## blockchain – Understanding Transactions, Mining, and the 10 minutes block solved

How do miners decide how many transactions they should have in a block in order to mine 1 bitcoin?

The amount of work miners do has no impact on the amount of Bitcoin they make. The block subsidy is a fixed amount, and transaction fees are determined from transactions. Mining 1 Bitcoin does not require some specific amount of work.

Miners determine how many transaction they should have by determining how much in transaction fees they stand to gain from including those transactions. This is typically done by ordering all known unconfirmed transactions by their fee rate. Then the miner just includes as many transactions that is allowed by the consensus rules, starting from the transaction with the highest transaction fees.

When miners compete to find the “nonce” that has the smallest possible hash number, would it be faster/easier to find the “nonce” if there are fewer transactions?

No. The number of transactions has no significant effect on the difficulty of a block or the amount of work required to mine a block. While including more transaction nominally requires computing more hashes, this is negligible in the grand scheme of things, especially since this calculation is only done once for a set of nonces and extraNonces.

Do all miners try to solve a solution where all the transactions should be the same in a single block and everyone’s trying to compete to finding the nonce and hash?

Everyone chooses their own set of transactions to include. Everyone is making their own block, just each block points to the same parent block.

Or is it random, and its just whoever finds a hash the quickest, saves those transactions and adds it to the blockchain?

It is entirely random. It’s however finds a block first and broadcasts it.

Also, I noticed looking at btc.com, there are blocks being mined less than 10 minutes back to back, I thought it needs to be 10 minutes to be mined?

The average time between blocks is 10 minutes, but that is an average, not a requirement. Blocks can be found in less than 10 minutes, or more than 10 minutes. The average block is ~10 minutes.

## cuda – Understanding pixel format and profile when encoding 10-bit video in ffmpeg with nvenc

I am trying to encode a 10-bit H.265 video from a 8-bit H.264 source using ffmpeg with CUDA hardware acceleration.

Without hardware acceleration, a typical command would be ffmpeg -i input.mkv -pix_fmt yuv420p10le -c:v libx265 -crf 21 -x265-params profile=main10 out.mkv.

Using CUDA, I expect the corresponding command to be ffmpeg -i input.mkv -pix_fmt yuv420p10le -c:v hevc_nvenc -profile:v main10 -cq 21 out.mkv.

However, when I list the supported encoder settings using ffmpeg -h encoder=hevc_nvenc (output of command pasted below), even though it supports main10, no 10-bit pixel format is supported: Supported pixel formats: yuv420p nv12 p010le yuv444p p016le yuv444p16le bgr0 rgb0 cuda d3d11. Does the encoding work for my use case, or not?

ffmpeg version 4.3.1-2021-01-01-full_build-www.gyan.dev Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable-libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil      56. 51.100 / 56. 51.100
libavcodec     58. 91.100 / 58. 91.100
libavformat    58. 45.100 / 58. 45.100
libavdevice    58. 10.100 / 58. 10.100
libavfilter     7. 85.100 /  7. 85.100
libswscale      5.  7.100 /  5.  7.100
libswresample   3.  7.100 /  3.  7.100
libpostproc    55.  7.100 / 55.  7.100
Encoder hevc_nvenc (NVIDIA NVENC hevc encoder):
General capabilities: delay hardware
Supported hardware devices: cuda cuda d3d11va d3d11va
Supported pixel formats: yuv420p nv12 p010le yuv444p p016le yuv444p16le bgr0 rgb0 cuda d3d11
hevc_nvenc AVOptions:
-preset            <int>        E..V...... Set the encoding preset (from 0 to 11) (default medium)
default         0            E..V......
slow            1            E..V...... hq 2 passes
medium          2            E..V...... hq 1 pass
fast            3            E..V...... hp 1 pass
hp              4            E..V......
hq              5            E..V......
bd              6            E..V......
ll              7            E..V...... low latency
llhq            8            E..V...... low latency hq
llhp            9            E..V...... low latency hp
lossless        10           E..V...... lossless
losslesshp      11           E..V...... lossless hp
-profile           <int>        E..V...... Set the encoding profile (from 0 to 4) (default main)
main            0            E..V......
main10          1            E..V......
rext            2            E..V......
-level             <int>        E..V...... Set the encoding level restriction (from 0 to 186) (default auto)
auto            0            E..V......
1               30           E..V......
1.0             30           E..V......
2               60           E..V......
2.0             60           E..V......
2.1             63           E..V......
3               90           E..V......
3.0             90           E..V......
3.1             93           E..V......
4               120          E..V......
4.0             120          E..V......
4.1             123          E..V......
5               150          E..V......
5.0             150          E..V......
5.1             153          E..V......
5.2             156          E..V......
6               180          E..V......
6.0             180          E..V......
6.1             183          E..V......
6.2             186          E..V......
-tier              <int>        E..V...... Set the encoding tier (from 0 to 1) (default main)
main            0            E..V......
high            1            E..V......
-rc                <int>        E..V...... Override the preset rate-control (from -1 to INT_MAX) (default -1)
constqp         0            E..V...... Constant QP mode
vbr             1            E..V...... Variable bitrate mode
cbr             2            E..V...... Constant bitrate mode
vbr_minqp       8388612      E..V...... Variable bitrate mode with MinQP (deprecated)
ll_2pass_quality 8388616      E..V...... Multi-pass optimized for image quality (deprecated)
ll_2pass_size   8388624      E..V...... Multi-pass optimized for constant frame size (deprecated)
vbr_2pass       8388640      E..V...... Multi-pass variable bitrate mode (deprecated)
cbr_ld_hq       8            E..V...... Constant bitrate low delay high quality mode
cbr_hq          16           E..V...... Constant bitrate high quality mode
vbr_hq          32           E..V...... Variable bitrate high quality mode
-rc-lookahead      <int>        E..V...... Number of frames to look ahead for rate-control (from 0 to INT_MAX) (default 0)
-surfaces          <int>        E..V...... Number of concurrent surfaces (from 0 to 64) (default 0)
-cbr               <boolean>    E..V...... Use cbr encoding mode (default false)
-2pass             <boolean>    E..V...... Use 2pass encoding mode (default auto)
-gpu               <int>        E..V...... Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on. (from -2 to INT_MAX) (default any)
any             -1           E..V...... Pick the first device available
list            -2           E..V...... List the available devices
-delay             <int>        E..V...... Delay frame output by the given amount of frames (from 0 to INT_MAX) (default INT_MAX)
-no-scenecut       <boolean>    E..V...... When lookahead is enabled, set this to 1 to disable adaptive I-frame insertion at scene cuts (default false)
-forced-idr        <boolean>    E..V...... If forcing keyframes, force them as IDR frames. (default false)
-spatial_aq        <boolean>    E..V...... set to 1 to enable Spatial AQ (default false)
-spatial-aq        <boolean>    E..V...... set to 1 to enable Spatial AQ (default false)
-temporal_aq       <boolean>    E..V...... set to 1 to enable Temporal AQ (default false)
-temporal-aq       <boolean>    E..V...... set to 1 to enable Temporal AQ (default false)
-zerolatency       <boolean>    E..V...... Set 1 to indicate zero latency operation (no reordering delay) (default false)
-nonref_p          <boolean>    E..V...... Set this to 1 to enable automatic insertion of non-reference P-frames (default false)
-strict_gop        <boolean>    E..V...... Set 1 to minimize GOP-to-GOP rate fluctuations (default false)
-aq-strength       <int>        E..V...... When Spatial AQ is enabled, this field is used to specify AQ strength. AQ strength scale is from 1 (low) - 15 (aggressive) (from 1 to 15) (default 8)
-cq                <float>      E..V...... Set target quality level (0 to 51, 0 means automatic) for constant quality mode in VBR rate control (from 0 to 51) (default 0)
-aud               <boolean>    E..V...... Use access unit delimiters (default false)
-bluray-compat     <boolean>    E..V...... Bluray compatibility workarounds (default false)
-init_qpP          <int>        E..V...... Initial QP value for P frame (from -1 to 51) (default -1)
-init_qpB          <int>        E..V...... Initial QP value for B frame (from -1 to 51) (default -1)
-init_qpI          <int>        E..V...... Initial QP value for I frame (from -1 to 51) (default -1)
-qp                <int>        E..V...... Constant quantization parameter rate control method (from -1 to 51) (default -1)
-weighted_pred     <int>        E..V...... Set 1 to enable weighted prediction (from 0 to 1) (default 0)
-b_ref_mode        <int>        E..V...... Use B frames as references (from 0 to 2) (default disabled)
disabled        0            E..V...... B frames will not be used for reference
each            1            E..V...... Each B frame will be used for reference
middle          2            E..V...... Only (number of B frames)/2 will be used for reference
-dpb_size          <int>        E..V...... Specifies the DPB size used for encoding (0 means automatic) (from 0 to INT_MAX) (default 0)


## pgp – Understanding GnuPG –export-options backup

The GnuPG documentation lists an option called --export-options parameters. One of the possible parameters for this option is backup (aliased export-backup).

The description for --export-options backup states:

Export for use as a backup. The exported data includes all data which is needed to restore the key or keys later with GnuPG. The format is basically the OpenPGP format but enhanced with GnuPG specific data. All other contradicting options are overridden.

What data is included in “all data which is needed to restore the key or keys later?”

When the documentation says, “is basically the OpenPGP format but enhanced with GnuPG specific data,” what enhancing data is it talking about?

In stating “other contradicting options are overridden,” what contradicting options are being referred to?