Archive for the ‘Uncategorized’ Category

15
Mar

RetinaDisplay mode is enabled ONLY if you want to use HighRes images on an iPhone4. Remember that an iPhone4 also works in “low res” mode.

// Add this code in your Application Delegate, right after initializing the director

// Director Initialization
[director setOpenGLView:glView];

// Enables High Res mode (Retina Display) on iPhone 4 and maintains low res on all other devices
if( ! [director enableRetinaDisplay:YES] )
CCLOG(@”Retina Display Not supported”);

14
Mar
StatFs stat = new StatFs(Environment.getExternalStorageDirectory().getPath());
long bytesAvailable = (long)stat.getBlockSize() * (long)stat.getAvailableBlocks();
long megAvailable = bytesAvailable / (1024 * 1024);
Log.e("","Available MB : "+megAvailable);

29
Feb

Returns the direction the device is traveling in degrees clockwise from true North. If negative, the direction is invalid.

Syntax:

event.direction

 

30
Dec

Row Locking in MySQL can be performed in two ways.

 
 

1) SELECT … FOR UPDATE

Any lock placed with the FOR UPDATE will not allow other transactions to read, update or delete the row. Other transaction can read this rows only once first transaction get

commit or rollback.

Example:

SELECT * FROM tblTest WHERE id=100 FOR UPDATE;

 

2) LOCK IN SHARE MODE

Any lock placed with LOCK IN SHARE MODE will allow other transaction to read the locked row but it will not allow other transaction to update or delete the row. Other transaction can update or delete the row once the first transaction gets commit or rollback.

Example:

SELECT * FROM tblTest WHERE id=100 LOCK IN SHARE MODE;

 

Here once the first transaction commit or rollback then second transaction which is waiting for first transaction to finish will get an updates row rather than the old one.

 
 

This way we can serve the fresh data to the user and can handle the concurrent request in better way.

30
Dec

//To get a file

local path = system.pathForFile( "data.txt", system.DocumentsDirectory )

//To read from file
local file = io.open( path, "r" )
if file then -- nil if no file found
   local contents = file:read( "*a" )
   print( "Contents of " .. path .. "\n" .. contents )
   io.close( file )
end

//To write in a file
 file = io.open( path, "w" )
   local numbers = {1,2,3,4,5,6,7,8,9}
   file:write( "Feed me data!\n", numbers[1], numbers[2], "\n" )
   for _,v in ipairs( numbers ) do file:write( v, " " ) end
   file:write( "\nNo more data\n" )
   io.close( file )

29
Dec

void CCSpriteFrameCache::addSpriteFramesWithFile:(NSString *plist)

Adds multiple Sprite Frames from a plist file. A texture will be loaded automatically.

The texture name will composed by replacing the .plist suffix with .png.

If you want to use another texture, you should use the  method,

” addSpriteFramesWithFile:texture  ”

 

 

id CCTimer::initWithTarget:selector:( id t, [selector] SEL  s)

Initializes a timer with a target and a selector.

void CCTimer::update:( ccTime  dt)

 

triggers the timer

28
Dec

Sample code to add a horizontal carousel inside a panel in Sencha touch is given below.

 
 

test.views.MenuTypeView = Ext.extend(Ext.Panel, {

fullscreen: true,

layout: ‘card’,

cardSwitchAnimation: ‘slide’,

initComponent: function () {

this.backButton = new Ext.Button({

text        : ‘Home’,

ui                : ‘back’,

handler        : this.backButtonTap,

scope        : this

});

this.saveButton = new Ext.Button({

text        : ‘Save’,

ui                : ‘action’,

handler        : this.saveButtonTap,

scope        : this

});

 
 

 
 

this.carousel = new Ext.Carousel({                 

fullscreen: true,

defaults: {

styleHtmlContent: true

},

 
 

items: [

{

id                : 'idOne',

html         : 'IMAGE-1 MENU ITEMS',

style        : 'background-color: #5E99CC'

}, {

id                : 'idTwo',

html         : 'IMAGE-2 ICON MENU ITEMS',

style        : 'background-color: #759E60'

}, {

id                : 'idThree',

html         : 'IMAGE-3 TABBED BAR ITEMS'

}, {

id                : 'idFour',

html         : 'IMAGE-4 TESTING'

}

 
 

]                

});                 

 
 

 
 

 
 

this.appCarouselPanel = new Ext.form.FormPanel({         

dockedItems        : [{

xtype        : 'toolbar',

title        : 'Select Menu Type',

items        : [

this.backButton,

{xtype: 'spacer'},

this.saveButton

]

}],        

items                :[{

layout: 'hbox',                                        

items: this.carousel

}]

 
 

});

 
 

 
 

 
 

this.items = [this.appCarouselPanel];

test.views.MenuTypeView.superclass.initComponent.call(this);

},

saveButtonTap: function () {

console.log(this.carousel.getActiveItem().getId());

 
 

},

backButtonTap: function () {

 
 

}

});

16
Dec

In video games, hearing the same sample over and over gets extremely fatiguing. One way around that is to subtly vary the playback rate a bit every time. This example varies the pitch by +/- 200 cents from the default value:

Example:

laserSound = audio.loadSound(“laserBlast.wav”)
pitchVariation = (math.random(400) – 200)
laserChannel = audio.play(laserSound, {pitch=pitchVariation})

In music applications, we are constantly changing the pitch and time of the sample, for any variety of reasons.

Note that I am simply talking about varying the playback of the sample rate of the asset – so if an audio sample plays back with {pitch=-1200}, or an octave lower, then it would also playback twice as slowly. To maintain a sample’s duration while varying the pitch, or vice versa, involves some heavy DSP and is probably not worth the effort.

28
Nov
Arduino programs can be divided into: structure,values(variables and constants) and functions.
Structure comprises of: Control structures,Arithmetic operators,Comparison operators,Boolean operators,Bitwise operators,Compound operators,comments,etc
Variables comprises of: Constants like HIGH/LOW,true/false,input/output,integer constants,floating point constants
                                   Data types like void,boolean,char,byte,int,string,word,long,double,array,etc
                                   Data type conversion methods like char(),int(),byte(),word(),long(),float()
Functions comprises of: Digital I/O functions-pinMode(), digitalWrite(), digitalRead()
                                    Analog I/O functions-analogReference, analogRead(), analogWrite()
                                    Advanced I/O functions-tone(), noTone(), shiftOut(), shiftIn(), pulseIn()
                                    Time functions-millis(), micros(), delay()
                                    Math functions-min(),max(),abs(),map(),pow(),sqrt() and so on.
Arduino programs are written in C/C++, although users only need define two functions to make a runnable program:
setup() – a function run once at the start of a program that can initialize settings
loop() – a function called repeatedly until the board powers off
Example: To blink an LED
/*
   Turns on an LED on for one second, then off for one second, repeatedly.
 */
void setup() {
  // initialize the digital pin as an output.
  pinMode(13, OUTPUT);
}
void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  delay(1000);              // wait for a second
}

, , , , , , , , , , , , , , , , , , ,

31
Oct
NSString*  deviceName= [[UIDevice currentDevice] name];
	NSLog(@"deviceName --->  %@",deviceName);