Configure Smarty in Code-Igniter

Today I successfully configured Smarty in Code Igniter. I found there is a very good reference to do this job. So, I just mention that link : http://devcha.blogspot.com/search?q=smarty

Comments { 0 }

.Net Game Programming With Direct X

When a child plays a computer game or mobile game, sometimes he dreams to make a game. If you study about the childhood of the best and famous game developer, you’ll find most of them are game addicted in their childhood.

netgame.jpg

So why not try yourself to make a game.

A game starts with a good idea. But it consists of some basic features. Though the game is a pc game or a mobile game.

  • Music
  • Drawing
  • Color
  • Animation
  • Code
  • Level Design
  • Quality Assurance
  • Project Management
  • Testing and so on…

So,

Comments { 1 }

Base Conversion – Handle upto 36 bases

Sometimes we need base conversion for different purpose. Here I have shown a technique that handles upto 36 bases. I implemented this using C++ language. But using this concept you could modify it and change it to any language.

The main concept is, to change base ‘X’ to base ‘Y’. First convert base ‘X’ to base ‘Decimal’. Then convert the ‘Decimal’ base to base ‘Y’.

/*BASE CONVERSION
Programmer: Md. Mahmud Ahsan
Description: Alpha Numeric Base Conversion
            Handle upto 36 bases
*/
#include <iostream>
#include <string>
using namespace std;

int myPow(int number, int power){
	int total=1;
	for (int i = 0; i < power; ++i)
		total *= number;
	return total;
}

void revStr(char *str){
	char s[100];
	int len = strlen(str)-1;
	for (int i = 0; str[i]; ++i)
		s[i] = str[len-i];
	s[i] = '\0';
	strcpy(str, s);
}

int otherToDec(char *str, int base){
	int len = strlen(str) - 1;
	int alpha[100];
	long long i, number, j=9; // j for alphabetical base digit
	for (i = 65; i < 65+26; ++i){
		alpha[i] = ++j; // collect numeric data suppose A=10
	}

	number = 0;
	for (i = 0; str[i]; ++i){
		if (str[i] >= 'A' && str[i] <= 'Z')
			j = alpha[str[i]];
		else 
			j = str[i] - 48;
		number += j * myPow(base, len);
		--len;
	}
	return number;
}

char* decToOther(int number, int base){
	char str[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	char final[100];
	int n, temp, j;

	j = -1;
	do{
		temp = number % base;
		final[++j] = str[temp];
		number = number / base;
	}while (number != 0);

	final[++j] = '\0';
	revStr(final);
	return final;
}

int main(){
	int number, base10, base, from, to;
	char str[100];
	while (cin >> str >> from >> to){
		base10 = otherToDec(str, from);
		strcpy(str, decToOther(base10 ,to));
		cout << "Base 10: " << base10 << " " 
                << "Base " << to << ": " << str << endl;

	}
	return 0;
}
Comments { 1 }

A J2ME application that connects and read data from HTTP protocol

This example shows you how to connect and read data from a http protocol. When you implement it and run it from your mobile device, you have to change the url from localhost to a real hosting address. (Like http://www.temp.com/somefile.txt)

/*
* Midlet.java
* Created on March 14, 2007, 1:15 PM
* @author  mahmud
* @version
*/

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;

public class Midlet extends MIDlet {
    private Display display;
    private Form form;
    public void startApp() {
        display = Display.getDisplay(this);

        form = new Form('Http Example');
        StringBuffer buffer = null;

        try{
            // you could use other http://www.something.com/file.html as a example

            String url = 'http://localhost/shaon.txt';

            StreamConnection conn = (StreamConnection) Connector.open(url);
            InputStream in = conn.openInputStream();

            buffer = new StringBuffer();
            int ch;

            while ( (ch = in.read())!= -1){
            buffer.append( (char) ch);

            }
        }
        catch(Exception o){
            o.printStackTrace();
        }

        form.append(new StringItem(null, buffer.toString()));
        display.setCurrent(form);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }
}
Comments { 5 }

Know your Mobile – A simple j2me application

This is a very simple code of j2me. By implementing it, and running it by your mobile device, you could learn some attributes of Java configuration of your mobile device.

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;

    public class AttributesMIDlet extends MIDlet{
        private Display display;
        private Command cExit;

        public void startApp(){
            display = Display.getDisplay(this);

            cExit = new Command('Quit', Command.EXIT, 0);

            Canvas canvas = new DummyCanvas();

            Runtime runtime = Runtime.getRuntime();
            Form form = new Form('Attributes');

            form.append(new StringItem('Know Your Mobile', ''));
            form.append(new StringItem('Total Memory:', String.valueOf(runtime.totalMemory()/1024)+'Kb'));
            form.append(new StringItem('Free Memory:', String.valueOf(runtime.freeMemory()/1024)+'Kb'));
            form.append(new StringItem('n', null));
            form.append(System.getProperty('microedition.configuration'));
            form.append(System.getProperty('microedition.profiles'));

            boolean isColor = display.isColor();

            form.append(new StringItem(isColor ? 'Colors:': 'Grays:', String.valueOf(display.numColors())));
            form.append(new StringItem('Width: ', String.valueOf(canvas.getWidth())));
            form.append(new StringItem('Height:', String.valueOf(canvas.getHeight())));
            form.append(new StringItem('Repeat:', String.valueOf(canvas.hasRepeatEvents())));
            form.append(new StringItem('Double Buff:', String.valueOf(canvas.isDoubleBuffered())));

            form.addCommand(cExit);
            form.setCommandListener(
                new CommandListener(){
                    public void commandAction(Command c, Displayable d){
                        if (c == cExit){
                            destroyApp(false);
                            notifyDestroyed();
                        }
                    }
                }
            );

            display.setCurrent(form);
        }
        public void pauseApp(){
        }
        public void destroyApp(boolean unconditional){
        }
    }

    class DummyCanvas extends Canvas{
        public void paint(Graphics g){
                ;
        }
    }
Comments { 0 }

Subversion – A tool for controlling version of source code.

tyrus-svn2

SVN (Subversion) is a tool used by many software developers to manage changes within their source code tree. SVN provides the means to store not only the current version of a piece of source code, but a record of all changes (and who made those changes) that have occurred to that source code. Use of SVN is particularly common on projects with multiple developers, since SVN ensures changes made by one developer are not accidentally removed when another developer posts their changes to the source tree. Information about accessing this Subversion repository may be found in “Subversion (Version Control for Source Code)“.

In order to access a Subversion repository, you must install a special piece of software called a Subversion client. Subversion clients are available for most any operating system. Information about Subversion client software may be found in our document titled “Recommended User Software Configuration“.

Comments { 0 }

JSON -A lightweight data-interchange format

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition – December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

Visit: http://www.json.org/

Comments { 0 }

AJAX -Simple to implement

Hello,
I found Prototype.js http://www.prototypejs.org/download is a nice tool for implementing ajax. You could use it in any framework. Just download the file, and load that by <script src=””>. Then implement the following code
A typical example to how to use ajax:
Ajax.Request is the main function here.
<script type=”text/javascript” language=”javascript”>
function myProcess(action)
{
url = “”;
url = url + ‘startPHP.php';
pars = ‘action=’ + action;
myAjax = new Ajax.Request(url, {method: ‘get’, parameters: pars, onLoading: showLoad, onComplete: showResponse, onError: showError} );
}
function showLoad()
{
$(‘content’).innerHTML = ” What you want to show”;
}
function showResponse(response)
{
var newData = response.responseText;
$(‘content’).innerHTML = newData;
}
function showError(ale)
{
alert(ale);
}</script>
Comments { 4 }

Google Hack – A must read to learn…

Google is now a days the most popular search engine. But from a scratch Google becomes internet giant. There are various types of business directed by Google.

DOWNLOAD GOOGLE HACK

Why Google Hacks?
“Hacks” are generally considered to be “quick-n-dirty” solutions to programming problems or interesting techniques for getting a task done. But what does this kind of hacking have to do with Google?
Considering the size of the Google index, there are many times when you might want to do a particular kind of search and you get too many results for the search to be useful. Or you may want to do a search that the current Google interface does not support.

The idea of Google Hacks is not to give you some exhaustive manual of how every command in the Google syntax works, but rather to show you some tricks for making the best use of a search and show applications of the Google API that perform searches that you can’t perform using the regular Google interface. In other words, hacks.
Dozens of programs and interfaces have sprung up from the Google API. Both games and serious
applications using Google’s database of web pages are available from everybody from the serious programmer to the devoted fan .

Comments { 2 }

Hacking Secret Revealed

Hacking Secret Revealed Download
By downloading and reading this material you’ll learn

• How “hackers” get into your system
• What tools they use
• How a hacker can effectively “Bug” your house via your computer. (Don’t believe me, read on you’ll be very surprised)
• What information they have access to. And why you should try to protect yourself. (You might be surprised to ind out what they know.)
• Tips and tricks that hackers use
• How your Antivirus software alone is not enough
• What to look for if you suspect you’re being hacked
• What the greatest flaw to all computers are
• And more…

Comments { 1 }