Processing websites with java

Today in less than an hour I managed to make a program that reads the user input, which should be a valid URL. Then it can give you the number of pages that the link has, the html code in the console or make a new html file and save the html code there. I should also give all the links that the site has, but I wasn’t able to do this properly in the given time and it was only returning the whole html line in the source code. However I will continue the work later and make that function work. I used eclipse IDE and a lot of internet browsing in order to make the program work.

Here’s a link to my repository and the working java program: https://github.com/powerworr/TP/tree/master/C14

Using eclipse and object oriented design

I know I haven’t posted anything in a while, but there wasn’t really anything intresting to post about.
So now I’ll tell you again about my homework. I was supposed to rewrite the program with the airplane in object oriented way and add some additional stuff like name and gender to the people that I add to the plane.

So here’s the source code:

https://github.com/powerworr/TP/tree/master/H12

Yellow Belt

//Училище : Технологично училище “Електронни системи” към ТУ-София
//Клас: 11 Б
//Номер: 8
//Име: Виктор Георгиев Стоянов
//Задача: Да се намери сбора на първите 10 числа от .csv file

import java.io.*;
import java.util.*;
import java.lang.*;

class Yellow{
public static void main(String[] args){
float[] time = new float[10];
String fileName = args[0];
String line;
int i =0;
try{
BufferedReader reader = new BufferedReader(new FileReader(fileName));
while((line=reader.readLine())!=null){
time[i]=Float.parseFloat(line.split(“,”)[0]);
i++;
}
reader.close();
}catch(Exception e){

}
float timeSum = 0;
for(int j=0;j<10;j++){
timeSum += time[j];
}
try{
BufferedWriter writer = new BufferedWriter(new FileWriter(“TopTests.csv”));
writer.write(timeSum + “;\n”);
writer.close();
}catch(Exception e){

}
}
}

First exam

For our first exam we needed to make a program on any language that we want, which was ment to read a csv file and write to an other one. It sounds easy, but less than 10 students have done it. Maybe it’s because the time was very limited or maybe we were just not prepared for this. However no one from the 6 people that did it used java. This may be because java is a good OO language and for such sort task you need to write a lot lines just to make the code works properly, while the whole code on ruby is less than 10 lines.

Here’s the link to the task using ruby:

https://github.com/powerworr/TP/blob/master/C8/Yellow_belt.rb

Here’s the link to the task using java:

https://github.com/powerworr/TP/blob/master/H9/YellowBeltJava.java 

How to use Github Ubuntu

GitHub is a web-based hosting service for software development projects that use the Git revision control system. GitHub offers both paid plans for private repositories, and free accounts for open source projects. As of May 2011, GitHub was the most popular open source code repository site. And I’ve started using it lately on both on Ubuntu and Windows and from my personal expirience I want to say that here the windows (8) app is a lot easier to use and saves a lot of time. But how ever I think there is no need for a tutorial on how to use Github with the windows app so I am going to explain to you how to use it through Ubuntu.

Ubuntu:
First you need to configurate your user name and email by using the commands:
git config –global user.name “username”
git config –global user.email “Email”

https://powerworr.wordpress.com/gallery/#jp-carousel-127

The next thing is to initialize an empty repository and copy yours there. This is made by using using the HTTP link and the following commands:
git init
git clone “repositoryURL”



https://powerworr.wordpress.com/gallery/#jp-carousel-128
https://powerworr.wordpress.com/gallery/#jp-carousel-130

After that you need to enter your cloned repository and copy your files inside or just start working there, which is the better option in my opinion.

https://powerworr.wordpress.com/gallery/#jp-carousel-131

And we are just few steps away from the end. When you have done this just add the files to your commit, actually commit and push everything to your online repository:

git add . (where the dot is used to add all new files to the commit)
git commit -m “theReason” (you need to use -m “text”, where text is the reason for your commit)
git push


https://powerworr.wordpress.com/gallery/#jp-carousel-135

When you use “git push” you’ll get a message that tells you to write your Github username and password. When you write them both you are ready with everything and you can go to your repository in Github.com and look the new added files.

https://powerworr.wordpress.com/gallery/#jp-carousel-136

Most popular person in class

This tuesday was pretty intresting, because we all went out of the building with 1 paper and pen per student and wrote our numbers on the papers of our classmates. Despite that it was quite a mess we managed to fill 29 papers with 29 numbers per page. Then we went back to the computers and made 29 csv files in which we entered the info from the papers. Afterwards we needed to spread this sheets so that everyone can work with all of them. And after all of you got all the csv files we were told to make a program which shows, which is the most common number on the papers, which is the most uncommon, who is on which paper most common… etc.

Task:

https://docs.google.com/document/d/1cICd34PbUugfGjPO2FmAABreKEQhAEeJgaOh9Vzw6IY/edit

My program:

https://github.com/powerworr/TP/blob/master/H7/Count.java

Air plane seats arrangement

This time we had to write a program that arranges the seats in a normal plane with 27 rows and 6 seats(3 on the left and 3 on the rigth) at each row. I had no choice and needed to write it using Java and Ruby. It wasn’t hard at all, despite that most of my classmates are complaining about this task.

Here’s the link to my repo with the source codes:

https://github.com/powerworr/TP/tree/master/H6