Sunday, May 31, 2020

Friday, January 8, 2016

AngularJS Helloworld

As a Developer, we know that Web browser understands HTML. Most of the client side frameworks works on HTML to improve the performance of user experience. Similar way AngularJS also works on HTML tags and its customized directives (ng-app, ng-controller) to render page.

How it works ?


Scope is glue between view and model. Whatever entered information will be updated in syc with Model.
View template:
<!DOCTYPE html>
<html ng-app="helloApp">                       
<head>
    <title>AngularJS - Hello World</title>
<script src="angular.js"></script>
<script src="helloController.js"></script>
</head> <body ng-controller="HelloController">                   
<input type="text" ng-model="name"> <br />  
Hello <strong> {{name}} </strong>
</body> </html>
Controller:
var helloApp = angular.module('helloApp', []);

helloApp.controller('HelloController', function($scope) {
   $scope.name = 'world';
});
Output


download

Friday, May 22, 2015

Major Web applications attacks in .Net

As a Programmer, when we write code, we will concentrate on the functionality and output, but we are least bother about security of the application. Secure code gives always freedom from hacking.

Below are few known attacks of web application (OWSAP top 10 .Net attacks)

  1. Security Misconfiguration
  2. Cross Site Scripting
  3. SQL Injection
  4. Cross Site Request Forgery
  5. Failure to Restrict URL Access
  6. Insuffitient Transport Layer protection
  7. Unvalidated redirects and Forwards
  8. Insecure Direct Object Reference
  9. Authentication Breach
  10. Insecure Cryptographic Storage

Wednesday, June 13, 2012

Android versions and version codes

All of us learned A for apple and B for ball, isn't it?. Google followed same approach for version code names. Version code names also follows same approach except A.They left A coz i think A for Android.

Th following are the versions and and code names

Version
Version Code
API
1.0 and 1.1
BASE
1,2
1.5
CUPCAKE
3
1.6
DONUT
4
2.0.x and 2.1.x
ÉCLAIR
5,6,7
2.2.x
FROYO
8
2.3.x
GINGERBREAD
9,10
3.x
HONEYCOMB
11,12,13
4.0.x
ICE-CREAM-SANDWICH
14,15
4.1.x
JELLY BEAN

Thursday, May 31, 2012

Scheduling background task using Alarm Manager Android

All of us know, what Alarm does. Alarms will run in the background, whenever it counter the time, plays nice Music. Alarm wake-up us. Every phone has this feature from low end to high end mobiles.

In Android, we can use Alarms to schedule the tasks. Android has Alarm manager to manage these Alarms.

Service, perform long-running operations in the background and does not provide a user interface.

We need to use Alarm manger as well as service for scheduling background task like downloading information at particular time.

Steps to Create background task :
1. Create project, specify default activity. The following code to set schedule and cancel schedule for background task
public void btnStartSchedule(View v) {

  try {
   AlarmManager alarms = (AlarmManager) this
     .getSystemService(Context.ALARM_SERVICE);

   Intent intent = new Intent(getApplicationContext(),
     AlaramReceiver.class);
   intent.putExtra(AlaramReceiver.ACTION_ALARM,
     AlaramReceiver.ACTION_ALARM);

   final PendingIntent pIntent = PendingIntent.getBroadcast(this,
     1234567, intent, PendingIntent.FLAG_UPDATE_CURRENT);

   alarms.setRepeating(AlarmManager.RTC_WAKEUP,
     System.currentTimeMillis(), 10000, pIntent);
   
   toast("Started...");
  } catch (Exception e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

 }

 public void btnCancelSchedules(View v) {

  Intent intent = new Intent(getApplicationContext(),
    AlaramReceiver.class);
  intent.putExtra(AlaramReceiver.ACTION_ALARM,
    AlaramReceiver.ACTION_ALARM);

  final PendingIntent pIntent = PendingIntent.getBroadcast(this, 1234567,
    intent, PendingIntent.FLAG_UPDATE_CURRENT);

  AlarmManager alarms = (AlarmManager) this
    .getSystemService(Context.ALARM_SERVICE);

  alarms.cancel(pIntent);
  toast("Canceled...");
 }
2. Create AlarmReceiver, for waking up the task
public static String ACTION_ALARM = "com.alarammanager.alaram";

 @Override
 public void onReceive(Context context, Intent intent) {
  
  Log.i("Alarm Receiver", "Entered");
  Toast.makeText(context, "Entered", Toast.LENGTH_SHORT).show();
  
  Bundle bundle = intent.getExtras();
  String action = bundle.getString(ACTION_ALARM);
  if (action.equals(ACTION_ALARM)) {
 Log.i("Alarm Receiver", "If loop");
 Intent inService = new Intent(context,TaskService.class);
 context.startService(inService);
  }
  else
  {
 Log.i("Alarm Receiver", "Else loop");
 Toast.makeText(context, "Else loop", Toast.LENGTH_SHORT).show();
  }
 }
3. Create a Service do background task
public class TaskService extends IntentService {

 public TaskService() {
  super("TaskService");
  // TODO Auto-generated constructor stub
 }

 @Override
 protected void onHandleIntent(Intent arg0) {
  
  // Do some task
Log.i("TaskService","Service running");
 }

}
4. Specify the receiver and service in the Manifest file.

<application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".AlaramScheduleActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver
            android:name="AlaramReceiver"
            android:process=":remote" >
        </receiver>

        <service android:name=".TaskService" >
        </service>
    </application>
References : download_source_code

Saturday, May 5, 2012

My New Mobile HTC One X and its Reviews

Recently, Went to service center for repairing my old phone Samsung galaxy Captivate. They told that phone screen is damaged and have to replace the screen. i asked him that “How much will you charge for changing screen”. He told that it will cost around 10,000. I shocked and realized it is the time to change the phone. 

I have done market research on android phones as well as apple, Came to know that HTC One series mobile are good as per software and hardware. 

Checked HTC One X features and bought it.

Specifications :
Processor : 1.5 GHz Quad core processor
Display : 4.7-inch (1280 x 720 resolution) - HD 720p touch
RAM : 1 GB
Music: Beats Audio
Connectivity : NFC, Wi Fi, Wi Fi Direct, Bluetooth
Camera : 
  • 8 megapixel camera with auto focus, smart LED flash, and BSI sensor (for better low-light captures)
  • 1.3 megapixel front camera (720p for video chat)
Memory : 32GB Internal memory
Software : ICS - 4.0.3

Reviews : 
  1. Camera quality is extra ordinary
  2. Audio is awesome
  3. Display is mind blowing 
  4. Battery life is not too bad
Coming to negatives, it does not have extra SD card port. i feel 32 GB is enough for mobile devices. Also, phone heats a lot whenever playing games and using camera for more time.




At the end, i feel HTC OneX is the best phone in the market as of now. 


References : http://www.htc.com/www/smartphones/htc-one-x/

Thursday, March 29, 2012

Bind Spinner (Dropdown) Android

As a beginner, It is difficult to bind the data to Spinner (Drop down). If we consider HTML, it is easy to add option values to the drop down. But In Android, we have to use Adapters to bind the data. So here I am targeting my approaches to bind to the Spinner. 

Binding static Array to the spinner

static final String[] COUNTRIES = new String[] { "India", "US", "UK",
   "Sri Lanka", "Austraila", "Denmark", "Saudi" };

Spinner spCountry = (Spinner) findViewById(R.id.spCounty);

ArrayAdapter<CharSequence> adCountry = new ArrayAdapter<CharSequence>(
                this, android.R.layout.simple_spinner_dropdown_item, COUNTRIES);  

adCountry.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
 
spCountry.setAdapter(adCountry);

Binding resource Array to the Spinner

Spinner spCities = (Spinner) findViewById(R.id.spCities);

String[] cities = getResources().getStringArray(R.array.arr_cities);

ArrayAdapter<CharSequence> adCities = new ArrayAdapter<CharSequence>(
       this, android.R.layout.simple_spinner_item, cities);

adCities.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 

spCities.setAdapter(adCities);

Binding resource Array to the Spinner Using ArrayAdapter.createFromResource

Spinner spLocalities = (Spinner) findViewById(R.id.spLocality);

ArrayAdapter<CharSequence> adLocalities = ArrayAdapter
   .createFromResource(this, R.array.arr_localities,android.R.layout.simple_spinner_item);

adLocalities.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

spLocalities.setAdapter(adLocalities);



References : download_source_code       
http://developer.android.com/resources/tutorials/views/hello-spinner.html
http://developer.android.com/reference/android/widget/ArrayAdapter.html

Monday, March 26, 2012

Openframeworks Vs A Day Made of Glass

Few days ago, I watched a video - "A day made of glass".My reaction was, "When will I see this technology in action?"





Few months later, I found one framework by name "OpenFrameworks". I realize that the things that were shown in " A day made of Glass" are possible by this framework.

Here is the one of the most popular game - SNAKE, implemented using openframeworks in a different way.

 

Wednesday, March 7, 2012

Android Preparing Development Environment

I feel many developers wants to write mobile app and run in their mobile. Tools are plays important role while developing any application. Like wise, If you want to develop android app, first you need to prepare develop environment. In this post will see how to install and create hello world project.

What to install ?
  1. Java ( JDK5 or JDK6 or any latest version )
  2. Android
    1. SDK
    2. Platforms ( at least one )
  3. Eclipse
  4. Eclipse ADT
Java

If Java is not installed in system, you need to download the java file from the following link and install it.

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Android SDK

If Android SDK is not installed in system, you need to download the SDK file from the following link and install it.

http://developer.android.com/sdk/index.html

Eclipse

If Eclipse is not available in machine, you need to download from the following link.
http://www.eclipse.org/downloads/

Note: No need to install eclipse, download and extract the eclipse. You will find eclipse.exe, just open this. 

Eclipse ADT

  1. Start Eclipse, then select Help > Install New Software....
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
  1. Click OK
Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
  1. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  2. In the next window, you'll see a list of the tools to be downloaded. Click Next.
  3. Read and accept the license agreements, then click Finish.
Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.

Android Platforms

After successful installation, you will find SDK Manager.exe or AVD Manager.exe files in android installation folder.
  • Open the SDK Manager.exe, you will find the following screen
 
  • Select the platforms which you want to install. (it is better to install Eclair[ 2.1 ], Froyo[ 2.2], Gingerbread[2.3.3] and Honey Comb coz will find only these platforms in mobiles and tabs as per present market)
  • Click on the Install Packages and then select Accecept all, Click install

  • After successful installation, open the AVD Manager and create virtual device by clicking New button
 

  Creating Helloworld project
  1. Open eclipse by clicking on eclipse.exe
  2. Click on File -> New 

 3. Select the Android project
 4. Will find Create New Project Window, type the Project Name as Helloworld
 5. Next screen, will find Select Build target window. Select target platform, Click next


 
6. Here you will find Application name and project name. Type some names and click on the Finish button.



7. Run the application by clicking Run button and select Run as Android project.

You done... You will be able to see hello world application in Emulator.

Good luck :-)

References : http://developer.android.com/resources/tutorials/hello-world.html
                    http://developer.android.com/sdk/installing.html