Skip to content

Instantly share code, notes, and snippets.

View jamescook's full-sized avatar
🏠
Working from home

James Cook jamescook

🏠
Working from home
View GitHub Profile
#! /usr/bin/env python
""" Convert values between RGB hex codes and xterm-256 color codes.
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
* http://en.wikipedia.org/wiki/8-bit_color
* http://en.wikipedia.org/wiki/ANSI_escape_code
require 'mechanize'
URL_FILE = "qc_urls"
OUTPUT_FILE = "qc_urls_out"
class QuantcastCrawler
def initialize(file_path, output_path)
@file_path = file_path
@output_path = output_path
end
# named_scope :relative_of, lambda { |id|
# subject = Subject.find(id)
# ids = subject.child_subjects.map(&:id)
# ids << id
# { :conditions => { :subject_id => ids } }
# }
# This is the current solution. It merely validates the string's inclusion in
# the given list, and saves it as a string.
ActiveRecord::Schema.define(:version => 20110101000000) do
create_table "foos", :force => true do |t|
t.string "bar"
end
end
class Foo < ActiveRecord::Base
def makeProgress(i, t)
percent = (Float(i) / Float(t)) * 100
percent = (( percent / 5).round * 5).to_i
number_of_bars = percent / 5
progress = "B"
for g in 0..number_of_bars do
progress = progress + "="
end
if number_of_bars > 0
progress = progress + "D"
people = Person.with_status_code_not_as("Pending Federal Benefits Direct Deposit Credit")
people.each do |p|
next if p.direct_deposit_status.direct_deposit_status_code.to_s == "Rejected"
if !p.federal_benefits_enrollments.empty?
p.direct_deposit_status.change_status!("Pending Federal Benefits Direct Deposit Credit", p.direct_deposit_status.created_by, nil)
end
end
@addon_products = @card.person.account_addon_products.map{|product| product.type.to_s }
in view:
%td.cardholder-product
= @addon_products.to_sentence