How to print NSDictionary in Objective C?
SolutionNSDictionary*dict = nil;dict = [NSDictionary dictionaryWithObject:@"1" forKey:@"one"];// method 1for(NSString *key in dict){ NSLog(@"key : %@",key); NSLog(@"value : %@",[[dic...
View ArticleHow does SMTP debug looks like on sending email?
mymac:bin mv$ ./run.sh com.infuzee.service.test.EmailerTestDEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]DEBUG SMTP: useEhlo...
View ArticleHow to clean Cocos2d cache?
AnswerThe Cocos2D framework caches a lot of objects in memory like Textures, Sprites etc. to application increase performance by avoiding repititive loading overheads. When the device is about to run...
View ArticleHow to do get handle to various shared Cocos2D objects?
AnswerThe Cocos2D framework provides a lot of singleton objects that act as delegates/managers for basic objects like Textures, Sprites, Audio etc. The following methods provides the handler to these...
View ArticleSingleton Example in Objective C?
Solutionstatic MyManager *sharedManager = nil;+(MyManager*) sharedManager{ if (sharedManager == nil) { sharedManager = [[MyManager alloc] init]; }...
View ArticleQuartz Jobs fails- java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
IssueException in thread "main"java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.quartz.impl.StdSchedulerFactory.<init>(StdSchedulerFactory.java:274) at...
View ArticleHow to check if a String is a number in Java?
Snippetpublicboolean isNumeric(String s){ boolean isNumber =false; if(s ==null){ return isNumber; } for(int i =0; i < s.length(); i++){...
View ArticleHow to hide a Drupal block based on post url?
Durpal provides various options 3 options to include a block based on the post url. Normally the first two are good enough however if you need more control you can use the third option i.e. writing a...
View ArticleJDBC - link failure CommunicationsException
ExceptionCaused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failureThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not...
View ArticleWrite a prepend String function in Java?
/** * Method to PrePend String */ publicString prependString(String source, String pad, int length) { if(source ==null) { returnnull; } if(pad...
View ArticleHow to convert hex to bytes and viceversa in Java?
// hex to byte[] publicbyte[] hex2Byte(String str) { byte[] bytes =newbyte[str.length()/2]; for(int i =0; i < bytes.length; i++) { bytes[i]=(byte)Integer...
View ArticleHow to convert bytes into human readable string format in PHP?
Snippet//////////////////////////////////////////////////// formatBytes($file_size) mixed file sizes// formatBytes($file_size, 0) KB file sizes// formatBytes($file_size, 1) MB file sizes...
View ArticleHow to get video id from a Youtube url in Javascript?
Snippete.g. if the youtube, video url is:http://www.youtube.com/watch?v=xptDCPlSSfI& The snippet will return xptDCPlSSfI var url = "http://www.youtube.com/watch?v=xptDCPlSSfI"; var video_id =...
View ArticleHow to make iPhone vibrate on recieving Push Notification?
Snippet When the push notification is received, the didReceiveRemoteNotification method of the App Delegate is called and one can make the phone vibrate invoking the AudioServicesPlaySystemSound...
View ArticleHow to clear the iPhone number badge when the Push Notification Alert is...
Snippet When the push notification is received, the didReceiveRemoteNotification method of the App Delegate is called and then we can perform the required action and clear the badge./** * Remote...
View ArticleHow to remove numbers from a String in PHP?
Snippet<?phpfunction cleanup_numbers($string){ $numbers = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0", " "); $string = str_replace($numbers, '', $string); return $string; }...
View ArticleHow to clean spaces and truncate to a given length in PHP?
Snippet////////////////////////////////////////////////////////////////////////////////////////////// USAGE//// [if second argument is false the word length is not truncated// [if second argument is...
View ArticleHow to get contents of a URL using Curl in PHP?
Snippet// get contents via curlfunction curl_get($url){ $browser_agent="Firefox"; $ch=curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);...
View ArticleHow to generate random string in Perl?
Snippet########################## Generate Randon String#########################sub generate_random_string{ my $length_of_randomstring= shift; my @chars=('a'..'z','A'..'Z','0'..'9'); my...
View ArticleHow to get the current PHP version in the script and compare?
SnippetThe PHP version is stored in the PHP_VERSION variable and is available to the script at runtime. This with the version_compare function we can evaluate and compare and do the required action as...
View Article