How to get into programming part 1

I have been asked a lot of times, especially from fellow Ethiopians, on how to get into programming as a career or stream of life style..
But this note is not only for those who are asking that, it is for:
– those peoples with a lot of potential into programming and not just do it only because they don’t have enough information where to begin
– Friends, and relatives whom I see are in some other work stream but I think they are a good candidates for programming and make a decent living out of it..

First thing first, lets start from addressing common questions:
How could I get into computer profession?
It is a broad question and I will try to dissect into the following parts

1. Computer Technician
Are you interested in getting dirty hands with fixing computers, mobile devices, network configurations, fixing broken hardwares and the like? if so you can be on this area and be professional
What you need – usually you are required to have certificate in electronics and/or maintenance stuff along with a bit of experience.
MarketIn demand
2. Network Administarator
Large enterprises with so many, not limited to, computers and users that needs management require Network administrators.
Largely, this is a task where you would configure servers that run different kind of services like web or file, management of user access and resource access, management of computer’s resources that task out the above and related services, making sure server softwares are upto-date are among the tasks you will be working on
What you need You need certification for this one. The common one is cisco certification. There are tones and tones of books and training material that would help you get up and ready for the exam.. you can take a look at http://www.cisco.com/web/learning/certifications/index.html
MarketIn demand
3. Database Administrator (DBA)
Every interaction with have Facebook, the emails records we have on gmail, or any other interaction that needs to remember our data needs a database. A database is a huge part of computer related profession. The data that is stored could be in millions, each data would interact with another data, it will be backedup incase something wrong happens, it needs to be consistent and available, it should be upto-date, it shall handle insertion editing and deletion of data nicely .. you got the idea – for this there are well trained peoples who would make sure the data that we care for is properly handled. You can be one of those peoples
What you needThere are several brands of database management systems. The notables are oracle, MSSQL Server, MySQL and Postgres. You need a certification in at least one of these big database providers. Once you got the idea of one jumping to the other should be easy. And the good thing is when you are preparing for the certification you would know most of the basic stuff you would need for future profession
MarketIn demand

4. Designer (Front end developer) These days all you would see is a websites and mobile application. And apart from doing what they do, they have to be attractive and simple, easy to use, faster, forgiving on error and much more. This is usually the task of the designer.
Designer are usually artful peoples. If you are that kind of person, then design might be yours. Probably, you have come across the site or app that you tot you could have done the layout better or something..
What you needMost of the designers that I know are self-taught ones. Pretty much all you need an introductory lesson into HTML, CSS and Javascript. You need to have a good image processing software like adobe photoshop or something that can process images nicely. For that matter, there are well talented peoples that can make a good image from simple image processing softwares like MS-Paint.
Another thing would be to look as many website and apps as possible. This will give you a best approach to have your own signature that singles you out. Like a writer reads more before s/he writes kinda thing 🙂
The other good thing is, you can start to design just today. You have already what it needs to be the designer. A simple notepad and a web browser. There is a good step by step guide on HTML Introduction. Once you are done with it, you will be a good designer or front end developer

5. Developer/Programmer

react/zmq installation error on PHP 5.4 with composer

Last week I upgraded my PHP to 5.4 on my mac. It was not that bad, but I am starting to pay little by little.
I am using Ratchet for a websocket and for pushing I was using 0MQ.
My composer.json looks

....
    "require": 
        "cboden/Ratchet": "0.3.*",
		"react/zmq": "dev-master"
    }
...

Then I do composer install, it was complaining zmq is not found in the system.
I had zmq already but it is on the php5.3 default directory. And I can’t use the zmq.so file I compiled b/c i am using 5.4 now.
Here is the fix:
Go and grab the git clone from github

git clone git://github.com/mkoppanen/php-zmq.git

for further ways checkout this
Then

cd php-zmq

Then do the following

phpize

Make sure you run the correct phpize in this case. If you are upgrading from 5.3 and still you have the old version sitting around on your machine, phphize will take the older one by default.
My new php 5.4’s one is in /opt/local/bin/phpize54. So make sure you are running the phpize with the new one.
One easy thing to do would be to symlink the old phpize with the new one like:

sudo ln -s new/phpize/path old/phpize/location/phpize

Backing to the topic,
Then do the configure, being inside the php-zmq folder, as follows

./configure --with-php-config=/opt/local/bin/php-config54

make sure to replace the value of –with-php-config with your proper php-config path

if you don’t have the packageconfig, you will have an error requesting for that and you can install it from macport – if you are using mac as follows:

sudo port install pkgconfig

Just search for pkgconfig for others distros you have and it should not be that difficult ..
once you do that install it by

make && make install

Hollla..
the compiled file should be inside the modules directory.
After this, copy that file into the php executables folder and add extention=zmq.so into your php.ini

Now you can do the composer install and it should install it..

Apache not executing PHP code – just renders the as it is

This is the issue when you are having a fresh install of apache usually.
You need to tell apache should handle the extensions so that it could process them accordingly.
On you apache path, go to the config and open the httpd.conf file
and add the following

AddType application/x-httpd-php .php

Also, make sure the Module for php is installed as well..
in your httpd.conf file, search for:

#LoadModule php5_module libexec/apache2/libphp5.so

and, of course, uncomment that to enable php.

installing macports

If you are a programmer/developer one thing you would face on date to date basis is handling packages.
Macports is a package manager for mac using that simplifying the installation of free/open softwares on you mac.
All how to install procedure is found on http://www.macports.org/install.php
After installing the macports don’t forget to update it

sudo port -v selfupdate

Running a single PhpUnit test

Well, we all love tests :). There are times we would like to run a single test that has failed so that we can fix or look at it thoroughly.
The problem, when you are running

phpunit -c /testFolder..

All tests would run.
The fix..
Let’s assume you have this particular test in one of your test files

public function testPhpIsAwesomeOrNot(){
}

All you have to do is to add the group annotation above the function


/**
 * @group awesome
 */
public function testPhpIsAwesomeOrNot(){}

then run it with –group
like
phpunit -c /testfolder –group awesome

How to dynamically construct Backbone js collection url

Constructing Dynamic URL in backboneJS Tutorial with Example

Working on Backbone js and wanted to pass the url dynamically?

Say you want to fetch the data based on the url


url: someurl/{dynamic-value}/content/{dynamic-value}

Here are some steps to accomplish constructing backboneJS url dynamically based on runtime values.

How to select element with multiple class

Solution

Lets assume your collection looks like this


var Members=Backbone.Collection.extend({
	url: function(){
		return url+'attendees/'+this.options.group;
	},
	initialize: function(models, options){
		this.options=options;
	}
});

On the above example your dynamic url might look like
http://somethingsomething.com/attendees/presenters – where presenters is something you added dynamically

and on your view


var Attendees=Backbone.View.extend({
	el: 'YOUR VIEW',
	render: function(){
		var view=this;
		var member=new Members([], {group: 'presenters'});
		member.fetch({
			success: function(members){
				var template= ...YOUR STUFF GOES HERE
		});
	},
	events: {
		'click #activities': 'membersByActivity'
	},
	membersByActivity: function(){
                YOUR LOGIC..
		return false;
	}
});

The important part for creating dynamic url in backbone js is:


var member=new Members([], {group: 'presenters'});

where you can change the presenters part as you like dynamically

Fatal error: require(): Failed opening required Hydrator in mongodb

I was working on putting POPO to MongoDB in symfony project.
I have the Document inside BundleDocumentMyDocument.php

I want to create this document for the first time, but would like to update the document if it exists based on its two fields like:
* I have taken out some of additional information and focus on the main code only..

$file_id = getTheFileId();
$accessor_id = getAccessorId();
$repository=$this->getMongoService()
				->getManager()
				->getRepository('SomethinSomethingBundleDocumentFileAccess');
			$file_access=$repository->findOneBy(array('fileId'=>$file_id, 'accessorId'=>$accessor_id));
			if ($file_access && $file_access instanceof FileAccess){
				$file_access->setAccessCount($file_access->getAccessCount()+1);
			}else{
				$file_access=new FileAccess();
				$file_access->setFileId($file_id);
				$file_access->setAccessorId($accessor_id);
				$file_access->setAccessorType(FileAccess::ACCESS_TYPE_MEMBER);
				$file_access->setAccessDate(time());
				$file_access->setAccessCount(1);
			}
			$document_manager=$this->getMongoService()->getManager();
			$document_manager->persist($file_access);
			$document_manager->flush();

The problem I was facing was when I try to access the record, not when I was adding it.
and I know the record was there by using the command line mongo tool

The solution appears to be the missing config item for mongo:
on your config for mongo add

auto_generate_hydrator_classes: true

and that should fix the problem.

bundle does not contain any mapped documents/entities

This will be an error you would see when trying to generate entities or documents using:

app/console doctrine:mongodb:generate:documents YourPathToBundle

Actually the error would also suggest if you have mapping annotation error.

Mostly this could arise from mapping error as suggested.. check if you have @MongoDbDocument in the case of document or the respective @ORMEntity that would tell what that Plain Old Php Object is representing..
btw, the MongoDb and ORM are the aliases, so it could different on your setting..