Skip to content

Instantly share code, notes, and snippets.

View girish3's full-sized avatar
🎯
Focusing

Girish Budhwani girish3

🎯
Focusing
View GitHub Profile
def createAux(W):
# initializing the array aux with 0's
aux = [0] * len(W)
# for index 0, it will always be 0
# so starting from index 1
i = 1
# m can also be viewed as index of first mismatch
m = 0
while i < len(W):
W = "acabacacd"
T = "acfacabacabacacdk"
# this method is from above code snippet.
aux = creatAux(W)
# counter for word W
i = 0
# counter for text T
j = 0
// the example is in Java
class Base {
private int i = 0;
void inc1() {
i++;
}
void inc2() {
@girish3
girish3 / go_oop2.java
Last active March 25, 2018 17:50
golang oop 2 article snippet
// the example is in Java
class Base {
private int i = 0;
void inc1() {
inc2(); // the change
}
void inc2() {
// Go’s syntax is very much like C, you should be fine
// reading it.
// Defining Human type, it has a variable Name of type string.
// (Yes, type is mentioned after variable name)
type Human struct {
Name string
}
// Defining a method GetName on the type Human which
public class Human {
public String name;
public Human(String name) {
this.name = name;
}
}
public class Student {
private Human human;
// 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}
@girish3
girish3 / MyKeyboardBindings.mkd
Last active March 25, 2018 17:49
My customised IDE keyboard bindings
  • 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

@girish3
girish3 / alert_dialog.java
Last active November 11, 2018 05:07
[Alert Dialog] Alert dialog is created using a builder pattern #android_snippet #android
// 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() {
@girish3
girish3 / Intent.java
Last active November 11, 2018 05:07
[Intent] Intent snippets to start Activity, Service or sending broadcast. #android_snippet #android
// 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();