Skip to content

Instantly share code, notes, and snippets.

@ryangadams
ryangadams / 0_reuse_code.js
Last active August 29, 2015 14:06
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Keybase proof

I hereby claim:

  • I am ryangadams on github.
  • I am ryangadams (https://keybase.io/ryangadams) on keybase.
  • I have a public key whose fingerprint is 1075 C5ED 8EB8 E408 C2B3 27B4 4337 6D24 99DA 8326

To claim this, I am signing this object:

@ryangadams
ryangadams / page-preview.js
Created October 4, 2012 21:40
A js bookmarklet to show a preview of the whole of a long page (try it on the daily mail site)
// javascript:PagePreview%20=%20{run:%20function()%20{var%20ifr%20=%20document.querySelector(%22#my-preview-iframe%22);var%20source%20=%20window.location.href;if%20(!ifr)%20{ifr%20=%20document.createElement(%22iframe%22);ifr.setAttribute(%22id%22,%20%22my-preview-iframe%22);}var%20width%20=%20%22100%22;var%20height%20=%20%22100%22;ifr.setAttribute(%22style%22,%20%22position:absolute;top:0px;left:0px;z-index:100000;background:#fff;width:%22%20+%20width%20+%20%22px;height:%22%20+%20height%20+%20%22px;overflow:hidden;border:2px%20solid%20#008800;%22);ifr.setAttribute(%22src%22,%20source);document.body.appendChild(ifr);ifr.addEventListener(%22load%22,%20PagePreview.scalePage,%20false);ifr.contentWindow.location%20=%20window.location.href;},scalePage:%20function(){var%20pageWidth%20=%20document.body.scrollWidth;var%20pageHeight%20=%20document.body.scrollHeight;var%20scaleFactor%20=%200.1;var%20bd%20=%20this.contentDocument.body;bd.style.transformOrigin%20=%20%22center%20top%22;bd.style.transform%20=%20%22scale(%22
@ryangadams
ryangadams / air-quotes.js
Created October 2, 2012 23:34
A js bookmarklet to extract the words on news websites that are 'quoted'.
var myPanel = document.querySelector("#my-quote-panel");
if (myPanel == null) {
myPanel = document.createElement("div");
myPanel.setAttribute("id", "my-quote-panel");
}
myPanel.innerHTML = "<h1>Air Quotes</h1>";
myPanel.setAttribute("style", 'position:relative;padding:10px;border-bottom:1px solid #008800;background:#fff;color:#333;z-index:1000;font-size:16px;clear:both;overflow:hidden;');
document.body.insertBefore(myPanel, document.body.firstChild);
var fullContent = "";
var content = document.querySelectorAll("body > div");