Skip to content

Instantly share code, notes, and snippets.

View flazz's full-sized avatar

Franco Lazzarino flazz

View GitHub Profile
module Main where
-- input is 1.2MB
-- Tue Oct 13 08:14 2009 Time and Allocation Profiling Report (Final)
--
-- parmd +RTS -p -RTS
--
-- total time = 0.10 secs (5 ticks @ 20 ms)
-- total alloc = 491,900,336 bytes (excludes profiling overheads)
--
#!/usr/bin/env io
List do (
pivot := method(first)
upper := method(select(x, x < pivot))
lower := method(select(x, x > pivot))
qsort := method(if(size > 1, lower qsort append(pivot) appendSeq(upper qsort), clone))
)
writeln("building list")
require "sinatra"
require "json"
# this should integrate to a real Q
DATA = %w(foo bar baz eta beta alfa romeo)
get "/q" do
JSON.generate(DATA).to_s
end
<html>
<head>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
//load_q();
$("#queue").sortable();
@flazz
flazz / gist:239034
Created November 19, 2009 20:43 — forked from anonymous/gist:239024
it "returns 400 on POST if request is missing X-Package-Name header" do
post '/', "FOO", "Content-MD5" => "cccccccccccccccccccccccccccccccc"
last_response.status.should == 400
last_response.body.should == "Missing parameter: package_name"
end
# % spec sp.rb ~
# nil
# {"Content-Type"=>"text/html"}
@flazz
flazz / gist:239053
Created November 19, 2009 21:10 — forked from anonymous/gist:239024
% spec sp.rb ~
...nil
{"Content-Type"=>"text/html"}
.Fnil
{"Content-Type"=>"text/html"}
Fnil
{"Content-Type"=>"text/html"}
.
1)
require 'uuid' # gem install uuid if you havent already
# it sounds crazy but this is very sufficient for generating IDs with no central authority.
ugen = UUID.new
10.times { puts "info:fcla/#{ ugen.generate }" }
-module (bencode).
-export ([encode/1, decode/1]).
%% Simple bencoding definition:
%% byte strings: <ascii number in base 10>:contents
%% integers: i<ascii number in base 10>e
%% lists: l<contents>e
%% dictionaries: d<contents>e, contents are string keyed in lexographic order
%% ============
#!/bin/env ruby
require 'nokogiri'
require 'open-uri'
class PlayList < Array
attr_accessor :version
def PlayList.parse s
lines = s.lines.map { |l| l.chomp }
magic = lines.shift
<?xml version="1.0" encoding="UTF-8"?>
<mets xmlns="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" OBJID="test:/3dccd630-fe28-012c-8021-001b63b4d6a3" xsi:schemaLocation="http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/mets.xsd http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd info:lc/xmlns/premis-v2 http://www.loc.gov/standards/premis/premis.xsd">
<!-- DMD -->
<dmdSec ID="dmd-1">
<mdWrap MDTYPE="PREMIS">
<xmlData>
<mods xmlns="http://www.loc.gov/mods/v3">
<titleInfo>
<title>heavyweight title</title>
</titleInfo>