Thursday, July 12, 2012
Search Google using a Picture
Just found out that you can search pictures similar to a picture in Google. This is just amazing for me.
Here's the search result I got after uploading a picture from my computer:
Click here.
Saturday, June 23, 2012
Links with Hash Not Working on Offline Mobile Browsers
Problem: On mobile browser when opening a local file, I get a white page each time I click a link with a hash (#) on it's href attribute.
Note: The code above does not cover all mobile devices - only the popular ones.
Solution: Using jQuery, I applied the following javascript code to cleanup the link's href attribute by removing the href substring starting from the hash (#) sign:
$(document).ready(function() {
Link.cleanupForMobile();
});
var Device = {
isAndroid: function() {
return navigator.userAgent.match(/Android/i) ? true : false;
},
isBlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i) ? true : false;
},
isIos: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
},
isWindows: function() {
return navigator.userAgent.match(/IEMobile/i) ? true : false;
},
isMobile: function() {
return (Device.isAndroid() || Device.isBlackBerry() || Device.isIos() || Device.isWindows());
}
};
var Link = {
cleanupForMobile: function() {
if (Device.isMobile()) {
Link._performCleanup();
}
},
_performCleanup : function() {
$("div#contentcolumn a").each(function(i, item) {
var $item = $(item);
var href= $item.attr("href");
window.console.log(href);
var hashIndex = href.indexOf("#");
if (hashIndex > -1) {
var hash = href.substr(hashIndex);
if ($(hash).length < 1) {
$item.attr("href", href.substr(0, hashIndex));
}
}
});
}
}
Wednesday, June 13, 2012
Git SVN - Merge Conflict During Commit
Just encountered an error while committing in Git SVN:
Merge conflict during commit: File or directory...
Too good the solution was easy:
git svn fetch
git svn rebase
#resolve files in conflict if any
git svn dcommit
git svn rebase
#resolve files in conflict if any
git svn dcommit
The processing instruction target matching "[xX][mM][lL]" is not allowed.
Problem: Was running a jspx when the message appeared on my console log
The processing instruction target matching "[xX][mM][lL]" is not allowed.
(Easy) Solution: Just have to remove the first few empty lines of the file.
Monday, June 11, 2012
Fatal error: Maximum Execution Exceeded in PHP
Problem: Using PHP you just encountered an error similar to the following:
Fatal error: Maximum execution time of 30 seconds exceeded
Solution: Just add these line of code in your PHP file
$durationInSeconds = 60;
ini_set('max_execution_time', $durationInSeconds);
ini_set('max_execution_time', $durationInSeconds);
The code above gives the maximum execution time of 60 seconds for your PHP script. Just be warned that your script may hog your system if it is running a heavy process for a long time.
In case you want your script to run in an unlimited amount of time, just set zero to $durationInSeconds:
$durationInSeconds = 0;
ini_set('max_execution_time', $durationInSeconds);
ini_set('max_execution_time', $durationInSeconds);
Sunday, June 10, 2012
Notes Using git svn
Git is one thing and SubVersion (SVN) is another thing. Using git while working on an svn repository is yet another thing.
Now here are my notes:
Go to master branch:
git checkout master
Get remote changes:
git svn fetch
Apply remote changes to master:
git svn rebase
Create new branch named dev:
git branch dev
Go to dev branch:
git checkout dev
Update dev branch from changes in master:
git rebase master dev
Update master branch from changes in dev:
git rebase dev master
Commit to svn repository:
git svn dcommit
Wednesday, June 6, 2012
How to Access Image Dimensions from MultipartFile in Java
Here's how to access image dimensions from MultipartFile:
java.awt.image.BufferedImage image = javax.imageio.ImageIO.read(new BufferedInputStream(multipartFile.getInputStream()));
System.out.println("Image height: " + image.getHeight());
System.out.println("Image width: " + image.getWidth());
System.out.println("Image height: " + image.getHeight());
System.out.println("Image width: " + image.getWidth());
Subscribe to:
Posts (Atom)