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
| require File.dirname(__FILE__) + '/magtek.rb' | |
| require 'logger' | |
| require 'rubygems' | |
| require 'httpi' | |
| require 'curb' | |
| Process.daemon | |
| logger = Logger.new("/var/log/monitor_usb.log") | |
| logger.level = Logger::INFO |
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
| require 'rubygems' | |
| require 'usb' # this is the ruby-usb gem, I'm also using libusb 1.0 and linux | |
| require 'logger' | |
| class MagTek | |
| def initialize | |
| @device = find_device | |
| interface = @device.interfaces.first | |
| @endpoint = interface.endpoints.first | |
| @logger = Logger.new("/var/log/monitor_usb.log") |
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
| import java.awt.image.BufferedImage; | |
| import java.beans.Beans; | |
| import java.io.FileOutputStream; | |
| import java.io.IOException; | |
| import java.util.Date; | |
| import java.util.logging.FileHandler; | |
| import java.util.logging.Logger; | |
| import java.util.logging.SimpleFormatter; | |
| import com.sun.image.codec.jpeg.JPEGCodec; |
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
| require 'rubygems' | |
| require 'httpi' | |
| require 'curb' | |
| # at some point before the request is made you'll need a kerberos ticket | |
| # i.e., kinit -k -t ticket_path | |
| image_path = "/tmp/some_image.jpg" | |
| url = URI.escape("https://some_ssl_spnego_url.com/upload_file_here") |
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
| module Spreadsheet | |
| module Excel | |
| module Writer | |
| class Worksheet | |
| alias_method :write_from_scratch_without_header, :write_from_scratch | |
| def write_header | |
| write_op opcode(:header), [@worksheet.header.bytesize, 0].pack("vC"), @worksheet.header | |
| end | |
| def write_from_scratch | |
| write_header |
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
| $chain_lengths = {:largest_num => 0, :largest_chain => 0, 1 => 1, 2 => 2} | |
| def get_chain_length_for(n) | |
| return $chain_lengths[n] if $chain_lengths.has_key?(n) | |
| next_n = 3 * n + 1 if n.odd? | |
| next_n = n / 2 if n.even? | |
| return ($chain_lengths[next_n] = get_chain_length_for(next_n)) + 1 | |
| end | |
| (2..999999).each do |x| |
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
| <div class="fields"> | |
| <div class="field"> | |
| <%= f.label :name %> | |
| <%= f.text_field :name %> | |
| </div> | |
| <div class="field"> | |
| <%= f.label :image %> | |
| <%= f.file_field :image %> | |
| </div> | |
| </div> |
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
| <div class="fields"> | |
| <div class="field"> | |
| <%= f.label :name %> | |
| <%= f.text_field :name %> | |
| </div> | |
| <div class="field"> | |
| <%= f.label :bar %> | |
| <%= f.text_field :bar %> | |
| </div> | |
| <%= link_to_remove_fields "remove", f %> |
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
| <%= form_for setup_foo(@foo), :html => { :multipart => true } do |f| %> | |
| <% if @foo.errors.any? %> | |
| <div id="errorExplanation"> | |
| <h2><%= pluralize(@foo.errors.count, "error") %> prohibited this foo from being saved:</h2> | |
| <ul> | |
| <% @foo.errors.full_messages.each do |msg| %> | |
| <li><%= msg %></li> | |
| <% end %> | |
| </ul> | |
| </div> |
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
| <h1>Editing foo</h1> | |
| <%= render 'form' %> | |
| <%= link_to 'back', :back %> |