Category Archives: Uncategorized

Android – Final project COMP 3617

COMP 3617 needs to be validated by a  final project, that need to be presented to the class, for the last session.

Here is the pitch :

Motivation :

I like to visit the Georgia straight new paper on my smartphone to check for the latest events and have time to see them.

I find out the website to be a little heavy in order to access the information I just need.

The purpose of this application will be to display the just announced events which are under the URL :

http:// http://www.straight.com/listings/events

georgia

I can choose to display the Music events  or arts event from the Georgia straight Journal.

Clicking on one of the event shows the details of the show with the Image, the location the date, the price and the full description.

Implementations :

The main activity will display a list View with 2 tab , one tab will display the music events and the other to display the arts events.

It will display those events with the title, the image, and the date.

Clicking on one of the item in the listView , will display a second Activity called EventActivity

EventActivity :

Displaying further details of the event.

Display the picture, the date of the show, the event’s location, the price and also a short description.

There will be options to set up the event on the calendar or to share it by email.

In order to get the information’s from the website I could choose to use the news feeds or to try to GET the webpage and parse the HTML, I find out than the news feeds might not have the just announced events.

I will also implement a preference menu to choose to display the images or not in the Main Activity, and also an another CheckBoxPreference to choose to display only the week end events.

Every time the application opens, the Main activity will load the events from the website, which depends on the users Preferences, there will be a refresh button to refresh those events.

Further implementation :

If I have the time I can choose to show the event’s address on a map with a button in the EventActivity.

First Game in C

Hello,

i was busy learning about C and making some progress as i did manage to get a Game fully working in C with the SDL library.

This is a very short video  of my game working, i did manage to get it working on my linux box with the GCC 4.7.2 and SDL version 1.2.

but i do not have an exe file for windows for now.

Borpion

exercice sur les operations binaires.

voici un exercice tire du livre learning c with K&R 2nd edition
il sagit de l’exercice 2-6

Exercise 2-6. Write a function setbits(x,p,n,y) that returns x with the n bits that begin at position
p set to the rightmost n bits of y, leaving the other bits unchanged.

voici une solution trouver sur un forum.
je vais tenter d’expliquer le resonnement pour y arriver

——————————————————————————————

// Assume x = 10010011 (binary), p = 3 (decimal), n = 2 (decimal), y = 11001010 (binary)
// Also assume rightmost bit (LSB) is position 1.

uint8_t setbits(uint8_t x, uint8_t p, uint8_t n, uint8_t y)
{
uint8_t mask;
uint8_t temp;

mask = ~0; // All bits set (mask = 11111111)
mask >>= 8 – n; // n bits set in lowest position (mask = 00000011)

temp = y & mask; // set to first n bits of y (temp = 00000010)
temp <<= p – 1; // set to n bits of y at position p (temp = 00001000)

mask <<= p – 1; // n bits set at position p (mask = 00001100)

x &= ~mask; // n bits at position p cleared (x = 10010011)
x |= temp; // x set to first n bits of y at position p (x = 10011011)

return x;
}

——————————————————————————————

explications :

Il faut mettre le nombre de bit de longeur n venat de y(qui commence a la position p) dans x sans modifier les autres bits.
il faudra donc pour cela utiliser un masque, on l’apelle temp.

ce masque temp devra donc avoir des valeurs qui seront les seules valeurs a modifier les restantes ne seront pas modifier et garderont leurs valeurs apres l’operation.

l’operateur le plus apte a cette mission semble etre le OU (|), car il met a ‘1’ les bits qui sont a ‘0’ mais pas bit qui sont a ‘1’ ou ‘0’ vers ‘1’ si le temp est a ‘0’.

comment obtenir cette temp.
on sait que les bits a modifier sur ce temp seront a ‘1’ les autres seront a ‘0’, il seront aussi a la bonne position.

pour l’instant mettons en pausse l’etape precedente nous y reviendront.

il faut dons modifier certains bits de x, donc il va falloir initialiser les bits qui seront modifier.
il faudra un autre masque appelons le MASK.
ce masque devra faire une operation ET (&) entre MASK et X, mettant les valeurs a initialiser ( a ‘0’) dans x a zero, celles qui ne doivent pas etre modifier seront a ‘1’ dans le masque MASK ex : 0 & 1 = 0, 0 & 0 = 0.

Donc ce masque MASK doit connaitre la position des bits a modifier, p nous aide dans cette tache, car il indique la position ou commencer a compter les bits n a modifier (en allant ver la droite).

on sait combien de bit ne doivent pas etre modifier 8bits – n donne le nombre de bit qui ne seont pas modifier.

maintenant MASK connait le nombre de bits a modifier il seront mis tous a droite dans MASK, L’etape suivante est de les positionner.

(pour cela on utilisera Temp qui connait les bits a modifier et leur positions.)

on utilisera MAK et Y pour avoir les valeurs qui doivent etre apporter a X et seulemtn celles-ci.
un & operateur fera l’affaire, seulement les positions a calquer de Y seront dans TEMP, si Y =’0′ il sera mis a ‘0’ dans TEMP, si Y = ‘1’ il sera tjs a ‘1’ dans MASK.

donc TEMP decoulera de Y & MASK.

temp connais maintenant les valeurs a modifier ainsi que leur positions.

et voila.