This file contains 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 User < ActiveRecord::Base | |
has_one :candidate_profile | |
alias_method :candidate_profile_without_initialization :candidate_profile | |
def candidate_profile | |
candidate_profile_withough_intitialization || build_candidate_profile | |
end | |
end |
This file contains 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
1. Setup javaCache.cmake below | |
2. ./bootstrap --prefix=/usr/local --system-libs --datadir=/share/cmake --docdir=/share/doc/cmake --mandir=/share/man --init=javaCache.cmake | |
3. make && make install |
This file contains 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
#!/bin/sh | |
# Shell script to install your public key on a remote machine | |
# Takes the remote machine name as an argument. | |
# Obviously, the remote machine must accept password authentication, | |
# or one of the other keys in your ssh-agent, for this to work. | |
ID_FILE="${HOME}/.ssh/id_rsa.pub" | |
if [ "-i" = "$1" ]; then |
This file contains 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
data = [] | |
((90.days.ago.to_date)..Date.today).each do |date| | |
date = date.to_formatted_s(:db) | |
value = db_data.has_key?(date) ? db_data[date] : 0 | |
data << [date, value] | |
end |
This file contains 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
filename = Rails.root.join("2-XML Schema", "[OSA-EAI-CCOM-ML-XSD-V03-2]CCOM-ML_V3-2-3 (2010-11-30).xsd") | |
doc = Nokogiri::XML(File.read(filename)) | |
def complex_types_of(doc,base) | |
hash = {} | |
doc.xpath("//xs:extension[@base='#{base}']").each do |extension| | |
complex_type = extension.parent.parent | |
name = complex_type[:name] | |
hash[name] = complex_types_of(doc,name) | |
end |
This file contains 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 ExtendThroughInclude | |
def included(klass) | |
klass.extend(ClassMethods) | |
klass.send(:include, InstanceMethods) | |
end | |
class InstanceMethods | |
end |
This file contains 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
######################################################################## | |
# | |
# harvest-sample.rb | |
# | |
# Basic API demo. Use this sample as a starting point on how to | |
# connect, authenticate, and send requests to the Harvest API and | |
# handle the API throttle limit. This is not a libary, if you want one | |
# for Ruby, we recommend investigating ActiveResource::Base. | |
# | |
# To execute this sample, save this file to your computer and |
This file contains 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
<!-- http://www.quirksmode.org/css/forms.html --> | |
<html> | |
<head> | |
<style> | |
label,input { | |
display: block; | |
width: 150px; | |
float: left; | |
margin-bottom: 10px; | |
} |
This file contains 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 Person | |
include ActiveModel::MassAssignmentSecurity | |
attr_accessor :name, :birthday, :handsomeness | |
attr_protected :handsomeness | |
def initialize(params = {}) | |
self.attributes = params | |
end |
This file contains 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
Factory.define(:kit) do |f| | |
f.association :primary_palette, :factory => :palette # association doesn't match class name | |
f.association :secondary_palette, :factory => :palette | |
f.association :user, :factory => :user | |
f.sequence(:name) { |i| "Kit#{i}" } | |
f.bg_images { |images| [images.association(:attachment)] } # has_many assoc | |
f.default false | |
f.display_fonts { [Factory(:font), Factory(:font)] } | |
f.body_font { Factory(:font) } | |
end |