Skip to content

Instantly share code, notes, and snippets.

@mazuhl
mazuhl / jquery_get_favicons.js
Created February 4, 2010 13:52
jQuery script and accompanying CSS to pull in favicons for URLs
$(document).ready(function(){
jQuery('a.rss-item').filter(function(){
return this.hostname && this.hostname !== location.hostname;
}).each(function() {
var link = jQuery(this);
link.css('backgroundImage', 'url(' + 'http://s2.googleusercontent.com/s2/favicons?domain_url=' + escape('http://' + this.hostname) + ')');
});
});
accept
add
admire
admit
advise
afford
agree
alert
allow
amuse
@mazuhl
mazuhl / gist:294694
Created February 4, 2010 14:50
Embedding a PDF into a webpage
<!-- using <object> (doesn't work in IE) -->
<object height="450" width="600" type="application/pdf" data="/attachment/hello.pdf">
<h2>This content requires a PDF plugin</h2>
<p>View the PDF file here: <a href="/attachment/hello.pdf">hello.pdf</a></p>
</object>
<!-- using an iframe (does work in IE) pass options in the query string -->
<iframe height="900" width="99%" src="/attachment/hello.pdf#toolbar=0&amp;scrollbar=0&amp;navpanes=0"> </iframe>
@mazuhl
mazuhl / googledocsstrikeoutkeyboardshortcut.user.js
Created February 9, 2010 13:34
Firefox Greasemonkey script to add strikeout keyboard shortcut
// ==UserScript==
// @name Google Docs strikeout keyboard shortcut
// @description Adds a keyboard shortcut for strikeout
// @namespace http://userscripts.org/scripts/review/68438
// @include http*://docs.google.com/*
// ==/UserScript==
(function() {
document.addEventListener('keydown', function(e){
@mazuhl
mazuhl / Webserver one liner
Created April 13, 2010 09:42
Start a Ruby webserver in the pwd
ruby -rwebrick -e"s = WEBrick::HTTPServer.new(:Port => 3000, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start"
@mazuhl
mazuhl / gist:387466
Created May 2, 2010 21:29
Bookmarklet for posting images/URLs
/*
* This bookmarklet can be used to post an image/URL
* to a script, just click it. Adds a form and submits it.
*/
javascript:(
function(){
b=document.getElementsByTagName('body')[0];
/* create the form */
@mazuhl
mazuhl / gist:397443
Created May 11, 2010 15:36
Google Notebook bookmarklet - opens new window, adds script tag and loads script
javascript: (function () {
var w = window;
var d = document;
var g = w.open('about:blank', 'gnotesWin', 'location=0,menubar=0,scrollbars=0,status=0,toolbar=0,width=300,height=300,resizable');
var s = d.createElement('script');
s.setAttribute('src', 'http://www.google.com/notebook/bookmarkletPoster?zx=' + (new Date()).valueOf());
d.body.appendChild(s);
w.setTimeout(function () {
w.blur();
g.focus();
@mazuhl
mazuhl / gist:404793
Created May 18, 2010 09:03
Nokogiri example - inserting a node
require 'rubygems'
require 'nokogiri'
html = Nokogiri::HTML(DATA)
html.xpath('//table').each do |htable|
tbody = Nokogiri::XML::Node.new('tbody', html)
htable.children.each do |child|
child.parent = tbody
end
htable.add_child(tbody)
@mazuhl
mazuhl / gist:404806
Created May 18, 2010 09:18
Nokogiri example - using collections and hashes
#!/usr/bin/ruby1.8
require 'nokogiri'
require 'pp'
html = <<-EOS
<table >
<tbody>
<tr> <!-- table header --> </tr>
</tbody>
@mazuhl
mazuhl / gist:404814
Created May 18, 2010 09:27
Bookmarklet to sending page (from Instapaper)
javascript: function wrb() {
var d = document,
z = d.createElement('scr' + 'ipt'),
b = d.body;
try {
if (!b) throw (0);
d.title = '(Saving...) ' + d.title;
z.setAttribute('src', 'http://www.website.com/__UNIQUE__?u=' + encodeURIComponent(d.location.href) + '&t=' + (new Date().getTime()));
b.appendChild(z);
} catch (e) {