Skip to content

Instantly share code, notes, and snippets.


Georgi Mirchev n0m0r3pa1n

View GitHub Profile
View Effective Java

Effective Java Notes

Creating and Destroying Objects

Item 1: Consider static factory methods instead of constructors

  • One advantage of static factory methods is that, unlike constructors, they have names
  • A second advantage of static factory methods is that, unlike constructors, they are not required to create a new object each time they’re invoked
  • A third advantage of static factory methods is that, unlike constructors, they can return an object of any subtype of their return type
  • The main disadvantage of providing only static factory methods is that classes without public or protected constructors cannot be subclassed
n0m0r3pa1n /
Created Apr 1, 2017
Android Developer Toolbox - Notes

Android Developer Toolbox - Notes


  • Create different build variants which contain different code of your app
    • Internal - for the company. Embed a lot of tools to locate issues easily.
    • Production - only for customers

U+2020 application


Redux Rules

  1. Immutable state - it should not be changeable instead is replaced. Everything that changes in your app including the date and the UI state is stored in a single object tree.
  2. State is read only - to make a change you need to dispatch an action. An action is a plain javascript object. State = data, change = action

Pure vs Impure functions

  1. Pure 2. Depend only on their input params 3. Some value for some input elements
View gist:956725eb5912f07002e5
//This method is supposed to tell the sockets server
//to post an refresh event with data to a selected client id
export function* postRefreshEvent(clientId, data) {
var connection = require('')({ host: '', port: 8081 });
connection.emit('refresh', clientId, data);
return {statusCode: OK}
// Websockets
View gist:cc09d3b931f010ee0ccf
private static final String DATABASE_NAME = "BGHISTORY_v3";
private static final String DATABASE_PATH = "/data/data/com.nmp90.bghistory/databases/";
private void copyDataBase() throws IOException {
//Open your local db as the input stream
InputStream myInput = myContext.getAssets().open(DATABASE_NAME);
// Path to the just created empty db
You can’t perform that action at this time.