Yesterday I was pairing the socks from the clean laundry, and figured out the way I was doing it is not very efficient. I was doing a naive search -- picking one sock and "iterating" the pile in order to find its pair. This requires iterating over n/2 * n/4 = n^2/8 socks on average.
As a computer scientist I was thinking what I could do? sorting (according to size/color/...) of course came into mind to achieve O(NlogN) solution.
And everyone gets it wrong. The correct answer is actually:
1) Throw all your socks out.
2) Go to Uniqlo and buy 15 identical pairs of black socks.
3) When you want to wear socks, pick any two out of the drawer.
4) When you notice your socks are wearing out, goto step 1.
Fun fact: the actual programs in the spacecraft were stored in core rope memory, an ancient memory technology made by (literally) weaving a fabric/rope, where the bits were physical rings of ferrite material.
"Core" memory is resistant to cosmic rays. The state of a core bit will not change when bombarded by radiation in Outer Space. Can't say the same of solid state memory.
For her yearly month-long project at Slate, Annie Lowrey wanted to learn how to code. She picked Ruby and became interested in the story of _why, the mysterious Ruby hacker who disappeared suddenly in 2009. In a long article at Slate, Lowrey shares her experience learning to program and, oh, by the way, tracks down _why. Sort of.
The pickaxe book first shows you how to install Ruby on your computer. (That leads to a strange ontological question: Is a programming language a program? Basically, yes. You can download it from the Internet so that your computer will know how to speak it.)
Then the pickaxe book moves on to stuff like this: "Ruby is a genuine object-oriented language. Everything you manipulate is an object, and the results of those manipulations are themselves objects. However, many languages make the same claim, and their users often have a different interpretation of what object-oriented means and a different terminology for the concepts they employ."
Programming manual, or Derrida? As I pressed on, it got little better. Nearly every page required aggressive Googling, followed by dull confusion. The vocabulary alone proved huge and complex. Strings! Arrays! Objects! Variables! Interactive shells! I kind of got it, I would promise myself. But the next morning, I had retained nothing. Ruby remained little more than Greek to me.
Codify is an iPad app that allows you to code iPad games on your iPad.
We think Codify is the most beautiful code editor you'll use, and it's easy. Codify is designed to let you touch your code. Want to change a number? Just tap and drag it. How about a color, or an image? Tapping will bring up visual editors that let you choose exactly what you want.
Codify is built on the Lua programming language. A simple, elegant language that doesn't rely too much on symbols -- a perfect match for iPad.
We lost a tech giant today. Dennis MacAlistair Ritchie, co-creator of Unix and the C programming language with Ken Thompson, has passed away at the age of 70. Ritchie has made a tremendous amount of contribution to the computer industry, directly and indirectly affecting (improving) the lives of most people in the world, whether you know it or not.
These sorts of comparisons are inexact at best, but Richie's contribution to the technology industry rivals that of Steve Jobs'...Richie's was just less noticed by non-programmers.
A schrödinbug is a bug that manifests only after someone reading source code or using the program in an unusual way notices that it never should have worked in the first place, at which point the program promptly stops working for everybody until fixed.
On text2re.com, you can input some text you want to use a regular expression on, click on what you want to match, and it'll generate the regular expression for you.
This system acts as a regular expression generator. Instead of trying to build the regular expression, you start off with the string that you want to search. You paste this into the site, click submit and the site finds recognisable patterns in your string. You then select the patterns that you are interested in and it writes a fully fledged program that extracts those patterns from that string. You then copy the program into your editor or IDE and play with it to integrate it into your program.
Andre Torrez offers some advice for those who think that they can clone a popular web app over the weekend. The best part -- or the worst, if you're the aspiring weekend programmer -- is that each item on the list is a little Pandora's box of Alice's rabbit holes. Like this:
Lost password flow. You'll want to generate a key and store it someplace for when someone requests to reset their password. So that's another email that has to go out.
If you actually want your email to arrive at its destination, you're gonna have to worry about all this. Or go through a third-party service, which is another interface (and bill (and moving part)) that you need to worry about. You get the point...making a web app work for more than just one person is hard, way harder than it looks unless you've done it.
Charles Babbage built one of the first mechanical calculating machines but Ada Lovelace was the first to show how the machine's arithmetic function could be abstracted to produce things other than numbers: language, graphics, or music.
Cross-site scripting and SQL injection are the 1-2 punch of security weaknesses in 2010. Even when a software package doesn't primarily run on the web, there's a good chance that it has a web-based management interface or HTML-based output formats that allow cross-site scripting. For data-rich software applications, SQL injection is the means to steal the keys to the kingdom. The classic buffer overflow comes in third, while more complex buffer overflow variants are sprinkled in the rest of the Top 25.
In mid-September I purchased a shiny new 24" Apple iMac and an iPhone 3GS. I signed up for the Apple iPhone Developer Program. I bought some books and started doing the tutorials, step by step. I came up with the idea for an app I needed and built a prototype, then plunged in and started creating a full app that would be good for others, too.
After writing The Cat in the Hat in 1955 using only 223 words, Dr. Seuss bet his publisher that he could write a book using only 50 words. Seuss collected on the wager in 1960 with the publication of Green Eggs and Ham. Here are the 50 distinct words used in the book:
a am and anywhere are be boat box car could dark do eat eggs fox goat good green ham here house I if in let like may me mouse not on or rain Sam say see so thank that the them there they train tree try will with would you
From a programming perspective, one of the fun things about Green Eggs and Ham is because the text contains so little information repeated in a cumulative tale, the story could be more efficiently represented as an algorithm. A simple loop would take the place of the following excerpt:
I do not like them in a box. I do not like them with a fox. I do not like them in a house. I do not like them with a mouse. I do not like them here or there. I do not like them anywhere. I do not like green eggs and ham. I do not like them, Sam I am.
But I don't know...foreach (\$items as \$value) doesn't quite have the same sense of poetry as the original Seuss.
Ingredients. 72 g haricot beans 101 eggs 108 g lard 111 cups oil 32 zucchinis 119 ml water 114 g red salmon 100 g dijon mustard 33 potatoes
Method. Put potatoes into the mixing bowl. Put dijon mustard into the mixing bowl. Put lard into the mixing bowl. Put red salmon into the mixing bowl. Put oil into the mixing bowl. Put water into the mixing bowl. Put zucchinis into the mixing bowl. Put oil into the mixing bowl. Put lard into the mixing bowl. Put lard into the mixing bowl. Put eggs into the mixing bowl. Put haricot beans into the mixing bowl. Liquefy contents of the mixing bowl. Pour contents of the mixing bowl into the baking dish.
5.21. Prefer the standard to the offbeat Young writers Inexperienced programmers will be draw at every turn toward eccentricities in language. They will hear the beat of new vocabularies abstractions, the exciting rhythms of special segments of their society industry, each speaking a language of its own. All of us come under the spell of these unsettling drums; the problem for beginners is to listen to them, learn the words, feel the vibrations, and not be carried away.
Basically, Atari's marketing folks would negotiate a license to ship GameCorp's "Foobar Blaster" on a cartridge for the Atari Home Computer System. That was it. That was the entirety of the deal. We got ZERO help from the original developers of the games. No listings, no talking to the engineers, no design documents, nothing. In fact, we had to buy our own copy of the arcade machine and simply get good at the game (which was why I was playing it at the hotel - our copy of the game hadn't even been delivered yet).
Casey Reas and Ben Fry, inventors of the Processing programming language (that's Proce55ing to you old schoolers), have just come out with a book on the topic that looks fantastic. In addition to programming tutorials are essays and interviews with other heavy hitters in the programmatic arts like Golan Levin, Alex Galloway, Auriea Harvey, and Jared Tarbell. The site for the book features a table of contents, sample chapters, and every single code example in the book, freely available for download. Amazon's got the book but they're saying it's 4-6 weeks for delivery so I suggest hoofing it over to your local bookstore for a look-see instead.
Update: I corrected the above statement about Perl et. al. not existing and modified it to read that they didn't make the list. Perl, Ruby, nd Java all existed in one form or another in 1995. (thx to everyone who sent this in)
Update: here's the game's web site. "This game eliminates intimidation of many kids and their parents, bored by the mention of 'computer programming', often associated with visions of geeky guys glued to their computers."
Here's a story that mentions that Slashdot commenter that outsourced his job. "About a year ago I hired a developer in India to do my job. I pay him $12,000 out of the $67,000 I get. He's happy to have the work. I'm happy that I have to work only 90 minutes a day just supervising the code. My employer thinks I'm telecommuting. Now I'm considering getting a second job and doing the same thing."