Created
February 17, 2013 21:19
-
-
Save dheaney/4973533 to your computer and use it in GitHub Desktop.
QR codes in Sinatra
This file contains 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
<style type="text/css"> | |
table { | |
border-width: 0; | |
border-style: none; | |
border-color: #0000ff; | |
border-collapse: collapse; | |
} | |
td { | |
border-width: 0; | |
border-style: none; | |
border-color: #0000ff; | |
border-collapse: collapse; | |
padding: 0; | |
margin: 0; | |
width: 10px; | |
height: 10px; | |
} | |
td.black { background-color: #000; } | |
td.white { background-color: #fff; } | |
</style> | |
<table> | |
<% @qr.modules.each_index do |x| %> | |
<tr> | |
<% @qr.modules.each_index do |y| %> | |
<% if @qr.dark?(x,y) %> | |
<td class="black"/> | |
<% else %> | |
<td class="white"/> | |
<% end %> | |
<% end %> | |
</tr> | |
<% end %> | |
</table> | |
This file contains 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
require 'sinatra' | |
require 'rqrcode' | |
set :views, settings.root | |
get '/' do | |
@qr = RQRCode::QRCode.new('github.com/dejay') | |
erb :index | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment