While working on a Ruby project, I often find myself referring to the code of various libraries when it’s easier than looking up the documentation. For this, I used to use code (bundle show GEM_NAME), but recently I’ve been getting this warning: Okay, that’s fine, but bundle info returns a bunch of stuff that would… Continue reading A quick shortcut to open a Ruby gem in VS Code
Category: Code Snippets
Facebook: Pop-in.
What do you do when you have a Facebook app tab (inside an iframe, mind you) that’s externally linkable? Pop-in. Let’s break this down. if (self === top) { This conditional will be true when the browser is not inside an iframe. window.location.href = ‘https://www.facebook.com/test/app_1234’; If we are not inside an iframe, then redirect to… Continue reading Facebook: Pop-in.
Anchor Links inside Facebook Apps
If you haven’t noticed, you can’t use anchor links: <a href=”#hello”>Go to id=”hello”</a> Inside Facebook Apps (Page tab, Canvas app, etc). So I wrote a little snippet that emulates this behaviour by using FB.Canvas.scrollTo(x, y); /* anchorlinks-fbcanvas.js Enables anchor links (<a href=”#hello”>Go to id=”hello”</a>) in Facebook Canvas (page tabs, canvas app, etc) Requires: jQuery, Facebook… Continue reading Anchor Links inside Facebook Apps
Retina
Been wondering how to simply retina-ize your website? Put this at the end of your site: $(function() { try { if (window.matchMedia(‘(-webkit-min-device-pixel-ratio: 2), (min-device-pixel-ratio: 2)’).matches) { $(‘.autoRetina’).each(function(i, e) { var orig_src = $(e).attr(‘src’); var new_src = orig_src.replace(/^(.*?).(png|jpe?g|gif)$/i, ‘[email protected]$2’); $(e).attr(‘src’, new_src); }); } } catch (e) {} }); If you’re on a Retina-equipped device, your images… Continue reading Retina