Skip to content

Instantly share code, notes, and snippets.

View voxxit's full-sized avatar

Josh Delsman voxxit

View GitHub Profile
# 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)
def gethostname(domain)
Socket.getaddrinfo(domain, nil)[0][2]
end
if server = CpanelServer.find_by_hostname(gethostname(servername))
core_cpanel_server_id = server
else
core_cpanel_server_id = nil
end
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
def controller_action
render :update do |page|
page << "$('#div1, #div2').html('content');"
end
end
export ARCHFLAGS='-arch x86_64'
PATH=$PATH:/path/to/postgresql/bin sudo gem install pg
# 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"
def column
Time.parse(read_attribute(:column))
end
def column=(datetime)
write_attribute(:column, datetime.to_i)
end
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
class Notes(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey(User)
order_id = models.PositiveIntegerField()
note = models.TextField()