Skip to content

Instantly share code, notes, and snippets.

ActiveRecord::Base.transaction do
orders_to_fix = Order.joins(:billing_address).where("orders.billing_address_id = addresses.id AND addresses.addressable_type = 'User'")
orders_to_fix.each do |order|
billing_address = order.build_billing_address order.billing_address.attributes_for_clone
billing_address.addressable = order
billing_address.save(:validate => false)
ActiveRecord::Base.connection.execute("UPDATE orders SET billing_address_id = #{billing_address.id} WHERE id = #{order.id}")
end
arr = (1..129).map{|a| a}
arr2 = (1001..1129).map{|a| a}
(0..ARGV[0].to_i).each do |a|
(0..128).each do |b|
if arr[b] % 2 == 0
arr[b] += arr2[b]
else
arr2[b] *= arr[b]
end
import sys
arr = [a for a in range(1,129)]
arr2 = [a for a in range(1001,1129)]
for a in xrange(0, int(sys.argv[1])):
for b in xrange(0,128):
if arr[b] % 2 == 0:
arr[b] += arr2[b]
else:
arr2[b] *= arr[b]
class Girl
def initialize(secret_name)
@secret_name
end
end
class Ala < Girl
def name
@secret_name
end
@detomastah
detomastah / Adjust areas of expertise
Created September 18, 2013 13:06
Adjust areas of expertise
ActiveRecord::Base.transaction do
ExpertiseArea.find_by_name!("Development / programming").update_attribute(:name, "Technical & data feasibility")
ExpertiseArea.find_by_name!("Market research / customer development").update_attribute(:name, "User & market insight")
ExpertiseArea.find_by_name!("Marketing / customer acquisition").update_attribute(:name, "Marketing")
ExpertiseArea.find_by_name!("User experience / Design").update_attribute(:name, "User experience")
ExpertiseArea.create!(:name => "Idea screening")
ExpertiseArea.create!(:name => "Web development (HTML, CSS, Javascript)")
ExpertiseArea.create!(:name => "Social app development (Facebook)")
end
<% if @recruitment.tandc %>
<% content_for :title, "Education Partner Checklist 2013/14" %>
<h2>Training</h2>
<p>Before you start running the Apps for Good course you need to attend a Train The Trainer session, so that you feel confident in delivering the course to your students.</p>
<h3 style="margin-top:1em;">Please register to attend to one of the Train The Trainer sessions listed below.</h3>
<!-- <p>The Education Partner checklist provides you with the training, resources and expert guidance to successfully deliver the Apps for Good course.</p> -->
<%
# TODO: EventBrite API
Utwórz repozytorium na Github (o nazwie nie wskazującej, że jest to zadanie z Kodologii). W pierwszym commicie dodaj poniższe pliki, nie zmieniając ich.
Twoim zadaniem jest:
1) Napisanie modułu Validator (validator.rb), który po dołączeniu do klasy `User` sprawi, że ta klasa będzie działać poprawnie.
2) Napisanie w Rspec testu modułu validator i klasy User.
Kod powinien zawierać wszystkie elementy, dzięki którym, po pobraniu go na mój komputer będę mógł go uruchomić, wpisując polecenie rspec
Link do repozytorium z rozwiązaniem wyślij mi mailem.