Skip to content

Instantly share code, notes, and snippets.

View girish3's full-sized avatar
🎯
Focusing

Girish Budhwani girish3

🎯
Focusing
View GitHub Profile
@girish3
girish3 / poodir-notes.md
Last active June 16, 2019 04:24 — forked from speric/poodir-notes.md
[Notes From Practical Object-Oriented Design In Ruby" by Sandi Metz] #design_pattern
@girish3
girish3 / kotlin_basics.md
Last active May 31, 2019 13:49
[Kotlin basic syntax] #kotlin

1. Kotlin primary header constructor

// the immutable parameters passed to the constructor are not member variables!, they need to be explicitly created as below
// parent class takes in the passed values to the child class.
class MyListAdapter(ctx: Context, res: Int) : ArrayAdapter<String>(ctx, res)
	val context: Context
    val resource: Int
    
    init {
    	context = ctx
@girish3
girish3 / streams.md
Last active May 31, 2019 13:50
[What is InputStream & Output Stream in Java? Why and when do we use them?] #java

The goal of InputStream and OutputStream is to abstract different ways to input and output: whether the stream is a file, a web page, or the screen shouldn't matter. All that matters is that you receive information from the stream (or send information into that stream.)

InputStream is used for many things that you read from.

OutputStream is used for many things that you write to.

Here's some sample code. It assumes the InputStream instr and OutputStream osstr have already been created:

int i;
@girish3
girish3 / notes.md
Created September 30, 2018 12:43
[Futures and Promises] #design_pattern

In the broadest sense,

  • A future or promise can be thought of as a value that will eventually become available.
  • Future is used for sychronizing program execution.
  • Future acts as a proxy for an result which will be eventually available.
  • The construct ( future X ) immediately returns a future for the value of the expression X and concurrently begins evaluating X. When the evaluation of X yields a value, that value replaces the future.
  • A future is a placeholder object for a result that does not yet exist. A promise is a writable, single-assignment container, which completes a future. Promises can complete the future with a result to indicate success, or with an exception to indicate failure.
@girish3
girish3 / gradle_basics.md
Last active May 27, 2019 04:47
[Gradle basics] #android #android_tutorial #tutorial

Importand Gradle commands

how to list down all tasks of a project?
gradle tasks --all

Following command list down all task to be executed for a task but it does not execute the command.
gradle (some task) --dry-run
gradle assembleDebug --dry-run

@girish3
girish3 / kotlin_basics.md
Last active May 12, 2019 14:02
[Kotlin basics] #android
@girish3
girish3 / AvoidSetter.md
Last active August 16, 2018 06:00
[Building an object model without setters] #design_pattern

Some pointers

  • Having setters violates open/close principle, prevents information hiding (breaks encapsulation)
  • Discussing getter/setters vs public fields often obscures bigger problems with objects manipulating each others' internal state in an intimate manner and hence being too closely coupled. The idea is to make methods do what your business logic wants it to do, rather than have setters which change things at a field level.
  • One way to avoid writing setters is a task based approach to the model. Think of every task that is performed in an application and add a method that changes all the affected fields at once, to perform this task.

Ref:

@girish3
girish3 / speed_up.md
Last active April 5, 2020 05:11
[[Deprecated] Android studio/Gradle performance tips] #android

[Deprecated] migrated to notion

Gradle tweaks

Open or create a file called gradle.properties in .gradle directory. Inside the file, add following

  • org.gradle.parallel=true: Allow you to build multiple modules in the same project at the same time
  • org.gradle.daemon=true will turn on daemon so that every time we build the application, it doesn’t need to rerun the entire Gradle application every time.

Memory Allocation tweaks

@girish3
girish3 / menu.md
Last active February 17, 2019 09:37
[Menus] Menus are common user interface component in Android. It provides consistent user experience at the cost of flexibility. #android_snippet #android #android_tutorial #tutorial

Menus are common user interface component in Android. It provides consistent user experience at the cost of flexibility. You should use the Menu APIs to present user actions and other options in your activities.

There are 3 types of Menu:

Options menu

The options menu is the primary collection of menu items for an activity. It's where you should place actions that have a global impact on the app, such as "Search," "Compose email," and "Settings."

Context menu and contextual action mode

A context menu is a floating menu, like dialog, that appears when the user performs a long-click on an element. It provides actions that affect the selected content or context frame.

@girish3
girish3 / viewpager.md
Last active November 11, 2018 05:06
[View Pager incomplete, add fragment example] #android_snippet #android

A ViewPager is a ViewGroup that allows the user to flip left and right through pages of data. You supply an implementation of a PagerAdapter to generate the pages that the view shows.

Create a custom Pager Adapter

// override 4 methods as shown below
class MyPagerAdapter: PagerAdapter() {

    override fun instantiateItem(container: ViewGroup, position: Int): Any {