Skip to content

Instantly share code, notes, and snippets.

View shafaque's full-sized avatar
🚀

Shafaque Sattar shafaque

🚀
View GitHub Profile
@shafaque
shafaque / kotlin_classes_basics.kt
Created December 9, 2019 11:56 — forked from gpetuhov/kotlin_classes_basics.kt
Kotlin Classes Basics
// this is empty class, constructor and curly braces are omitted
class EmptyClass
// this is class with constructor
class Person(name: String)
// constructor cannot contain any code
// initialization must be placed inside init blocks
// here name is not a property
class InitOrderDemo(name: String) {
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Build
import android.os.Bundle
/**
* Extensions for simpler launching of Activities
*/
@shafaque
shafaque / View.kt
Last active July 25, 2024 21:53
Extension for Views
fun View.showOnlyWhenEmpty(data: List<String>?) {
visibility = when {
data == null || data.isEmpty() -> View.VISIBLE
else -> View.GONE
}
}
fun View.cancelTransition() {
transitionName = null
}
@shafaque
shafaque / clean_code.md
Created July 10, 2018 10:04 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@shafaque
shafaque / http-status-codes.md
Created July 10, 2018 10:02 — forked from subfuzion/http-status-codes.md
General REST API HTTP Status Codes

Reference: RFC 2616 - HTTP Status Code Definitions

General

  • 400 BAD REQUEST: The request was invalid or cannot be otherwise served. An accompanying error message will explain further. For security reasons, requests without authentication are considered invalid and will yield this response.
  • 401 UNAUTHORIZED: The authentication credentials are missing, or if supplied are not valid or not sufficient to access the resource.
  • 403 FORBIDDEN: The request has been refused. See the accompanying message for the specific reason (most likely for exceeding rate limit).
  • 404 NOT FOUND: The URI requested is invalid or the resource requested does not exists.
  • 406 NOT ACCEPTABLE: The request specified an invalid format.
@shafaque
shafaque / introrx.md
Created July 10, 2018 10:01 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@shafaque
shafaque / README-Template.md
Created July 10, 2018 09:59 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@shafaque
shafaque / ImagePicker.java
Created April 20, 2017 06:46 — forked from Mariovc/ ImagePicker.java
Utility for picking an image from Gallery/Camera with Android Intents
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.content.res.AssetFileDescriptor;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.ExifInterface;
@shafaque
shafaque / README.md
Created April 13, 2017 13:00 — forked from lopspower/README.md
All InputType for EditText

All InputType for EditText

Twitter

Constant Description
none There is no content type. The text is not editable.