Skip to content

Instantly share code, notes, and snippets.

@saitoha
Last active August 29, 2015 13:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save saitoha/10483508 to your computer and use it in GitHub Desktop.
Save saitoha/10483508 to your computer and use it in GitHub Desktop.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2014 Hayaki Saito <user@zuse.jp>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
#!/usr/bin/env ruby
require "rqrcode"
@qr = RQRCode::QRCode.new(ARGV.size == 0 ? $stdin.readline.chomp : ARGV[0])
puts "\033c\033Pq"
puts "#1;2;100;100;100" # white
puts "#2;2;0;0;0" # black
puts "---"
printf "$!18?#1!%d~", (@qr.modules.length + 2) * 6
puts "-"
for x in @qr.modules.each_index
print "$!18?#1"
color = 1
run = 6
for y in @qr.modules.each_index
current = @qr.dark?(x, y) ? 2: 1
if current != color then
printf "#%d!%d~", color, run
color = current
run = 0
end
run += 6
end
if color == 1 then
printf "#1!%d~", run + 6
else
printf "#%d!%d~#1!6~", color, run
end
puts "-"
end
printf "$!18?#1!%d~", (@qr.modules.length + 2) * 6
puts "\033\\\033[20H"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment