вторник, 30 октомври 2012 г.

Изпит за жълт колан

Ето задачата на изпита за жълт колан .

#Да се събере времето за тестове с време > 5
require "csv"
sum = 0
CSV.open("output.csv","w") do |writer|
    CSV.foreach("feature_scenarios_times.csv") do |row|
        temp = row[0]
       
        temp = temp.to_f
       
        if temp > 5.0
            sum = sum + temp
        end
    end
    puts sum
    writer << [sum]
end
puts sum

понеделник, 29 октомври 2012 г.

require "csv"
x = ARGV[0]
a = Array.new
b = Array.new
y = Array.new
for i in 0..49
a[i] = 0
b[i] = 0
y[i] = 0
end
CSV.open("output.csv","w") do |writer|
i=0
CSV.foreach("belt.csv") do |row|
a[i] = row[0].to_i
puts a[i]
b[i] = row[1].to_i
y[i] = (a[i].to_i * b[i].to_i) / x.to_i
puts "#{a[i]} #{b[i]} #{y[i]}"
writer << [a[i],b[i],y[i]]
i+=1
end
end
кода от поредната тренировка за изпита

понеделник, 22 октомври 2012 г.

GitHub Tutorial


Hello and welcome to my GitHub tutorial. Today I will teach you how to use GitHub. But first :

1. What is GitHub ?


GitHub.svg is a web-based hosting service for software development projects that use the Git version control system. The site provides social networking functionality such as feeds, followers and the network graph to display how developers work on their versions of a repository.The site is very user friendly and is really easy to work with.


2. Let's get started.

We will need to register. You can register here .
I will use my account in order to show you how to work with the VCS.

We have to create a repository ! 

How ? You'll see.
First you have to click the create a new repository (a.k.a repo) button on our user page.


After that you have to write the name of the repository , click on the public button to make our repository public and click the green button !


And now we have our first repository !


3. How to install Git on your system


To use GitHub you have to install Git on your computer . I will explain it in few easy steps:

1. Open the terminal


2.Write : sudo apt-get install git-core

3.Write : Y


4.And it's ready for use !





4. Username

We can configure username and with : 

git config --global user.name 'Your username here'




5. Fork

When we create a repository we have to fork it using "fork" button.



6. Clone


After forking we have to clone our repository on our computer . In order to do it you have to type " git clone https://github.com/Username/Repository_name.git"


Now you have your repository on your hard drive.

7. Add and Commit

When you have the repository on your computer you have to put files in it. In order to "add" them to
the repository you have to use "add"(I've already created a ruby file called Hello_world.rb)



After adding the file we have to commit it by using : 


8. Push

Now we have the files in our local repository ,but still nobody have access to them. In order to "upload " them we have to use "push" (git push master origin).


9. Pull

What to do if somebody else have pushed something new in the GitHub repository and we don't have it  in our local repository? We can update our local clone of the repository by using "Pull" (git pull)


These are the most common commands in git.