Summer Synopsis

This summer, I spent most of my time at work creating a thirteen-part video course about electronics. I became quite comfortable in front of a camera and even though I didn’t have a teleprompter, I came up with a fairly engaging final product. The company president asked me to do a presentation to anyone willing to listen about the four projects I’ve worked on over the past two summers. To present my course, I decided to make a video about what I’d done. It highlights some of the best parts. You can watch it here:

Better yet, if you want to take my course, you can at the K12 Global Classroom once I make it publicly available.

Review: Insten Portable Docking Speakers

Full disclosure – I didn’t buy a high-end iPod speaker dock. As a matter of fact, calling what I bought an iPod speaker dock is a stretch: it has a standard headphone jack connector that fits in a wide variety of devices, my iPhone included. It won’t charge your phone, even though it is battery-powered and has a 6V (either from USB or another source) connector as an optional power source. I’m not even sure if you can use both at the same time because I’m afraid to try. However, the speakers do have a nifty little clip that will hold your device in place and even end up looking kind of like an iHome without any fancy features.

Insten Speaker Dock

The word “swag” almost pops into my head when I see this.

Oh, I forgot to mention that you can buy a pair of these headphones here for the too-low-not-to-try price of $7.49. With free shipping. Considering that and the five-egg reviews, I decided that these would probably do everything I needed them to, so I pulled the trigger. A week or so later, they arrived after being mailed in a bag. I was a little surprised, since these are plastic and don’t even have speaker covers and thus are probably somewhat fragile.

In your hand, these speakers do feel a little bit cheap, but I wouldn’t say they feel $7.49 cheap. Both the volume control and power switch feel solid enough, but the audio cord is pretty short and feels flimsy. It won’t last. The battery cover doesn’t snap into place very convincingly and that magic phone holder feels like it would snap pretty easily. The glaring lack of speaker covers also adds to how cheap these look. Still, the blue power LED is very bright and I’ve still seen much more poorly made products sell for much more money.

Folded Speakers

Yes, they will fit in your pocket for convenient carrying, albeit a little awkwardly.

$7.49 becomes an even better deal for these speakers when you take the sound they are able to produce into account. I didn’t know what to think when I saw that these speakers have a response range of 150 Hz to 18 kHz. I’m more experienced as a headphone buyer, but for the sake of comparison, my Sennheiser HD 448s have a response range of 16 Hz to 24 kHz, meaning that they are able to produce a far better range of sounds, particularly in the bass neighborhood. You don’t really hear any noises above 16 kHz so that’s irrelevant here.

That being said, you won’t mistake these speakers for the auditory masterpieces that are the Shure SE 215s and the Sennheiser HD 448s anytime soon. These speakers don’t sound overwhelmingly tinny but they are definitely treble-heavy. The underlying bass components from dubstep songs are more or less absent. Zomboy’s “Bass Cannon” remix is just some weird noises. Still, for most other genres (including a lot of electronica), these speakers are surprisingly punchy and hold their own. These speakers make your music way louder than your iPhone’s built-in speaker. My iPhone said they managed to produce 93ish dB at about a foot away before they started to clip a lot. Not too shabby.

To summarize:

  • Pros: Value – the sound quality, construction, convenience and volume for the money. Free shipping is a big plus, too.
  • Cons: Still not very well made, lack of bass, lack of AC adapter, does not include rechargeable batteries, will not charge iPhone.

I give the Insten Portable Docking Speakers 4/5 stars.

Porting my Calculator to Python

Although the first language I actually learned was VB.NET, Python is what actually inspired me to begin programming. My dad talked me out of learning it (one of my friends suggested that I did); who knows what kind of programmer I would be today if I had learned it. My guess is that I would be better with server-sided activities and worse on the desktop. Perhaps I’d be more of a Linux guy.

Anyway, I got inspired to learn Python yesterday for whatever reason, and today, I decided to port my calculator to Python. For the sake of comparison, I stayed fairly true to my original C# program. Here’s the very annoying program I came up with (it has no way to exit and loops forever so you have to close the console if you want to close it):

# Python calculator program
# This is the first Python program I've written for a LONG time.
def main():
	while 1==1:
		try:
			number1 = float(raw_input("Enter a number, then hit enter: "))
			number2 = float(raw_input("Enter another number, then hit enter: "))
			operator = raw_input("Which operation do you want? (Choose +, -, * or /, then hit enter): ")
			if operator == "+":
				print "The sum is:", Add(number1, number2)
			elif operator == "-":
				print "The difference is:", Subtract(number1, number2)
			elif operator == "*":
				print "The product is:", Multiply(number1, number2)
			elif operator == "/":
				print "The quotient is:", Divide(number1, number2)
			else:
				print "Please choose another operator."
 
		except:
			print "Error, please try again."
 
		print "\r\n"
 
def Add(num1, num2):
	return num1+num2
 
def Subtract(num1, num2):
	return num1-num2
 
def Multiply(num1, num2):
	return num1*num2
 
def Divide(num1, num2):
	return num1/num2
 
main()

Here it is in action, running in PowerShell:

Python Calculator Image

You can do the four most basic operations over and over! Woo!

In doing this port, I noticed that my beginner-targeted C# code was way longer than it needed to be (with all the helper methods) but very easy to understand. I also noticed a lot of things about Python, some of which I liked and some of which I did not.

The Good

  • The console print command makes it very easy to concatenate variables in.
  • In the small program I had, relying on indentation instead of { } to organize code saved a lot of screen space.
  • The raw_input() function serves as an equivalent to Console.WriteLine(), Console.ReadLine() in C#, saving more keystrokes.
  • Overall simplicity and intuitiveness. I’m a C# developer, not a Python developer, but I was able to complete this port with a little help from Google. Python operators were similar to the C# ones and the syntax isn’t difficult to understand at all. I can read Python code and understand much of what it does, unlike Ruby programs which tend to make my eyes glaze over.

The Not-So-Good

  • I’m not sure how well the whole indentation thing would work in a huge program. Things are bound to get mixed up eventually. Still, I’ve spent plenty of time counting curly brackets trying to figure out why my code won’t compile, so it may just come down to preference.
  • Lack of strong typing. I’m used to seeing float number1, not just some random variable declaration. Again, things could get confusing, especially if you forget what a variable is for.
  • The variable declaration syntax. It makes copy and pasting code much easier not having to get rid of keywords, but it is nice to know that you are declaring a variable for the first time, even if it is with the var keyword in JavaScript.
  • This page says, “Java is a pair of scissors, Ruby is a chainsaw.” That’s fair enough, but where does Python figure into things? Does it have enough horsepower to get things done or should I stick with my C#?

Even with its flaws, I do rather like Python. XKCD sums it up pretty well. I think I will try writing some more programs in it. Heck, I might do some server-sided things with it. Learning another programming language can’t possibly be a bad thing.

Project Railgun

My friend David chatted me on Facebook this morning and told me that me he’d finally figured out something cool we could build together – “a huge catapult or something”. His anticlimactic message inspired me, however. For the past few years, there have been three things I have really wanted to build but have not for some reason:

  1. A barely-street-legal electric bike
  2. An antweight robot with an eggbeater weapon (the fairyweight has been taken care of!)
  3. A railgun

David’s mentioning of “catapult” gave me an amusing idea: what if we built an electric catapult of sort? What if we built a railgun? I looked on YouTube a few weeks ago and found this small, interesting specimen. It seems to use 3 120 microfarad photoflash capacitors charged up to 330v – a fairly cheap project.

If David and I decide to build this device, I will update this blog with our progress. This is a fascinating project for two high schoolers to undertake – we both took and did well in AP Physics last year but there are a huge numbers of variables that we’ll have to deal with and there is a large amount of danger considering the energy we’ll be storing. Still, it’s nothing we won’t be able to handle. After all, I’ve only been building combat robots for nine years!

Here’s what we’ll have to consider:

  • Rail material. I’ve read that copper is good but I have also heard of railgunners (I guess you could call railgun hobbyists that!) using aluminum and even graphite as materials.
  • Armature material. Obviously, making complicated armatures for a hobby railgun seems pointless since the railgun will either melt it or launch it in such a way that it will deform upon striking a barrier, so we’ll need some other kind of solution. I want to try metal BBs, but I’ve also heard of small railguns using everything from aluminum foil to nuts.
  • Capacitor capacitance and what voltage we want to use. I found a cheap source of photoflash capacitor chargers online (they sell for ~$5) that can charge capacitors to several hundred volts with the help of a power supply. We’ll have to do some calculations to see how large a capacitor we should use. There is a lot to consider – Lorentz forces on the rails (keeping our railgun from breaking), the massive losses (this Princeton railgun writeup states that good hobby railguns achieve an efficiency of 0.1%), how massive our projectile is, and how fast we want to shoot it.
  • How to activate the railgun. We will need to design some sort of large switch that will have four modes: fire, charge, discharge and disconnected. We will need to be able to activate it without shocking ourselves or anything else (and without spraying sparks everywhere). We also want to avoid welding the switch shut.

With all these worries and potential problems, I feel crazy even thinking about attempting something like this with college apps happening – it’s a near-certainty this project will get tabled come, oh, say, August 29th when I go back to school. I can’t wait to get started!

Brute Security

DISCLAIMER: I do not endorse the use of any “cracking” methods I discuss in this article for anything but educational purposes, nor do I claim to be any sort of “security expert”. Everything here is provided “as-is” with no warranty whatsoever.

With the legal jargon taken care of, let’s discuss passwords and why you have them (note the plurality – I sure hope you don’t simply have one password!). Passwords protect your information.Without them, everyone would have access to everything with only a username. Would you feel comfortable with that? I didn’t think so.

So, if the point of a password is to protect your security, then it follows that a password should be as secure as possible. What makes a secure password? I turned to Google for some advice. Here’s the jist of what I learned:

  • Length is super-important
  • Mixing uppercase letters, lowercase letters, numbers and symbols makes the best password possible

What’s groundbreaking about that? Absolutely nothing – tips for crafting great passwords have been around for as long as I have been able to read them. The problem is that great passwords are often difficult to remember. For example, AsJ*()gM,4 is ten characters long and has at least one character from each category I just mentioned. XKCD came up with a solution to the problem, though I don’t agree with simply using lowercase letters (and Google rates the example “correcthorsebatterystaple” password as “Good” rather than “Strong”). Why only strong for such a long password? Here are two common for breaking passwords:

  • Dictionary attacks are attacks using common “passwords”, usually derived from the dictionary or other common phrases. Dictionary attacks are the easiest, fastest way to break insecure passwords. Is your password “password”, “password1″, “123456″, “qwerty”, or anything else on this list of tragically bad passwords? It will be broken with a dictionary attack.
  • Brute force attacks are exactly what they sound like – they try every password combination possible. They are useful when dictionary attacks fail, because “zebra” will be cracked by a dictionary attack, but “ze6ra!” probably won’t be. They also aren’t very much work to implement but take much, much longer than a dictionary attack. How much longer? I wanted to find out.

I wrote a very, very slow brute forcer implementation in C#. I am not going to publish the source code on the blog, but I’ll give you an idea of how it works:

  •  The brute forcer is passed a string containing every character it should try, which could be something like “abcdefghijklmnopqrstuvwxyz”. It is also passed the MD5 hash of the string it is trying to break.
  • The brute forcer uses a for loop starting at zero up to the length of the trial string raised to the power of the maximum length to look for.
  • It computes the MD5 of the generated string and compares it with the one it is trying to break. If they match, it is done.
  • There are some big slowdowns – the .NET framework (which I did my best to counteract by using the “unsafe” keyword) and that I am only using one core. Sure, I have a 3.7gHz i7, but I am only using one of eight possible cores. These passwords would break much faster if I used all of them or if I had a supercomputer.

The way this brute forcer works has taught me two things just how correct that password advice is. It’s all in the math.

Longer passwords make taking passwords way longer. Let’s examine a two character password comprised of uppercase and lowercase letters. There are 52 possible first letters and 52 possible second letters, so the total number of password permutations is 52 * 52, or 52 ^ 2. It follows that the number of permutations is 52 ^ N, where N is the length of the password. Therefore, assuming every cracking iteration takes the same amount of time (around 50 microseconds on my password cracker near the beginning, which isn’t very fast), every letter you add makes cracking take 52 times as long. If you add three characters, there will be about 140,000 times as many combinations.

Special characters make password cracking take far longer as well. Think about it – if your password is comprised solely of lowercase letters, there are 26 ^ N permutations. Add the uppercase letters, and there are 52 ^ N. With the numbers 0 – 9, there are 62 ^ N. Add ~`!@#$%^&*()_-+= and there 78 ^ N.

According to my expert Windows calculator usage (in scientific mode, which the C# calculator tutorial didn’t cover), a five-character lowercase password has 11,881,376 permutations, while a five-character password that could use every symbol I have mentioned has 2,887,174,368 permutations. That’s right – the jump is from 11.8 million to 2.9 billion. In fact, you would have to use about a seven-character (well, about 6.7-character) lowercase password to match the strength of the five-character anything-possible password.

Not convinced about the huge difference? Here are some action shots with some different password lengths (all matching against the “anything-possible” string of 78 characters):

Three-Character Password

Three-character password.

Four-Character Password

Four-character password.

Five-Character Password

Five-character password. To be fair, my computer was asleep for much of that time.

So, in going from a three character password we went from less than one million iterations to success to 2.4 billion iterations to success. Imagine how long this would take with, say, an eight-character or ten-character password.

As always, there is one big concept I want you to take away from my articles. In this case, it is that adding just one symbol to your current password (even if it as simple as putting it in parentheses or putting an asterisk in front) will strengthen it immensely. Stay secure!

And so Begin the Crazy College Apps

Today is August 2, 2012. Yesterday was August 1, 2012. Why is that special, other than that I can now say later this month, I will be entering my senior year of high school? Ladies and gentlemen, this year’s Common App is out. The essay topics aren’t any different, but the release comes as a reminder that college crunch time is coming (and has helped me realize that there are limitless alliteration possibilities with the word “college”).

I have two shots at the SAT to get my score up just a little bit in hopes that it will give me just a little edge. I also have to take an SAT Subject Test on the date I don’t take the real deal. I will need to figure out which test is right for me. I have realized in the last 36 hours or so why the autumn of one’s senior year is so crazy. Come August 29th, I will have to balance fall golf, four AP classes, SAT studying, “Common Apping” and applying to two non-Common-App schools. My amazing 10:30 bedtime from junior year is beginning to seem out of reach, at least in the short term. It’s a classic case of “pick two of friends, sleep or grades” situation, except I only have time to pick one.

At the moment, my big concerns lie with the SATs and application essays – I want to make the best impression I possibly can. Unfortunately, I can’t rely on chance to bring my SAT scores up. However, I have a study book and I’ll be working from that. One thing that has really stuck out to me about the entire college process is its expense. The SAT is $50 to take and costs extra money to send your score to more than four colleges. College application fees are in the $75 range. I will probably end up spending something in the $900 range on applying to schools, an amount in pales in comparison to the $40,000+ per year that college will cost, even with financial aid.

Because of the already immense cost, it is hard to justify spending in upwards of $150 per hour on an SAT tutor or a thousand more on an essay reader. Does it bother me that I will have to work excruciatingly hard to get into one of the schools I want to attend? Not in the least. I’ve never been a stranger to effort, and all my extra work will make (hopefully) getting in all the sweeter.

With all that said, I still have a month of summer – one last month of freedom. I’ll blog regularly about my progress.