calculation and analysis – How to shorten the length of the tangent line

I have all the necessary equations to manipulate the tangent line on the graph … but the tangent line is too long, what would be the best way to shorten it?

f (x_) = Sin (x);

Plot (f (x), {x, -2 Pi, 2 Pi})

tangent (f_, a_, x_): = f (a) (x – a) + f (a)

Manipulate(Plot({f(x), tangent(f, p, x)}, {x, -2 Pi, 2 Pi}, Epilog -> {Red, PointSize(.015), Point@{p, Sin(p)}}), {p, -Pi, Pi})

blockchain – Chain Race: How to know the length of a chain in competition?

What happens if the 10% fork (chain A) now extracts a block and sends it to the network?

When a miner under construction over A has found a valid block, he will relay it to the rest of the network. By convention, suppose that the fork (chain A and chain B) has reached the height of the block N. This is how the different nodes in the chain will react.

  1. Nodes already use channel A: For them, this block N + 1 is a natural progression of the blockchain and therefore they will only add this block to their blockchain.
  2. Nodes using string B but having the block of string A: Some nodes might have received the string A block in height N after receiving the block in height N This block received later is not rejected, but is processed and kept on the disk in the format. Thus, when a block of height N + 1 is received from the version of the chain A, these nodes simply reverse the height string N and use the other block kept on the disk.
  3. Nodes with only the B string: When they receive a block of height A + 1 of the string A, these nodes will see that they have no parent. As a result, these nodes will query the parent block using the previousblockhash and see if that exists. Nodes with this block then pass this block to nodes that do not have it. When this block is received, these nodes will see that this string is the proof of the longest proof of the chain of work. They will now operate on channel A. The block located at the N height of the B-channel becomes out of date, but it is not ignored and remains on the disk.

How do they know this chain is longer?

Nodes accept the longest proof of the chain of work (in most cases, the longest chain). The nodes first synchronize the headers and check the proof of the work of the chain before asking the real blocks to the other nodes. When the version B nodes of the string receive the N + 1 block header of version A, they will see that the chainwork the received block is greater than that of the other string and will use it to query the block associated with it.

How do they know that the block is not part of DDoS attacks?

When they receive the block header, proof of work is checked first. So, if the attacker wants to spam the network with invalid blocks, he will have to do it with valid proof of work. This means spending a huge amount of energy like other miners, but not receiving a reward (the block having no ancestor, it will be rejected). If the node receives a block header with an invalid proof of work, the node that sent this block header will be placed on a blacklist after some attempts of this bad. This is actually the basis of the war program in the 90s, when it was used to prevent spam.

layout – Slack or similar application: length of the message line?

I was just wondering why Slack did not limit the length of the message text on the desktop one way or the other, as if we were going full screen and no side window was available. open text message being difficult to read?

Do they know that many users resize the Slack window and that they do not want to embarrass it or that they just say if you want, you can, because why not :]? ?

I took Slack as an example of messaging application, but – Messenger has a different approach – limits and a conversational presentation.

What you think?

measure a rectangle length and width from a data table

For an array of data points x, y, z:

{{0.9999, 0.9999, 1000}, {0.9999, 0.99991, 1000}, {0.9999, 0.99992, 
  1000},...., {1.0001, 1.00008, 50}, {1.0001, 1.00009, 50}, {1.0001, 1.0001, 
  1000}}

The value z at x = y = 1 has an identical value in a rectangular pattern on x and y centered on x = y = 1. Is there a way to find the length and width of this rectangle? Or the number of points x and y that share the same z-value for that rectangle? Here is the code that shows the central rectangle, with a length of 9 points and a width of 5 points:

collatzStuffC = 
  Compile({{c1, _Real}, {c2, _Real}, {nStart, _Integer}, {nStop, 
_Integer}, {maxStepsToCheck, _Integer}}, 
   Module({stepsForEachN = Table(-1, {i, nStop - nStart}), 
     stepsForEachNIndex = Table(-1, {i, nStop - nStart}), n = -1, 
     m = -1}, Table(n = x;
     Table(
      If(n < 2 && i > 1, {-1, -1, -1}, 
       If(EvenQ(n), n = Round((n/2)*c1), n = Round((3*n + 1)*c2));
       m = i;
       {x, m, n}), {i, maxStepsToCheck}), {x, nStart, nStop})));
Options(collatzData) = {"Coefficient1" -> 1, "Coefficient2" -> 1, 
   "Start" -> 1, "Stop" -> 10, "MaxIterations" -> 100};
collatzData(OptionsPattern()) := 
  collatzStuffC @@ 
   OptionValue({"Coefficient1", "Coefficient2", "Start", "Stop", 
     "MaxIterations"});
collatzStuff(ops : OptionsPattern()) := 
 With({cd = 
    collatzData(
     ops)},(*this is just a bunch of vectorized junk to pull the last 
position before the {-1,-1,-1}*)
  Extract(cd, 
   Developer`ToPackedArray@
    Join(ArrayReshape(Range(Length@cd), {Length@cd, 1}), 
     Pick(ConstantArray(Range(Length@cd((1))), Length@cd), 
       UnitStep(cd((All, All, 1))), 1)((All, {-1})), 2)))

plots3Dlist = {};
startN = 2002;
stopN = 2002;
c1min = 0.9999;
c1max = 1.0001;
c2min = 0.9999;
c2max = 1.0001;
c1step = 0.00001;
c2step = 0.00001;
maxIterations = 1000;
For(abc = startN, abc <= stopN, abc++, 
 Print(StringForm("loop counter `` of ``", abc - startN, 
   stopN - startN));
 thisIsATable = 
  Table({c1, c2, 
     collatzStuff("Coefficient1" -> c1, "Coefficient2" -> c2, 
       "Start" -> abc, "Stop" -> abc, 
       "MaxIterations" -> maxIterations)((1, 2))}, {c1, c1min, c1max, 
     c1step}, {c2, c2min, c2max, c2step}) // Flatten(#, 1) &;
 AppendTo(plots3Dlist, 
  ListPointPlot3D(thisIsATable, PlotRange -> All)))
plots3Dlist
thisIsATable

This code comes from the other question here:

solve for two variables for each n related to Collatz's conjecture

I would like to find the length and width of the rectangle for several graphics, then compare the length and width to see if there is a pattern.

How to generate fixed length cryptographic hashes?

I'm trying to implement some sort of email checking system with a stateless node.js server.

The strategy

  1. The user sends his email to the server
  2. The server generates a 4-digit code based on the email address and sends it to the user by email.
  3. The user returns the code received by email + the email address to the server
  4. The server recreates the 4-digit code according to the email and compares it to the code sent by the user.

My implementation to generate the 4 digit code

  1. Create a HEX digest using the HMAC SHA-256 hash function
  2. Take the first 3 characters of the digest
  3. Convert them to an integer
  4. If length <4, concatenates one or more 0 at the end
const crypto = require('crypto')

const get4DigitsCode = (message) => {
  const hash = crypto
    .createHmac('sha256', Buffer.from(SECRET_KEY, 'hex'))
    .update(message)
    .digest('hex')

  const first3HexCharacters = hash.slice(0, 3)

  const int = parseInt(first3HexCharacters, 16)

  let code = int.toString()
  code =
    Array(4 - code.length)
      .fill(0)
      .join("") + code

  return code
}

After generating codes for 8293 email addresses, I noticed that I had 4758 duplicates. Is it normal to have as many duplicates for a code of this type? Are my strategy and my implementation secure (possibility of guessing the code)?

tracing – Increasing the length of frame ticks

Honestly, I am a little surprised that the statistics of the plot have not been the object of a little attention during this last important update. I hope a little that this is on their list, but I will not hold my breath.

The best way I've found to do it somewhat easily, is to download and install one of Mark Caprio's packages, either SciDraw or CustomTicks(Http://library.wolfram.com/infocenter/MathSource/5599/). Once installed in the appropriate directory for your system (the guide provides instructions), you can do something like this:

< 2);
Plot(
  x^2,
  {x, 0, 5},
  Axes -> False,
  Frame -> True,
  FrameTicks -> {{LinTicks, StripTickLabels(LinTicks)}, 
                 {LinTicks, StripTickLabels(LinTicks)}}
)

Parcel of x ^ 2 with longer ticks.

I admit that it requires a little extra work the first time, but I installed it once when I got Mathematica 10, and I do not have to m & # 39; to worry since. More, CustomTicks has a number of other useful features for ticks, such as the easy passage of internal ticks to external ticks.

The other approach is to create your own function to generate ticks. It works, but it is heavy, and there are often unexpected cases (well, there are some for me, but others may have better foresight).

ticks(min_, max_, stepsz_, majdivs_, baselength_, 
  insideticks_?BooleanQ, labels_?BooleanQ) := 
    Table(
      {i, If(Mod(i - min, majdivs) == 0 (And) labels, ToString(Round@i), ""),     
        If(insideticks, #, Reverse(#)) &({If(Mod(i - min, majdivs) == 0, 2 
          baselength, baselength), 0})}, 
      {i, min, max, stepsz}
    )

Plot(
  x^2,
  {x, 0, 10},
  Axes -> False,
  Frame -> True,
  FrameTicks -> {{Automatic, Automatic}, 
                 {ticks(1, 9, 0.2, 2, 0.02, True, True), 
                  ticks(1, 9, 2/10, 2, 0.02, True, False)}}
)

Draw x ^ 2 using my own tick generator function.

Tick ​​length in the plot

I know I can manually adjust the tick length of the frame using FrameTickStyle. However, is there a way to globally increase the length of ticks?

Certificates – ECDHE_RSA_WITH_AES_128_GCM_SHA256 – How to determine the length of the ECDHE key?

Server: SSL certificate, public key RSA 2048 bits, signature algorithm is sha256RSA

What do I forget here? !

  • I have browsed the RFCs and I have not found anything yet on how to determine the size of the ECDHE key (or any key exchange algorithm key size) in a TLS encryption suite. I must confirm that ECDHE is at least 256 bits for compliance reasons.

  • In RFC8422 and RFC4492, it is pointed out that for ECDHE_RSA, the certificate MUST contain an RSA public key … now understood, how can I determine the key length of the curve?

I do not understand why in SSH, a key exchange algorithm such as "ecdh-sha2-nistp384" contains the size of the curve (which also determines the hash size), the bit of a sequel TLS encryption is not the case.

  • The same goes for DHE_RSA_WITH_AES_128_GCM_SHA256 – How can I confirm that Diffie Hellman Ephermal has 2048 bits?

Do I need to see other information than Cert and Cipher Suite? Should I dig in the code? Thank you in advance for any help with that!

dnd 5th – If the rope length used in Rope Trick is the same as the height of the piece, is the entry at the ceiling level?

In Rope Trick, you can use a rope length Up & # 39; to 60 feet long to create "an extradimensional space that lasts until the end of the spell", but does the extradimensional space have to adapt to the material plane or does it create there an entry into his space, similar to a portable hole? Specifically, would the entry of space be at the ceiling level or would it stop a few feet beneath it?

What affects the most of … the distance to the subject or the focal length?

Say I want to shoot a butterfly. My goal is to ensure that the butterfly fills the frame. I can do it in two ways … I can use the zoom or just bring the subject closer to the camera.

Who will have a bigger DOF? Zoom max or min-zoom + camera closer?