Posts

Showing posts from May, 2013

Animals: Fun Time. Animals Can Be Jerks

Image
I'm just so entertained and laugh with this video. Hope you enjoy it!

iOS: How to use a delay call to a method or execute a time or with intervals

In iOS or and its underlying Framework extends it to use Grand Central Dispatch (GCD) . So in this example, let say you wanted to call or execute a method at a specified time, you can use the code below, Say you wanted to play an audio file after 2 seconds.             NSURL *audioURL  =   [ [ NSBundle  mainBundle ]  URLForResource : @"TheAudioFile" withExtension : @ "mp3" ] ;              NSError   * error;              AVAudioPlayer * audioPlayer  =   [ [ AVAudioPlayer alloc ]  initWithContentsOfURL : audioURL error :& error ] ;                         dispatch_time_t popTime  =  dispatch_time ( DISPATCH_TIME_NOW, 2.0  * NSEC_PER_SEC ) ; // where 2.0 as a second * nano seconds             dispatch_after ( popTime, dispatch_get_main_queue ( ) ,  ^ ( void )   {                  [ audioPlayer play ] ;              } ) ; You need to call dispatch_get_main_queue() in order to add it and flag to the queue that this needs to be exe

PHP: Awesome scripts in PHP that mostly programmers tend to use it in common applications

I just wanted to carry this scripts that I found in another blog. 10 awesome PHP functions and snippets Check it out, specially for beginners trying to learn these functions and snippets. Enjoy!

Taking notes: Complexity of Algorithms (using Java)

Just wanted to take this as my own notes from  http://introcs.cs.princeton.edu/java/41analysis/ . Just take not that from Quadratic algorithm down below, aren't just that perfect algorithms that you would enjoy when handling large data structures. Complexity Description Examples 1 Constant  algorithm does not depend on the input size. Execute one instruction a fixed number of times Arithmetic operations (+, -, *, /, %) Comparison operators (<, >, ==, !=) Variable declaration Assignment statement Invoking a method or function log N Logarithmic  algorithm gets slightly slower as N grows. Whenever N doubles, the running time increases by a constant. Bits in binary representation of N Binary search Insert, delete into heap or BST N Linear  algorithm is optimal if you need to process N inputs. Whenever N doubles, then so does the running time. Iterate over N elements Allocate array of size N Concatenate two string of length N N log N Linearithmic  al

Great JS frameworks for creating games or JS applications

I just wanted to list this JS frameworks that would be good for developing games. http://www.impactjs.com http://www.createjs.com https://github.com/photonstorm/phaser http://angularjs.org/ Templating like, http://akdubya.github.io/dustjs/ or http://linkedin.github.io/dustjs/ http://coffeescript.org/

iOS: Adding icon in the button and a center text title

Image
In my end, I did this using UIEdgeInsetsMake which the left corner is calculated to make it to the center. I am not sure if there's something really you can make the text at aligned at the center but this works for me. Make sure that you set your left corner to your desired position by calculating the width. e.g. UIEdgeInsetsMake(0.0f, 42.0f, 0.0f, 0.0f) UIButton  * scanBarCodeButton  =   [ UIButton buttonWithType : UIButtonTypeRoundedRect ] ; scanBarCodeButton.frame  =  CGRectMake ( center, 10.0f, fieldWidth, 40.0f ) ; [ scanBarCodeButton setImage : [ UIImage imageNamed : @ "BarCodeIcon.png" ]  forState : UIControlStateNormal ] ; [ scanBarCodeButton setTitle : @ "Scan the Barcode"  forState : UIControlStateNormal ] ; scanBarCodeButton.titleEdgeInsets  =  UIEdgeInsetsMake ( 0.0f, 42.0f, 0.0f, 0.0f ) ; [ scanBarCodeButton setContentHorizontalAlignment : UIControlContentHorizontalAlignmentLeft ] ; [ scanBarCodeButton addTarget : self action : @sele

iOS: Animating a View (Sample of hiding a UITabBarController view)

The UIView class has it's animation methods like beginAnimations, commitAnimations, animateWithDuration, and setAnimationDuration. You can use this methods to animate such specific view. Below is an example of hiding a UITabBarController view and retain the non-UITabBar class views.           [ UIView beginAnimations : nil  context : NULL ] ;      [ UIView setAnimationDuration : 0.5 ] ;          //    CGRect temp = appDelegate.tabBarController.view.frame;      //    temp.origin.y += 100;          for ( UIView  * view  in   appDelegate.tabBarController.view.subviews )      {          if ( [ view isKindOfClass : [ UITabBar class ] ] )          {              [ view setFrame : CGRectMake ( - 320 , view.frame.origin.y, view.frame.size.width, view.frame.size.height ) ] ;          }          else          {              [ view setFrame : CGRectMake ( view.frame.origin.x, view.frame.origin.y, view.frame.size.width,  480 ) ] ;          }      }          [ UI