ponedjeljak, 28. svibnja 2012.

Erasmus student exchange in Porto part 2

It has been more than two months since I wrote my last report. Life started rolling on in it's normal way. Only while writing this blog I regain the feeling that nothing is actually normal. Everything is refreshingly different from home, but it was due time for me to get used to it.
I still live alone in two-bed room, but I was told that one student is coming in June to the residence and that they will put him with me in the room.
One piece of information: the protocol for downloading torrents is blocked from university network. I tried a lot of workaround, and managed to get some download but it was very rare and the speed was awful.

Life is Porto is very relaxed. People here are immune to stress. Whether it is a positive or a negative one, they don't tolerate it. Everything can wait. That is most evident in Portuguese administration. I have three friends already complaining how Portuguese administration managed to make their lives very complicated. Two friends waited for several months for their grants to be paid in full. This could all be some coincidence if I didn't personally know a girl who is also on exchange and works in the International Office at the Rectorate of University of Porto. She explained to me in details how student e-mails stay unread for several days and unanswered for several weeks without any cause other than the people there don't feel like working.


FC Porto
(recapture your love for football)
Porto's finest football team enjoys a great fame and united support of all its citizens. And rightfully so, considering that despite Benfica (Lisbon) having better predispositions for football success (bigger city, better financial background), Porto still year after year demonstrates domination not only in Portugal but also in European championships. I've actually met Slovakian students on Erasmus that have been living here for an entire year. They started visiting Porto home matches within months after they moved here and they were really passionate about it.

Futsal is also very popular in Porto. For me it is actually one of rare occasions to speak and interact with Portuguese people over longer period of time. Neighbourhood's futsal playground is the place where I learnt most of the Portuguese language I speak.

In May, there is a traditional celebration called Queima das Fitas which lasts one week. All students walk around the town yelling and wearing black harry potter outfits with funny cylinder hats and sticks in various colours. They are often kicking each other on the head with a stick, so probably the purpose the hats is also to protect the head. Only the senior students who are finishing college get hit on the head because it is actually something like a knighting ceremony here. Only difference is that here everyone is drunk. In Matosinhos there is a big area surrounded by fences, where concerts are being held all week. Inside that area, every faculty has its own stand where they sell alcohol. Every stand has its own theme and its own music. Each year, a lot of even internationally famous singers, DJs and music groups make an appearence on this annual Portuguese festival.

Sea is very cold. Temperature of the sea can go up to 18°C. Higher than that maybe in extremely rare occasions. Surfing is very popular in Porto. For Erasmus students there is a special discount on surfing courses and a lot of students use it. I went surfing only once and it was great. I always forget to go to ESN office to apply for some more surfing classes.

Another great thing about Porto is that it's very well connected to other European cities via low-cost flights. RyanAir, Transavia, and probably many other companies travel to Porto. It is normal to find a return flight to Barcelona, Madrid, Paris for no more than 30€.

Food here is slightly different than what I was used to. Portuguese people eat a lot of fish especially Bachalau. They have a lot of different recipes for this fish and it is considered traditional food here. Other characterstic dish is Francesinha. I tried it in couple of places and the taste was very different, so if you don't like it the first time, you should try some other place, every restaurant has different recipe. Near the river, there is one restaurant called "Verso em Pedra" which has a special "Mega Francesinha" in the offer. This is sort of a competition, because whoever successfully eats a mega francesinha alone within one hour, recieves a prize: an electric guitar. I forgot the brand of the guitar but I know it is very high quality. It should be, because nobody has ever won the prize. I would say it's close to impossible because I actually saw that meal. They say it's 3kg, but i think it's even more. The price of mega francesinha is 35€ so it could be a good idea to order it regardless of the competition for 7 or more people to eat. A normal meal to order if you are hungry and don't want to experiment much is "prego em prato". That's a steak with egg and potatoes. Pastel de nata is my desert of choice. It's so creamy and delicious and you can buy it almost anywhere, including in supermarkets.

utorak, 15. svibnja 2012.

Camera Toshiba Camileo P10 - "MEMORY FULL" Problem

I was using the camera for several months with no problems when suddenly after a few weeks of inactivity I tried to use it and I couldn't take pictures anymore - the camera reports "memory full".
I took out the memory card, plugged it into my laptop and deleted all pictures and videos, put it back into the camera and still the same message appeared even though there is no picture nor videos on the memory card.

FIXED:
All I did:
1) extract the memory card
2) put the camera on charging (to recharge the battery)
         -> try to take pictures while the camera is charging without memory card, this should work
3) when it's fully charged, put the memory card back in and everything should be ok

utorak, 27. ožujka 2012.

MySQL Stored Procedure - application example

USER_ACTIVITY

user_id nightmorningdayeveninglast_update
1 4.62.43.68.62012-03-26 16:22:42
214.29.98.210.42012-03-26 07:45:22
31.26.36.513.12012-03-25 22:12:55
43.12.65.22.92012-03-24 11:34:12
...

distribution of hours:
night = 21h-5h
morning = 5h - 10h
day = 10h - 16h
evening = 16h-21h


-------------------------------------------------------------------------------------------------

Say you need to make record of users' activity. Each time you check upon a user and see that he was active since you last checked him, you add 1 point to his activity.

Example:
Current time is: 2012-03-26 20:42:38
We use some other service (not important which one) to find out whether user was active since we last checked him or not.
For simplicity, we assume that all users had some activity since the last time they were checked.

I check upon user#1.
I need to distribute 1 point of activity across the times of day.
Since it was the same evening since we last updated this user, we add 1 point to 'evening activity'.

Then i check upon user#2.
Since his last update 12.95 hours passed. 2.25 hours of that time was in the morning, 6 hours were during the day and 4.7 hours was during the evening. In the same ratio, 1 point should be distributed to the day parts (morning, day, evening). This means: 0.174 to 'morning', 0.463 to 'day' and 0.363 to 'evening'.

In the case of user#4 we would like to do something like this:
Since last update of this user 57,133 hours passed. We create variable hour_inc = 1/57.133.
Then we add (hour_inc*8) to 'night', (hour_inc*5) to 'morning', (hour_inc*6) to 'day' and (hour_inc*5) to 'evening'.
Sumation of these increments in this case is less than 1.

So if we want to do this for arbitrary 100 users from this table and we want to update existing information based on the information we just calculated, how would we do it?
Is it possible to do it with one with one SQL statement?
I don't think so... if you know let me know...

So the first thing we do. We open our programming language of choice and make a function that will do this for us:
{
    1) do a SELECT query to fetch needed data
    2) iterate through users and calculate new activities for each one
    3) after that, we do a 100 of consecutive update statements. Each update statement is different because 'last_update' time for each user is different
}

The other approach is using stored procedures.
We make a procedure that uses a cursor and iterates through all users.
For each of them builds up a big UPDATE statement (string) using concatenation in combination with some form of loop.
After a statement is built, we use PREPARE-EXECUTE to preform a statement which was up to now in a some variable of type VARCHAR(1500).

The thing that I observed is that using this approach 20000 users gets correctly updated in up to 7 seconds.
Then I modified the stored procedure so that it doesn't apply those update statements but instead prints them out using SELECT command.
I copied one of update statements, made a complement update statement that annuls first one's effect.
Then I copied this pair many times until I had 500 update queries. I executed them and waited 34 seconds before it finished.
That is the duration of merely updating information in database, not including the time it took to calculate this data that is being put in database. While the stored procedure does the calculation + update within 7 seconds for 20000 users.

If I did everything right, THAT is pretty impressive.

utorak, 20. ožujka 2012.

Erasmus student exchange at Porto

It's been 3 weeks since I arrived to Porto. I'm a student of computer science from Croatia, now studying at Faculdade de Engenharia da Universidade do Porto - FEUP.

I got here by myself so I basically didn't know anyone the first few days. In some way I feel like I still don't know anyone, but I guess that depends on how do you define "knowing someone".

So, what are the experiences so far...

Portuguese girls in average are not as nearly as pretty as Croatian girls.



They put kitchen tiles on the outside of their houses in the old city core.



There is a tradition in Portugal that the students wear funny looking "Harry Potter" outfits (black suit with some kind of cape).
It is not obligatory, but they respect this tradition very much. 
They group in some way, and leaders of those groups also carry around some sort of wooden spoon that I first thought was a rowing paddle. They wear it all the time when they are outside, regardless of the weather. It amazes me to see how many of them are doing it. It's like carnival whole year long.
Not everybody can wear it, though... First year students need to pass the initiation period during which they are compelled to do all sorts of humiliating activities. This lasts from the start of academic year until May.
In May there is a holiday with huge ceremony in the streets of Porto where all freshmen can finally wear these black uniforms.

In a way I can understand it because there is a lot of young student that come here from many parts of Portugal to an unknown environment to study. For them it's a way to bond to other students who are in similar situation.
Still, I could never picture myself wearing that.




A majority of people don't speak English. I guess that is the case in all nations that speak one of the biggest languages in the world - Chinese, Spanish, Portuguese, French, German, Italian, ...

People are often late for appointments. And I don't mean 5-10 minutes late. 30 minutes to 1 hour and 30 minutes... that's the range. Or many times they just don't show up. This is not just my observation, I heard it from a lot of people.

The Erasmus students here are 50% Brazilians... Prior to my arrival, I heard all these stories about Brazilian hedonistic life-style and general laziness. But I have had contact with only one Brazilian with those characteristics and only over e-mail.

In my experience, foreign students come here to party. It's high school all over again for them. Party all the time, drinking also... I don't mind that. I like beer, sangria, martini... But the way they drink, it's not for humans.

Before I came here, my expectations were not high. I thought I will make some Portuguese friends, go surfing, play futsal in the afternoon, learn some basics of Portuguese language... basically integrate myself in a domestic culture.
These goals now seems hardly achievable. People here have their own lives, friends, daily routines, families... it's difficult to get involved in all of that.
On the other hand, the Erasmus students are more often willing to connect with new people. So that makes foreigners form their own groups instead of mixing with the locals.

I live in student residence Alberto Amaral. It's cheap (130€), I have two-bed room all for myself. But at any time that could change. I don't have kitchen, but student canteen is a hundred meters from the dorm. I have my own fridge. There is a microwave in the lobby, also a big fridge and TV with like a hundred channels. I don't it watch very often, only English Premier League on weekends and Champions League during some weeks.
One thing to take into consideration if you are on exchange in Porto during winter or early spring: ordinary flats here don't have any kind heating installed. Rooms in a dorm do.

Laundry is done in a special room here in a dorm. You need your own detergent, softener and whatever... Washing machine works on special coins. One coin costs €2. There is also a dryer (usage is free, no coins), and the ironing board.

Student canteen, price of lunch or dinner is €2.30, but it's not even worth the money. You always have 4 menus at your choice: Vegetarian, Meat, Diet, Fish. I only haven't tried Diet. Of other three, Vegetarian seems to be the best choice every time. The meat in the canteen is simply awful.

Transportation.
The city is divided in zones. When you buy a monthly ticket, you have to choose which zones you want to include. Price of monthly ticket depends on number of zones you use. I use two zones and pay monthly ticket €22.5.

For now my estimation of monthly expenses are like this:
€130 - accommodation
€30 - transportation
€280 - food
€7.5 - phone

Those are some kind of fixed monthly costs. There are also one-time purchases (glasses, spoons, knives, cleaning detergent, sponges, iron...) and variable monthly costs. Variable monthly costs (drinking, chocolate, ordering a pizza, ...) you can always cut down if you need to save up money.

ponedjeljak, 9. siječnja 2012.

Nagradno putovanje na Krf (Jupiter International d.o.o.)

Na facebooku preko privatne poruke obaviješten sam da sam sretan dobitnik besplatnog putovanja na Krf. Ljubazna djevojka zatražila me broj telefona te me tokom dana nazvala i objasnila malo detaljnije da sam osvojio bogatu nagradu. Dogovorili smo se da će sve napisati u mailu. Stigao je mail:

http://dl.dropbox.com/u/5257657/KrfNagrada.htm

E-mailom sam zatražio:
da preuzmem samo besplatan smještaj na Krfu (bez njihovog putnog asortimana) -> nije moguće
da mi pokažu popis dobitnika nagrade -> "štitimo privatnost dobitnika"
da mi daju kontakt broj tih apartmana u Grčkoj -> dobio sam samo neke slike

Uglavnom, muljaža.