Tuesday, December 27, 2011

I'm a big fan of good naming in code, here's a recent example:

Suppose you have a unique index in a database table and you're trusting that index to enforce no more than one record with the key.

So you're using an insert ignore into...on duplicate key update statement.

So you end up calling something like DataAccess.InsertRecord(data) or DataAccess.AddRecord(data). Looking at such code it's very unclear that what really happens is an insert/update and you're only left with one record.

You can go the way of making your code explicit my moving the logic into your app and doing something like

var record=DataAccess.GetRecord(key);
if(record == null)
  DataAccess.InsertRecord(data);

But then you'll be losing the power of using the database do that for you.

So what I'm suggesting is just making your naming better, for example: DataAccess.ReplaceRecord(data).

Want to join me as partner in a cool new startup?
Get in touch: pasha at cohai dot co

Bookmark and Share Tuesday, December 27, 2011 9:34:39 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [26]  
 Monday, December 26, 2011

If you have annoying scrollbars around your Facebook app's canvas, here's what you need to do:

First, go to your app's settings, click "Edit App" and then "Advanced" on the right.

Scroll all the way down to "Canvas Settings" and change "Canvas Height" to "Settable".

Second, add a call to FB.Canvas.setSize() (http://developers.facebook.com/docs/reference/javascript/FB.Canvas.setSize/). Make this call inside window.fbAsyncInit, after calling FB.init.

That's it! Gorgeous app, no scrollbars!

Want to join me as partner in a cool new startup?
Get in touch: pasha at cohai dot co

Bookmark and Share Tuesday, December 27, 2011 4:50:42 AM (Jerusalem Standard Time, UTC+02:00)  #    Comments [6]  
 Sunday, December 18, 2011

If you're using the PayPal Adaptive Payments API in sandbox mode, redirecting the user to https://www.sandbox.paypal.com/cgi-bin/webscr and getting the following error:

This transaction has already been approved

The problem may be that you're using an incorrect sandbox user as the "sender" in the transaction.

You need to go to the sandbox (https://developer.paypal.com/) and then to "test accounts" on the left.

You need to create a test account. Click "preconfigured" next to "new test account" and then make sure you select "buyer" under "account type".

Now use the email of this account that you've just created as the "senderEmail" in the call to the "Pay" API operation.

Want to join me as partner in a cool new startup?
Get in touch: pasha at cohai dot co

Bookmark and Share Sunday, December 18, 2011 8:09:59 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [5]  
 Saturday, December 17, 2011
“When we would become friendly with an office,” he explained, “and they were important to us, and the chief of staff was a competent person, I would say or my staff would say to him or her at some point, ‘You know, when you’re done working on the Hill, we’d very much like you to consider coming to work for us.’ Now the moment I said that to them or any of our staff said that to ‘em, that was it. We owned them.”

Amazing stuff on the Jack Abramoff story.

Want to join me as partner in a cool new startup?
Get in touch: pasha at cohai dot co

Bookmark and Share Saturday, December 17, 2011 11:34:34 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [4]  

First you need to go to Server Manager, expand "Roles", right-click "web server" and choose "add role services".

Then under "security" choose "basic authentication".

Now go to IIS Manager, click "Authentication" and enable "basic authentication".

Last, set up a local user: go to Server Manager, expand "configuration"->"local users and groups". Right-click "users" and click "new user...". Set up a user/password.

Voila, now user the user/password you've set up when browsing to your website.

Want to join me as partner in a cool new startup?
Get in touch: pasha at cohai dot co

Bookmark and Share Saturday, December 17, 2011 11:12:13 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [5]