View markdown.md
  1. The following line is bold
    Hi, I am Bold (**Hi, I am Bold**)

  2. The following line is given emphasis
    I am cooool. (*I am cooool.*)

  3. To write something on the new line, give two spaces and hit enter
    Yay! we are on the next line

  4. Now comes the Headline

View basics.md

regex for finding text with 2 substrings

Ex. 'git' and 'rm'

grep "git.*rm"

View SharedPreference.java
// MODE_PRIVATE means created file can only be accessed by the calling application.
// if the preference file ("file name") does not exist by the given name, file will be created.
SharedPreferences sharedPref = context.getSharedPreferences(
"file name", Context.MODE_PRIVATE);
// Use the following if you need to use only one shared preference file for the activity.
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
// Writing to it
SharedPreferences.Editor editor = sharedPref.edit();
View SpannableString.java
// https://stackoverflow.com/questions/10696986/how-to-set-the-part-of-the-text-view-is-clickable
SpannableString ss = new SpannableString("Android is a Software stack");
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
startActivity(new Intent(MyActivity.this, NextActivity.class));
}
};
// 0 is the start index and 7 is the end index
ss.setSpan(clickableSpan, 0, 7, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
View LayoutInflater.java
// if you are in an activity
LayoutInflater inflater = getLayoutInflater();
// If you have the context
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// or in a cleaner way, from() uses system service interally so its the same inflater
LayoutInflater inflater = LayoutInflater.from(context);
// inflating a view
// if you need to attach the inflated to rootView, returned view will be rootView.
// 3rd parameter is attach_to_root
View Intent.java
// starting an activity from another activity
// this is a Activity context
Intent intent = new Intent(this, AnotherActivity.java);
intent.putExtra(Intent.EXTRA_TEXT, "some text");
intent.putExtra("id", 4);
startActivity(intent);
// Receiving intent in AnotherActivity
Bundle extras = getIntent().getExtras();
View alert_dialog.java
// this is a context
AlertDialog.Builder builder = new AlertDialog.Builder(this);
// Check other builder methods like setCancelable, setIcon..
builder.setTitle("Set Title");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// do something
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
View MyKeyboardBindings.mkd
  • File structure (Navigate to functions, variables of the same class)

    cmd + r

  • Navigate Back to last cursor position

    cmd + [

  • Navigate Forward

    cmd + ]

  • Move Line/Lines up/down

View go_oop4.go
// Taking the same Go example as above
// Human and Student structs ....
human := Human{"John"}
// human will be passed by value, new copy will be created.
student := Student{human, 1}
View go_oop3.java
public class Human {
public String name;
public Human(String name) {
this.name = name;
}
}
public class Student {
private Human human;