Skip to content
out 12 11

Getting OpenFrameworks running in Mac OS Lion with Xcode 4.1

by Vinícius Krolow

Today I was starting learning openFrameworks (a c++ plus library to make interactive projects), and so I started downloaded the last version of oF, that is here for download.

After download I have extract the compacted file and put this into my workspace.

So after that I have choose one of the examples programs that comes up with the oF library, to start test. I have decided to use the advanced3dExample, inside this folder we have the Xcode file, so we just click on it the Xcode should open with the project.

After  pick up the program, and open the Xcode, I just tried build an run the code, but I have received a fail message.

Looking for in the web I have found that oF, have some problems with the MacOS 10.7 SDK, so to run properly the example, looks that the 10.7 changed some structure and code, and oF it’s not enable yet to use this new code, and structure. So what I have to do next, is change the Base SDK, of my project to use the old version MacOS 10.6 SDK, that’s works well with oF.

First off change the OpenFramework, Base SDK:

And after, change also your application Base SDK:

After be sure that both are using the 10.6 MacOS SDK, it’s time to compile again, but first check if you choose the correct program to be compile, as the fact that we have to projects (the example project, and the openFrameworks project), it’s possible that is selected to compile the openFramework not our application advanced3dExample.

So check if the project to be compiled is our example program, the image below shows where this information appears in the Xcode (it’s show beside the RUN icon):

In case that the program that shows there is not our example that we want you have to click to change:

Everything looks well now, so it’s time to build and run our example, and after the compilation it’s done we receive our application running:

Now I`m able to keep learning C++ and OpenFrameworks, and you also :)

set 2 11

Vaga para Programador Backend Conrad Caine

by Vinícius Krolow

A CONRAD CAINE, agência digital com escritórios em Munich, Pelotas e Buenos Aires procura programador backend para integrar a equipe de Pelotas-RS.

Responsabilidades

- Desenvoler sistemas e sites para web;
- Manutenção em sistemas e sites existentes;
- Desenvolver utilizando as melhores técnicas de programação;
- Estruturar códigos e banco de dados;
- Escrever código limpo e bem organizado;
- Capacidade de lidar com desafios e novas tecnologias diaramente.

Qualificações
- Dominío de uma ou mais linguages de programação;
- Dominío de programação orientada a objetos;
- Facilidade na adptação com novas tecnologias;
- Responsável com o projeto/produto a ser desenvolvida;
- Dominío de banco de dados;
- Pró-ativo e autodidata;
- Rápido na solução de bugs;
- Habilidade para entregar estimativas corretas;
- Inglês intermediário/avançado;
- Experiência com desenvolvimento WEB;
- Experiência com CakePHP;
- Experiência com .NET.

Currículos devem ser enviados para vkrolow@conrad-caine.com, com o título “Programador Backend”

ago 11 11

CakePHP: Check and Deal with POST Requests for AJAX and REST Applications

by Vinícius Krolow

Several times I have to check if a request it’s really a HTTP POST and if the data of post was passed in this request too, so these controllers where I need this check always have to check the data, and type of request…

To avoid repeat the code I wrote this method:

1
2
3
4
5
6
7
8
9
	protected function _isPOST($data = false) {
		if ((isset($this->RequestHandler) && !$this->RequestHandler->isPost()) || ($_SERVER['REQUEST_METHOD'] != 'POST')) {
			$this->redirect(null, 405);
			exit;
		} else if ($data === true && empty($this->data)) {
			$this->redirect(null, 400);
			exit;
		}
	}

You can put this method in your AppController

It’s really simple, but useful for me. The code just check if it’s a POST Request if it’s not, bring a HTTP CODE 405, check if the POST data it’s not empty if it is bring a HTTP CODE 400.

And that’s it, now you don’t need wrote codes like this anymore:

1
2
3
4
5
6
7
8
9
10
11
	public function my_action() {
		if ($this->RequestHandler->isPost()) {
			if (!empty($this->data)) {
 
			} else {
 
			}
		} else {
 
		}
	}

You have just to put this:

1
2
3
	public function my_action() {
		$this->_isPOST(true);
	}

The first argument it’s a boolean one, you pass true if you want to check if the $this->data it’s not empty, otherwise you pass false, or pass nothing.

jul 14 11

MySQL Order the results by a predefined sequence

by Vinícius Krolow

Sometimes you wanna that the results come following a predefined sequence, for example following one sequence of ID’s (10, 20, 4, 123, 3)…

So how order this? You can not use order as DESC, or ASC… perhaps you can create some procedure or function to do it for you but there is a simple way to do this without create a function or procedure, using the native function FIELD().

So for our example the query will looks like:

1
SELECT * FROM our_table WHERE id IN (10, 20, 4, 123, 3) ORDER BY FIELD(id, 10, 20, 4, 123, 3)

It’s also possible using with strings for example:

1
SELECT * FROM our_table ORDER BY FIELD(type, 'car', 'bus', 'motorcycle')

That’s it, the function FIELD can be useful in otherways as well, you can check it in the documentation.

jun 26 11

CakePHP turn your routes internationalized

by Vinícius Krolow

CakePHP support internalization, but some times I’m developing some websites that will support just one language, but usually I wrote my code in English, also the tables in the database and the text in the site, and so generate the po file for the native language of the site. But so we must write the routes too in the native language for keep the URL friendly.

You can create aliases for your routes, or you can put your router also as a translatable text, like the code above:

1
2
3
	Router::connect(__('articles', true), array('controller' => 'articles'));
	Router::connect(__('histories', true), array('controller' => 'histories'));
	Router::connect(__('calendars', true), array('controller' => 'calendars'));

So it’s something really simple that we can use to allow the URL use the native language of the site and we also have the powerful to translate as we want in the po file in the end.

We also can combine this with the language, in the case of your site is multilanguage we can use the prefix of the language and after that we apply the translate also, so the URL will be always friendly for each language of the system.