OSScamp Talks
by sanchitgulati on Oct.04, 2009, under Open Source, Osscamp
If you are wondering what to talk about at event, here is a guide to get you going.
If you are planning to attend osscamp then you must be part of IT world, maybe as a student or as a professional developer. So, you must also have used various softwares, library, technology either proprietary or open source. Osscamp is a place to share the same knowledge with all us. So the talk would be either about some framework you used on your php project or any c/c++ library you used to create GUI application or maybe about the some API. Or you and your friends maybe in involved in some open source project from which you require developers from your vicinity, osscamp is the place to be, a place to share, a place to talk. What else? I am out of ideas but if you are some open source enthusiast and know about any other way to use this platform then please, Osscamp would be proud to host you.
PHP : Working over Linux Distro
by mage on Oct.03, 2009, under Programming, php
Well as you know PHP runs over server rather than your OS, so its platform independent.
So while working with PHP, Linux, Windows, OSX it doesn’t matters what are you using actually..
In this tutorial you’d get how to install LAMP server, and writting PHP scripts over it.
Installing LAMP server on Linux :
> Considering apt-get installation.
Since most of you use debian flavour of Linux esp. Ubuntu, So this tutorial would be targetted on it.
> First of all LAMP is Linux Apache MySQL PHP
To install Apache :
Apache is a server that is used to host the web files(html,js,php,asp etc.).
Goto Application>Accessories>Terminal
run :
mage@h4ck-b0x:~/$sudo apt-get update
mage@h4ck-b0x:~/$sudo apt-get install apache2
Testing Apache :
Open up any web browser and then enter the following into the web address:
http://localhost/
Open it and you will see a message saying “It works!” , congrats to you!
Your Apache server location would be
/var/www
To write html, javascript, PHP etc scripts, you’d need write permissions on that folder.
to do that run :
mage@h4ck-b0x:~/$sudo chmod 777 /var/www
mage@h4ck-b0x:~/$sudo chmod 777 /var/www/*
Working with Apache :
Basic functioning of apache server is operated via /etc/init.d/apache2 file.
starting apache server :
mage@h4ck-b0x:~/$sudo /etc/init.d/apache2 start
re-starting apache server :
mage@h4ck-b0x:~/$sudo /etc/init.d/apache2 restart
stoping the apache server :
mage@h4ck-b0x:~/$sudo /etc/init.d/apache2 stop
Installing PHP :
In the terminal type :
mage@h4ck-b0x:~/$sudo apt-get install php5 libapache2-mod-php5
In order for PHP to work and be compatible with Apache we must restart it. Type the following code in Terminal to do this:
mage@h4ck-b0x:~/$sudo /etc/init.d/apache2 restart
Testing PHP :
In the terminal copy/paste the following line:
mage@h4ck-b0x:~/$sudo gedit /var/www/testphp.php
This will open up a file called phptest.php.
Now write this code in this file :
<?php phpinfo(); ?>
Now goto your browser and browse to
http://localhost/phptest.php
If the page loads up, it means php is installed successfully.
Working with PHP :
PHP is a scripting language that is used to handle scripting over web,
It is primarily used to enter values in database and use them with algorithms to display into html content.
To learn PHP : google tutorials or refer w3xchools
Installing MySQL
Again open up your terminal,
mage@h4ck-b0x:~/$sudo apt-get install mysql-server
This would install the mysql server,
during installation, it’d prompt for root password for the mysql server.
Testing MySQL server
Goto terminal :
mage@h4ck-b0x:~/$mysql -u root -p
it’d prompt for password.. type the one you set during installation.
if it shows up like
mysql>
in the terminal, that means installation is successful!!
Configuring PHP with MySQL :
To do this we will need to open a file entitled php.ini. To open it type the following:
mage@h4ck-b0x:~/$sudo gedit /etc/php5/apache2/php.ini
Find this line :
; extention=msql.so
and remove the semi-colon from it and save the file.
Installing PHPmyadmin :
PHPmyadmin is a GUI utility for mysql database management.
mage@h4ck-b0x:~/$sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin
Now add link into the /var/www folder for phpmyadmin
mage@h4ck-b0x:~/var/www/$sudo ln -s /usr/share/phpmyadmin /var/www/phpmyadmin
Testing PHPmyadmin
Open your browser and traverse to
http://localhost/phpmyadmin
it’d show the GUI for MySQL, enter your mysql username as root and password that you set via installation,
There you have it
PS – All functioning must be Done via root using sudo command.
PHP:server-side scripting language
by sanchitgulati on Oct.02, 2009, under Open Source, php
PHP, stands for PHP: Hypertext Preprocessor, is a widely used, general-purpose scripting language that was originally designed for web development, to produce dynamic web pages. It can be embedded into HTML and generally runs on a web server, which needs to be configured to process PHP code and create web
page content from it.You can read more from wiki.
To learn php,you would require to install Apache, MySQL, PHP on your local machine.
If using Windows : Install AppServ or Wamp . ( Appsevr for no0bs)- ( Latest Stable release for AppServ 2.5.10)
If using Linux : Install lamp ( Linux Apache Mysql Php )
Further Tutorial are guided according to Appsevr installation.
Step 1.
Tutorial on this link is self explaining.
Step 2.
Checking the installation:
Open firefox or any other broswer and typie localhost in address bar ( this is the space where you type facebook.com )
If you see the html page with “The AppServ Open Project – 2.5.10 for Windows”,then congrats.
Open “http://localhost/phpinfo.php” to know more about php-server installed.
Step 3.
Appsevr store all public html files “C:\AppServ\www\” – Default Location
Step 4.
Create a new file in the above folder with extension php , example hello.php ( Not hello.php.txt)
Edit the file using Notepad and type in the following code
<html>
<body>
<?php
echo “Hello World”;
?>
</body>
</html>
Step 5.
In your broswer open “localhost/hello.php”
You should be seeing a html page with “Hello World”.
Basic PHP Syntax
A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the html document,as you can see in example above.
OUTPUT
`echo` is used for printing strings or variable,similar to printf() or cout in c/c++ .
Also,
echo (”Hello World”);
printf(”Hello World”);
INPUT
As php is server-side scripting language it doesn’t not take inputs like c/c++ but accepts arguments in the form of GET or POST .Which is out of the scope of this tutorial. #WaitForOurWorkshop
VARIABLE
All variables in PHP start with a $ sign symbol and carries no datatype,So we don’t need separate variable for int,float or char.
<?php
$strg = “Hello World”;
echo (”$strg”);
$x=16;
echo $x;
?>
FURTHER LESSONS
Operators,If…Else,Switch,Arrays,While Loops,For Loops,Functions are similar to c/c++ you can learn about them on http://www.w3schools.com/PHP/
IDE (Integrated development Enviroment)
There are many open source as well as proprietary software available for easy development of php scripts.Notepad++ or PHPeclipse (Plug-in to Eclipse) works great on windows or you can spend thousands for Adobe Dreamweaver, which is the best option available to industry as of now.For linux machine try gPHPEdit or Codeblocks
LINUX INSTALLATION
Blog on how to install and configure LAMP on linux machine will follow shortly.Atleast I hope so.
DOUBTS AND QUERY
You can ask any doubt on php or any other open source technology on http://cuclante.com/forum/
How to go about with a new Linux Distro : Ubuntu
by mage on Sep.25, 2009, under Open Source
Well as many of the people are confused of linux, this tutorial might just help you :
INTERNET
> To configure internet on your ubuntu OS, first goto your network manager and select your connection/interface.
> It would be set to automatic DHCP, to set a static IP. Right click on the network manager and edit prefrenced, now here specify your ip,gateway,netmask and DNS settings.
> Ubuntu unlike windows has an advantageous feature of Proxy settings. You can apply proxy for every application by specifying it once at System>Administration>Network Proxy
MULTIMEDIA
> Another problem that ppl face is in understanding why linux cannot play mpeg formats by default.
> To start playing your mp3,flv,wav etc files, you can either install vlc player or you can install the gstreamer plugins for default players(Totem, Audacious).
> To install VLC : goto Application>Accessories>Terminal and run this command.
$sudo apt-get install vlc
> To set up gstreamer plugins, just run the type of multimedia file and it’d install the related plugin automatically.
INSTALLING SOFTWARES
Considering ubuntu, it follows the debian color.
You have 3 ways to install any application on ubuntu :
1. Using Ubuntu repository (apt-get).
> Ubuntu has a repository and a method to fetch it on your machine, so that installation occurs without any pain.
> You can find maximum no. of softwares in the repository for installation. To check all of them goto Application>Add/Remove application and select the drop down box to All Available Applications.
> These are a list of applications that you can install without hastle.
Using binaries.
When surfing for a software and you come accross binary version, select the .deb version or the ubuntu recomended version for installation.
Binaries are another easy way of installing a software, now after downloading just double click your .deb file and it’d install it automatically
Compiling program from Source.
When Compiling from source you’d probably have a .tar.gz or other format compressed file.
extract that file to a location.. and in your terminal traverse to that path.
Now for installation from source you require 3 steps :
- configuration
- make install file
- execute install file
Configuration
This process checks whether the system has everything required to install the application, the compilers and libraries to be precise.
You can configure the application by running this file.
mage@h4ck-b0x:~/software_directory$ ./configure
If this runs without error, then proceed to next step otherwise keep installing the compilers and libraries on which it is dependent upon, uptill configure file runs successfully.
MAKE
In this process we tend to make (compile) all the files to create an installation file for the application.
the command for this would be simple :
mage@h4ck-b0x:~/software_directory$ make
INSTALL
In this process we finally compile and execute the installation file,
mage@h4ck-b0x:~/software_directory$ make install
If all the process work in order… your s/w would be ready to go.
How to install your new Linux Distro : Ubuntu
by mage on Sep.25, 2009, under Open Source
Installation :
You can easily install ubuntu on your laptop/desktop via 2 methods.
1. Installing it inside windows’ partition.
- This one is really easy.
- When working on windows, put the Ubuntu Live CD inside the CD-ROM.
- In the AutoPlay menu launch the Install inside Windows feature.
- Select the desired options and here you have you ubuntu running fine.
PS- Installing it in supposing D drive would lead all the contents of D drive inaccessible from Ubuntu.
2. Installing on a separate partition.
- Put in your Ubuntu Live CD and reboot your computer.
- Now boot from your CD-ROM and enter into the Ubuntu Live CD.
- Now select the Install feature. A installer much like windows one would pop up.
- Follow the options that occur blindly except for the partition manager.
- Make sure you select it to manually specify the partitions or else your whole HDD would get formated.
- In the partition manager, you would get the partitions on HDD, you can recognize them with there size. For eg. 106 GB partition is supposed to be my E drive… similarily.
- Select the one you want to format and install ubuntu on then click on edit partition.
- Format the partition to ext3/ext4 format, and mark, use this space as ‘/’
- Now click on Next, it would ask you to create a swap partition, if you have enough memory on your RAM click on continue, other wise create another partition atleast 256mb and use it as swap.
- Finally enter remaining details and you are good to go.
Hope this article helps you install Linux on your machine.
Installing and Using Allegro library
by mage on Sep.01, 2009, under Programming
Hey in this post i would be giving the tutorial to install allegro
library for the open source project.
For people who want to use windows operating system for development :
Compiler suggested – gcc/g++ (GNU c/c++ compiler)
Text editor to be used – Dev C++
Installation :
1. Google “dev c++ download” and follow the links to source-forge to
download the dev-c++ compiler/text-editor.
2. After you have installed Dev-C++, goto tools and click on update
manager.
3. An update manager would show up, click on planetmirror and select
it to devpacks.org.
4. Now click on update, it would download updates.
5. Now click on groups and select Allegro.
6. A list of libraries would show up, select allegro 4.2.2 it is the
latest version.
7. Click on download package and it would install Allegro on Dev C++.
Running your first Allegro Program :
1. Open Dev C++, click on File>New>Project, Select second tab and
select allegro program.
2. A code would pop up, now click on execute and click on compile.
3. If no error shows up, congrats you just compiled your first program
on Allegro.
4. Click on execute and run, and you should see a black screen,
congrats for the first program.
For people who want to use Linux Operating system for development :
Compiler suggested – gcc/g++(GNU c/c++ compiler)
Text editor to be used – You can use any text editor here, recommended
(editra, emacs, vi)
Installation :
1. To install allegro you can either do it from source via tar ball :
http://prdownloads.sourceforge.net/alleg/allegro-4.2.2.tar.gz?download
2. Debian users can run :
|$sudo apt-get install build-essential
|$sudo apt-get install liballegro4.2-dev
This would install allegro library on your system.
Running your first Allegro Program :
1. Open your text editor and type any sample allegro code and save as
‘.c’.
2. Then open terminal and traverse to the path of the program.
|$gcc test.c -o test.out `allegro-config –libs`
now your program would compile.. or give errors accordingly.
3. to execute your program run test.out file.
|$./test.out
Congrats you just wrote your first Allegro program.
Learning Allegro :
Here are the links to the two tutorials that you must go through so as
to get some basic knowledge about allegro library.
http://www.loomsoft.net/resources/alltut/alltut_index.htm
http://www.cppgameprogramming.com/cgi/nav.cgi?page=intro
ANY PROBLEMS REGARDING INSTALLATION AND COMPILATION CAN BE DISCUSSED IN THE FORUM
The real C++ : c99 standards
by mage on Aug.31, 2009, under Programming
Well many of us have already done c++ programming and many would be doing it.
C/C++ doesn’t really matters, what matters is the compiler. People teach and learn basically on TurboC compiler.
Whats wrong with TurboC:
Well TurboC compiler is one of the earliest c/c++ compilers and still hasn’t grown much. It still works on 16-bit compiler(we have 64bit PCs these days). It follows old c/c++ standards c89 or c90, now these are old.. we have c99 as current standards for writing c++ codes.
Which Compiler to Use:
Well there are a lot of 32/64 bit compilers available to use, best ones being visual c/c++ and gcc/g++. Since we follow open source i’d recomend gcc/g++ to compile your programs. For people who don’t like command line interface of gcc/g++ can use DevC++ software to compile it.
These are available as 32/64 bit compilers (according to the type of pc you are using and operarting system) and follow latest c99 standards.
How does this difference effect me:
Well running a 16bit compiler on a 32/64 bit machine tells to the fact that it isn’t as capable of processing like the rest. Also noting that the previous standards weren’t perfect and had loop holes into it, so a need of better standards always comes up for improvement and c99 is just a good improvement.
Later on you’ll find no c/c++ code is developed on TurboC.
Is The Code for c99 different:
Well somewhat yes and no, I mean c/c++ won’t change, except some ways to refer things do change.
Now i’ll explain the difference in codes :
1. The is no iostream.h header file to include instead you include iostream file.
#include<iostream>
2. You cannot refer cout and cin statements as it is, you need to point it to std for standard I/O.
cout<<"Hello"; becomes std::cout<<"hello";
3. If you don’t want to write std everytime you can use the namespace concept to point it to standard by default.
eg code :
#include<iostream>
using namespace std;
int main()
{
cout<<"hello";
return 0;
}
4. There is no conio.h -> conio.h is a dos based header file and cannot be used except TurboC.
you can use alternatives to the major functions you used there.
getch() -> getchar()
clrscr() -> system(”cls”); //windows
clrscr() -> system(”clear”); //linux
5. The is no void main… your main function should always return a value, so we go with int main.
Keeping in mind only these few things you’d be programming better than the rest and one step above them.
What is Open Source : Introduction
by mage on Aug.31, 2009, under Open Source
Well many people don’t know about it… they know that cuclante is about it but don’t really know it.
This blog post will clear your doubts
What is Open Source :
Well open source is a form of technology, its main aim is to provide source code of the softwares that we use daily, so that it can be used by contributors to develop it more and according to users need and security. As the name says the source code is open.
Why should i use Open Source :
If you are an end-user, nothing can be better for you. All your daily needs application are available for free, plus because of open contribution a lot of programmers are working on it, leading to a good end product.
I mean firefox is open source its free and its better than internet explorer. VLC is open source and is a favouriate of all isn’t it
If you are a developer, you get to show your ability in application writting. taking an example, if im good at writting security for applications then i can contribute same code to many softwares. It gives me the freedom to write codes, what i want and for whom i want. Im not bound to a superior guy forcing me to develop an applet of which i have no information about.
Open Source and World :
Well Open Source has spread a lot lately, Google has shown surprisingly huge response in Open Source. All its latest applications are open source (chrome browser, android OS, Chrome OS). Apple uses most of the Open Source apps in its OSX… being frank it is the best company to optimise open source to the fullest.
Open Source Addiction :
Well once a person starts using open source technology, he becomes a fan of it… and this technology fantasises him so much that he keeps on going into it
Open Source and India :
A good example of an open source s/w from india is Maya-Vi (developed by IIT).
Various organisations support Open Source technologies in india, primarily being OSScamp, Barcamp, OSScube you can google them and be a part of it.