Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Adding "post to" links for del.icio.us, digg, and ma.gnolia in Textpattern

Here's how to add "post to" links for del.icio.us, digg, and ma.gnolia to individual articles in Textpattern

del.icio.us

post to <a href="http://del.icio.us/post?url=<txp:permlink />&amp;title=<txp:title />">del.icio.us</a> 


digg

post to <a href="http://www.digg.com/submit?phase=2&amp;url=<txp:permlink />">digg</a>


ma.gnolia

post to <a href="http://ma.gnolia.com/bookmarklet/add?url=<txp:permlink />&amp;title=<txp:title />">ma.gnolia</a>


Clicking one of the those links will automatically post a permanent link for an article and, in the case of del.icio.us and ma.gnolia, the title to one of the above services.

Fix Firefox search engine ordering

1. Type about:config at your Firefox address bar.
2. Type browser.search.order at the filter bar.
3. Change browser.search.order.1 to Google.

The new del.icio.us extension broke my search engine order... cheeky plugin placed itself #1

Ruby script to post daily del.icio.us links to a blog.

This is a ruby script I (sloppily) cooked up to post daily del.icio.us links to my blog. It requires the Rubilicious library, and (because I'm lazy) is hardcoded to point at my blog.

Change the line

server = XMLRPC::Client.new( "cracker.mocephus.org", "/xmlrpc.php")


So that it points to your blog and your xmlrpc endpoint. Only tested with my Wordpress blog.

An example run would be:

./daily_delicious.rb myblogusername myblogpassword mydelicioususername mydeliciouspassword 1


The last argument is how many days back you'd like to gather links for.

Example post here

#!/usr/local/bin/ruby

require "xmlrpc/client"
require 'rubygems'
require_gem 'Rubilicious'

begin
	unless ARGV.size == 5
		$stderr.puts "Usage: $0 [bloguser] [blogpass] [deluser] [delpass] [days_back]"
		exit -1
	end
	bloguser,blogpass,deluser,delpass,days_back= ARGV

	# Gather Links
	links_date = (Time.now - (86400 * days_back.to_i))
	r = Rubilicious.new(deluser,delpass)
	content = "<ul>"
	r.posts(links_date.strftime("%Y-%m-%d")).each do |link|
  		content += "<li><a href=\"#{link['href']}\">#{link['href']}</a>"
  		content += "<ul>"
  		content += "<li>Description: #{link['description']}</li>"
  		content += "<li>#{link['extended']}</li>"
  		content += "<li>Posted: #{link['time']}</li>"
		content += "</ul></li>"
	end
	content += "</ul>"

	content += "<p>Click <a href=\"http://del.icio.us/mocephus/\">here</a> for all of my del.icio.us bookmarks."

	# Post Links To Blog Via XMLRPC
	server = XMLRPC::Client.new( "cracker.mocephus.org", "/xmlrpc.php")
	newPost = Hash.new
	newPost['title'] = "del.icio.us bookmarks - #{links_date.strftime('%m/%d/%Y')}"
	newPost['description'] = content
	result = server.call("metaWeblog.newPost",1,bloguser,blogpass,newPost,true)

rescue XMLRPC::FaultException => e
	puts "XMLRPC Error: "
	puts e.faultCode
	puts e.faultString
rescue StandardError => e
	puts e.to_s
end