Archive

Archive for the ‘compting’ Category

Ajax – How to comunicate with a server with reloading

February 2, 2009 Leave a comment

Ajax (as I understand it) basically means you can use javascript to request a webpage without haveing to reload the one the javascript is on. You can then use the script to process the repponce from the server, for example by setting the innerHTML of an object in the page to the responce.

In order for it to work you will need a number of different functions. It was uses somthing called an xmlHTTPRequest object. This is what is used to process the actual request. Not all browsers support it and they all treat it slightly diffrently so unfortunatley you have to use a squence of ifs to set it up.

The code to do this is below:

function hehe(bit, meth, parameters)
{
alert(“heheness”);
if (window.XMLHttpRequest)
{// code for Firefox, Opera, IE7, etc.
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
if (xmlhttp!=null)
{

//this is where some of the code were going to look at later goes

}
else
{
alert(“Your browser does not support XMLHTTP.”);
}

Now we also need a function that is to be called when the xmlhttp does something which im going to call statChanged. This is where we put the processing for the responce of the server and where we can display a loading message or whatever.

The xmlhttp objext contains a variable called readystate that can be one of the numbers from 1 to 4 and shows what stage the request is at. I genrally only use states 1 and 4 because one shows the process has started so allows me to display a loading message and 4 shows the request has completed and allows us to process the responce. These are again determined by if statements.

The servers respionce can be accessed by calling xmlhttp.responseText where xmlhttp is the name of the object. So the final code is: (where add is the url to be requested, meth is the method to use(POST or GET) and parameters are any parameters to be sent like form data)

function ajaxcall(add, meth, parameters)
{

if (window.XMLHttpRequest)
{// code for Firefox, Opera, IE7, etc.
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
if (xmlhttp!=null)
{

xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open(meth,bit,true);
if(parameters != null)
{
xmlhttp.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
}
xmlhttp.send(parameters);

}
else
{
alert(“Your browser does not support XMLHTTP.”);
}
}

function stateChanged()
{
//alert(“hohoho” + xmlhttp.readyState);
if(xmlhttp.readyState==4)
{
//processing of responcee text
}
if(xmlhttp.readyState==1)
{
//loading process started
}

}

Categories: compting Tags: , , ,

3D Graphics

December 5, 2008 Leave a comment

Now at www.breakingwave.co.nr – the home of trevorpythag

This is a brief explanation of how to create basic 3D graphics. There are many different packages that will allow you to program using pre written 3D graphics library’s, such as Java 3D but this is aimed at using and understanding the actual formula that can be used to draw the graphics yourself.

This assumes you are looking straight ahead from a single point and will map points in the 3D space in front of you onto a single plane at a fixed distance in front of you, probably 1 unit to keep it simple.

First of all consider the vertical direction, y axis. If we consider the right angled triangle formed by taking the line from you eye to the point, the line from your eye to beneath the point (ie the line where y =0) and the final verical equal to the y cordinate, we can use trigonometry to work out the height that need to be displayed.

From this we can work out the angle at your eye would be tan-1(y/(x2+z2))
This is because the length of the “opposite” is equal to the y co-ordinate and the adjacent can be found using pythagoras from the x and z co-ordinates.

We now can use the angle we have found to work out where the point needs to be displayed in our plane. Again we need to form a triangle similar to the first one but where the top corner is the final position of the point when it is projected. Ie the opposite is the y co-ordinate we need.
therefore,
y = tan(t)((x/z)2+1)
y=y((x/z)2+1)
(x2+z2)

MySQL: mysql dump > using to upload database

October 13, 2008 Leave a comment

I recently created a website in PHP, with page details stored in a database using MySQL and then came acorss a problem when trying to upload it.

Basically mysqldump is a command that allows creates a file which contains all the sql statements required to rebuild the database or table you want. This is usefull for creating backups or allowing you to upload your database to your host server.

The command to do this is as follows
mysqldump –user=username –password=password databasename > locationofdump.sql

Note this should be entered in the normal command prompt, cmd.exe on windows, not the mysql command line tool thingy else it wont work. You can then use this to import the database on your host using phpmyadmin.

How to Create a Facebook Application

July 13, 2008 3 comments

This is aimed at people how already know programming and want to apply some of these skills to making a facebook application. You dont need to know much, even html will do though you wont make much of an application with this. Ive made mine using php and it was a site i had already developed.

Facebook is a great place to put your web apps and is easy to do but the documentation I could find on the site wasn’t that great (though mayb im just blind). First of all you need a facebook account, you should be able to do this easily enough, you also need an application, the application is no different to any other website and can be written in any language your familiar with (we just put it in a frame later on), i wrote my app when learning php with no intention of ever using it in facebook.

The first thing you need to do is get the developer application on facebook. Then choose to create an application by clicking set up an application. Choose a name and then click optional fields(this is where we set it up).

Callback URL is where you enter the address of your app, so if you have created a website you put a link to that sites home page. The canvas URL is the url for app on facebook, you have to choose a unique address for it which people can use to get to the app. If you just want to place your app in the page like i did, meaning that it works like a normall webpage, choose iframe under the canvas url box. We then choose application type to be website.

The next important field is “Can you application by added on facebook” and since your making an app for face book you probably want to set this to yes. You then need to fill in the install option page(if it can be added on face book). Here you want users to be able to add it to all pages. The default FMBL is the code that will appear on their facebook page when they add it.  I set as a link to the apps home page.

The final section to fill in is the integration points that helps facebook work with your app. The only part you need to fill in here the side nav URL which is the link that will appear in the applications part of the users page when they use facebook, so they can get to your app.

Finally click save, after that you can mess around on the developer trying out the different parts, try adding an image in the settings part. You also have to develop some code so that you application actually does something have fun,

David Woodford 🙂

Matrix C++ program

July 12, 2008 1 comment

I recently went back to my c++ matrix calculator program and noticed it needed some improving so here are the improvements along with the source code.

Download the c++ matrix calculator here

Firstly I have added add/minus features to it. I accidentaly forgot to code these last time but have included them in the new program with the commands add and min. A note on the code, all the min function actually does is reverse all the signs on the second matrix and then call add.

I have also allowed you to determine both the number of rows and columns in the matrix to give it more flexibility. However this is not extended to the transformations (rotate and reflect) which still only work in 3 dimensions. Also in this process I have changed the lgth variable in the matrix to colls so that it now has rows and colls.

Finally to avoid some errors i have ensured all answer matrices are assigned colls and rows values.

Please feel free to use the program and don’t be put off by the fact it uses a command prompt, just type help to see the list of commands and when you type the command followed by enter it will give you step by step guidance on what to do.

David Woodford

// matrix.cpp : main project file.

#include “stdafx.h”
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

class mat
{
public:
double mata[20][10];
int colls;
int rows;
void dimmat()
{
cout << “enter collums of matrix” << endl;
cin >> colls;
cout << “enter rows of matrix” << endl;
cin >> rows;
//    cout << “” << endl;

for(int n=0;n<rows;n++)
{
cout << “enter values for row” << n << ” , each followed by ‘enter’:” << endl;
for(int m=0;m<colls;m++)
{
cin >> mata[n][m];
}
}
}

void display()
{
int rcount = 0;
int ccount = 0;

while(rcount < rows)
{
while(ccount < colls)
{
//cout << “matrix:”<<endl;
cout << mata[rcount][ccount] << ” , “;

ccount++;
}
cout << ‘\n’;
ccount=0;
rcount++;
}
}

/*void rotate()
{
mat mat2;
mat2.dimmat();
mat mat3;
mat3 = mult(this, mat2);
}*/
};

mat mult(mat A, mat B)
{
cout << “multiply started” << endl;

//char pause;

mat ans;
ans.colls=B.colls;
ans.rows=A.rows;

int rcount = 0;
int ccount = 0;
int c2 = 0;

while(rcount < 3)
{
//cout << “row: ” << rcount << ” started” << endl;
while(ccount < A.colls)
{
//cout << “collum: ” << ccount << “started” << endl;

ans.mata[rcount][ccount] = 0;
while(c2 < A.rows)
{
ans.mata[rcount][ccount] = ans.mata[rcount][ccount] + (A.mata[rcount][c2] * B.mata[c2][ccount]);
c2++;
}
//cout << “value is: ” << ans.mata[rcount][ccount] << endl;
//cin >> pause;
c2=0;
ccount++;
}
ccount=0;
rcount++;
}

if(A.colls != B.rows)
{
cout <<“matrices are wrong sizes to be multiplied” << endl;
return A;
}
else
{

ans.display();
return ans;
}
}

mat add(mat A, mat B)
{
mat ans;
if(A.colls == B.colls && A.rows == B.rows)
{
ans.colls = A.colls;
ans.rows=A.rows;
int i = 0;
int j = 0;
while(i < ans.colls)
{
j=0;
while(j<ans.rows)
{
ans.mata[i][j] = A.mata[i][j] + B.mata[i][j];
j++;
}
i++;
}
return ans;
}
else
{
cout << “matricies cannot be added : diffrent lengths” << endl;
return A;
}
}

mat minus(mat A, mat B)
{
int i =0;
int j =0;
while(i<B.colls)
{
while(j<B.rows)
{
B.mata[i][j] = 0 – B.mata[i][j];
j++;
}
j=0;
i++;
}
return add(A,B);
}
mat rotate(mat A, int angle)
{
mat T;
T.colls = 3;

mat matans;

//creat transformation matrix
double pi = 3.14159265;
double theta = (angle*pi)/180;
T.mata[0][0] = cos(theta);
T.mata[0][1] = 0 – sin(theta);
T.mata[0][2] = 0;

T.mata[1][0] = sin(theta);
T.mata[1][1] = cos(theta);
T.mata[1][2] = 0;

T.mata[2][0] = 0;
T.mata[2][1] = 0;
T.mata[2][2] = 1;

matans = mult(T, A);
return matans;
}

mat reflect(mat A, int angle)
{
mat matans;
mat T;
T.colls = 3;
//creat transformation matrix
double pi = 3.14159265;
double theta = (angle*pi)/180;
T.mata[0][0] = cos(2 * theta);
T.mata[0][1] = sin(2 * theta);
T.mata[0][2] = 0;

T.mata[1][0] = sin(2*theta);
T.mata[1][1] = 0 – cos(2*theta);
T.mata[1][2] = 0;

T.mata[2][0] = 0;
T.mata[2][1] = 0;
T.mata[2][2] = 1;

matans = mult(T, A);
return matans;
}

void input()
{
string dim = “dim”;

string com;
int end = 0;

mat matans;
int matcount = 0;
mat mats[11];
while(end == 0)
{
cout << “enter command>”;
getline(cin, com);

if(dim == com)
{
cout << “matrix” << matcount <<endl;
mats[matcount].dimmat();
matcount++;
}
if(com == “rot”)
{
cout << “which matirx?” <<endl;
int matnum;
cin >> matnum;
cout << “what angle (degrees)” << endl;
int rotang;
cin >> rotang;
matans = rotate(mats[matnum], rotang);
mats[10] = matans;
}
if(com == “rlt”)
{
cout << “which matirx?” <<endl;
int matnum;
cin >> matnum;
cout << “what angle (degrees)” << endl;
int rotang;
cin >> rotang;
matans = reflect(mats[matnum], rotang);
mats[10] = matans;
}
if(com == “ans”)
{
matans.display();
}
if(com == “mlt”)
{
cout << “first matrix” << endl;
int mat1;
cin >> mat1;
cout << “second matirx” << endl;
int mat2;
cin >> mat2;

matans = mult(mats[mat1], mats[mat2]);
mats[10] = matans;
}
if(com == “add”)
{
cout << “enter first matrix” << endl;
int A;
int B;
cin >> A;
cout << “enter second matrix” << endl;
cin >> B;

matans = add(mats[A],mats[B]);
mats[10] = matans;
matans.display();

}
if(com == “min”)
{
cout << “enter first matrix” << endl;
int mata, matb;
cin >> mata;
cout << “enter second matrix” << endl;
cin >> matb;

matans = minus(mats[mata], mats[matb]);
mats[10] = matans;
matans.display();
}
if(com == “dsp”)
{
cout << “which matirx?” << endl;
int matdsp;
cin >> matdsp;
mats[matdsp].display();
}
if(com == “let”)
{
cout << “which matirx?” << endl;
int mat1;
cin >> mat1;
int mat2;
cout <<“eaqual to (10 is answer matrix)” << endl;
cin >> mat2;
mats[mat1] = mats[mat2];

}
if(com == “help”)
{
cout <<“Davids Woodfords matrix calculator” << endl;
cout << “takes the following commands” << endl;
cout <<” ‘dim’    ::  allows you to dfine a matrix”<< endl;
cout <<” ‘rot’    :: roates a matrix through an agnle” << endl;
cout <<” ‘rlt’    :: reflects a matrix through the line y=tan(a) where a is given” << endl;
cout <<” ‘ans’    :: displays the answer to the last calculation” << endl;
cout <<” ‘mlt’    :: lets u multiply 2 matricies together” << endl;
cout <<” ‘dsp’    :: displays a matrix specified”<<endl;
cout <<” ‘let’    :: allows u to assign one matrix the value of another, eg answer”<<endl;
cout <<” ‘add’    :: lets u add 2 matricies together” << endl;
cout <<” ‘min’    :: lets u minus 2 matricies together” << endl;
cout<<“===================================================================”<<endl;
cout <<“matricies are sotred in an array of 10, with numerical values starting at 0″<<endl;
cout<<“matrix 10 is the answer matrix”<<endl;
cout<<“any parameters will be asked for wen needed”<<endl;

}
}

}

int main()
{
cout << “Welcome to David Woodfords Matrix calculator” << endl << endl;
cout<<“type ‘help’ for a list of commands” <<endl;
//    mat mata;
//    mata.dimmat();

/*    mat matb;
matb.dimmat();

mat matans;
matans = mult(mata, matb);
//    mata.display();
*/
//rotate(mata, 30);
input();
return 0;
}

Powerset : the new search engine

I recently found an article on a new search engine called powerset , www.powerset.com, which has a new way of displaying the results. Instead of just displaying a list of results, like other search engines like google, it displays data that it has collected about the search with the results page and when you click on one of the results it is displayed within the results page.

At the moment it just searches wikipedia so you cant get all your information from it, though there is allot on wikipedia, i think this also makes it easier for it to display the pages within the results page and collect information about the pages.

It also attempts to be the first search engine in which you can type in plain english opposed to having to carefully select your keyword, it does this to varying degrees of success.

One useful feature it has on the results page is factz, this collects all of the information about the search term and displays it in lists that are grouped together, eg on its henry VIII example it has a property called wives, in this it then lists each of his wives, you can then click on one of these and it will display more detailed information on this.

I find that when using powerset it manages to find large amounts of information and display it to you in an easy to understand way, so that you don’t have to go digging around all the different pages to find it yourself. The only major draw back is that it has only indexed a small section a wikipedia compared to other search engines like googles billions of pages.

Anyway the only decent way to get a fell for power set is to use it!!!!!!!!!!!!!!!!!!!!!!!!!!!!

www.powerset.com

Prolog — Install and use

this is a quick guide on how to get going with swi-prolog. Prolog is a fith generathion “declerative” laungage, it uses facts and rules which can then be quired to give a responce, this sort of thing can used to create Artifical Inteligence (AI). Despite this sounding complicated it is in fact much easier to use and learn (once youve got your head round the way it works) than other (4th generation) laungages such as java and c++.

First of all you need to download it, go to http://www.swi-prolog.org/dl-stable.html and download the version of prolog for you operating system. You can then run the file you have downloaded (follow the instructions) to install it.

Prolog programs are saved as text files, ending in .pl, you should save these into the prolog folder (this was created in my documents during installation) these can then be opened by typing [file without .pl]. rember the dot (.) at the end, in the prolog window.

To run a prolog program you must first open the prolog command thing, from the start menu, programs can then be loaded and run.

Some things to rember about prolog:
>all commands and lines should end in a dot
>leave a line at the end of each file
>reload a file after it has been changed
>dont use capital letters for values only for things in which the value changes
>it wont recognise a calculation unles you use is, X=5+2 doesnt mean X=7 but X is 5+2 does
>a semi collon (;) will show the next result of the query

I dont have a good enough knowlage to write a full tutorial of prolog, only some basic points like those above however a good one is at

http://www.cs.nuim.ie/~jpower/Courses/PROLOG/

anyway enjoy coding

Matrix Calculator, C++ Program by David Woodford

April 23, 2008 5 comments

Ive been learning c++ and doing matrices in maths as well so I’ve decided to combine to the two in a simple command based program. The basic idea of the program is that it can quickly multiply matrices together and perform reflection and rotation transformations on them. Below is a download of the program and the source code. In the following weeks ill also make some tutorials on doing matrices by hand (click here for my multiplication lesson). Later im hoping to add some more features to it like finding the inverse matrix and the determinate

Download now !!!!!!!!!!

So how to use the program, well first of all type help. This will then display a list of the commands and what they do. When using it type your command, eg mlt, on its own, the program will then ask you to enter which is the first matrix and the second matrix in the multiplication. Every value should have the enter key pressed after its typed.

The program allows up to 10 matrices to be stored in memory plus the answer to the last calculation. They are stored in an array and are given numerical values. The first one you define, using dim, is matrix 0 the second is matrix 1 etc. The answer to the last calculation is matrix 10. When the program ask you which matrix you want to use it is asking you to enter this value for the matrix

Using the let command allows you to give one matrix the value of another. The first matrix number you enter is the one that the values being assigned to, the second is the value thats being assigned. This command is useful if you want to store the answer, after youve done the next calculation, to do this type let, when prompted type matrix that you want to be given the value of the answer and then give the value 10 for the value its being assigned.

Below is the code, i wrote it in visual c++ 2008, for the program. You may have to make changes if you using a diffrent complier to the includes at the top.

Enjoy using, but only to check, note all angles are in degrees recomplie if you want radians.


// matrix.cpp : main project file.

#include “stdafx.h”
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

class mat
{
public:
double mata[20][3];
int lgth;
void dimmat()
{
cout << “enter length of matrix” << endl;
cin >> lgth;
//    cout << “” << endl;

for(int n=0;n<3;n++)
{
cout << “enter values for row” << n << ” , each followed by ‘enter’:” << endl;
for(int m=0;m<lgth;m++)
{
cin >> mata[n][m];
}
}
}

void display()
{
int rcount = 0;
int ccount = 0;

while(rcount < 3)
{
while(ccount < lgth)
{
//cout << “matrix:”<<endl;
cout << mata[rcount][ccount] << ” , “;

ccount++;
}
cout << ‘\n’;
ccount=0;
rcount++;
}
}

/*void rotate()
{
mat mat2;
mat2.dimmat();
mat mat3;
mat3 = mult(this, mat2);
}*/
};

mat mult(mat A, mat B)
{
cout << “multiply started” << endl;

//char pause;

mat ans;
ans.lgth=B.lgth;

int rcount = 0;
int ccount = 0;
int c2 = 0;

while(rcount < 3)
{
//cout << “row: ” << rcount << ” started” << endl;
while(ccount < A.lgth)
{
//cout << “collum: ” << ccount << “started” << endl;

ans.mata[rcount][ccount] = 0;
while(c2 < 3)
{
ans.mata[rcount][ccount] = ans.mata[rcount][ccount] + (A.mata[rcount][c2] * B.mata[c2][ccount]);
c2++;
}
//cout << “value is: ” << ans.mata[rcount][ccount] << endl;
//cin >> pause;
c2=0;
ccount++;
}
ccount=0;
rcount++;
}

int smelly;
ans.display();
return ans;
}

mat rotate(mat A, int angle)
{
mat T;
T.lgth = 3;

mat matans;

//creat transformation matrix
double pi = 3.14159265;
double theta = (angle*pi)/180;
T.mata[0][0] = cos(theta);
T.mata[0][1] = 0 – sin(theta);
T.mata[0][2] = 0;

T.mata[1][0] = sin(theta);
T.mata[1][1] = cos(theta);
T.mata[1][2] = 0;

T.mata[2][0] = 0;
T.mata[2][1] = 0;
T.mata[2][2] = 1;

matans = mult(T, A);
return matans;
}

mat reflect(mat A, int angle)
{
mat matans;
mat T;
T.lgth = 3;
//creat transformation matrix
double pi = 3.14159265;
double theta = (angle*pi)/180;
T.mata[0][0] = cos(2 * theta);
T.mata[0][1] = sin(2 * theta);
T.mata[0][2] = 0;

T.mata[1][0] = sin(2*theta);
T.mata[1][1] = 0 – cos(2*theta);
T.mata[1][2] = 0;

T.mata[2][0] = 0;
T.mata[2][1] = 0;
T.mata[2][2] = 1;

matans = mult(T, A);
return matans;
}

void input()
{
string dim = “dim”;

string com;
int end = 0;

mat matans;
int matcount = 0;
mat mats[11];
while(end == 0)
{
cout << “enter command>”;
getline(cin, com);

if(dim == com)
{
cout << “matrix” << matcount <<endl;
mats[matcount].dimmat();
matcount++;
}
if(com == “rot”)
{
cout << “which matirx?” <<endl;
int matnum;
cin >> matnum;
cout << “what angle (degrees)” << endl;
int rotang;
cin >> rotang;
matans = rotate(mats[matnum], rotang);
mats[10] = matans;
}
if(com == “rlt”)
{
cout << “which matirx?” <<endl;
int matnum;
cin >> matnum;
cout << “what angle (degrees)” << endl;
int rotang;
cin >> rotang;
matans = reflect(mats[matnum], rotang);
mats[10] = matans;
}
if(com == “ans”)
{
matans.display();
}
if(com == “mlt”)
{
cout << “first matrix” << endl;
int mat1;
cin >> mat1;
cout << “second matirx” << endl;
int mat2;
cin >> mat2;

matans = mult(mats[mat1], mats[mat2]);
mats[10] = matans;
}
if(com == “dsp”)
{
cout << “which matirx?” << endl;
int matdsp;
cin >> matdsp;
mats[matdsp].display();
}
if(com == “let”)
{
cout << “which matirx?” << endl;
int mat1;
cin >> mat1;
int mat2;
cout <<“eaqual to (10 is answer matrix)” << endl;
cin >> mat2;
mats[mat1] = mats[mat2];
}
if(com == “help”)
{
cout <<“Davids Woodfords matrix calculator” << endl;
cout << “takes the following commands” << endl;
cout <<” ‘dim’    ::  allows you to dfine a matrix”<< endl;
cout <<” ‘rot’    :: roates a matrix through an agnle” << endl;
cout <<” ‘rlt’    :: reflects a matrix through the line y=tan(a) where a is given” << endl;
cout <<” ‘ans’    :: displays the answer to the last calculation” << endl;
cout <<” ‘mlt’    :: lets u multiply 2 matricies together” << endl;
cout <<” ‘dsp’    :: displays a matrix specified”<<endl;
cout <<” ‘let’    :: allows u to assign one matrix the value of another, eg answer”<<endl;
cout<<“===================================================================”<<endl;
cout <<“matricies are sotred in an array of 10, with numerical values starting at 0″<<endl;
cout<<“matrix 10 is the answer matrix”<<endl;
cout<<“any parameters will be asked for wen needed”<<endl;

}
}

}

int main()
{
cout << “Welcome to David Woodfords Matrix calculator” << endl << endl;
cout<<“type ‘help’ for a list of commands” <<endl;
//    mat mata;
//    mata.dimmat();

/*    mat matb;
matb.dimmat();

mat matans;
matans = mult(mata, matb);
//    mata.display();
*/
//rotate(mata, 30);
input();
return 0;
}

Internet Advertising: can it survie?

March 21, 2008 1 comment

When browsing the web it is amazing how many large sites are “free”, these sites make their money from advertising but if evreyone is providing a service reliant on advertising then who is ultimatley getting the money to pay for the adverts?

here is a quick list of site that provide “free” services:

  1. Google
  2. Yahoo
  3. Microsoft(msn)
  4. Facebook
  5. Youtube(now owned by google)
  6. Bebo
  7. Times online
  8. addictive games
  9. BBC
  10. Miniclip

The point is demand for adverts is a derived demand, ie there is only deamnd for ads because there is demand for the goods and services that are advertised, and therefore the money to pay for adverts comes from selling the goods/services they advertise. But if all of these services are “free” then no one is paying for the adverts and the 10 sites above shouldnt be able to sell ads.

Lets look at an example. I want to launch my site, www.breakingwave.co.nr, as a comerical site. I decide that since it would be hard to sell the content on it i will gain money by putting adverts along side. Sounds like a good idea.

So i get people to apply for adds and one of these people is yahoo, so they buy advertising space off me to attract customers to their site. Their site also needs to make money so they approach google to sell adverts which makes them some money.

But at the moment i dont have many visitors to my site so i decide to advertise, like any other company, to attract more and tell them how great it is. I decide that the best company to sell me ad space is Google, so google makes their money off my ads and i get visitors to clikc on the ads on my site.

this all sounds good enough and we have 3 goods services being provided for “free” to the consumer subsidesed by advertising. But what happens when we consider the profits of these companies. Well for any company following this model its verey simple. You pay for adverts which attract customers who click on the ads on your site. We know to make a profit you must earn more through selling than your costs, so if my costs are buy ad space and my earnings are selling ad space i make money by selling for more than i buy for.

I decide i can sell adds for £15, and can buy for £10 so i make a £5 profit. Now yahoo is paying£15, to me, for its adds so trys to sell ads to google for £20, the problem being that im only buying adds worth£10 off google so their gonna end up making a loss of £10. Under market forces this would force all the prices of converge at one price, probably £10 so over all no one is making a profit on adds, but they still have to provide their services for free so their going to end up losing money.

So.
If the online advertising industry (which includes all site that make money from advertising to provide a free service) is bigger than the rest of the online company the market is going to collapse, similar to the .com crash. Lets hope them that amazon and ebay are making up for these losses.

But why would anyone advertise at all is the most baffaling. If you have a decent site its gonna be well ranked in search engines like google and yahoo, so you can get all your visitors from here and no need to advertise. And this means companies will no longer be able to sells ads and this may contribute to their fall.

Anyways ive been far to pestimitic here as im sure the bosses of these compaines have learnt from their mistakes in the late 90’s and arnt gonna let the same thing happen again but it does seem strange the way these market work!!!!!

please leave your thoughts below

Basic Arithmatic in Binary

March 9, 2008 1 comment

This is a simple guide in using binary and performing simple arithmetic like addition and subtraction

What is Binary

Binary is an alternative number system that uses base 2, opposed to our normal system that uses base 1. Binary is used extensively in computers as it allows numbers to be represented by a current being on or off and therefore allowing them to do calculations.

Counting in binary

In base 10, our usual number system, we have 10 characters (0,1,2,…,9), and when we want to add 1 to our last character, 9, we have to move across to the next colloum, ie 9 + 1 = 0 carry 1. In binary we have 2 characters (0 and 1) and when we want to add one to one we move to the next colloum, so 1+1=0 carry 1.

so how do we read the binary number. Well on the far right we have our units (1’s) the same as in bas 10, however the next colloum across we have our 2’s instead of tens. Then we have 4’s instead of 100’s. So each collum is the next power of 2 across.

here are some numbers in binary and decimal(base 10):

decimal:binary
1 = 1
2 = 10 * 21
3 = 11
4 =100 * 22
5 = 101
6=110
7 = 111
8=1000 * 23
9=1001
10=1010 *101
15=1111
16=10000 * 24
20=10100
100=1100100 * 102

Adding in binary

In binary each number is either a 1 or 0, so if we have a 1 and we want to add 1 we have to put 0 and carry 1 to the next colloum.

eg 1+ 1 = 0 carry 1 = 10
eg 11011+10010 = 101101

In binary there are four combinations of digits that can be added

0+0 = 0
1+0=1
0+1=1
1+1=0 carry 1

You can add binary numbers in collums like you do with decimals, only it so much easier cos its only 1 and 0.

Subtraction

Subtraction is just the reverse of addtion so:

1-0=1
1-1=0
0-1= 0 carry 1 (to the left this time)
0-0=0 (obviously)