Saturday, April 25, 2015

Mac Hardware

mac models

OS X Yosemite version 10.10 Oct. 2014
Mavericks version 10.9 Oct. 2013

mac specs by machine model machine

apple authorized reseller
Ten Plus

The Air wins this round because it’s thinner and lighter

The Pro’s Retina display blows the Air’s 1440 x 900-pixel panel out of the water an HDMI port and an SDXC card slot. This means that the Pro can support up to two monitors at 2560 x 1600, as well as an additional monitor at 1080p. The Air can only support one external monitor

Processor and Memory:
Air comes with a 1.4-GHz Core i5-4260U processor, 4GB of RAM, 128GB of PCI Express storage, and Intel HD 5000 graphics. The 13-inch MacBook Pro, by comparison, features a 2.6-GHz Intel Core i5-4278U processor, 8GB of RAM

The 13-inch Air lasted 12 hours and 50 minutes on the LAPTOP Battery Test (Web surfing via Wi-Fi).

The Pro lasted 10 hours and 44 minutes, least expensive version of the 13-inch

Air costs $999 and comes with a 1.4-GHz Intel Core i5 processor, Intel HD Graphics 5000, 4GB of RAM and 128GB of flash storage.

The Pro with Retina display starts at $1,299 and includes a 2.6-GHz Intel Core i5 processor, 8GB of RAM, 128GB of flash storage and Intel Iris graphics. The more expensive version of the Air costs $1,199 and has the same processor and RAM as the starting version, but comes with 256GB of storage. - 2 air models - You're going to want to choose a Retina MacBook Pro if you're big on gaming - Get the MacBook Pro if you're a heavy user with processor-intensive tasks, but if you're like most people, and your computing tasks consist mainly of typing and web browsing, get the MacBook instead

Monday, December 15, 2014


firebase joins google - g+ page  why

three way binding:

We can synchronize our data back to Firebase by using the following methods provided by the $firebase object.

  • $add(value)
  • $remove([key])
  • $save([key])
  • $save()
  • $child(key)
  • $set(value)

create a free account

Once you are logged in, you can view your url  on

plunkr demo #1

Friday, December 5, 2014

client side reorder list

I am looking into jquery ui drag and drop grid row

Enable a group of DOM elements to be sortable. Click on and drag an element to a new spot within the list, and the other items will adjust to fit. By default, sortable items share draggable properties

items: Specifies which items inside the element should be sortable
handle:Restricts sort start click to the specified element.

stop( event, ui )Type: sortstop This event is triggered when sorting has stopped

example : 

Sunday, November 23, 2014

Coursera Content provider Exercise - week 8

This lab will build off of the week 7 Location lab. This application will have the same UI elements and behaviors as the week 7 Lab.

This application, however, manages a user's Place Badges using a ContentProvider.

Because ContentProviders persist data across application sessions, when the application initially starts up, it should get all existing Place Badges from the ContentProvider and display them on the screen.

PlaceViewAdapter extends CursorAdapter - see
- Adapter that exposes data from a Cursor to a ListView widget.
- swapCursor() : Swap in a new Cursor, returning the old Cursor.

This is the most important reason why you have to use swapCursor, it doesn’t close the Cursor when you swap it with another Cursor

- content: scheme indicating data that is managed by content provider
- authority: id for content provider
-path: 0 or more segments indicating type of data accessed
-id : optional is specific record within dataset

Provider: ContentProviderCustom

course.examples.ContentProviders.StringContentProvider.StringsContentProvider class

public synchronized Uri insert(Uri uri, ContentValues value) {

User: ContentProviderCustomUser

DataContract class:
public static final String _ID = "_id";public static final String DATA = "data";public static final String DATA_TABLE = "data_table";
private static final Uri BASE_URI = Uri.parse("content://course.examples.ContentProviders.StringContentProvider/");
// The URI for this table.
public static final Uri CONTENT_URI = Uri.withAppendedPath(BASE_URI,

CustomContactProviderDemo class:
ContentValues values = new ContentValues();
// Insert first record
values.put(DataContract.DATA, "Record1");
Uri firstRecordUri = contentResolver.insert(DataContract.CONTENT_URI, values); 

Coursera Location Exercise - week 7

The screencast for the assignment demonstrates a ListView containing a set of Place Badges.

There is a context menu in this application with a list of preconfigured locations.  The user will click on the context menu and select one of the menu items, specifically "Place One", "Place Two," or "Place No Country."

The application will be set up to listen for the context menu selections.  Moreover, when one of the menu items is chosen, the app will receive the corresponding location details.

The footer for the ListView displays the words "Get New Place." When the user clicks on the footer, the application will go out and retrieve  the place Badge based on the user's current location. Although,  when the application first starts, the user will not have any Place Badges.

Each Place Badge contains
  • a country flag
  • a country name
  • place name corresponding to the user's location when the Place Badge was acquired

For the case when the user clicks on the footer and the application does not already have a Place Badge for the location, the application will create and execute an AsyncTask subclass called PlaceDownloaderTask that acquires the data needed to create the Place Badge. As well, the application should prevent the user from clicking on the footer when the application has not selected  a valid user location.

The ListView documentation details how you work with this type of widget, such as dealing with footers.

The HelloAndroidWithMenus example application demonstrates how to of work with a context menu. 

The applications listens for location updates from a network connection. You have to create an account at Your username will need to be updated in

Coding details:

PlaceViewActivity extends ListActivity

- ListView placesListView is the list view used in the Activity
        placesListView. setFooterDividersEnabled(true);
                 - Enables or disables the drawing of the divider for footer views.
        mAdapter = new PlaceViewAdapter(getApplicationContext());

- private PlaceViewAdapter mAdapter;
implementation class provided,  extends BaseAdapter, makes use of a PlaceRecord class
- set up a Location Manager

(LocationManager) getSystemService(Context.LOCATION_SERVICE);

- private MockLocationProvider mMockLocationProvider : 
implementation class provided, has method to push a Location instance which specifies the longitude,latitude, altitude, time, elapsedRealtimeNanos. Note that the LocationManager class has a method called setTestProviderLocation()

On Resume : you start listening for location updates, get last known location if reading was recent

mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, mMinTime, mMinDistance, this);

mLastLocationReading = new Location(mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER)); 

Context Menu change handler method :

onOptionsItemSelected(d(MenuItem item)) - pushes location to the MockLocationProvider

ClickListener for the footer:

get a location reading:
mLastLocationReading = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if there is a reading:
if ((currentLocation != null) && (ageInMilliseconds(currentLocation) > ageInMilliseconds(mLastLocationReading))) {
           mLastLocationReading = currentLocation;

if there was already a place for this location in list:
"You already have this location badge",

Callback method used by PlaceDownloaderTask - check if the place you received has details, if so add it to list adapter:

                 boolean b = place.getCountryName().equals("");
                 if (b==false){
                 }  else {
                    "There is no country at this location",                     Toast.LENGTH_LONG).show();

Friday, November 21, 2014

Coursera (Week 8) DataManagement , Content Providers, and Services


Manage data across multiple application sessions

SharedPreferences class - small primitive data i.e. username, account name, user customizations
- persistent Map : key value pairs of simple data types
- automatically persisted across application sessions
- long term storage of customizable application data
- to get SharedPreferences class within an activity,  use Activity.getPreferences (int accessmode) - example of mode is MODE_PRIVATE
to get SharedPreferences class NOT within an activity,  use Context.getSharedPreferences(String name, in accessmode) - name example could be name of shared preferences file
- after saving object, can edit file using SharedPreferences.edit() method returns SharedPreferences.editor instance - putInt(key,value), putString(key,value), remove(key)
- SharedPreferences.editor.commit() to persist
- read it later SharedPreference object - getAll(),  getBoolean(key) , getString(key)

DataManagementSharedpreferences app

File - storage area internal (smaller, application private data sets) or
external (larger non private)
Internal device storage - medium amount data private  i.e. temp files
External device storage - large amount non private i.e. songs, pictures

File API - FileOutputStream - openFileOutput(String name, int mode)
- open private file for writing
- openFileInput() for reading
DataManagementFileInternalMemory app
- see if its exists, otherwise opens it, writes text to it, reads text, displays its
Context.openFileOuput method() - passed in an integer, Context.MODE_PRIVATE: only be accessed by applications sharing the same user ID as the calling application

databases - private structured data Complex SQL Lite databases

External memory - removable such as sdk card, appear or disappera without warning, first determine state of external emmory


DataManagementFileExternalMemory app

Cache files - temp files, cache directories, may be deleted when storage is low

- in memory relational database with small footprint

SqliteOpenHelper class
call super() from sublclass
override OnCreate() and onUpgrade()

DataManagementSql app
-DatabaseOpenHelper extends SQLiteOpenHelper
- android.database.Cursor

ContentValues values = new ContentValues(); values.put(DatabaseOpenHelper.ARTIST_NAME, "Frank Sinatra"); mDbHelper.getWritableDatabase().insert(DatabaseOpenHelper.TABLE_NAME, null, values); values.clear();

ContentValues values = new ContentValues();
values.put(DatabaseOpenHelper.ARTIST_NAME, "Johnny Cash");     mDbHelper.getWritableDatabase().update(DatabaseOpenHelper.TABLE_NAME, values, DatabaseOpenHelper.ARTIST_NAME + "=?", new String[] { "Jawny Cash" });


emulator terminal:
# adb -s  emulator-port# shell

#sqlite3 /data/data/course.examples.DataManagement.DataBaseExample/databases/artist_dbd

#sqllite3 -help


Fundamental component android : content providers - centralized repos of structured data
data to be shared across multiple app - inter-application data sharing
ContentResolver class
- databae style interfaxe for read write data
- notifies addtl services such as notify when data changed

Code running in one process access data in another process

standard content providers
Call Log
user dictionary
Represented as database table

Use URI - content providers referenced by URI

- content: scheme indicating data that is managed by content provider
- authority: id for content provider
-path: 0 or more segments indicating type of data accessed
-id : optional is specific record within dataset

example content://

following classes applications use to identify and access a ContentProvider:
- ContentResolver, URI


query returns a cursor, has input parms such as URI, columns , selection pattern, pattern args, and sort order

ContentProviderWithCursorAdapter app

- contacts provider and photo
- columns specified
- ContentResolver class reference
-query string pattern
- sort order
- query which returns cursor
-bindView method fills in view

CursorLoader - can take while to complete, avoid intensive operation
this class uses async task so its done on background thread
LoaderCallbacks interface
initLoader() - init and activate loader

callback onCreateLoader()
callback onLoadFinished()
callback onLoaderReset - previous loader reset

ContentProviderWithCursorLoader app
- getLoaderManager().initLoader(0,null,this) - this callback

onCreateLoader() method -  query returns new CursorLoader

onLoadFinished() - swap new cursor that is passed in into List adapter
OnLoaderReset() - called when last cursor to finished method is about to be closed


uri, sql pattern, pattern args

uri , parms

new field values, pattern

ContentProviders/ContactsListInsertContacts  app

mAccountList = AccountManager.get(this).getAccountsByType("");
-permission  android.permission.GET_ACCOUNTS

getContentResolver.applyBatch - does inserts all at once

Create content provider -

Implement storage system
Define a Contract class
ContentProvider subclass with insert,delete, etc
Declare it in manifest file

ContentProviderCustom app
- StringsContentProvider class
- delete method
- DataRecord object
-query method with MatrixCursor

manifest file is a provider tag
- exported to true

ContentProviderCustomUser app


Service class

Fundamental component - long running processes

work in background, one process interact with another process

remote method execution

starting it:
run in background indefinately
perform single operation, and dont transfer results
by default run on main thread
 - allows component to send requests and receive responses from a local or remote service
at binding time, start service if not started already. will run as long as one client connected


Tuesday, November 18, 2014

Links i have learned about lately - Spring Boot, Spring Data, Spring Rest and JQuery UI (see GalleryRepository class , PagingAndSortingRepository)