Skip to content

Instantly share code, notes, and snippets.

@dheaney
Created February 17, 2013 21:19
Show Gist options
  • Save dheaney/4973533 to your computer and use it in GitHub Desktop.
Save dheaney/4973533 to your computer and use it in GitHub Desktop.
QR codes in Sinatra
<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>
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