The first one would be just to double check if we have correct configuration for xdebug.
But the main and common culprit for this is using
extension=xdebug.soinplace ofzend_exention=xdebug.soin php.ini
The first one would be just to double check if we have correct configuration for xdebug.
But the main and common culprit for this is using
extension=xdebug.soinplace ofzend_exention=xdebug.soin php.ini
There would be a need for this or that reason to serve more than one site from apache. And this is quite possible using configuration inside the apache
First thing first
go to the apache config, by default it should be
/etch/apache2/apache.conf
And search for
#Include /private/etc/apache2/extra/httpd-vhosts.conf
Which, as you can see, is commented. Hence uncomment that by deleting the # infront of it.
The above task will allow us to mess around the httpd-vhosts.conf file that is in the extras directory.
Lets assume we have a site names siteVH which is residing in the directory /www/sitevh
and lets assume we have another site called siteAnother residing in director /www/siteanother
Now the goal is to access those sites independently. So we will create two different virtual hosts for each one and be able to access them independently
ServerAdmin youreamil@domain.com
DocumentRoot "/www/siteVH"
ServerName sitevh.com
ServerAlias local.site
ErrorLog "/private/var/log/apache2/sitevh.log"
CustomLog "/private/var/log/apache2/sitevh.com-access_log" common
AllowOverride All
Order allow,deny
Allow from all
Options Indexes FollowSymLinks
And the we will have the same duplicate values for the other one as well.
Then update the /etc/hosts to let know our local “DNS” 🙂 to know what to do
127.0.0.1 sitevh.com siteanother.com
This shall take care of the whole thing.
One more thing, restart apache
sudo apachectl restart
When setting up a new mac, you will have the default lengthy name that would appear on your terminal. Here is how to change the computer name in mac
here
On your terminal:
sudo scutil HostName short-name
Where ‘short-name’ is what ever you want to be your computer name
That is it!
If you have upgraded jQuery to 1.9 then you would have dreaded Uncaught TypeError: undefined is not a function would be barking at you on your javascript console.
The fix
According to the jQuery site, you would need to replace live with on
Say if you have:
$('.selector-class-name').live('click', function(){console.log('
Applications programming is a race between software engineers, who strive to produce idiot-proof programs, and the universe which strives to produce bigger idiots. So far the Universe is winning.
Rick Cook
')});
Then you would have to change this to the new version using on as follows.
*The current on will be passed the event owner as a parameter so, we have to have a way to know the parent of the event owner, in this case the object with class selector-class-name.
If we don’t know the parent we can implement body tag
$('parent-of-object').on('click', '.selector-class-name', function(){
Applications programming is a race between software engineers, who strive to produce idiot-proof programs, and the universe which strives to produce bigger idiots. So far the Universe is winning.
Rick Cook
});
This shall take care of the problem.
For debugging you might want to see the final native query constructed by doctrine
$raw_sql = $query->getSQL();
the raw_sql variable would contain the sql constructed from entity objecs.
If you are working on Java Persistence API JPA on tomcat or any other web server this would be happening if you have multiple threads going off for connections.
The rule of thumb shall be to have one EntityManagerFactory and get EntityManagers out of it. Hence we would have one factory but multiple products that would take care of closing and managing them selves.
What are the signs:
1. Do you instantiate Persistence.createEntityManagerFactory(“name”) from multiple places?
2. What do you see on Process when you run
ps -aux | grep tomcat
Do you see multiple instances
If either or both of the above have yes, then here is the solution.
The first thing have single instance of ManagerFactory
package com.enderase.persistence;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
/**
* Singlton implementation for EntityManagerFactory
*
* @author Kaleb Woldearegay<kaleb@gullele.com>
*/
public class HibernateUtil {
private static final EntityManagerFactory entityManagerFactory;
static {
try {
entityManagerFactory = Persistence.createEntityManagerFactory("jpa");
} catch (Throwable exception) {
//log your error here
throw new ExceptionInInitializerError(exception);
}
}
public static EntityManagerFactory getEntityManager() {
return entityManagerFactory;
}
}
Then make sure you are taking care of the instances of the EntityManagers that are created from the factory using
EntityManagerFactory entityManagerFactory = HibernateUtil.getEntityManager(); EntityManager em =Â entityManagerFactory.createEntityManager();
Make sure to close them appropriately after using them
This should pretty much take care of the problem
I got this question while helping a friend on the course work. It is relatively simple question. But the way how it is approached can make a difference on efficiency.
The question is, given an array of numbers, you are to find if there are three numbers that would total the given number T.
If done in a very naive way, it can soar to o(n^3) like having three loops and checking the sum inside the third loop.. well.. this is a no no..
I have approached it in a log n ( for sorting) and n for (searching) approach..
package algorithm;
import java.util.Arrays;
/**
* Given an array of integers, find if there are three numbers that would sum up to the
* number T
*
* @author https://gullele.com
*
*/
public class ThreeNumbersSummingT {
public static void main(String[] args) {
int[] test = new int[]{1,3,4,5,10,12, 18};
ThreeNumbersSummingT summt = new ThreeNumbersSummingT();
int[] response = summt.findThreeNumbers(test, 29);
if (response.length > 1) {
for(int num : response) {
System.out.println(num);
}
} else {
System.out.println(":( Couldn't find those three gems");
}
}
public int[] findThreeNumbers(int[] nums, int t) {
int[] indexes = new int[1];
if (nums.length == 0 || nums.length <= 2) {
return indexes;
}
//for primitive this would be quick sort so we have nlogn
Arrays.sort(nums);
int minIndex =0;
int maxIndex = nums.length-1;
int current = 1;
while (minIndex != maxIndex) {
if (nums[minIndex] + nums[maxIndex] + nums[current] == t) {
int[] summingNumbers = new int[3];
summingNumbers[0] = nums[minIndex];
summingNumbers[1] = nums[current];
summingNumbers[2] = nums[maxIndex];
return summingNumbers;
}
int lookingFor = t-(nums[minIndex] + nums[maxIndex]);
//if the number being sought is beyond the max, then jack up the min index
if (lookingFor >= nums[maxIndex]) {
minIndex++;
current = minIndex + 1;
} else if (nums[minIndex] + nums[maxIndex] + nums[current] < t) {
current++;
} else {
maxIndex--;
current = minIndex + 1;
}
}
return indexes;
}
}
If you want pdo to thow exception so that you can see what is going on kinda thing.. you can add the following parameter when you instantiate PDO just next to the password part of the pdo
array(PDO::ATTR_EMULATE_PREPARES => false,
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
**Note: This is not the best way to handle exception by any means!!
Zend will ship its elements with tags of dd dt
But if you want to get only the element with out decorator being around it.
you can do:
$this->addElement('text', 'you_element', array(
....
'decorators' => array('viewHelper'),
....
));
But if you want to display errors along with the HTML format,
add errors in the decorators array
This should give you only the element that you can implement your own decorator around it
I would say we have to use annotations and Injection to get the bean inside another bean.
But in case you are interested to get it without using annotation you can use the following in the action/actionListener
TheBean theBean = (TheBean)FacesContext.getCurrentInstance() .getExternalContext().getRequestMap().get("theBean");
Where theBean is one we are interested to get it from being in the other bean.
That is it!