What I Learned In Silicon Valley


So since I’m pretty much the only active author here (for now), I figured I’d change things up a bit. While I’ll try and keep the technical articles flowing, doing two or three a week isn’t really feasible. So expect a few more editorial-type articles – they’ll be clearly marked, so if you hate them, watch for the “Opinions” tag and run like hell!

Two months ago I packed up and left for the sunny state of California, hoping to keep out of the massive east-coast blizzards and learn a bit more about myself. While living in Oakland for two rainy and windy month’s wasn’t exactly what I’d had in mind, I’ve definitely learned a lot out here, especially as a software developer.

School Is Worthless

Without a doubt. If you’re a computer science, IT, or computer engineering major, I would strongly reconsider the choice. Not because you won’t learn anything at all – for sure, some of the computer architecture classes I took were quite interesting. Software engineering was one of the best classes I’ve taken.

All that doesn’t matter, though. Take all that knowledge I’ve gleaned from my classes over the four years of school, and it’s something I could learn on my own in a few months; less, perhaps. For all the talk of ‘getting used to working on projects and meeting deadlines’, school mostly just teaches you how to procrastinate and conform to pointless guidelines. It doesn’t teach you to really think, and it saps you of your energy.

If you’re a chemical engineer, or a nurse, or something else, rock on! School works for you – you need lab access, and you get plenty of hands-on work that you really can’t get anywhere else. But for us in the tech world, we’ve got access to all the materials we need, without the regimented bullshit of the universities.

So if you’re a CS major, check out something else. History, art, music – these will teach you so much more than the classes you’re required to take. Some of the best programmers I know have graduated with Fine Arts degrees, and been happier for it.

Meeting People Is Better Than Studying

I don’t mean studying in the ‘sitting down in the library, reading away at a book and taking notes.’ Plenty of times I would look around documentation, clean up code I’d done before, or think about some of the problems I was working on. I’d learn something each time.

However, nothing teaches you as much as a second perspective. The conferences and meetups, these were the things that pushed me further. Talking to real people about new or old topics resulted in more progress than any long coding session. It was an offhanded comment a Python meetup about the Mongrel2 web server that led up to me pushing for a redesign of my company’s front-end. A short talk with someone about heading to A Better World By Design lead me there and beyond, resulting in my traveling to San Francisco in the first place. Even roving discussions about topics that had nothing to do with programming would often give me a completely new view or idea about my work.

Ask Questions

Not everyone can be a mentor. People have their own jobs, their own life. But that doesn’t mean you can’t glean some kernels of information off the smart people around you. Traveling to PyCon and the various meetups in San Francisco taught me a lot about communication, and the importance of learning from others. I’m still using the stuff I talked with Zed Shaw about in my current job, and I’m learning a lot from the stuff Daniel Greenfield taught me at the PyCon sprints.

And it’s this yearning for answers that can get you into the communities you’re already striving to enter. I once thought that this blog would be the means to get into the tech world – now I realize that participating in discussion, learning, and asking those better than me tough questions are the real way.

Do It

Move out there. Maybe it will help you the way it helped me. Maybe it won’t. What do you have to lose?

PyCon 2011, AppEngine, and a BugFix

PyCon

Day 1 of tutorials has come and gone at PyCon, and I’m happy to say I learned quite a lot. While I’m fairly new to Python, I found the intermediate sessions I took informative and very understandable. I’d offer the same suggestion as others have given me – if you’re planning on taking a few lessons or attending a conference like this, pick the more advanced tutorials. The speakers were well-prepared and had very clear notes and examples – only true beginners would have found themselves lost.

Sadly, it’s impossible to attend all the tutorials at PyCon; having heard good things about every presentation I couldn’t make it to, it’s a shame. The community here is obviously very passionate and mature. Of the two talks I did get to attend, however, the presentation on Google AppEngine definitely stood out.

Wes Chun and Ikai Lan were (barring a missing VGA cable) very good teachers for the short three hours we had. It’s to be expected from a team from Google, but they knew the ins and outs of the AppEngine, and answered some very advanced questions about customer billing and the database models easily.

The main portion of the AppEngine workshop consisted of running through one of Google’s own code labs, designed to teach beginners how to deploy a simple app to the cloud. Though it may seem that running an exercise that’s available for free online would be a silly way of running a workshop, I think it worked quite well. Moving through it in a quick but concise manner, Wes and Ikai also talked about some of the more interesting features of the AppEngine, such as how the scaling works, how the ORM speeds up queries, and how to use the memcache to improve page speeds. They also talked about some of the limits of the engine, specifically with timing user requests and job lengths in the cloud.

Overall, AppEngine is clearly a very well-developed system and easy to use. It’s no wonder that it has taken off as almost a de-facto host for many smaller apps. Clearly systems like this and Amazon Cloud Services are in high demand, and the next several years should show us even more as the technology matures.

The Bug

Finally, there’s one small issue that someone setting up AppEngine on an Ubuntu machine should be aware of. Due in part to the fact that Ubuntu machines come with Python pre-loaded, some users may experience the following error while loading their code:

ERROR 20xx-xx-xx xx:xx:xx,xxx appcfg.py:###] Could not find version file at /usr/lib/pymodules/python2.5/google/../VERSION

The reason for this issue is that the built-in google package has a google.protobuf internal package that redefines the __file__ pointer that the AppEngine uses. There are several fixes, but the easiest is as follows:

The Fix

google_appengine/google/appengine/tools/appcfg.py

~Line 64:

-VERSION_FILE = '../VERSION'
+VERSION_FILE = '../../VERSION'

~Line 189:

-  version_filename = os.path.join(os.path.dirname(google.__file__),
+  version_filename = os.path.join(os.path.dirname(google.appengine.__file__),

google_appengine/google/appengine/tools/dev_appserver.py

~Line 149:

-VERSION_FILE = '../VERSION'
+VERSION_FILE = '../../VERSION'

~Line 3022:

-  version_filename = os.path.join(os.path.dirname(google.__file__),
+  version_filename = os.path.join(os.path.dirname(google.appengine.__file__),

Why Conferences Suck (For The Average Coder)

At Conference Start

As much as I love to promote conferences, I really have a bunch of problems with them. For everything that’s good about them, they’ve got a whole lot of issues, especially for the average coder.

Exorbitant Cost

For every conference like BxD, where attending doesn’t cost much more than $200, or $40 if you’re a student, there’s ten that cost $1000. Sure, even at that price, you could probably afford to go to one a year – but that’s not counting the airfare, or the ridiculous hotel prices you’ll have to pay. If you’re lucky, you’ll get the absolutely lovely “Conference Rate”. Yes, just for you, the conference goer, they’ve dropped the price from $189 a night! It’s now the ridiculously low price of $159 dollars a night!

This would have been fine ten years or so ago, but nowadays, with California’s real unemployment rate hovering at around 25%, most just don’t have the funds to do this kind of thing. So you end up having to choose between going to an affordable conference that is about a more general topic, and risking learning nothing when you get there, or going to something that might set you back a year of savings. It’s not a great choice.

Replaceable

Conferences can be great – intelligent speakers, companies who are eager to hire, and workshops that can teach you plenty. But often times, you can learn just as much on your own – there are thousands of resources online for any language you’re using. Screencasts, blogs, or lecture videos, you can learn just as much from these sources as you can from almost any conference.

If you’re looking to get hired, you’re better off looking elsewhere as well – you’ll be competing with the very best at conferences. You might make a few good social contacts at one, but there are many smaller events – hackerspaces, or various small programming events – that you can use to the same effect. There really isn’t anything you can learn at a conference that you couldn’t learn elsewhere.

A Solution?

There really isn’t much of a way to fix the first issue of cost. Conferences often do all they can to make things affordable – offer sponsorships through various companies, offer student discounts, and ask for donations. Conference halls, paying the speakers, paying for food, it all costs a lot. There’s only so much they can do to drop the prices.

Luckily, conferences do try to be less replaceable. They try to get the most prolific and intelligent speakers, and to run workshops that teach things you can’t often find on the internet. While the resources online are plentiful, sometimes the best way to learn is to be taught first-hand by the experts, and for most people, conferences are the way to do so.

In the end, it will be a while before conferences are again useful to the average coder. So don’t worry if you don’t have the money or the time – there are plenty of ways to replace them.

Spring and SuperProfundo

Spring?

Spring is coming around, and you know what that means! Good, because I don’t.

Hello loyal readers – I’m Vasja, one of the founders of this cheery niche called SuperProfundo, and I’m here to talk to you about just what the heck is happening around here, and what you should expect for the future.

Where are my damn articles?

If you’ve been subscribed for a while, you’ve probably noticed we’ve been releasing fewer articles over time. No, it isn’t because of you – we appreciate the readership and the good comments. But it seems that we’ve bitten off a bit more than we can chew; we’ve realized that writing articles consistently each week requires good commitment, serious writing skill, and a good body of knowledge.

While we’ve got all these things, and we are working on them daily, life has gotten in the way. So here’s what’s happening in the near future:

  • We’ll be running a solid redesign of the site. We’ve been wanting a theme that fits us for a while now, and we’ve been listening to your suggestions as well. Now, we’ve finally drawn one up.
  • We’ll still be posting regularly. You won’t be getting the same 5 posts a week that you’re used to, but you won’t be going without content.

When are you guys coming back?

While we can’t promise anything, we’re working on getting back in to this. SuperProfundo is important to us in a lot of ways, and it’s not a project we’re just going to give up on. But we’ve realized we can’t keep up a pace like this.

Then what should we (the readers) do?

Keep reading! We appreciate your time, and we hope you keep reading our articles, sparse as they may be. And don’t stop learning. SuperProfundo is all about improving, be it professionally or personally, and we hope that those are goals of yours as well.

- Vasja Volin (co-Founder)

Basics of AI : Local Search Algorithms

Chess and AI

AI is a huge field, and it’s often hard to understand where to start learning. If you’ve done some programming, you’ve probably learned something about ‘classical search’ – things like breadth-first or depth-first search of trees and graphs. This serves as a pretty decent introduction to artificial intelligence – a search through various states, looking for the best one, is at the core of making any sort of intelligence. But these basic searches make plenty of assumptions that don’t hold for the real world – for that you’ll need better algorithms:

Local Search

In the basic search algorithms mentioned above, the search spaces of the problem at hand are kept in memory – when a goal is found, the solution is the path from the initial position to the goal state. But in many cases, the path does not matter – only the resultant state. This is illustrated well with the familiar ‘8 Queens‘ problem –
[quote]Given a standard chess board and 8 queens, position them in such a way as to have no two queens ‘attacking’ each other – thus, no queen may be on the same row, column, or diagonal as another[/quote]

8 Queens PuzzleIt’s a fairly simple problem, but one that easily illustrates the importance of having viable algorithms. While on a small board like the standard 8×8, it would be fairly simple to brute force the problem – simply test every set of queen positions. If you build the brute force algorithm under the fair assumption that there can only be one queen per row, then the search space is very small – 8! (40,320) or less positions. However, this simple search rapidly gets much larger. If you extend the problem to be ’12 Queens’, you’re now dealing with 12! (479,001,600) states. On a modern computer, that amount is still fairly testable – but move to 15 or 20 (1,307,674,368,000 or 2,432,902,008,176,640,000) states, which rapidly changes the problem from taking seconds to taking years.

Luckily, however, local search algorithms handle this problem. At their heart, local search algorithms hold only the current state. At each step, the ‘surrounding’ states are evaluated based on some chosen heuristic, the best one is chosen, and the process repeats. Simple, right?

Not quite. This search algorithm is known as ‘hill-climbing‘, and it has one glaring problem – it’s not always guaranteed to find the solution. To understand why, consider the following concept:

The State-Space Landscape

State Landscape
The ‘state-space landscape’ is a way to describe how the overall structure of states looks – the landscape’s domain (x-axis) is the set of various states. The range (y-axis) is the value of that particular state based on whichever heuristic we are using to evaluate it. This two-dimensional graph is simplification – depending on the heuristic and branching factor, the real environment may have many more dimensions.

On the chart are several points of interest. (a) is the global maximum – our ‘goal’ state, and the one for which the heuristic gives the highest value. However, at (b) and (c) is where we encounter problems. Hill-climbing, obviously, cannot hop from hill to hill. If it hits the local maximum at (b) or the ‘flat’ local maximum at (c), it won’t have any way of moving further. Every state in its vicinity will return a value less than the current one. So how can we solve this problem?

Variants on Hill Climbing

The simplest way to solve this, and definitely the worst, is random restart hill climbing. This simply means that when the hill-climbing algorithm hits a local maximum, the process is restarted at another random state. In this way, the algorithm is guaranteed to eventually return the global maximum – over time, it will find a spot where the hill climbing will not result in hitting a global maximum or a flat point.

There are better solutions, however. Simulated annealing is another type of hill-climbing method. This method is based off annealing in metallurgy – allowing a metal to heat and cool slowly to get it in to its proper shape. In the algorithm, a variable T starts at a high value and slowly lowers – this value dictates the probability of choosing the next state, which is picked randomly from the current one.

At the start of the algorithm, when T is high, the states move about more quickly, and the algorithm can ‘bounce’ out of any local maxima. As T lowers, however, the process resembles hill-climbing more and more. If T is lowered slowly enough, the algorithm will return the global maximum with a probability approaching 1.

Then there is local beam search. This method is very similar to hill-climbing, with one exception. In hill-climbing, there is only one current state, but in local beam search there are many. At each step, the neighbors of each current state are evaluated, and those with the best value are chosen. Because of the random starts, this algorithm is much more likely to return the global maximum than just hill-climbing alone.

Even local beam search is not without its problems, though. Because the best states are chosen from the entire pool of next states, this method tends to end up ‘bunching up’; though the states start randomly along the landscape, if certain areas are significantly higher valued than others, the states will all ‘hop’ across to the better areas. This means that while the probability of returning the global maximum is higher, it still isn’t guaranteed.

This is where stochastic local beam search comes in. Just like local beam search, this algorithm uses many starting states. However, when the pool of next states is created, they are each chosen only with a certain probability – while the higher-valued states still have the highest probabilities to be chosen, the smaller-valued ones are still often chosen. This way, we guarantee that over time, the algorithm does not get stuck at any local maximums.

Other Algorithms, and Moving Further

The few local search algorithms presented here are only a small part of the those which have been created over the years. Not only that but these are only a small part of creating intelligent agents, and an even smaller part of AI at large. They are a good place to start, however.

If you’re interested in learning more about AI or the algorithms that are a part of it, leave some feedback in the comments below – we’d love to learn more about what our readers are interested in, and it helps us tailor our articles better to you.

Arming Your Computer Against Theft

Kensington Lock
If you’re very lucky, you’ll never have your laptop or mobile stolen from you. However, this probably won’t be the case. Surveys from even five years ago reported that over 600,000 laptops a year were stolen or lost – and as time has gone on, this figure has only risen. The risks of losing your laptop are obvious : loss of precious information, possible subjection to identity theft, and the cost of the laptop itself. So what can you do to protect yourself?

The Obvious

Have someone ‘keep an eye on it.’ Install tracking software on your computer, such as Prey or LoJack. There are many services available like this, though the free-to-use Prey is my personal favorite here: it’s an open-source software that is currently under constant revision, and it’s available for all of the major operating systems, as well as for Android phones. These kinds of software will allow you to access your computer even after it is gone, and generally run very discretely, so only the most apt thieves will be able to detect it.

Next, securing your information is important. Use different passwords for each service, and try not to save them in your cookies. If you’ve got trouble remembering the dozens, you could use a clever naming scheme or use something like LastPass to encrypt them. This isn’t specifically a ‘stolen laptop’ issue, but it’s important nonetheless.

Finally, backing up your drives is your last line of defense. In many cases, you won’t be able to get back your computer – and if you do, there’s a chance it’s already been wiped clean of your files. Not everyone is lucky enough to have their important data returned.

The Less Obvious

Along the same vein of securing your information, encrypting your hard drives is a good way to keep thieves from having a field day with your files. This is especially important if you’re using a work computer with sensitive files. TrueCrypt seems to be the go-to software for this, having been featured on several prominent blogs such as Lifehacker and HowToGeek.

Running VNC on your computer is another less-obvious trick. If you have some other way of tracking your computer, you can wait until it is connected to the network and possibly secure your data further – perhaps you’ve installed Prey but forgotten to encrypt your information. You might be able to save some of your more important files or – better – get enough information about the attacker to get your laptop back.

Not locking your computer with a password is another technique. Stupid in some cases? Maybe. But in this case, less can be more. Most laptop thieves aren’t very tech-savvy, and are just looking for something to sell. If they can’t get into your computer, they may just wipe it clean – if they can access anything, however, they may not bother. Not only will this enable you to possibly recover your information, it will let your installed software (Prey and the like) to run. If you’re not convinced, check out Zoz’s awesome talk at Defcon 18 – he recovered a stolen computer after two whole years for this reason.