Skip to content

Instantly share code, notes, and snippets.

View tpendragon's full-sized avatar

Trey Pendragon tpendragon

  • Princeton University Library
  • Salem, OR
View GitHub Profile
def content
translatedContent = self[:content]
if(!self.has_translation?(I18n.locale) && self.has_translation?(self.parent_translation(I18n.locale)))
translatedContent = self.translation_for(self.parent_translation(I18n.locale)).content
end
translatedContent
end
<%= form_tag products_path, method: :get do %>
<p>
<%= text_field_tag :search, params[:search] %>
<%= submit_tag "Search", title: nil %>
</p>
<% end %>
class DellInfo extends \SoapClient {
//const ADDR = 'http://xserv.dell.com/services/assetservice.asmx?WSDL';
const ADDR = 'http://143.166.84.118/services/assetservice.asmx?WSDL';
const GUID = 'F5EE89B0-5332-11E1-B47D-8E584824019B';
function __construct($options = array()) {
if (!isset($options['exceptions'])) {
$options['exceptions'] = false;
}
## I need to have a Group that can consist of Users and/or Companies
class User
has_many :relationships
has_many :companies, :through => :relationships
has_many :groups, :as => :groupable
end
class Relationships
belongs_to :user
class Carnivore < Player
before_save :set_lvl
def initialize(attributes = {})
super
self.xp = 0
self.max_xp = 50
self.hp = 5
self.max_hp = 5
self.ap = 3
class TournamentEntry < ActiveRecord::Base
attr_accessible :entry_reqs, :format, :future, :links, :location, :name, :ongoing, :past, :prizes, :sponsor :status
# attr_accessor :status
def status
if !self.future.blank?
return "future"
elsif !self.ongoing.blank?
return "ongoing"
elsif !self.past.blank?
class CreateOpenroomTables < ActiveRecord::Migration
def connection
ActiveRecord::Base.establish_connection("openroom_#{Rails.env}").connection
end
def change
create_table "BannerLookup", :primary_key => "ID", :force => true do |t|
t.string "onid", :limit => 9, :null => false
t.string "status", :limit => 30, :null => false
t.string "email", :limit => 128, :null => false
t.string "fullName", :limit => 41, :null => false
class BooleanSurvey < Survey
def self.translate_answer(answer)
ActiveRecord::ConnectionAdapters::Column.value_to_boolean(answer)
end
end
# before, would depend on routing constraints to block .json/.xml as 404 not found
class ThingyController < ApplicationController
def show
@thingy = Thingy.find params[:id]
end
def update
@thingy = Thingy.find params[:id]
# Connects to a Z39.50 resource and yields the connection.
def self.connect
ZOOM::Connection.open(self.endpoint, self.port) do |conn|
conn.database_name = self.database
conn.preferred_record_syntax = 'USMARC'
unless self.user.blank? || self.password.blank?
conn.set_option('user', self.user)
conn.set_option('password', self.password)
end
yield conn