While on break, I’ve been playing around with Mozilla’s File API and integrating it with Duke Webfiles, which I work on for OIT. This is only a proof of concept since the spec has not been completed and I only implemented it in the icon view of Webfiles. Regardless, I think it is pretty cool and makes the application much easier to use. Here is a screencast to see it in action:
To do this I used examples from here for the new File API and here for the AJAX upload. Obviously this could be expanded upon by implementing it in all three file views in Webfiles and by showing progress bars for each file. Additionally, there are some small bugs with uploading large files. However, if you are a Duke student and want to give it a try, follow the instructions below. Please note, this is a alpha version of the software, and you may run into some bugs when using it.
For my discrete math course (CPS 102) this semester, I had to create a space-filling curve for one of my homework assignments. I decided to take this as an opportunity to play with HTML5′s canvas element since I’ve yet to had a legitimate use for it in any programming yet. I think it came out decently well (and it’s kind of fun to play with), so I thought I’d post it. Here is a link to it on my Duke account http://duke.edu/~amb79/fillSpace.html Like I said, nothing huge but fun to program and cool to watch.
I am on fall break now, and will be spending the weekend at home. Hopefully I’ll do something cool while I’m home and will post if anything comes out good.
After playing with the Jetpack API and having an increasing desire to procrastinate my Spanish homework, I decided to give the Ubiquity API a shot too and make a few small scripts just to make my life easier. The first extension I made was a script to do look ups of IP addresses and get more information about them. This is useful mainly if you are looking at raw logs from a web server. After realizing how easy it was to make these scripts, I made two more for bit.ly links which I frequently come across on Twitter. The first can get more info and stats about a link (the number of clicks) and easily send you to the bit.ly info page for that link. The second script can be used to quickly expand the links from their compressed bit.ly form to their original form. I know there are other scripts that can do this across an entire page, but felt I’d rather keep short links with a quick and easy way to find out what the link contains. If any of these sound interesting/useful or if you just want to see some simple examples of how to code Ubiquity extensions, you can check the scripts out here. I have also included screenshots for each of these scripts below.
Recently, while flying between Durham and New York, I decided to take a picture of the propeller during take off. I don’t know what prompted to me to do this, but when I pointed my iPhone camera at the propeller out my window I noticed very odd pattens. I took multiple pictures throughout the flight with my iPhone, and in some cases at the same time took pictures/video with my Canon camera. To clarify the specs of the two cameras: I have an iPhone 3G (8 GB) and a Canon SD700 IS. As you will see in the pictures below, the iPhone’s picture simply makes no sense with the blades appearing to be disconnected vertical lines. The photo from the Canon seems reasonable, but as you will see in the video the propeller appears to be going fairly slowly, when in real life all I could see was a blur because of how fast it was moving.
Plane Propeller Photo from iPhone 3G
Canon SD700 IS Plane Propeller Photo
Update: here is a video taken from my iPhone 3G of the propeller.
This got me thinking about why the images looked the way they did. I assumed they were related to frame rate and as a result wondered if I could work backwards to find the speed of the propeller. When I got back to Duke, I talked it over with some of my friends. We discussed one theory that explained the slow spinning in the video from my Canon. I later found out is similar to the Wagon-wheel effect, and will go into more detail on this later. We also discussed possible distortions and other possible causes but couldn’t figure out exactly what was causing the odd pattern in the iPhone photo. Eventually, I decided to search around the internet and found that I was not the only one to notice this oddity. I also stumbled upon this great post explaining clearly and graphically why the iPhone photo looks the way it does. In short, most cameras save pixels from all parts of the lens at once, while the iPhone camera goes through the lens saving pixels linearly over time, similar to watching a scanner save the page of a book. (If anyone has an iPhone 3GS and can snap a picture and/or video of a propeller, please let me know. I’m very intrested to see if Apple’s upgraded camera still behaves this way. Please let me know if you find out.) The writer of the post also demonstrated this in a cool video made from a Matlab script:
Personally, I think this is really cool so I decided to play around with it some more. As I mentioned earlier, my friends and I had discussed the wagon-wheel effect or the stroboscopic effect, so I thought I’d modify his script to demonstrate it more clearly since the Wikipedia pages on the twotopics both seemed a bit lacking. First, it is necessary to explain the general concept. The stroboscopic effect explains if you only see flashes or quick individual frames of a moving object at regular intervals you can get a distorted view of the motion, especially if the motion of the object that is being watched is cyclic or has a frequency. The relationship between the frequency of the flashes or frames and the frequency of the motion is what determines the perceived motion. The most common case of this is seeing a wheel which you know to be rolling forward, but it looks to be spinning backwards slowly. I modified the previous Matlab code to create a basic example of this with the propeller (download the code here). As you will see, the propeller on the left will spin counterclockwise at a moderate speed and every 8 frames the image on the right will update with a copy of the image on the left. This out of sync updating will make the propeller on the right appear to rotate clockwise.
Click the image to view the video
I also decided to show this more mathematically by plotting these movements in Mathematica. In the following examples I graph both the y-coordinate of the tip of the propeller and the angle that the blade has rotated in radians. In the graph of y the coordinate, there are three sinusoidal functions representing 3 propellers, each offset from the previous by 120 degrees (thus equally spaced). These lines and their colors correspond to the colored lines on the radian vs. time graph. The red lines mark a flash or frame and the dot on the line shows the top-most propeller. As you vary the spacing of the lines and thus change the frame rate, you can see the propeller will appear to stay still, then go backwards, then flip back and forth with no perceived motion, then go forwards, until it appears to stand still again. Below are pictures showing each of these stages, followed by a video fluidly showing these variations.
Here is the propeller appearing to stand still. This is due to the fact that the spacing of the frames is twice the period.
The graphs below show the propeller appearing to go backwards. Here we see that the frame rate is just below two periods of the propeller. The downward slope on the radian graph is a simple quick way to see the direction of the propeller rotation.
Propeller appearing to flip repeatedly:
This example shows the propeller appearing to rotate forwards. Again, the upwards slope of the points on the radian graph is an easy way to see the direction of rotation.
Last, here is the propeller appearing to stand still again. Unlike the first case of the propeller standing still, the spacing of the frames is not a multiple of the period. Rather, we see here that it is a multiple of 1/3 the period. It is only necessary that the spacing be a multiple of 1/3 the period because there are three blades and the blades are indistinguishable.
And finally, putting it all together:
The Mathematica code can be viewed here or downloaded here, and a printout of the entire Mathematica worksheet can be found here. Last, if one had a camera which could vary the frame rate just so slightly as to find two nearest frame rates to show the propeller standing still, the frequency of the propeller could be calculated as shown below.
As for the iPhone picture, a single image (and knowing the number of blades) is enough to roughly approximate the speed of the propeller as shown below.
However, just as a warning both of these are back of the envelope calculations and it is very possible I made a mistake (if so please let me know). That is all for now. Nothing ground breaking, but as the title suggests, it was a good chance for some mental masturbation, playing with Mathematica and Matlab.
I got an e-mail this morning from someone who saw my post on Twitter about using LDAP on the iPhone here at Duke. The person said they followed the tutorial but couldn’t quite get it to work. So I figured it may be useful to post a few quick instructions on setting it up. As the post on Twitter explains, the basic instructions for getting to adding an LDAP account can be viewed here and Duke’s LDAP server settings can be found here. Once you are set to add the LDAP account, simply set the server to ldap.duke.edu, no need for a username or password. Once you click next you will want to turn off SSL and change the Search settings for duke,edu to have a base value of “ou=People,dc=duke,dc=edu” (leave the scope at subtree). And that’s it. To use it, which turned out to be the issue for the person emailing me, go to write a new email and start to type in the name of the person to search. You should see a throbber show up at the top of your screen, showing that it is connecting to the server. There is a bit of a lag but it should eventually return the contacts for people by that name. Below are some pictures of the settings and the search. Let me know if you run into any issues.