Skip to content

Instantly share code, notes, and snippets.

View martinomburajr's full-sized avatar
🦆
Relentlessly pursuing those carbs

Martin Ombura Jr. martinomburajr

🦆
Relentlessly pursuing those carbs
View GitHub Profile
@martinomburajr
martinomburajr / medium-main-method-vb.vb
Created December 7, 2017 11:47
Visual Basic Programming Language - Main Method
Sub Main()
Debug.Print "Hello World!"
MsgBox "Arguments if any are: " & Command$
End Sub
public class Parent {
public static void main(String []args) {
System.out.println("Im in the parent main method!");
}
}
//This is the class that is run
public class Child {
public static void main(String []args) {
Parent.main(args);
public class Parent {
public static void main(Object []args) {
System.out.println("Im in the main method!");
}
}
/**
* Retrieved from AOSP
* H class embedded in the ActivityThread class
*/
private class H extends Handler {
//Several Application State Identifiers ...
public void handleMessage(Message msg) {
//other code
switch (msg.what) {
/**
* Retrieved from AOSP.
* ActivityThread class
*/
private void handleLaunchActivity(ActivityClientRecord r, Intent customIntent, String reason) {
//... initialize graphics,do some logging, call GC if need be, etc
Activity a = performLaunchActivity(r, customIntent);
//... handle how to resume an existing activity
}
/**
* Retrieved from AOSP
* ActivityThread class
*/
//Handler created within the ActivityThreadClass, that holds a variety of id's for app events/states
private class H extends Handler {
public static final int LAUNCH_ACTIVITY = 100;
public static final int PAUSE_ACTIVITY = 101;
public static final int PAUSE_ACTIVITY_FINISHING= 102;
@martinomburajr
martinomburajr / medium-starting-activity-main-instrumentation-class.java
Created December 15, 2017 19:27
Instrumentation class, calling the Activity's onCreate
/**
* @Retrieved from AOSP
* Instrumentation class
*/
public void callActivityOnCreate(Activity activity, Bundle icicle) {
//Note that the activity has already been initialized thanks to the prepareLaunchActivity().
//all that remains is just calling onCreate()
prePerformCreate(activity); //prepares the activity
activity.performCreate(icicle); //calls the oncreate
postPerformCreate(activity);
@martinomburajr
martinomburajr / java-simple-server.java
Last active May 1, 2021 16:18
This is a simple server written in Java! Use Netcat or Telnet to connect to it!
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
/**
* Written by Martin Ombura Jr. <@martinomburajr>
*/
public class MyServer {
public static void main(String[] args) {
@martinomburajr
martinomburajr / java-multithreaded-server.java
Last active May 12, 2018 05:25
This is an improvement to our simple server we created earlier. It now supports more than 1 simultaneous connections.
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Scanner;
/**
* Written by Martin Ombura Jr. <@martinomburajr>
*/
public class MyServer {
public static void main(String[] args) {
@martinomburajr
martinomburajr / medium-building-a-go-web-app-from-scratch-to-deploying-on-google-cloud-welcome-app-main.go
Last active December 9, 2020 10:19
medium-building-a-go-web-app-from-scratch-to-deploying-on-google-cloud-welcome-app-main.go
package main
import (
"net/http"
"fmt"
"time"
"html/template"
)
//Create a struct that holds information to be displayed in our HTML file
type Welcome struct {