Skip to content

Instantly share code, notes, and snippets.

@rehanift
rehanift / vm.js
Created April 29, 2012 21:23
Using contextify to replace vm second version
var vm = function(){
//avoid contextify's js wrapper
var contextifyPath = require('path').resolve(require.resolve('contextify'), '..', '..');
var contextify = require('bindings')({
module_root: contextifyPath,
bindings: 'contextify.node'
});
// basic WeakMap shim if not available
var WM = typeof WeakMap !== 'undefined' ? WeakMap : function WeakMap(){
var keys = [], values = [];
@rehanift
rehanift / fb-reinit.js
Created June 15, 2012 17:58 — forked from anonymous/fb-reinit.js
Issues with FB.init called inside a FbReady callback
var getFriendsInApp = function (callback) {
FB.login(function (response) { // Force FB client to re-authorize
var friends = "SELECT uid, name, pic_square FROM user WHERE uid = me() OR uid IN (SELECT uid2 FROM friend WHERE uid1 = me())",
friends_in_app = "SELECT uid, name, pic_square FROM user WHERE is_app_user AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"
FB.api({
method: 'fql.query',
query: friends_in_app
}, callback);
});
};