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
# This will generate something like "jfonda51", and a password like "0be21405590f", | |
# which is completely secure. | |
if client.first_name? && client.last_name? | |
new_credentials = Credentials.new([client.first_name[0..0], client.last_name].join.downcase) | |
# Replace the username, if it is blank | |
if client.username.blank? | |
# Check for existing usernames, and regenerate until unique | |
until Client.exists?(:username => new_credentials.username) == false | |
new_credentials = Credentials.new([client.first_name[0..0], client.last_name].join.downcase) |
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
def gethostname(domain) | |
Socket.getaddrinfo(domain, nil)[0][2] | |
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
if server = CpanelServer.find_by_hostname(gethostname(servername)) | |
core_cpanel_server_id = server | |
else | |
core_cpanel_server_id = nil | |
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
core_client_id = Client.find_by_old_client_id(clientid) | |
core_state = case active | |
when 0 then "cancelled" | |
when 1 then "active" | |
when 3 then "suspended" | |
when 4 then "cancelled" | |
else | |
"queued" | |
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
def controller_action | |
render :update do |page| | |
page << "$('#div1, #div2').html('content');" | |
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
export ARCHFLAGS='-arch x86_64' | |
PATH=$PATH:/path/to/postgresql/bin sudo gem install pg |
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
# Edit this Gemfile to bundle your application's dependencies. | |
source 'http://gemcutter.org' | |
gem "rails", "3.0.0.beta" | |
gem "hpricot" | |
gem "epp" | |
gem "opensrs" |
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
def column | |
Time.parse(read_attribute(:column)) | |
end | |
def column=(datetime) | |
write_attribute(:column, datetime.to_i) | |
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
validate_on_create :between_valid_dates? | |
private | |
def between_valid_dates? | |
date1 = dynamically_generate | |
date2 = dynamically_generate | |
if !birthdate.between?(date1, date2) | |
self.errors.add(:birthdate, "is invalid") and return false |
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 Notes(models.Model): | |
created_at = models.DateTimeField(auto_now_add=True) | |
user = models.ForeignKey(User) | |
order_id = models.PositiveIntegerField() | |
note = models.TextField() |