plotting – How to reverse the order in which ListPlot plots multiple array of numbers?

list = {{1, 2}, {1, 2, 3}, {1, 2, 3, 4}};

Add x-coordinates to each data point using MapIndexed + Thread:

list2 = MapIndexed[Thread[{#2[[1]], #}] &, list]
{{{1, 1}, {1, 2}}, 
 {{2, 1}, {2, 2}, {2, 3}},
 {{3, 1}, {3, 2}, {3, 3}, {3, 4}}}
ListPlot[list2, PlotStyle -> PointSize[Large], PlotLegends -> InputForm /@ list]

enter image description here

You can also use MapThread + Thread to construct list2:

list2 = MapThread[Thread[{##}] &, {Range@Length@list, list}]
{{{1, 1}, {1, 2}}, 
 {{2, 1}, {2, 2}, {2, 3}},
 {{3, 1}, {3, 2}, {3, 3}, {3, 4}}}

Reverse Load Balancer: Out Balancer?

Load balancing in is a common topic, but there isn’t as much said about load balancing out. I may have an application that can prepare 1mm requests/s but is unable to send them all out at that speed because of network restraints.

Is there a concept of an out-balancer? Are there any ready-made solutions out there that can take, say, a csv of 1mm requests and distribute them across nodes and send them?

enter image description here

The "Out Balancer Coordinator" could just be a queue. But that’s getting into DIY territory where I’m wondering if something like this already exists.

mathematical optimization – How to reverse or restore the order of my cells in Wolfram Mathematica Cloud?

Thanks for contributing an answer to Mathematica 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.

reverse engineering – What is source of bad characters exist in buffer overflows

I’m new to exploit development and while watching a tutorial I came across the topic of “Bad character identification”. I’m referring to the process of sending all possible characters to the vulnerable process to see if there are characters which fail to pass to the receiver.

The existence and identification of those characters has been discussed many times before but I couldn’t find the root cause of their existence.

Why are there bad characters a target process mis-handles?

c# – Converting a string into an array and returning the values spelled in reverse

Good code, few suggestions.


Instead of having to check each and every time to make sure you can add a "," or not, add it for all the cases, use String.TrimEnd to remove the extra leading ","

            var names = s.Split(",");
            string temp = "";

            for (int i = 0; i < names.Length; i++)
            {
                for (int j = names(i).Length - 1; j >= 0; j--)
                {
                    temp += names(i).ElementAt(j);
                }
                temp += ",";
            }
            return temp.TrimEnd(',');

With that change, we have the ability to foreach loop to further improve the readability of the code.

            string temp = "";
            foreach (var name in s.Split(','))
            {
                for (int j = name.Length - 1; j >= 0; j--)
                {
                    temp += name.ElementAt(j);
                }
                temp += ",";
            }
            return temp.TrimEnd(',');

That’s good. Although we can improve this further by using a better (faster and cleaner) method to reverse the individual names, and that is to use String.ToCharArray and Array.Reverse

The idea is to convert the string into a character array, use the inbuilt Reverse method to reverse it, add it to temp.

            string temp = "";
            foreach (var name in s.Split(','))
            {
                char() NameArray = name.ToCharArray();
                Array.Reverse(NameArray);

                temp = temp + new string(NameArray) + ",";

            }
            return temp.TrimEnd(',');

You can also use StringBuilder which is slightly faster

            StringBuilder reversed = new StringBuilder();

            foreach (var word in str.Split(','))
            {
                char() singlesentence = word.ToCharArray();
                Array.Reverse(singlesentence);
                reversed.Append(singlesentence);
                reversed.Append(",");
            }
            return reversed.ToString().TrimEnd(',');

Nitpick:

  • Prefer using a better name like reversed compared to temp, it tells more to the reader.

  • Use string.Empty and not ""


Benchmarks

Your original code

        static public string Reverse(string s)
        {
            var names = s.Split(",");
            string temp = "";

            for (int i = 0; i < names.Length; i++)
            {
                for (int j = names(i).Length - 1; j >= 0; j--)
                {
                    temp += names(i).ElementAt(j);
                }
                temp += i == names.Length - 1 ? "" : ",";
            }
            return temp;
        }

New

        static public string Reverse2(string s)
        {
            
            string reversed = string.Empty;
            foreach (var name in s.Split(','))
            {
                char() NameArray = name.ToCharArray();
                Array.Reverse(NameArray);

                reversed += new string(NameArray) + ",";

            }
            return reversed.TrimEnd(',');
        }

New2

        static public string Reverse3(string str)
        {
            StringBuilder reversed = new StringBuilder();

            foreach (var word in str.Split(','))
            {
                char() singlesentence = word.ToCharArray();
                Array.Reverse(singlesentence);
                reversed.Append(singlesentence);
                reversed.Append(",");
            }
            return reversed.ToString().TrimEnd(',');
        }

Note that I have static to use the function without an object reference.

I will use the following method to call the two functions multiple times, and benchmark it.

static void Perform(Func<string, string> Function, string names, int iterations, string type)
{

    var watch = System.Diagnostics.Stopwatch.StartNew();
    for (int i = 0;i < iterations;i++)
        Function(names);

    watch.Stop();

    var elapsed = watch.ElapsedMilliseconds;
    Console.WriteLine($"Time taken for {type}: {elapsed} ms");
}
        static void Main()
        {
            string names = "Jack,Dylan,Bobby,Peter";
            const int iterations = 1000000;

            Perform(Reverse,  names, iterations, "Original");
            Perform(Reverse2, names, iterations, "New");
            Perform(Reverse3,  names, iterations, "New2");
       
        }

Here are the results

/*
" Release " Configuration

 Iterations  |   Original  |   New     |   New2
-------------+-------------+-----------+--------
 10 000      |    29   ms  |    5   ms |   5   ms
-------------+-------------+-----------+--------
 100 000     |    226  ms  |    54  ms |   43  ms
-------------+-------------+-----------+--------
 1 000 000   |    1763 ms  |    442 ms |   405 ms


*/

Try it here

blockchain – How do I reverse an unconfirmed transaction to the original wallet

Is there an easy to understand step by step guide

No. There is no easy to understand guide if you do not understand the underlying processes.

I can execute to create a double spend and get the unconfirmed
transaction reversed back into the original wallet

The transactions can not be “reversed back” and are not going “to/from the wallet”.

so I can resend it with a higher fee and get it delivered?

The doublespending transaction is the transaction which uses the same input set, but has another outputs/fees. You do not need to do two steps (a) reverse original transaction (b) send another transaction with higher fees, because this is one step.

As far as I know, some wallets contain Replace-By-Fee features, but I use my own program. It is not “easy-to-understand”, but it works

unity – Character Controller and Reverse Gravity

So I have a Game object with Rigid Body , a Character controller and my Movement script. On a specific condition I am reversing gravity. The problem is that the velocity.Y when the gravity is reversed , keeps increasing to the infinity. If I try to reset it like in the first if statement (which works for normal gravity) the object keeps bouncing from the ground. Gravity scale is either 1 or -1 in order to reverse gravity and movement.

This is the code:

//Reseting States for new cycle , unless the object is falling
        if ((_isGrounded && velocity.y < 0))
        {
            velocity.y = -2f;
            _isRunning = false;
            _isJumping = false;
            _isFalling = false;
        }else if (velocity.y < 0 && !_isGrounded)
        {
            _isFalling = true;
        }
        //Moving on X axis
        float x = Input.GetAxis(KeyInputMove);
        if (x != 0)
        {
            _isRunning = true;
        }
        moveDirection = gravityScale*_transform.right * x;
        _controller.Move(moveDirection * moveSpeed * Time.deltaTime);

        //Perfoming jump
        if (Input.GetButtonDown(KeyInputJump) && _isGrounded)
        {
            velocity.y = (float) Math.Sqrt(1 * -2f * globalGravity);
            _isJumping = true;
        }
        
        velocity.y += gravityScale * globalGravity * Time.deltaTime;
        _controller.Move(velocity * Time.deltaTime);

How to properly focus using a Macro reverse ring?

Fourth question from me about this topic.

I’m trying to digitize a large number of family slide films with a modified slide projector by taking photos of the slides (I replaced the original yellow light bulb by a cheap cool white 50W LED).

I’m using a Nikon D5000 with a 55-200mm lens that I reversed using a reverse ring.

I’m able to get quite decent shots (in manual mode of course) however my focusing process can really be improved I think

  • When looking through the built-in viewfinder I only see blurry colors
  • When watching the live view with the camera screen I can’t see anything very sharp (but still better than the viewfinder).
  • When plugging the camera to my computer and using DigiCamControl to check the live view it’s also quite blurry

Only once I take the shot I can see a clearer picture. So when I set up everything to digitize some slides I always have to guess where’s the sharpest point, take several pictures and compare them to see which one is at the end the sharpest one.

Is there any way I can improve that? I really would like to be able to see through the built-in viewfinder directly to determine the exact sharpest spot.

Thanks for your answers

real analysis – Functions that satisfy a reverse triangle inequality: do they have a name?

Let $f : mathbb{R}^n to mathbb{R}_+$ satisfy
$$f(a) – f(b) le C f(a – b)$$
$forall a, b in mathbb{R}^n$ for some $C ge 0$. Is there a name for such functions? (I would be happy to have a name for the special case $C=1$.)

Note the similarity to
$$||x|| – ||y|| le ||x – y||$$
which is satisfied by all norms.

Can a reverse zone be nested inside another reverse zone?

Say I have a DNS server with a reverse zone as follows:

168.192.in-addr.arpa

Can I create an independent DNS server with the following reverse zone, and have both work correctly:

100.168.192.in-addr.arpa

Assume that the first server has no other entries related to the 192.168.100 subnet.