ENet Tutorial

August 12, 2012

Introduction

ENet is a smart and powerful library to send packets using UDP. It can send those package even reliably. It relieves you from creating sockets to do communication. Nothing in this tutorial is new, that is not explained in the standard tutorial of enet.bespin.org or linuxjournal. First I could not figure out how to combine different parts of the tutorial to create a client and a server. When I read its usage on some mailing list it became clear to me how it would work. This tutorial will try to explain a simple chat application I found there. Read the rest of this entry »

Introduction to valgrind

August 11, 2012

Introduction

Valgrind is a debugging tool. It runs target application in a virtual machine (this can cause larger programs to run slower).
Read the rest of this entry »

OpenAL tutorial using ALUT

August 4, 2012

Source: The OpenAL Utility Toolkit.pdf

I will be using OpenAL Utility Toolkit in this example. You can say OpenAL is a 3D audio library. It can be used efficiently in games and many other applications that requires sound.

Getting Started

To play a PCM data (e.g wave file), we first create some buffers, fill in sound from filesystem to these buffers, attach these buffers to different sources. If we like position, move the listeners and sources and finally play the sources. You can think sources are sound generating sources, which can be situated in different places on the 3D space, listeners as ears. Lets see a simple code (ignoring listeners and sources) to see this.

Read the rest of this entry »

Getting used to SQLite

July 28, 2012

Introduction

Once upon a time, I happened to think SQLite was worth trying. Gave it a shot, but could not figure out where to start. Created some tables and quickly dropped the idea of using it anywhere, because I didn’t know where to go from there.

Recently, I have been a keen admirer of bash scripts. I even started a project (https://github.com/neppramod/spring-mvc) that creates spring 3, hibernate, mysql project using a config file to change almost every aspect of the project. Some day I might even create a separate bash script to run ls. In that project I quickly reached a wall when I could not figure out why the DAO was not working. I have figured out the problem (bloody open sessions) and have created fresh project. I will soon have to convert them to scripts and commit the changes. I might even write an article describing how to change different aspects of the project.

Until that time, we will give some love to sqlite.

SQLite Intro

If you look at http://www.sqlite.org/about.html you will find a line that says “Think of SQLite not as a replacement for Oracle but as a replacement for fopen()”. SQLite is just that. It creates one flat file in the filesystem (which you can view using strings) and writes everything on to it. You just create a file (database file) using some scripts, create tables and are ready to go. You distribute your application with this file and use it to store and access what ever data your application needs (I am not talking about database applications). Lets create a database with a table called todo.

Read the rest of this entry »

C to Java

November 17, 2011

Well it is not an advanced topic by any means, just a place to recall some jargons of these languages (C, C++ and Java). This might be part one of two posts in a series. Some of the topics I haven’t covered are related to Generics, String, Networking, I/O (Even Google’s I/O), Concurrency etc. This post is a starter, yet complete on its own respect.

1. In C starting point is off course pointers.

What is a pointer?
A pointer is a variable that can hold the address of a variable. Here address means location in memory where the object or value of a particular variable is stored. We can get address of any variable with “&”.

E.g
int x = 5;
int *ptr = &x;

/*
int *ptr;
ptr = &x;
*/

int y = *(&x);
y = *ptr;

Lets look at above example. First we create a variable called x and gave it a value of 5. The variable can be located anywhere in the memory, the location which we don’t know. Next we create a pointer to integer called *ptr and put the address of variable x into it. Thus ptr is a pointer (a variable that can store an address). If this line makes no sense next line dissects it into two steps. First we create a pointer to integer with int *ptr and then put address of x (which we get using &x) and put it in ptr pointer. Next we create another variable y and dereference (return object or value) that is at address of x using the dereferencing operator * (don’t confuse this with our earlier pointer declaration as in int *ptr, both are different).

A pointer is thus a variable which is always the size of the underlying architecture (it does not depend upon the type of variable e.g int, char or double, because address size of first block to any of these types is same), though pointers are aware of the type they are pointing. They must know how much bytes they must occupy according to the type. E.g if integer takes 4 bytes (32-bit) and char takes 1 byte (8-bit) then if ptr is pointer to integer *(ptr + 1) will give value of next pointer location which could be four bytes ahead of current value and if ptr is pointer to  char, then it might need to go only one byte ahead to get value of next consecutive memory location.
Read the rest of this entry »

Hello world!

January 19, 2008

I lost my identity at pramodnepal.blogspot.com and pramodnepal.com.np is at zombie state i.e people who took to host it completely abandoned their project(free web site for Nepali citizen). I will maintain that site later, but now it is the place where I will be posting.