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
require 'udt_model' | |
class MetaMark::ActiveRecordModel | |
extend UdtModel | |
def self.active_record_model_as_file(udt) | |
# return if File.exist?(udt.path_to_udt_model) | |
# m = MetaMark::ActiveRecordModel.new(udt) | |
table_name = udt.db_table_name | |
new_class_name = udt.udt_class_name # m.udt_class_name(table_name, udt) |
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 Udt < ActiveRecord::Base | |
include AASM | |
has_paper_trail | |
belongs_to :project | |
has_one :organization, through: :project | |
has_one :workflow, dependent: :destroy | |
has_many :workflow_scripts, as: :aasm_scriptable, dependent: :destroy, class_name: 'AasmScript' | |
has_many :udt_table_fields, -> { order(position: :asc) }, dependent: :destroy |
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
Why not to use has_many association extension over has_many with conditions! | |
Has many is useful for adding in new functionality to the has_many association, however the problem with these entensions is | |
that Rails doesn't cache them. So every time you call object.members.requested it makes a call to the database. | |
has_many :organization_users | |
has_many :members, through: :organization_users, source: :user | |
has_many :members, through: :organization_users, source: :user do | |
def requested |
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
# A must have function for thinking sphinx, eg: | |
# | |
#Location.search("taco", :geo => [33.653275.to_radian, -117.646854.to_radian ], #:order => "@geodist ASC").map(&:address).map(&:city) | |
class Numeric | |
def to_radian | |
self * Math::PI / 180 | |
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
#!/usr/bin/ruby1.8 | |
require 'tk' | |
require 'open3' | |
require 'net/telnet' | |
require 'fileutils' | |
require 'date' | |
DESTINATION_DIR = "/tmp" |
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
sudo apt-get install postgresql | |
l; | |
1003 sudo apt-get install libproj-dev libxml2-dev postgresql-server-dev-8.4 | |
1004 sudo apt-get install libproj-dev libxml2-dev postgresql-server-dev-8.4.4 | |
1005 sudo apt-get install libproj-dev libxml2-dev postgresql-server-dev-8.4 | |
1006 psql |
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
Hey Ben, | |
if you add in the ' -limit memory 1 -limit map 1 ' to your transformation_command method it causes imagemagick to use file space instead of memory space. Now I dont have to buy more ram and it does the same thing! | |
----------------------------------------------------------- | |
"papermill_paperclip_processor.rb" 82L, 3241C written | |
def transformation_command | |
" -limit memory 1 -limit map 1 #{(crop_command ? super.sub(/ -crop \S+/, crop_command) : super)} #{copyright_command} #{watermark_command}".sub(%{-resize "0x" }, "") |
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 SubscriptionTransaction | |
named_scope :today, | |
:conditions => ['created_at > ? and created_at < ?', | |
Time.new.beginning_of_day, Time.new.tomorrow.beginning_of_day] | |
--------class Subscription | |
named_scope :due_today, | |
#:include => [:customer], |
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 AasmAddons | |
def self.included(base_class) | |
base_class.class_eval do | |
def aasm_fire_event(*args) | |
line_items.each do |li| | |
#li.send("#{args.first.to_s}!") | |
li.update_attributes(:state => args.first.to_s) | |
end | |
state_logs.create!(:state => args.first.to_s, :user => current_user) | |
super(*args) |
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
#-- | |
# | |
# Utility for creating Google Maps Encoded GPolylines | |
# | |
# License: You may distribute this code under the same terms as Ruby itself | |
# | |
# Author: Joel Rosenberg | |
# | |
# ( Drawing from the official example pages as well as Mark McClure's work ) | |
# |
NewerOlder