http://sean.cruels.net/directx has some video Tutorials on DirectX, they are pretty basic though (as is the case with most of the video tutorials) and may only help beginners to get started. Also, since they tutorials are made by some guy in his free time (in my opinion), do not expect the quality to be top of the notch.

and by the way, the above site (http://sean.crules.net) has some tutorials on other topics such as Java and SQL as well. I only checked SQL tutorials and they are very good especially for students who are using Oracle in their DB course labs.

Technorati Tags: ,

I had first heard the name around 3 months back, didn’t get a chance to try it until this weekend, and my my! they have really taken MVC to the extreme…

I was playing around with version 1.2.x.x on my Ubuntu Machine, here’s an overview of what I had:

  1. CakePHP 1.2.x.x
  2. PHP5
  3. MySQL5
  4. Apache2.2 (running on Ubuntu Fiesty)

Here’s what I did:

Install CakePHP:

  1. I downloaded Cake’s latest version (1.2.0.5427alpha to be specific) from CakePHP’s site and extracted into /var/www (so that my app path looked like /var/www/cake/app)
  2. Followed the Tutorial :Installing cakePHP on Ubuntu

Points:

  1. You may consider downloading the manual and api docs as well, (unfortunately there’s no manual for version 1.2.x.x as of yet, but the old one still serves as a good resource to start with)
  2. The Tutorial asks you to set DocumentRoot to /var/www/app/webroot, but if you keep the default directory structure, your webroot is actually sitting at /var/www/cake/app/webroot and this is where you should point your DocumentRoot to.
  3. Although the tutorial recommends to point your DocumentRoot to the app/webroot, I don’t recommend it for development machines which have a lot of other stuff installed in their DocumentRoot e.g. I have phpMyAdmin at /var/www/pma (http://localhost/pma), so I did not change the DocumentRoot. The only difference is that my cake url becomes http://localhost/cake instead of http://localhost which is alright with me, after all it’s a development machine.

Configure CakePHP:

By now, CakePHP should be up and running except that it might be raising some warnings (app/tmp not writable, db not present, etc). These solutions are quiet straight forward:

  1. To make tmp writable:
    sudo chmod -vR 777 /var/www/cake/app/tmp

    (I have made it globally writable, it should rather be writable only be the user the webserver runs as)

  2. Make changes to the config files inside app/config, specifically you need to provide a database.php (can be copied from database.php.default), and change the Session String constant.

CakePHP should be running warning-free now.

Read a Tutorial to get familiar:

  1. You may follow the Blog Tutorial or the User Authentication Example (both part of the manual if you downloaded it earlier) to get familiar with the framework, If you are new to MVC, you may consider reading the Basic Concepts chapter of the manual.

Setup the Console:

Then I set up the Console, which means adding the path to $PATH variable, if you can’t figure out, check this screencast.

Integrate with Eclipse:

  1. Use this: Setting up Eclipse to work with Cake

Points:

  1. Although this tutorial addresses a Windows environment, the steps are essentially the same (except the Console setup, which you have already done)

Use Bake to create a skeleton application:

  1. Using Bake is very straight forward, you just need to issue the following command from the app folder:
    cake bake

    and it takes you through a step by step procedure to create a skeleton for your Models, Controllers and Views. For a start, you may only create models and Controllers (with scaffolding ON)

Points:

  1. Make sure you don’t use a class name that conflicts one of the CakePHP’s core class names, I happend to name a model as “File” and ran into all sorts of errors. Specifically it’ll give you something like:
    Notice (8) Undefined property: File::$table[CORE/cake/libs/model/model.php, line 640]
    along with other bad things. You can check the api docs to make sure your class names don’t conflict with those of CakePHP’s.
  2. Bake is not the only shell, there are a number of others, their list is provide when you use:
    cake
  3. Do some exploration to get yourself fully understand the functionality you have at your hand.

Resources:

  1. You should join CakePHP Google Group to ask questions
  2. Cake Bakery is a good resource for tutorials and code snippets.
  3. Cake Screencasts are another good resource.

My target for next weekend is to explore simpletest for unit testing CakePHP apps. I’ll try to post my experience here. =)

NOTE:This post was posted to one of my old blogs about a year and a half ago, I am reposting it here because I think it’s useful information.

I am working on an application that needs all of the core functionality to be implemented in ANSI/ISO C/C++ for the code to be portable to multiple platforms. To implement the client front end on windows, I choose C#, so, to access the core modules, I would have to create DLLs from the source code, and call the functions from C# using Platform Invoke. I was amazed when I first came to know how easy it was.

1. Create a DLL in C/C++:
Create a new Visual C++ Project, Click File->New Project in Visual Studio, from the Visual C++ Projects, Choose “Win 32 Project” (NOT “Win32 Console Application”), Name it “MyDll” and Click OK, and in the dialog the appears next, click “Application Settings”, Select “DLL” and Check “Empty Project”.

1.1 The DLL Header
Create a Header File for your functions declarations as you normally would, Creating a DLL is nothing more than putting __declspec(dllexport) before all of your symbols that you want to be exposed from the DLL. Here, I am taking a simple example, it’s a function that adds to integers and returns the result (from my first course on C in the college ;) ). The Header file looks like this:

// MyDll.h
#ifndef _DEFINED_4B904A07_FC20_4589_825A_66604BF297F5
#define _DEFINED_4B904A07_FC20_4589_825A_66604BF297F5

#ifndef _COMPILING_4B904A07_FC20_4589_825A_66604BF297F5
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif //_COMPILING_4B904A07_FC20_4589_825A_66604BF297F5

#define CALL_CONV __stdcall

#ifdef __cplusplus
extern “C” {
#endif // __cplusplus

DLL_API int CALL_CONV sum(int x, int y); // The function being exported

#ifdef __cplusplus
}
#ifdef __cplusplus // __cplusplus

#endif //_DEFINED_4B904A07_FC20_4589_825A_66604BF297F5
 

Explanation:

The above code may seem Greek at first glance, but it’s C :). The first line #ifndef _DEFINED_4B904A07_FC20_4589_825A_66604BF297F5 and the corresponding #define and #endif are standard way to make sure that the header doesn’t get included twice. It may seem a little strange, Actually I created a GUID (Registry Format) from the GUID Creater (found in the Tools menu) and appended it’s value at the end of _DEFINED_, It makes sure that the symbol name can never conflict with any other symbol on planet. The two #ifdef __cplusplus/#endif pairs (notice the one at the before any symbol declarations and the other after them) make sure that the compiler doesn’t disturb the symbol names (C++ name mangling) so that the code is visible to standard C.

The #define CALL_CONV is only a common practice, so that if some time later I want to change the calling convention from __stdcall to something else (say __cdecl), I have to change it in only one place.

The #ifdef _COMPILING_4B904A07_FC20_4589_825A_66604BF297F5 is a bit tricky, actually you have to put __declspec(dllexport) before all the symbol names that you have to expose from your DLL, However, that’s only true when you are compiling the DLL. when you give this header file to someone who has to use the DLL (in C++ code of course, C# doesn’t use Headers, does it? :) ), he/she has to put __declspec(dllimport) before all of the symbols. Why, you may ask, well actually it would still work if you simply remove the __declspec(dllexport) from all the declarations, but putting __declspec(dllimport) would increase the efficiency of the linker (which doesn’t do any harm) because linker knows where these symbols would be located. Here’s the trick, in the .CPP file, I define the symbol _COMPILING_4B904A07_FC20_4589_825A_66604BF297F5 (as you can see in the listing below) before including the header, so when I am actually compiling the DLL, the compiler sees this symbol as defined and defines DLL_API as __declspec(dllexport) hence putting it in front of all the symbols that are to be exposed (which is precisely what I want). When the same Header file is included by an application that uses the DLL, the symbol _COMPILING_4B904A07_FC20_4589_825A_66604BF297F5 is undefined, so compiler uses __declspec(dllimport) as the definition of DLL_API, which is neat. Hence, I don’t need to use two separated Header files for the DLL.

1.2 The Source File:
The Source File is somewhat like this:

// MyDll.cpp
#define _COMPILING_4B904A07_FC20_4589_825A_66604BF297F5

#include "MyDll.h"

extern “C” DLL_API int CALL_CONV sum(int x, int y)
{
return (x + y);
}

Build the project (Ctrl + Shift + B), and It’ll create a MyDll.lib (to be included in the C++ application that uses the DLL) and MyDll.dll (the DLL itself).

Explanation:

The .cpp code is straight forward, I have define _COMPILING_4B904A07_FC20_4589_825A_66604BF297F5 before including the header file, so that DLL_API could be properly defined. Rest of the code is not a problem.

2. Using the DLL in C#

using a DLL in C# is a breeze. Create a new C# Console Project and name it “TestMyDll”, add using System.Runtime.InteropServices; to the using Statements, and declare any DLL methods with DllImport Attribute. Here’s the code:

// Program.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace TestMyDll
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“Sum of 5 + 6 is: “ + DllSum(5, 6));
}

[DllImport(“MyDll.dll”, EntryPoint=“sum”)]
public static extern int DllSum(int x, int y);
}
}

Explanation:

The code is straight forward except for the function DllSum(), the DllImport Attribute specifies the DLL in which the following symbol resides, Normally one would only use DllImport(”DllName.dll”), EntryPoint is only required if one uses a different name for the symbol (like I am using DllSum instead of sum, EntryPoint indicates where the entry point for the symbol is.).

Copy MyDll.dll to the Debug folder of the project, Build and Execute the Program (Ctrl + F5), its output will be:

Sum of 5 + 6 is: 11

NOTES:

1. If you download the attached demo project, you’ll find that the DLL file is named MyDllD.dll, Actually the debug and release versions of a DLL are incompatible and it is a common conventions to use different names (appending a ‘D’ to the Debug version DLL) to avoid confusion. Simply Set the Output File Name property of the linker (in project properties) to $(OutDir)\$(ProjectName)D.dll and it’ll create a debug DLL that has ‘D’ appended to its name.
2. The conventions in the DLL header have been directly copied from Joseph M. Newcomer’s The Ultimate (DLL) Header, http://www.codeproject.com/dll/ultimate_dll_header.asp
3. See detailed information on Platform Invoke at: http://www.codeproject.com/dll/ultimate_dll_header.asp

I have always been interested in things like game development and emulation (although, I keep trying web apps to change the taste, but my long term goal is to be a game developer =) , with my own company ofcourse).

Recently I thought to get practical taste of emulation, I searched on the internet, read some docs, and I got a feel that I sould go for a NES emulator (It’s easy, and a wealth of documentation is available).

Next decision was to make it in Java or C++, I choose C++ (though I still think Java would have been a better option).

So I have done some coding, starting with the 2A03 (NES’s CPU, modified form of 6502) emulation, will post about it when I am done.

Close
E-mail It