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
| class CreditCard < ActiveRecord::Base | |
| belongs_to :order | |
| has_one :billing_address, :as => :addressable, :class_name => "Address", :dependent => :destroy | |
| accepts_nested_attributes_for :billing_address | |
| before_validation :clean_number |
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 Algebra | |
| class MaximumIterationsReached < Exception | |
| end | |
| class NewtonsMethod | |
| def self.calculate(function, x) | |
| x - function.evaluated_at(x) / function.derivative_at(x) | |
| end |
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 'algebra' | |
| class IRR | |
| def self.calculate(profits) | |
| begin | |
| function(profits).zero | |
| rescue Algebra::MaximumIterationsReached => mir | |
| nil | |
| end |
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
| getPixel :: Point -> Image -> IO Color | |
| getPixel (x,y) i = | |
| withImagePtr i $ | |
| \p -> gdImageGetTrueColorPixel p (int x) (int y) |
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
| getPixels :: Image -> IO [[Color]] | |
| getPixels image = | |
| do (width, height) <- imageSize image | |
| pixelsPointer <- withImagePtr image $ | |
| \gdi -> #{peek gdImage, tpixels} gdi | |
| columnPixelArray <- peekArray height pixelsPointer | |
| mapM (\a -> peekArray width a) columnPixelArray |
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 Data.List | |
| import Text.Printf | |
| import Numeric | |
| tolerance :: Double | |
| tolerance = 1e-2 | |
| e :: Double | |
| e = 2.718281828 |
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
| class MyControllerOrPlainRubyObject | |
| extend CodedOptions | |
| coded_options :state, %w(initial active closed) | |
| STATES = %w(initial active closed) | |
| STATE_OPTIONS = [["initial", 0], | |
| ["active", 1], | |
| ["closed", 2]] |
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
| extend CodedOptions | |
| coded_options :state => ["Active", "Under Appeal", "Terminated"], | |
| :category => ["Private, Non-profit", "Private, For-profit", "Publicly Sponsored", "Church Sponsored", "Head Start Organization", "Public School 4K", "Military Prog | |
| :type => ["Center Child Care", "Accredited Center", "Group Day Care", "Family Day Care", "Exemption"], | |
| :authorization_type => %w(License Approval Military Exempt DDSN), | |
| :county => %w(Abbeville Aiken Allendale Anderson Bamberg Barnwell Beaufort Berkeley Calhoun Charleston Cherokee Chester Chesterfield Clarendon Colleton Darlingto | |
| :time => %w(closed 1:00AM 1:15AM 1:30AM 1:45AM 2:00AM 2:15AM 2:30AM 2:45AM 3:00AM 3:15AM 3:30AM 3:45AM 4:00AM 4:15AM 4:30AM 4:45AM 5:00AM 5:15AM 5:30AM 5:45AM | |
| :status => %w(Open Closed Partial/Exception) |
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
| = edit f, [[:name , "Name"], | |
| [:fein , "FEIN"], | |
| [:fein_suffix , "FEIN suffix"], | |
| [:state_id , "State"], | |
| [:category_id , "Category"] |
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
| class Controller < ApplicationController | |
| def show | |
| @transaction_record = TransactionRecord.find(...) | |
| respond_to do |wants| | |
| wants.html | |
| wants.pdf { send_data @transaction_record.pdf } | |
| end | |
| end |