Making a mobile accessible Facebook Page Tab App

In order to create a Page Tab App which has a mobile accessible version (an external website accessed directly, not via a Facebook iFrame). You need to add and configure 3 different “Platforms” in the app developer settings. These should be configured as follows:

Page Tab

Configure this as you would normally.

Website

This is where you configure the url for your mobile site

  • Mobile Site URL: This is the url you want mobile users to be redirected to (e.g. http://myapp.com/mobile-version)
  • Site URL: This is used for Facebook Connect, if you are not using Facebook connect, just put your mobile url in here too.

App on Facebook

This is going to be the gateway to your app. Mobile users arriving on this page will be redirected to the mobile website. You can use javascript to redirect desktop users to your Facebook Page Tab App.

Your Canvas Redirect Script

You want people arriving at your canvas app on a desktop browser to be redirected to your page tab app. Because it is loaded inside an i-frame, the only way to do this is using JavaScript.

This will be the content of your Canvas Url (http://myapp.com/canvas-redirect above):

<code>&lt;script&gt;top.location="http://facebook.com/page_tab_url/app_1234"&lt;/script&gt;
</code>

Note the “top.location” – this will redirect the parent window, not just the iframe to the page tab. When a user arrives on the canvas page in a desktop browser, they will be redirected via JavaScript to your Page Tab App. Mobile users will be redirected by Facebook to the Mobile Site Url you specified above.

Testing in Sandbox Mode

If your app is in Sandbox Mode, only admins, developers or testers of the app will be able to see it. In particular users not logged into Facebook, or who are logged into Facebook but are not admins or testers of the app, will not be able to access the app canvas page – they will just see a 404 error. In order to test your mobile redirect when the app is in sandbox mode, you need to ensure that you are an an admin, developer or tester of the app AND you are logged into Facebook’s mobile site on your phone’s web browser – i.e. Safari on iOS and Chrome on Android. It is not sufficient to be signed into the Facebook Mobile App on your phone, you must also be logged in using the browser.

A note about User Roles

You can configure the App User Roles by clicking on the “roles” tab in the app settings. You can add a Facebook user, or a Facebook Group as any of the roles. (If you add a Group, all the users in that group will have the role specified in the app). In order for a user to have a specific role on an app, they must:

A C program to find an inverse of 3×3 matrix

#include<stdio.h> 


void display_mat(int a[3][3])
{
     int i,j;
     for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
        printf("%d \t",a[i][j]);
        }
        printf("\n");
    } 
}
int det(int a[3][3])
{
    int i,j,x,y;
    int det=0;
    
    for(i=0;i<3;i++)
    {
        x =(i==2)? 0 : (i+1);
        y = (i>=1) ? (-1+i) : (i+2);
        det = det + a[0][i] * ( a[1][x] * a[2][y] - a[2][x] * a[1][y] ); 
    }
    return det;
}

void cofactor(int a[3][3],int cof[3][3])
{
    int i,j,x1,y1,x2,y2;
    
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
        x1 =(i==2)? 0 : (i+1);
        x2 = (i>=1) ? (-1+i) : (i+2);
        y1 =(j==2)? 0 : (j+1);
        y2 = (j>=1) ? (-1+j) : (j+2);
        cof[i][j] = a[x1][y1] * a[x2][y2]- a[x1][y2] * a[x2][y1];
        }
    }
}

void transpose(int a[3][3],int trans[3][3])
{
    int i,j;
    
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
        trans[j][i] = a[i][j];
        }
    }
    
}
void inverse(int a[3][3],float inv[3][3], int det)
{
    int i,j;
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
        inv[i][j] = (float) a[i][j]/det;
        
        }
    }
    
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
        printf("%.2f \t",inv[i][j]);
        }
        printf("\n");
    } 
    
  
    
}

int main()
{
int mat[3][3],i,j,cof[3][3],d,adj[3][3];
float invr[3][3];

printf("Enter the values of matrix:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("a[%d][%d]=",i,j);
scanf("%d",&mat[i][j]);

}//for j loop ends
}//for i loop ends


printf("\n\nGiven matrix is: \n");
display_mat(mat);
d=det(mat);
printf("\n\nDeterminant of given matrix is: %d \n",d );

if(d==0)
{
printf("Since determinant is zero, Inverse couldnot be calculated.");        
}
else{
cofactor(mat,cof);
printf("\n\nCofactor matrix is: \n");
display_mat(cof);

printf("\n\nSo, Adjoint matrix is: \n");
transpose(cof,adj);
display_mat(adj);


printf("\n\nThus, Inverse of given matrix is: \n");
inverse(adj,invr,d);

}
getch();
}

C Problem: Write a function invert(x,p,n) that returns x with the n bits that begin at position p inverted, You can assume that x, p and n are integer variables and that the function will return an integer.

As an example, if x=181(decimal) which is 10110101 in binary, and p=4 and n=2, then the function will return 10101101 or 173 (decimal). The underlined bits are the changed bits. note that bit positions are counted form the right to the left and that the counts starts with a 0. Therefore, position 4 is the 5th bit from the right values.

#include<stdio.h>
#include<conio.h>
#include<math.h> 
int invert(int x, int p, int n) 
{ 
    int temp,count,final,rem; 
    long binary; 
    count = 1; 
    binary = 0; 
    temp=x; 
    final = 0; 
    while(temp>0) 
    { 
     rem = temp%2; 
     if(count >= p && count < (p+n)) 
     { 
                  if(temp % 2) 
                     rem=0; 
                  else
                     rem=1;       
      }
       binary = binary*10 +rem; 
       temp=temp/2; 
       count++;      
     }
    count = 0; 
    temp=binary; 
    while(temp>0) 
    {      
            rem = temp%10; 
            final = final +rem * pow(2,count); 
            count++;
            temp=temp/10; 
    }
    return final; 
}

void main()
{
    int x,p,n, final_decimal; 
    printf("Enter the integer number");
    scanf("%d",&x); 
    printf("Enter the invert position");
    scanf("%d",&p); 
    printf("Enter the number of bits to be inverted");
    scanf("%d",&n); 
    final_decimal  = invert(x,p,n); 
    printf("The final Decimal value is: %d",final_decimal); 
    getch(); 
}

How to write a program to check whether a given two numbers are Amicable numbers or not.

Amicable numbers are two numbers so related that the sum of the proper divisors of the one is equal to the other, unity being considered as a proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 44, 55 and 110, of which the sum is 284; and the proper divisors of 284 are 1, 2, 4, 71, and 142, of which the sum is 220.

#include<stdio.h> 
#include<conio.h> 

int sumDivisors(int num){ 
int i, sum=0;
for(i=1;i<num;i++)
{ 
if ((n%i) ==0) 
sum = sum + i;
} //for loop ends here
} //function sumDivisors ends here 
void main() {  
int first, second;
clrscr();
printf(“Enter an first integer number: ”); 
scanf(“%d”, &first);
printf(“Enter an second integer number: ”); 
scanf(“%d”, &second);
if( (sumDivisors(first)==second) && (sumDivisors(second)== first)){
printf(“The given numbers are amicable ”); 
}
else{
printf(“The given numbers are not amicable ”); 
}
getch();
}  //main program ends here

 

How to write a program to find all Armstrong number in the range of 0 to 999

An Armstrong number of three digits an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3+7**3+1**3 =371.


#include<stdio.h>
#include<conio.h>
#include<math.h>

void main() {  
int i, temp, sum;

clrscr();

for (i=0; i<1000; i++)
{
sum = 0;
temp = i;

do{
sum = sum + pow((temp%10) , 3);
temp = temp/10;

}while( temp > 0);

if (sum == i)
            printf(“%d \n ”, i);

}  //for loop ends here


getch();
}  //main program ends here

Facebook coverpage for Buddha was born in Nepal

Today few websites claim that Siddhartha Gautama is born in India while he was born in Kapilbasthu, Nepal. Do you think that this is a error that people have been making or it is just that many people don’t know Nepal and think it is in southeast Asia which is india and not Nepal.

So, I am attempting to create few cover pages for Facebook, that promotes, Buddha was born in Nepal.

 

Buddha was Born In Nepal

How to write an interactive C program to generate the divisors of a given integer.

#include<stdio.h>
#include<conio.h>

void main() {
int n,count;
float rem;

clrscr();
count = 0;
printf("\n Enter an integer");
scanf("%d", &n);
printf("\n The divisors of %d are: ", n);

for( i=n-1; i>0; i-- ){
rem= n % i;
if(rem == 0){
printf("%d, ", i);
count++;
}

}
if(count == 0){
printf("\n \nSorry, there are no divisors of %d", n);
}

getch();
}

How to write an interactive C program to calculate simple interest and compound interest.

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float p,t,r;
float i,ci,a;
clrscr();
printf("enter the principal:\t");
scanf("%f",&p);
printf("enter the rate of interest:\t");
scanf("%f",&r);
printf("enter the time in years:\t");
scanf("%f",&t);
if((p<0)||(t<0)||(r<0))
printf("invalid");
else
{
i=(p*t*r)/100.0;
printf("the simple interest is rs.%.2f",i);
a=(float)p*(pow(1+r/100.0,t));
ci=a-p;
printf("the compound int is rs.%.2f",ci);
}
getch();
}

Arrow Symbols for webpages

Arrows are repeatedly used in websites. We can use arrows in a website using:

1. Image
2. CSS
3. Symbol

Images are easy to use, but cost you more HTTP requests, and page your load times. Using CSS is a good approach, but it is bit complicated and may cost you some of your time. Time matters when you are working on a big project with short deadlines. So, using arrow symbol is pretty handy, easy to use and clever approach to use arrows.

Read More

Tags: ,

Everest zoom, A simple lightweight jquery image zoomer

Everest zoom is a simple image zoomer that I developed using jQuery, CSS and HTML. It is easy to implement in your website and free for use.

Features

  • Free
  • Easy to implement
  • Small file size.
  • Browser support: Firefox, Chrome, Safari, IE8+
  • Easy to configure.

Please check the demo here:
Everest zoom Demo

For more details and documentations, please visit following url:
Everest zoom Documentation

Start using Everest zoom

If you need any help, twitt me @GoalLessWin.