Say you added an alias to your most common command to your ~/.bash_profile or .profile file and, to use the alias, you have to reload the terminal or you can do it in one line as
source ~/.bash_profile
That will refresh your terminal for ya
Say you added an alias to your most common command to your ~/.bash_profile or .profile file and, to use the alias, you have to reload the terminal or you can do it in one line as
source ~/.bash_profile
That will refresh your terminal for ya
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
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
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
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
this is a simple configuration error that can be solved by adding the bundle in the config.
in the app/config/config.yml file, locate the ‘assetic’ and under that you will see the bundles option – in there add the name of your bundle
bundled: [SomeBundle]
without any quotes around it
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.
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..
Certification is one way to keep on top of your expertise. It would help you to communicate easily, meet expectations. When you take certification, it is entirely for your own. No one, specially these days, will take certifications for granted. Still you will go thru a number of interviews and code challenges to show who you are. But, when there are times that all of us are the same colored potato, certification will rescue us by making us a bit bolder than the others.
Also, take the challenge. If you are working on some technology and you think you are expert on it, proof it thru certification.
I took the exam yesterday and it was cool. It was not that difficult to tell the truth. Here are some of my points that would help you if you are thinking to take that exam.
1. Are you a developer who is working on mysql as a backend and have done a number of selects, joins, where statements, group by and havings? How about querty statements like create table, alter table, add index and show databases/table..? If the answer for this questions is ‘Yes’ – congrats my friend, almost you have answered a bit more than half the questions on the exam already.
The exam’s most portion is on DML and DDL. If you have a good hands on those query types all you have to do is to get the grip on the principles behind those. Actually this will help you in general not for the exam only
Like, what are basic blocks of select statements, when do you use indexes, group bys and havings, how are the results of the query be affected? When to use Order by and limit. Practice with a number of queries with real tables..
2. Get this book – MySQL-5-0-Certification-Study-Guide. You will need only this book indeed. Read the part for the developer PartI and read on views, import and export and you will be pretty much set.
Guess what, this book is the same book you will need when you take the MySQL Developer exam I and II, which I am planning to take in the coming couple of weeks.
3. Do the exercises from the book’s CD. it has a concise exercises for each chapter and they are the best. Make sure you cover those before jumping to the exam.
4. Give it at least two weeks. It might depend on how you are prepared, but the more prepared the more walk in the park it would be.
5. Apply the general test rules đ – take a good rest before you sit for the exam, eat appropriately [dont be hungry and don’t be too loaded as well], make sure you visit the bathroom first đ
*For me applying all those points appropriately, I was able to finish the exam way ahead of the allotted time, and score 94% – which shows those guidelines are good to follow.
Got this error when trying to add the mongodb stuff your php project – specially using composer then here is how to solve it.
The first thing is you have to add the mongodb driver to php.
You might need PEAR on your system. Adding pear to your system is relatively easy and google can help on that.
Then do the following on your terminal
sudo pecl install mongo
pecl install mongo
The last lines of successful installation would tell where the installation has occurred and some more important information.
Now you need to add the mongo.so to the php.ini
if you don’t know where you have php.ini run (on ubuntu)
locate php.ini
then run
echo "extension=mongo.so" >> path-to-php.ini
It looks the days of PEAR are somehow covered by the era of composer. But, still there might be things we will depend on PEAR, hence we have to install it.
Are you on Mac OSX and wants to install PEAR.. follow these simple steps and you will nail it
1. download the phar file from go-pear.phar
curl -O http://pear.php.net/go-pear.phar
2. Then run the phar file
sudo php go-pear.phar
In some cases, you might want to run it with -d detect_unicode=0 option
3. You will be provided with option that would look like the following:
1. Installation base ($prefix) : /Users/gullele/pear 2. Temporary directory for processing : /tmp/pear/install 3. Temporary directory for downloads : /tmp/pear/install 4. Binaries directory : /Users/gullele/pear/bin 5. PHP code directory ($php_dir) : /Users/gullele/pear/share/pear 6. Documentation directory : /Users/gullele/pear/docs 7. Data directory : /Users/gullele/pear/data 8. User-modifiable configuration files directory : /Users/gullele/pear/cfg 9. Public Web Files directory : /Users/gullele/pear/www 10. Tests directory : /Users/gullele/pear/tests 11. Name of configuration file : /Users/gullele/.pearrc
Select 1 and enter where you would want to put the installation. In my case, I put it to the common installation directory /usr/local/pear
4. After that, you will have this options to choose:
1. Installation base ($prefix) : /usr/local/pear 2. Temporary directory for processing : /tmp/pear/install 3. Temporary directory for downloads : /tmp/pear/install 4. Binaries directory : /usr/local/pear/bin 5. PHP code directory ($php_dir) : /usr/local/pear/share/pear 6. Documentation directory : /usr/local/pear/docs 7. Data directory : /usr/local/pear/data 8. User-modifiable configuration files directory : /usr/local/pear/cfg 9. Public Web Files directory : /usr/local/pear/www 10. Tests directory : /usr/local/pear/tests 11. Name of configuration file : /Users/gullele/.pearrc
Ideally, you can put the binaries anywhere you want but you would have to add it to the PATH to be able to access it from anywhere. But if you put it inside /user/local/bin that would automatically be taken care of – do that and that would pretty much take you to the end of pear installation.
Happey PEARing