Skip to content

Instantly share code, notes, and snippets.

View vivien's full-sized avatar

Vivien Didelot vivien

  • Montréal
View GitHub Profile
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="/webservices/catalog/xsl/searchRetrieveResponse.xsl"?>
<searchRetrieveResponse xmlns="http://www.loc.gov/zing/srw/" xmlns:oclcterms="http://purl.org/oclc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<version>1.1</version>
<numberOfRecords>801</numberOfRecords>
<records>
<record>
<recordSchema>marcxml</recordSchema>
<recordPacking>xml</recordPacking>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="/webservices/catalog/xsl/searchRetrieveResponse.xsl"?>
<searchRetrieveResponse xmlns="http://www.loc.gov/zing/srw/" xmlns:oclcterms="http://purl.org/oclc/terms/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:diag="http://www.loc.gov/zing/srw/diagnostic/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<version>1.1</version>
<numberOfRecords>33587</numberOfRecords>
<records>
<record>
<recordSchema>info:srw/schema/1/dc</recordSchema>
<recordPacking>xml</recordPacking>
@vivien
vivien / allourl.rb
Created February 10, 2011 03:20
A tiny Ruby API for the AlloURL service.
# A tiny Ruby API for the AlloURL service.
#
# Author: Vivien 'v0n' Didelot <vivien.didelot@gmail.com>
require 'open-uri'
module AlloURL
module_function
# Retrieves the link encapsulated in the AlloURL +url+.
@vivien
vivien / coderwall.rb
Created June 4, 2011 04:50
Simple and Stupid Ruby API for Coderwall.com
# Simple and Stupid Ruby API for Coderwall.com
# Vivien Didelot <vivien@didelot.org>
require "open-uri"
require "json"
module CoderWall
class Achievement
attr_reader :name, :badge, :description
@vivien
vivien / mail.rb
Created August 8, 2011 19:36
Sample script for the mail gem.
#!/usr/bin/env ruby
require "mail"
require "optparse"
imap_opts = {
:address => "imap.gmail.com",
:port => 993,
:enable_ssl => true
}
@vivien
vivien / insert_into.rb
Created August 10, 2011 23:00
Insert text after a given line of a file
def insert_into file, lineno, text
new_text = File.readlines(file).insert(lineno, text + "\n").join
File.open(file, 'w') { |f| f.write new_text }
end
@vivien
vivien / Rakefile
Created August 11, 2011 23:43
Passing arguments from one rake task to another
task :first, :arg1, :arg2 do |t, args|
puts "first"
Rake::Task[:second].invoke(args.arg1, args.arg2)
end
task :second, :arg1, :arg2 do |t, args|
puts "second"
puts args.arg1
puts args.arg2
end
@vivien
vivien / coderay_tokens_patch.rb
Created October 21, 2011 04:55
CodeRay: Iterate on each token with its kind, and its starting line number
require 'coderay'
class CodeRay::Tokens
def each_token
lineno = 1
self.each_slice(2) do |token, kind|
yield token, kind, lineno
lineno += token.count("\n") if token.is_a?(String)
end
end
@vivien
vivien / tld.rb
Created November 10, 2011 23:49
List of (ascii only) Internet top-level domains (TLD)
#!/usr/bin/env ruby
# An approximative Wikipedia/Mechanize version of:
# curl -s http://data.iana.org/TLD/tlds-alpha-by-domain.txt | grep -v XN | sed -e 1d -e 's/\(.*\)/\L\1/'
# Vivien Didelot <vivien@didelot.org>
require 'mechanize'
wikipedia_page = "http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains"
agent = Mechanize.new
@vivien
vivien / fossil.bash_completion
Created June 5, 2012 01:39
A bash_completion file for Fossil SCM, as /etc/bash_completion.d/git works for Git, providing a __fossil_ps1 bash function, and other tools.
# Bash completion support for Fossil.
# It is based on the Git Bash completion file.
# It best fits in /etc/bash_completion.d/fossil
#
# Copyright (C) 2011 Vivien Didelot <vivien@didelot.org>
# This file is distributed under the same terms as the license of the Fossil project.
#
# This file contains routine to change your PS1, and helper functions.
#
# For instance, add those options to your bashrc to customize PS1: