Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/ruby
# Just splits up the queries into 20 tracks at a time, so I don't inundate the service, and so I can see what's happening.
# Its pretty slow on average.
# I'll need to parse the XML and reapply to the tags.
#
# get a MusicDNS key + genpuid & friends at http://www.musicip.com/
require 'rubygems'
require 'escape' # gem install escape
@chrislloyd
chrislloyd / page.rb
Created February 16, 2009 02:06 — forked from xaviershay/page.rb
Refactor this code: URL Matching Edition
--
So I have Pages, in a nested set so that each page has parent. That allows me to have urls like:
/foo/bar
where the Page with permalink 'foo' has a child with the permalink 'bar'. In my routes.rb I have a general catch-all route as my last route.
map.page '/*tree', :controller => 'pages', :action => 'show'
@chrislloyd
chrislloyd / gist:70644
Created February 26, 2009 03:56 — forked from lachie/gist:70629
def f(ra,n)
ra.select {|x| x.include? n}.size
end
Registration.find_all_by_complete(true).each_with_object({}) do |reg, count|
date = reg.sydney_updated_at.to_date
count[date] ||= 0
count[date] += 1
end
registration_count.inspect
0,128,128,544,128,1040,128,672,320,49284,33088,544,128,144,0,128
// global set by server
COMMENTS = [{
'title': 'hello',
'body': 'im a lonley comment'
}];
// template & controller codez together as friends
html5(function(html) {
html.import('jquery');
@chrislloyd
chrislloyd / prime.rb
Created November 19, 2009 00:52 — forked from atnan/prime.rb
class Integer
def prime?
("1" * self).match(/^1?$|^(11+?)\1+$/).nil?
end
end
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>sketch</title>
<style type="text/css" media="screen">
# Make sure that Node is %script{src'd} before Sprite
window.Node: class Node
addToStage: ->
console.log "Add node to stage"
<!doctype html>
<html>
<head>
<title>RSS Feed Viewer</title>
</head>
<body>
<h2>Hi there!</h2>
<p><%= open_rss.channel.title %></p>
</body>
</html>