RSS
 

Archive for the ‘DEVelopment EXPerience’ Category

upgrade to the new version of PhpMyAdmin 3.3.4

12 Jul

Since 28th of June, the new version of phpMyAdmin 3.3.4 came out and here is how you can upgrade your previously installed version to the newer one.
My setup is on Windows with Wamp so if you have another local host running, you’ll have to adapt to your way of working, but I’ll bet that the difference isn’t that big.

My start screen looked something like this, on which we can see the older version and obviously it’s time to upgrade.

Go to the download page and download the latest version you prefer. As my whole environment is set in English I just select the phpMyAdmin-3.3.4-english.7z version.

Second step is to extract the downloaded files to your local location and set the rights as you prefer. This can be done in different ways but I prefer the manual way, this is done by copying the config.sample.inc.php, renaming it to config.inc.php and change the preferences in the file as you prefer.

In my case the only two lines that had to be changed where:

$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = 'blabla';

If you need more information, it can be found in the documentation included in the package (documentation.txt).

If we go to the location on our local host now (in my case http://localhost/phpMyAdmin/) we get an error saying that we don’t have permissions to view this page.

In order to get this working we need to set the phpmyadmin.conf file and adapt it, the alias and directory need to be adapted to the freshly installed version.

Alias /phpmyadmin "C:\wamp\apps\phpMyAdmin-3.3.4-english"

# to give access to phpmyadmin from outside
# replace the lines
#
#        Order Deny,Allow
#	Deny from all
#	Allow from 127.0.0.1
#
# by
#
#        Order Allow,Deny
#   Allow from all
#

<Directory "C:\wamp\apps\phpMyAdmin-3.3.4-english/">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
        Order Deny,Allow
	Deny from all
	Allow from 127.0.0.1
</Directory>

After restarting your local wamp, you’ll get the correct and new version of phpMyAdmin in your browser.

Have fun.

 

Mysql-bin files ate up all disc space

02 Jun

Since a few weeks I got the problem that my C drive was getting completely filled and I didn’t found where it came from. Well seems like the MySQL-bin log files where eating up all of the space on the C as my Wamp folder is located there.

I have a Wamp running with Apache 2.2.14, PHP 5.2.11 and MySQL 5.1.41 and log files are stored locally in the bin folder.

Over the past few months those bin logs grew to huge files and where taking over 7 GB in space.

It could be good to know what those MySQL-bin log files are:

The binary log contains “events” that describe database changes such as table creation operations or changes to table data. It also contains events for statements that potentially could have made changes (for example, a DELETE which matched no rows). The binary log also contains information about how long each statement took that updated data.

So if I understand this correctly, these files are completely useless in my personal case. Time to remove them, but can you do that without destroying my whole setup?
Well the answer is quite easy: Yes!

How then: well go to your MySQL prompt and run this commando to get an overview of all current bin files.

MySQL > show binary logs;

An overview of binary logs is given.

show binary logs

Then simply remove all files that are changed before a certain date:

MySQL > PURGE MASTER LOGS BEFORE '2010-06-01 00:00:00';

And all magic is been done, logs are removed and you can start all over again filling up all space on your C drive.

To turn off log-bin, edit /etc/mysql/my.cnf and comment out log-bin:
#log-bin = <your-value>

Have fun.

 

Manage your directory structure for development

01 Jun

It isn’t easy to get your client data organized correctly and above all convenient. When you start out on a project you don’t need a complex structure, but as your project grows, you’ll see that your initial small structure grows very fast. Five years ago it might have been sufficient to just work with the mails clients send to you but today, that isn’t enough for several reasons:

  • colleagues need access to data that is included in the mail
  • you need backup files of your development files
  • planning has to be made and followed
  • you and others need to find information quickly in the future

These and many other reasons can have an influence on your method of working, but I’ll try to explain a few possibilities on how to organize your data properly and correctly. At least, this is how my way of doing things, from experiences I got along the past 5 years.

Most correspondence is done via mail to a specific contact person and he is in my opinion, one of the most important people in the whole cycle. He needs to develop a habit of managing the files directly as soon as he got them and if they might be important for analyze or development of the project. These actions should be done if we are dealing with: source files for development (images, xml …), documents (Word, Excel…) or feedback.

As files should be available for everyone who will work on the project, a shared folder is a good option. Different solutions are possible: Microsoft Groove, SharePoint, a folder on a server with a versioning system placed on it and many other ways. Personally I prefer a shared folder on a local server (if all users have access on this server) with Git or SVN to do the versioning. In this way data will never be lost and everyone has access to the repository.

For more information on Git, I recommend everyone to look at the video, it’s the one I saw Scott Chacon do on the Symfony Live conference in Paris and I must say that it was one of the most clarifying talks I have ever seen on the complex topic of versioning.

The folder you place your files in has to be logically split up in the way you prefer it. I had 2 different ways of organizing my data as I was, art of the time, developing small projects for different customers and developing for one big software.
In the case of the customers I chose to separate everything per client

client seperated structure

As you see everything is split up into customers and sub folders are created as needed, I generally start out with 3 folder: analyse, delivered and work area, each with there own topic related sub folders.

Note that I always use the camel-Case way of writing, this increases readability without using underscores or other special characters. A lot of sources recommend the use of dates in the naming convention, but personally I believe this is not a good way of working. In a versioning system (like Git) the update datetime of files often changes and it would be an extra workload to change the date in the name each time. From my experience, these kinds of updates are often forgotten and date of files and folders is most of the time viewable in explorer windows or Linux (ls –l commando).

In case of the one big software we were developing, we agreed to create 1 folder containing different sub folders for each small sub-project organized by: analyse, customer and documents.

software system

As you can see the structure you use is strongly dependent on the project you are working on, and is a part of development that has to be custom made, but if you start out with one of these basics, I guess you are taking the correct path.

A few things you might ask yourself before creating this kind of structure and will influence your choice are:

  • What entities and kinds of entities need to be stored?
  • Who needs access to the data?
  • Why do they need access it?
  • Are there any existing standards your organization is following?
    The bigger your company is, the harder it might be to change the current way of working.

Hope this works for you… it does for me…

 

Unit testing in Symfony

26 May

I hope I don’t have to convince you of the importance of unit testing… and if I do, just read this post from Adil Akhter on the importance of unit testing.

In Symfony, A lime test library has been included and makes it easy for us to do these kinds of tests.
You can do this by requiring the unit.php file that is included in the Symfony package.

And create an instance of the lime_test class

require_once dirname(__FILE__).'/../bootstrap/unit.php';

$t = new lime_test(3, new lime_output_color());

In this case with initialize $t as an instance of lime_test and in the constructor we set 3 as variable, being the number of tests we want to run.

If we run this test in a command prompt, it will execute our test and display the results line by line.
To make it more readable you could set extra text like this:

$t->diag(‘this is the start of the test’);

From the moment the class was initialized, you can create any test you want by simply using the predefined functions in the lime_test class.

Diag generates text
is compares two values
like compares two strings
and so on…

In our little test we simply use ‘is’ as we only want to check if the values that have been calculated are correct if we run it trough a function.

What we want to do is do a unit test of 2 functions, one called sum and one called multiply. The best way to test them is to split them up into 2 unit tests, but in my example, I’ll test them both at once.

The data we can use for this test is set up in an YML file called fixtures.yml and is placed in the same folder as the file that contains the unit test.
I like using this YML file for this kind of tests for several reasons:

  • You can set a huge amount of test data (almost equal to xml)
  • The test data is separated from the code, and code is therefore more readable

We save our file in the same folder as the yml file and call it: SumTest.php, the yml file, containing all the test data is called fixtures.yml.
Here is all code that I wrote in the SumTest.php file, and under the code, you can find the complete explanation.

require_once(dirname(__FILE__).'/../../bootstrap/unit.php');

/**
 * Sum of set of values
 * @param array $inputData
 * @return integer $sum
 */
function sum($inputData){
  $sum = 0;
  $sum = $inputData['a'] + $inputData['b'] + $inputData['c'];
  return $sum;
}

/**
 * Multiply set of values
 * @param array $inputData
 * @return integer $multiply
 */
function multiply($inputData){
  $multiply = 0;
  $multiply = $inputData['a'] * $inputData['b'] * $inputData['c'];
  return $multiply;
}

// Initialize the test engine.
$t = new lime_test(6, new lime_output_color());

$t->diag('Our small function test');

// retrieve test data
$dataProvider = sfYaml::load(dirname(__FILE__) . "/fixtures.yml");

//loop tests
foreach($dataProvider as $testId => $testData) {

  //for each test run the test data trough the functions, retrieving a result
  $sum = sum($testData['input']);
  $multiply = multiply($testData['input']);

  //get the expected data from the yml file
  $expectedData = $testData['expected'];

  //do the actual unit test for the sum and multiply
  $t->is($sum, $expectedData['sum'], " Result of the sum is: " . $sum);
  $t->is($multiply, $expectedData['multiply'], " Result of the multiplication is: " . $multiply);
}

On top of the file I wrote 2 functions that I wanted to test, sum and multiply, a better way would be to include them from the file where they were originally placed and used. If you copy your method in your test, and later change the original method, your test will be totally useless, so be sure to include that in stead of copying it.

The both simply loop the data and add or multiply it and finally return the result.

After initializing our lime_test and displaying a line on the output, we get all test data from the YML file.

We can execute all tests by looping them and using the test data by sending it trough our 2 functions we wrote on top of the page.
Get the expected results out of that same YML file and run them both trough the unit tests.

In our case we simply compare the result of the function with the expected result giving a third parameter as output result on success, or giving an error on failure.

In our YML file data is set as followed.

Test1:
  input: { a: 17, b: 26, c: 35}
  expected: { sum: 78, multiply: 15470 }

Test2:
  input: { a: 2, b: 13, c: 18}
  expected: { sum: 33, multiply: 468 }

Test3:
  input: { a: 3, b: 0, c: 1500}
  expected: { sum: 1503, multiply: 0 }

If we run our test in dos prompt, we see that all results went just fine, even when trying to multiply by 0 as this was an expected output.
You can run your test by calling Symfony test:unit and then the name of your test without Test.php on the end(Remember our file was called SumTest.php).

Hope this was a bit clear for y’all.
greetings.
K.

 

Developers to follow…

05 May

If you are a developer, the best way to get the latest news or interesting links and references, is to follow some of the best developers around. I myself have a list of people I like to follow, some of them are quite known, others are not that famous but have some interesting things to say.
Here is a list of guys to follow, by blog or twitter.

Matthew Weier O’Phinney
I met him at Symfony Live 2010 and was one of the most remarkable and helpful people around. Although I’m not into Zend framework, he explained the Symfony-Zend link in 50 minutes.

I am an open source web developer and IT specialist. My expertise lies with LAMP setups — Linux – Apache – MySQL – Perl/PHP(/Python). I am capable of administering a variety of Linux distributions, including Gentoo, Debian, Red Hat, Fedora, Slackware, as well as several other Debian- and RPM-based distros. In addition, I am skilled at installing and maintaining Apache, PHP, Perl, and MySQL on each of the distros previously mentioned, typically from source.

My primary skills are as a PHP developer. I am a Zend Certified Engineer, and a member of the Zend Education Advisory Board, the group responsible for authoring the Zend Certification Exam. I contribute to a number of PHP projects, blog on PHP-related topics, and present talks and tutorials related to PHP development and the projects to which I contribute.

Read the rest of this entry »

 

The Programmer Competency Matrix

01 Apr

It’s sometimes hard to know if you are up to date with all technologies that are out there. It might be even harder to know at what points your knowledge is just not enough.

To help you on that point there is a matrix containing almost all general fields in IT that should be covered. You can see the whole matrix here.

Here is a little example on computer science.

Computer Science
2n (Level 0) n2 (Level 1) n (Level 2) log(n) (Level 3)
data structures Doesn’t know the difference between Array and LinkedList Able to explain and use Arrays, LinkedLists, Dictionaries etc in practical programming tasks Knows space and time tradeoffs of the basic data structures, Arrays vs LinkedLists, Able to explain how hashtables can be implemented and can handle collisions, Priority queues and ways to implement them etc. Knowledge of advanced data structures like B-trees, binomial and fibonacci heaps, AVL/Red Black trees, Splay Trees, Skip Lists, tries etc.
algorithms Unable to find the average of numbers in an array (It’s hard to believe but I’ve interviewed such candidates) Basic sorting, searching and data structure traversal and retrieval algorithms Tree, Graph, simple greedy and divide and conquer algorithms, is able to understand the relevance of the levels of this matrix. Able to recognize and code dynamic programming solutions, good knowledge of graph algorithms, good knowledge of numerical computation algorithms, able to identify NP problems etc.
systems programming Doesn’t know what a compiler, linker or interpreter is Basic understanding of compilers, linker and interpreters. Understands what assembly code is and how things work at the hardware level. Some knowledge of virtual memory and paging. Understands kernel mode vs. user mode, multi-threading, synchronization primitives and how they’re implemented, able to read assembly code. Understands how networks work, understanding of network protocols and socket level programming. Understands the entire programming stack, hardware (CPU + Memory + Cache + Interrupts + microcode), binary code, assembly, static and dynamic linking, compilation, interpretation, JIT compilation, garbage collection, heap, stack, memory addressing…
 

Meet the next gen Development Environment

11 Mar

This is promising!!!! Everyone working with Eclipse or other development environments will see the advantages quickly!

More information can be found here

 

Symfony live 2010 – the Symfony 2 launch

25 Feb

I praise myself lucky to be one of the few people who had the opportunity to go to Symfony Live 2010 in Paris, and off course to be present on the launch of Symfony 2.

Here is that presentation by the lead developer Fabien Potencier. Quality isn’t that gr8, but what the hell, the most important things can be found on the Symfony 2 website.

 

Lecture on software project management

17 Nov

Very interesting lecture of Professor Kelkar from Bombai university. It isn’t given very actively, in fact, this is a good example of how not to do lectures, or presentations. But, the man tells us very interesting things and is a good introduction.
As I am reading ‘A Guide to the Project Management Body of Knowledge, Third Edition’ this might be a quicker way of getting the needed introduction. Off course if you want to get some examples, I would recommend, not only to watch these lectures, but try to read books on any issue. They contain tons of examples, and have real world business issues explained, often experienced by the writer.

 

Connectivity study

18 Sep

Anyhow, in the meantime I read a most interesting study about the connectivity for almost every country in the world.

The study is done by Professor Leonard Waverman, London Business School, and economic consulting firm LECG so this is a reliable source.

Belgium’s low 3G penetration amongst consumers is accompanied by a below average rate of broadband penetration.  Broadband speeds and infrastructure also lag behind many of their European counterparts, as does internet usage in general.  This is in contrast to high levels of consumer spending on software.

What universities and companies in Belgium say for years, has now again been confirmed by this study.
Let’s hope that for all the effort and investments companies and consumers do each day, government and network distributors now start acting more professional and leave super profits out of their strategy.
If we want to keep up with the big players in Europe, this has to be done in the near future.

The country is at best a middling performer in terms of production of science and engineering degrees, at both the first degree and doctoral levels. However, the share of ICT investment in total investment appears to be higher in Belgium than in most of the rest of Europe, excluding the UK and the Nordic region.

I guess the Belgian government has no choice and has to act right now as we are a nation with knowledge as only export product.
We are an average country, but we need to be outstanding in this field as we are with Robert Cailliau one of the pioneers of the internet.

Let’s hope that important investments are done, and our tax money doesn’t end up in the wrong hands, whoever they might belong to…

If you want to see how your country is scoring you can take a look at the study here