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
| $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
| 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
| 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
| 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 '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
| 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
| # create new rails app | |
| # rails new dynamic_select_boxes -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-haml-html5-template.rb | |
| # create models: | |
| # rails g model genre name:string | |
| # rails g model artist name:string genre_id:integer | |
| # rails g model song title:string artist_id:integer | |
| # rake db:migrate |
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
| # create new rails app | |
| rails new dynamic_select_boxes -m https://raw.github.com/RailsApps/rails3-application-templates/master/rails3-haml-html5-template.rb | |
| # create models: | |
| rails g model genre name:string | |
| rails g model artist name:string genre_id:integer | |
| rails g model song title:string artist_id:integer | |
| rake db:migrate |
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
| 3.times do |x| | |
| genre = Genre.find_or_create_by_name(:name => "Genre #{x}") | |
| 3.times do |y| | |
| artist = Artist.find_or_create_by_name(:name => "Artist #{x}.#{y}", :genre => genre) | |
| 3.times do |z| | |
| Song.find_or_create_by_title(:title => "Song #{x}.#{y}.#{z}", :artist => artist) | |
| end | |
| end | |
| end |