cartesian product algorithm in JavaScript
Actually, I’m not sure if cartesian product is the correct term for this (is finding handshakes a subset of the cartesian product of sets?) but I ran into this problem when trying to solve the handshake problem in JavaScript. All the cartesian product algorithms I can find on Stack Overflow work fine, except that they assume the arrays provided are unique.
So my question is: given 2 arrays that are not necessarily distinct, how can we find all the pairings?
Anonymous asked: Hi! so it looks like you mostly self taught yourself programming languages and how to use them to create cool programs and such. how did you manage to comprehend everything? Im trying to start but java as a language is really complex (for me anyways..) and im a total newbie at this; i cant think in a programmer's mindset. anything you can recommend for a beginner whos trying to self study over the summer?
Aw, I’m really flattered! :) Programming is a good skill to have.
Personally, I learned almost all of my programming out of necessity. Science fair project needed to get done, so I learned the skills I needed and sort of hacked my way through my projects. The pros are that I am able to accomplish things in very short amounts of time, but the cons are that without formal training, all my programs are sort of duck-taped together, and there is way too much trial and error.
People ask me sometimes what language they should learn. There are arguments I can make on behalf of nearly every language, but I recommend you spend a week trying all the popular ones and getting a gut feeling of which language “makes the most sense” to you.
Here is a list of the programming languages I think are worth learning. I’m not sure which will suit you better, but pick one of the following to start with (then quickly move on to the other ones):
C - you have to be very careful when programming in C. There are a lot of rules to follow, but they teach you the fundamental concepts of how a computer handles stuff (of course you could dive into an even lower level of code but there is a point at which trying to start with Assembly is just counterproductive).
Python - much easier and gets the job done faster, but you might not understand WHY things are the way they are (e.g. why are Python lists mutable while C/C++ enforce rigid arrays? Why are they called lists rather than arrays anyway?)
Also, if you want to get a software engineer job at a company, you should keep in mind what language they like to see. For example, Jane St. hires people who know OCaml, Mozilla + Startups like to see JavaScript, and you can’t go wrong with Python.
Links for dipping your toes in the water (in no particular order):
Java (i started with this)
JavaScript (I recommend you learn Java first - JavaScript has a lot of advanced CS concepts)
Python (this is my favorite language for getting things done quickly. also nice and easy to learn)
C++ (this is a popular but old language)
Objective-C (built on top of C. I don’t recommend learning this as a first language).
MATLAB/Octave
UNIX shell scripting (though Python/Perl tend to be more flexible)
Other than that, I guess the only two bits of advice I really have to offer are:
1. believe in yourself
2. remember why you are learning programming/CS in the first place
3. believe in yourself. Nothing is impossible.
good luck!
heemin is cool
Heemin is a good friend. He took me out for lunch today and missed part of his 7th period so we could stuff our faces with In N’ Out and catch up on our future plans. I haven’t really spoken to him in awhile, but I think he’s become a much wiser + mature person over the course of this year.
He’s also a great locker buddy. All you bitches be jealous.
compiling & running WebCL on Mac OSX Lion
The Kronos group has recently launched WebCL, which is a SUPER ÜBER AWESOME group that binds browser-side JavaScript to the OpenCL standard. In layman’s terms, that means that we get SUPER ÜBER AWESOME GPU COMPUTING.

almost-quadratic-complexity uniq() function in JavaScript
I’m working on a new version of my Social Docking project, built from the ground up! This time I’m going to try to make the code as fast as JavaScript will allow it, which means that I have to be careful when it comes to algorithm design. There are a lot of big shots who are actually quite interested in the project and my enthusiasm for chemistry has been re-kindled now that I am done with AP Chem.
I realized that in graph theory, using a neighbors(G,x) function on a pseudograph may be problematic because iterating over edges could potentially return a bunch of duplicated neighboring nodes So, we need a uniqueness function in JavaScript.
today
I walked into the new CHS bathroom and found a bunch of folding tables set up in there along with the 2012 Class Council (Steven and Rebecca for sure… maybe Heemin too) and a bunch of grownups.
Apparently President Obama was in the stall (somehow we could see the top of his head in there) and we were all waiting to paparazzi him after.
He came out eventually, and everyone sort of rushed him. It was kind of disgusting how people were telling them about their own accomplishments and trying to suck up. I just realized that the poor man didn’t even get the chance to wash his hands.
So when it was my turn, I told him that I used to save my toenail clippings in a container. And that my name was Eric. And I shook his hand nice and firmly.
Anyway, that was a rather odd dream.
Israel’s leaders should watch more Disney movies
http://972mag.com/armed-border-officer-chases-10-year-old-palestinian-boy-for-holding-flag/46412/
For some reason I’ve always been interested in the Israeli-Palestinian conflict - I think I’m fascinated by the clash or religions and the unyielding dogma from either side (though I personally root for the Palestinians).
I wrote a report on why the U.S. should not support Israel on account of conflicting agendas of the Israeli Lobby (this was an assignment for my Gov class). I am by no means a fantastic writer (and I probably could have done more literature research on this topic) but I’d love to hear your comments on it all the same:
http://www.scribd.com/doc/94509300/Monetary-Support-of-Israel-Outdated-Immoral-and-Unfair
OAuth + Graph API in JavaScript: lots of options with NodeJS
For quite some time now I’ve been struggling to understand how the Facebook API works and how to make applications that integrate with the Open Graph platform. There’s really quite a lot of interesting data out there. There is a client-side JavaScript SDK, yet there seems to be a server-side PHP SDK, iOS SDK, and so forth. Where are we supposed to make the requests from? This is all very confusing but I’m glad that it’s finally clicked.
This is the essential procedure for fetching a user’s data (+stuff that requires their permission):
I made a wallpaper using the NodeJS vector graphic + a near-white background (with 2% Gaussian monochromatic noise for a bit of texture). Feel free to download it (1440 x 900)!
According to CC, Harvard’s waitlist decisions will be emailed out tomorrow afternoon by 5:00pm. Oh please oh please oh please let me in.