Skip to content

Instantly share code, notes, and snippets.

View getsadzeg's full-sized avatar

Guri Getsadze getsadzeg

  • AzRy
  • Tbilisi, GE
View GitHub Profile
getsadzeg /
Created October 25, 2015 12:55 — forked from coolaj86/
How to publish packages to NPM

Getting Started with NPM (as a developer)

If you haven't already set your NPM author info, now you should:

npm set "Your Name"
npm set ""
npm set ""

npm adduser

getsadzeg / Android Studio .gitignore
Created January 23, 2016 07:44 — forked from iainconnor/Android Studio .gitignore
A .gitignore for use in Android Studio
# Built application files
# Crashlytics configuations
# Local configuration file (sdk path, etc)
# Gradle generated files
getsadzeg /
Created May 14, 2016 10:38 — forked from jtan189/
Java PBKDF2 Password Hashing Code
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.SecretKeyFactory;
import java.math.BigInteger;
* PBKDF2 salted password hashing.
* Author: havoc AT
getsadzeg /
Last active March 28, 2017 14:14
GEOI2017, #1
package main;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class Rectangle {
public static void main(String[] args) {
getsadzeg /
Last active April 7, 2017 17:15
GEOI2017, #2 ( needs to be fixed )
package main;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;
public class Grid {
static int n = 0;
static int m = 0;

AsyncTask helps us to do some heavy stuff on the thread other than UI. It allows us to do background operations and then publish to UI.

It must be subclassed and goes like this(for example):

 AsyncTask<Parameters, Progress, Result>

And it has 4 steps: onPreExecute, doInBackground, onProgressUpdate, onPostExecute.

getsadzeg /
Last active September 12, 2018 09:10
What does Adapter do? Understanding RecyclerView

Adapter class is a helper to RecyclerView. It has three responsibilities: To return how many items should be in RecyclerView, inflate item views from XML and return new ViewHolder instance(object). and populate them with appropriate data(Basically, everything is in this order). So, it has (constructor and) three methods:


public MyAdapter(int numberOfItems, ListItemClickListener onClickListener)

where ListItemClickListener is an interface, which has one void methoid defined, onListItemClick.

getsadzeg /
Last active March 29, 2019 13:13
Understanding Android Lifecycle
  • onCreate -> Builds UI. Activity is created.

  • onStart -> Activity is visible.

  • onResume -> Becomes active foreground app.

In reverse:

  • onPause -> Activity has lost focus(for example, if it's partially obscured: a dialog pops up or whatever).
getsadzeg /
Last active April 17, 2019 18:09

So, let's imagine that we're making Preferences as Settings.

First, we make SettingsActivity, of course, which is the plain activity we all know of. Its XML must actually be a fragment, referring to SettingsFragment(which we'll make; extends PreferenceFragmentCompat) with android:name.

Second, we make SettingsFragment with its XML preference xml(<PreferenceScreen and nested preferences in it) in res/xml directory. And we bond the resource to a Fragment with addPreferencesFromResource method.

Then, we must not forget to add preference theme(@style/PreferenceThemeOverlay) to styles.xml, otherwise our app will crash.

getsadzeg /
Created April 19, 2019 17:23
Launchmode: SingleTop

If you configured the activity with singleTop launch mode, when you send an intent to android os to get a new instance of such activity, android os will first check the top activity in the back stack, if it is the requested activity type, it will return it, otherwise it will create a new instance of requested activity and return.

Yeah. Just sayin'.