on the edge of Complexity

2011/06/28

Coffescript iteration caveat

In Cofffeescript, there are 2 built-in sytanxes for interation. for .. of .. / for .. in .. (by ..)

In Pragmatic Coffeescript book, the author says,

" Why have a seperate syntax? Why not just use for key, value of array?Because there're nothing stopping an array from having extra methods or data. If you want the whole shebang, then sure, use of. But if you just want to treat the array as an array, use in -- you will onlyget array[0], array[1], etc., up to array[array.length-1], in that order"




#============
entries = [5, 2, 4, 6, 8]
highstBid = 0
for bid of entries when bid > highstBid
highstBid = bid
console.log highstBid #return 4
#============
entries = [5, 2, 4, 6, 8]
highstBid = 0
for bid in entries when bid > highstBid
highstBid = bid
console.log highstBid #return 8
view raw gistfile1.txt hosted with ❤ by GitHub

2011/01/11

how to get OAuth Consumer Key / Secret for Google OAuth

I spent a hour to understand how to generate OAuth comsumer key for Google OAuth.
Here is the easiest way to do it.

step 0> visit Manage Domains Tool

step 1> Insert meta tag in your html and upload it server that is running.



step 2> after uploading the page, click verify. And then you'll see a page like this in you google master.



step 3> Generating keys using OpenSSL. I assume you're using OS X. Do this in your terminal

# Generate the RSA keys and certificate
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -sha1 -subj \
'/C=US/ST=CA/L=Mountain View/CN=www.example.com' -keyout \
myrsakey.pem -out myrsacert.pem


step4> Upload myrsacert.pem