Load jQuery when the HTML document is loaded:
$(document).ready(function() { // business code }); |
Load jQuery when all the images on a page have also loaded:
$(window).load(function() { // business code }); |
Load jQuery when the HTML document is loaded:
$(document).ready(function() { // business code }); |
Load jQuery when all the images on a page have also loaded:
$(window).load(function() { // business code }); |
Sometime happens you need to manually mount the cdrom to be able to install the Parallels Tools. Follow these instructions to do that:
1) Start the virtual machine. When the guest OS boots up, choose Install Parallels Tools from the Virtual Machine menu.
At this point, the prl-tools-lin.iso image file will be connected to the virtual machine’s CD/DVD drive.
2) Start a terminal in your Linux guest OS. Type the following command to gain the root privileges:
sudo su - |
3) ount the Parallels Tools installation disc image, enter the following:
mount -o exec /dev/cdrom /media/cdrom |
Note: /dev/cdrom is the virtual machine’s CD/DVD drive and /media/cdrom is the mount point for this device. In some of the Linux operating systems the virtual CD/DVD drive may appear as /dev/hdb and the mount point /mnt/cdrom. Some Linux OSs do not have the CD/DVD drive mount point. In this case, you should create the mount point directory manually.
4) When the installation disc image is mounted, change the directory to the CD/DVD drive directory using
cd /media/cdrom/ |
In the CD/DVD drive directory, enter the following to launch Parallels Tools installation:
./install |
Note: You must have the root privileges to run this command.
Follow the Parallels Tools Installer instructions to complete the installation.
To implement the MongoDB results pagination in Java, there are few parameters that need to be collected:
1) the order of results (ascending / descending)
2) the field used to order the results
3) the number of element and the page selected
4) the field and the value used to filter the results
As well as the results of query, the method needs to return the total number of elements. All returned elements will be saved in a HashMap.
HashMap<String, Object> resultMap = new HashMap<String, Object>(); Direction direction = Sort.DEFAULT_DIRECTION; if (sortDirection > 0) { direction = Sort.Direction.ASC; } else { direction = Sort.Direction.DESC; } List |
If a pagination is required, skip and limit are used
if (pageSize > 0) { query.skip((pageNum - 1 ) * pageSize); query.limit(pageSize); } if ( sortField != null && !sortField.equals("") ) { query.with(new Sort(direction, sortField)); } results = mongoTemplate.find(query, Object.class); |
If a pagination is required, queryCounter (basically a version of query without pagination an limit) is used to calculate the total number of results. Of course, if pagination is not required, is possible to use directly the size of results.
if ( pageSize > 0 ) { resultMap.put("RESULT_SIZE", (int) mongoTemplate.count(queryCounter, Object.class)); } else { // If pagination is not required, the query is not re-executed resultMap.put("RESULT_SIZE", results.size()); } |
mongoTemplate is a spring bean defined in this way on context configuration:
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate" c:mongo-ref="mongo" c:databaseName="${mongo.db.name}"> <property name="writeConcern" value="SAFE" /> </bean> |
Suppose you need to apply some filters to your MongoDB query, for example to extract some _ids that match a regex condition. This is the way to do that:
Query query; query.addCriteria(Criteria.where("_id").in(IDs).and(query_field).regex(".*" + query_value + ".*", "i")); |
In this example I used the Query (see here) and Criteria (see here) classes
And, this is the query you can use in mongoDB (Robomongo* or command line):
Query: { "_id" : { "$in" : [ "ID1" , "ID2" , "ID3" ]} , "detail.medicationBrandName" : { "$regex" : ".*x.*" , "$options" : "i"}}, Fields: null, Sort: { "medicationGenericName" : -1} } |
*Robomongo: is a shell-centric cross-platform open source MongoDB management tool (i.e. Admin GUI). Robomongo embeds the same JavaScript engine that powers MongoDB’s mongo shell. You can download it here.
I was thinking about a recommendation on LinkedIn. My concern is about this question: how To Get Great LinkedIn Recommendations and, in particular when. As a freelancer with a big customer is really important to have an exit strategy to prevent a regrettable situation so, I was thinking to ask to some recommendation on LinkedIn. This professional social network is starting to be a good starting point to find new business partners and, of course, a recommendation that offer specific results or tell a story of transformation about your professional experience should be a great way to improve your profile.
I read a lot of blogs but I found this one really interesting linkedin-recommendations
L’Agenzia delle Entrate ha sentito la necessità di ribadire e precisare quanto già previsto dal comma 1 dell’art.35 del DPR 633/72, diramando la risoluzione n. 60 datata 16 maggio 2006, recante: “Indicazione numero partita IVA nel sito web – articolo 35, comma 1, del D.P.R. n. 633 del 1972”.
Esso deve essere sempre indicato nelle dichiarazioni, nella home page dell’eventuale sito web ed in ogni altro documento destinato all’ufficio stesso.
[…Con il provvedimento in esame l’Agenzia delle Entrate precisa quanto segue:L’obbligo di indicazione del numero di partita IVA nel sito web rileva per tutti i soggetti passivi IVA, a prescindere dalle concrete modalità di esercizio dell’attività.
Di conseguenza, quando un soggetto IVA dispone di un sito web relativo all’attività esercitata, quand’anche utilizzato solamente per scopi pubblicitari, lo stesso è tenuto ad indicare il numero di partita IVA…]
Suppose you defined TemplateDao Spring bean in this way:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"><value>com.mysql.jdbc.Driver</value></property> <property name="url"><value>jdbc:mysql://${mysql.hostname}:${mysql.port}/${mysql.db}</value></property> <property name="username"><value>${mysql.user}</value></property> <property name="password"><value>${mysql.password}</value></property> </bean> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <bean id="TemplateRequestDao" class="com.afm.admin.dao.mysql.TemplateDaoMySql"> <property name="dataSource" ref="dataSource" /> </bean> |
and you get this error message: The name of the property, following JavaBean naming conventions. The reason is probably you forgot to extend your implementation class:
public class TemplateDaoMySql extends JdbcDaoSupport implements TemplateDao { @Override public List<TemplateRequest> getTemplateRequest(UserProfile userProfile) { // TODO Auto-generated method stub return null; } } |
Time lost to fix this issue: more or less 1 hour. Image the how many I was frustrated when I discovered what was the problem.
While evaluating template with Velocity I am affecting a null point exception but happened only on production environment because it seems that the application is trying to write to tomcat/bin the velocity.log file but it failed due to the permission. I tried to add velocity.property file:
# Fri Dec 6 10:14:26 EST 2013 - Mandatory to prevent Velocity null point exception
runtime.log.logsystem.class=org.apache.velocity.runtime.log.NullLogSystem |
but, after every startup I get the same error and, to fix that, it seems to be mandatory to remove the workdir tomcat folder. It’s not acceptable so, I tried to add this row before init the velocity:
Velocity.setProperty("runtime.log.logsystem.class", "org.apache.velocity.runtime.log.NullLogSystem"); |
Of course, my next step is to migrate to Freemarker because Velocity isn’t really under active development any more.
I was reading this post 9 Tips for a Better Company Culture and I think it’s a great lesson that some italian “Captain of industry” that lead not IT companies should learn. I posted here some rows from the post that should be entirely read by employers and employees.
“Hiring someone is a big commitment — and what if it doesn’t work out? For some kinds of businesses, freelancers make a ton of sense. “I like to say we have an army of freelancers, which means I can hire great talent without having to lure them away with a salary we could never afford,” says Rachel Hofstetter, founder-in-chief of Guesterly”.
I created a new Web application using Eclipse and, after Enabling Maven, I get this error updating the project:
Cannot nest 'PRJ/src/main/resource' inside 'PRJ/src'. To enable the nesting exclude 'main/' from 'PRJ/src' |
Basically I removed the folder /src and create folder /src/main/java, /src/main/resources etc and this fight with the sourceDirectory tag in Build section of maven pom. To fix that, just remove this row and update the project:
<sourceDirectory>src/</sourceDirectory> |