This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun hs-hide-initial-comment-block () | |
| "Hide the first block of comments in a file. | |
| This can be useful if you have huge RCS logs in those comments. | |
| Extended to work with XML, where there often is an XML declaration | |
| before the initial comment. | |
| " | |
| (interactive) | |
| (hs-life-goes-on | |
| (let ((c-reg (save-excursion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| md = ARGF.read | |
| map = {} | |
| md.lines(chomp: true).each do |li| | |
| if li =~ /^\*\[([A-Z]{2,})\]: (.*)/ | |
| if old = map[$1] | |
| puts "** dup #$1 #$2 #{old}" | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| s = ARGF.read | |
| s.gsub!(/%s"([^"]+)"/) { | |
| "%x#{$1.chars.map{|c|c.ord.to_s(16)}.join(".")}" | |
| } | |
| puts s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'open3' | |
| require 'tempfile' | |
| require 'shellwords' | |
| if ARGV.size != 2 | |
| warn "** usage: jsondiff.rb j1 j2" | |
| exit 63 | |
| end | |
| files = ARGV.dup.map do |arg| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'rexml/document' | |
| require 'open3' | |
| default_fn = "svg-fig-00" | |
| d = REXML::Document.new(ARGF) | |
| REXML::XPath.each(d.root, "//svg:svg", {"svg" => "http://www.w3.org/2000/svg"}) do |x| | |
| fn = default_fn.succ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby -Ku | |
| # coding: utf-8 | |
| require 'rexml/document' | |
| require 'open-uri' | |
| # require 'open-uri/cached' | |
| CBOR_TAGS = "https://www.iana.org/assignments/cbor-tags/cbor-tags.xml" | |
| ACCEPT_XML = {"Accept" => "application/xml"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby -Ku | |
| Encoding.default_external = "UTF-8" # wake up, smell the coffee | |
| require 'kramdown' | |
| # FIX THIS dirname: | |
| # You need to be in the root of the proceedings directory as obtained via rsync, | |
| # e.g. in my case via: rsync -av rsync.ietf.org::proceedings ~/std/proceedings | |
| # Warning: ~ 50 GB! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def remove_indentation(s) | |
| l = s.lines | |
| indent = l.grep(/\S/).map {|l| l[/^\s*/].size}.min | |
| l.map {|l| l.sub(/^ {0,#{indent}}/, "")}.join | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def uniq_c | |
| each_with_object(Hash.new(0)) { _2[_1] += 1 } | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby -Ku -i.bak | |
| fail "Usage: section1.rb foo.md" unless ARGV.size == 1 | |
| s = ARGF.read | |
| SECTIONS_RE = /Section(?:s? (?:[\w.]+, )*[\w.]+,? and)? [\w.]+/ | |
| puts s.gsub(/(#{SECTIONS_RE}\s+of)\s+{{([-\w.]+}})/) { "{{#$1 #$2" } | |
| # Note that we don't fix "Section 3 and 5 of {{foo}}" into "Sections 3 and 5 of {{foo}" | |
| # -- that must be done manually, with all the not so easy to recognize section references |
NewerOlder