Using Port Forwarding in Virtual Box
There are a variety of reasons to work in a virtual machine. You might want to keep your development environment separate from a personal environment or you might want to use features in a different operating system. When using a virtual machine it may not be immediately obvious how to connect from a browser on the host machine to a server on the virtual machine. This article will explain the setup steps required.
Our arrangement that looks something like this:
Our host OS is Windows running Virtual Box. The guest operating system is Ubuntu running a django server. Before we begin we need to know the IP addresses of the host OS and the guest OS.
Windows Host IP Address
Open a command prompt and run the command “ipconfig”. This will list information about every network adapter on the system. Find an adapter that is assigned an IP address. Not this for later, we will call this the host IP address.
Ubuntu Guest IP Address
Open a command prompt and run the command “ifconfig”. This command will list all of the network settings for the linux guest operating system. Note the IP, we’ll call it the guest IP address.
Port Forwarding in Virtual Box
Virtual Box has the ability to route a port on the host OS to a port on the guest OS. To do this we will need to pick an unused port on the host system. We’ll use 8080. If this port is taken on your machine, pick a different port. On the guest operating system we can configure the Django server to run on any port. We’ll use 8000. We can run the command “python manage.py runserver <guest-ip>:8000”. With these settings in mind we can open the port forwarding settings in Virtual Box. We do this by right clicking the network icon and selecting “Network Settings…”
In the Window that pops up, click on the “Port Forwarding” button. In the dialog that appears, create a new rule. Enter the IP and port information collected earlier. After confirming your settings, Windows firewall may say that Virtual Box was blocked by the firewall. Create an exception to allow appropriate access.
Testing the Settings
Start the Django development server. Open a browser on the host OS. Change the address to <host-ip>:8080. The request will be routed by Virtual Box to the guest OS. If you see your Django project then the process worked!
Resources
Living Elegance: Mathematical Patterns in Nature
Introduction
Consider something as simple as a sea shell. In today’s fast paced modern life it can be easy to miss a sea shell. But if we were to pause from the distractions swirling around us we would see that the world is full of beautiful patterns. We see things like symmetry, stripes, tessellations and other patternsĀ when we just look. Today we will focus on patterns that can be described with the help of an idea called fractals.
Repeated Structures
A fractal is self similar, meaning that it has similar patterns at large and small scales. This similarity lends it self naturally to mathematical models. Let’s consider a fractal that is built using geometric rules. We can construct a famous fractal called Sierpinski’s Triangle. The rules for constructing this triangle are simple:
- Start with an equilateral triangle
- Break the triangle into four triangles of equal size
- Color the middle triangle
- Repeat step 2 for the three other triangles in the subdivision
Here is what the first four iterations look like:
Spiral Fractal
The Fibonacci sequence is constructed using a few simple rules.
- The first term is 0
- The second term is 1
- The third term is equal to the first term plus the second term (1)
- The nth term is equal to the the sum of the (n-1) and (n-2) terms
The first few Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13…. There are a variety of uses for this sequence but we get something special when we use the numbers to draw boxes. We start with a 1×1 square. Then we add another 1×1 square next to it form a 2×1 rectangle. Next we add a 2×2 square to form a 3×2 rectangle. We continue in this fashion adding new squares to form a new rectangle. When we have added a few terms of the sequence we can go back and connect alternating arcs on each square we added. The result looks something like the image to the image below.
It turns out spirals with similar ratios happen all the time in nature. It forms a type of fractal because as you continue the pattern the macro view looks similar to the micro view. To help you see this spiral in more places, please flip through the slide show that follows. Whether it is galaxies, hurricanes, sea shells, broccoli,ram horns or flower seeds, this pattern repeats over and over again.
Branching Fractal
Consider a tree that grows and splits into two branches. Each branch in turn splits into two more pieces. If we keep going for a few iterations we will get somethingĀ that looks like this:
We can add variation to the tree like structures we create by altering the angles and number of each branch. A key break through for exploring fractals came from a theoretical biologist named Aristid Lindenmayer. Lindenmayer created a system that used simple letters to describe the state of a plant’s leaves and branches. That system can be combined with simple rules that change the representation of the system over time. We used simple rules earlier while we explored the Fibonacci set. Our rule was that each value was based on the previous two values.
Since the letters describe the tree, we actually draw the result. Now drawing each branch would be very tedious, but luckily computers are great at doing repetitive math operations. A computer program can be constructed to draw out the equivalent “plant”. For example, they may draw a branch, and then turn 35 degrees and then begin drawing again. These three elements of a simple grammar, simple rules and a drawing program allow for a vast array of fractal creations to be explored. With these techniques it is possible to draw mountains, trees and other natural formations quickly using an algorithm or calculation instead of an elaborate 3D model that captures each facet and face.
Conclusion
If we look just a little we will find a wealth of patterns in every aspect of the natural world. We can use simple, repetitive rules to model systems that would otherwise be impossible to model. Fractals present opportunities for both beauty and curiosity. As we begin to understand fractals more and more with computers, we may find that the cure for cancer or a similar world changing discovery to be just a simulation away using fractals.
“Bottomless wonders spring from simple rules… without end” Benoit Mandlebrot
Handouts
- Fibonacci Sequence and Fractal Spirals, Fractal Foundation, http://fractalfoundation.org/fractivities/FibonacciWorksheetAdvanced.pdf
- Fractal Triangles, Fractal Foundation, http://fractalfoundation.org/fractivities/TriangleWorksheet.pdf
References
- Patterns in Nature, Wikipedia, https://en.wikipedia.org/wiki/Patterns_in_nature
- Visualize It: Sierpinski Triangle, Khan Academy program by Charles Cozad, https://www.khanacademy.org/computer-programming/visualize-it-sierpinski-triangle/3208360053
- Fibonacci Numbers, The On-line Encyclopedia of Number Sequences, http://oeis.org/A000045
- Fibonacci Number, Wolfram Math World, http://mathworld.wolfram.com/FibonacciNumber.html
- Lindenmayer System, Wikipedia, https://en.wikipedia.org/wiki/L-system
- L-Systems Turtle Graphics Renderer – HTML5 Canvas – by Kevin Roast, http://www.kevs3d.co.uk/dev/lsystems/
Videos
Math Outreach
Today the students in my Math of Everyday Things class did a workshop with 120 second graders. During the workshop we presented a few simple ideas to prepare the students for more advanced math and did activities to reinforce concepts.
The three key ideas were
- A slice of pizza is a fraction
- Pizza is a favorite of many children. (and adults!)
- LEGOs also make a great visual for understanding fractions.
- A circle has 360 degrees
- We can extend our pizza analogy by considering a pizza with 360 slices.
- Sports like skate boarding, snow boarding, ice skating and gymnastics in corporate rotations or spinning.
- Kids like to move. Games like duck, duck, GOOSE! can help children understand rotations and movement around a circle.
- Rules determine order
- Many math operations involve understanding and applying rules to reach an outcome. Whether it is multiplying large numbers, adding fractions or using the order of operations in algebra, rule and sequence play an important role.
- A simple way to understand and apply a rule is to line up by different criteria such as height, birthday and last name