Category Archives: Programming Reference

Git (for Projects)

Place .gitignore file in the project’s root directory. (It can be version-ed). The .git/info/exclude can be configured to ignore personal project settings. The .git folder carries settings adjusted for the local user.

git config credential.helper store
git push -u origin master
Username:
Password:

Git will then not ask for username and password again and again.

The GIT Primer

Pulling a fresh Project from a repository first time

git fetch (to sync the project between different machines)

 

Create a file -> Add the file to staging area by commit –> modify the file and  add the file to staging area commit and –> Push

git clone https://nitinc@bitbucket.org/nitinc/eclipseinitialtest.git (for HTTPS…easier and more intuitive!!)

git log (shows all committed logs…AFTER CLONING)
git branch (showed only master…not r2….SEE)

DO GLOBAL GIT SETTINGS (for commits to recognize you)
git config –global user.name “Nitin Chaurasia VM”
git config –global user.email nitinc@bgsu.edu
git config –global color.ui tru

Networking

  • Switch –> Firewall –> Router –> Modem ———->INTERNET!!
  • Switch has Wireless Access Points (WAP) to allow wireless devices to be connected to it, and various computers are connected physically through wires to the switch.
  • Physical v/s Logical connection -> within a switch we can have logical connection.
  • Speed –> 12Mbps = 1.5 MBps (vendors talk in terms of bits to make it look bigger, divide by 8 and check)

The Modem

converts the signals into

OO Concepts

Class : Abstract Definition of something that has (attributes and Actions – AA)

  • attributes (variables, properties or state)
  • actions (methods)

Object : A specific instance of a class.

4 Concepts

Encapsulation: is Hiding Data

  • by declaring the attributes (variables) private and
  • using accessors (getters) and mutators (setters) methods to access them.
  • both getters and setters are public.

Abstraction : 

 “An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of object and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer.” — G. Booch,

  • providing only essential information to the outside world and hiding their background details

Inheritance  : 

 

Polymorphism : 

Polymorphism means one name, many forms.  Polymorphism manifests itself by having multiple methods all with the same name, but slighty different functionality

Serialization

“serializable” means converting an instance of a class (an object) into a format where it can be written to disk, or transmitted over a network.

“Deserialization” is the opposite – reading data from the disk to create an object.

In Java it is an interface that if implemented in a class, means that it can automatically be serialized and deserialized by the different serializers.

.gitignore

# IntelliJ Ignore file

.idea/
*.iml
*.iws
out/
*.DS_Store
#The .gitignore for the Android Project developed on Eclipse

# Macintosh files
.DS_Store

# generated files (except .apk)
bin/
!bin/*.apk 
gen/
libs/

# Eclipse project files
.classpath
.settings
.project
project.properties

# built application files
!*.apk
# files for the dex VM
*.dex

# Java class files
*.class


# Proguard folder generated by Eclipse
proguard-project.txt
proguard/

lint.xml

Handy Android methods

//Log Message
String msg = "Nitin inside MainActivity: ";
Log.e(msg,"Inside BroadCast Intent Method in Main Activity");

//Toast Message
Toast.makeText(getApplicationContext(),"Flashing Message", Toast.LENGTH_LONG).show();
Toast.makeText(this,"Flashing Message", Toast.LENGTH_LONG).show();
//sending the intent from mainActivity to TweetListActivity
Intent intent = new Intent(MainActivity.this, Next_Activity_To_Go.class);
startActivity(intent);
//Picking up the values from the TextBox which is called EDITTEXT View (R.id.enter_username) in Android.

EditText userName = (EditText) findViewById(R.id.enter_username);
//Convert into String
String userNameValue = userName.getText().toString();
//Check the result in LogCat
Log.d("CodeLearn","username cought = " + userNameValue);
// For on Click of a LIST
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
/* Picking up the tweetTitle textView and change its value */
//TextView t = (TextView) v.findViewById(R.id.tweetTitle);
//t.setText("Tweet Clicked");

//Calling another page (TweetDetail Activity)
Intent intent = new Intent(this, TweetDetailActivity.class);
startActivity(intent);
}

/* OnClickListener for a Button */

//Inline
findViewById(R.id.button).setOnClickListener(new View.OnClick
@Override
public void onClick(View v){
Toast.makeText(this, "Button Clicked :)", Toast.LENGTH_SHORT);
}
});
public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	/*setContentView is called withthe constant at
	 * R.layout.main to set the layoutcdefined in main.xml on the screen 
	 */
	setContentView(R.layout.activity_main);	
	}
@Override
public void onClick(View v) {
// Launch Activity Two
// Hint: use Context's startActivity() method
// Create an intent stating which Activity you would like to
// start
        Intent intent = null;
	intent = new Intent(ActivityOne.this, ActivityTwo.class);
// Launch the Activity using the intent
	startActivity(intent);
//in one Line
        startActivity(new Intent(ActivityOne.this, ActivityTwo.class));
}