Skip to content

Instantly share code, notes, and snippets.

View kiratheone's full-sized avatar
❤️
Kotlin

Arik Achmad kiratheone

❤️
Kotlin
View GitHub Profile
@kiratheone
kiratheone / Result.kt
Created June 22, 2021 05:32 — forked from cdmunoz/Result.kt
Generic Result sealed class to UI state management for a network result
sealed class Result<out T : Any> {
data class Success<out T : Any>(val data: T) : Result<T>()
data class Error(val exception: Exception) : Result<Nothing>()
object InProgress : Result<Nothing>()
val extractData: T?
get() = when (this) {
is Success -> data
is Error -> null
is InProgress -> null
@kiratheone
kiratheone / firebase-cloud-function-notification-to-topic.js
Created January 18, 2021 00:28 — forked from ricardodantas/firebase-cloud-function-notification-to-topic.js
Sample showing how to use Firebase Cloud Function to send push notification for a topic.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.database.ref('/messages/{pushId}/text').onWrite((event) => {
const data = event.data;
console.log('Message received');
if(!data.changed()){
console.log('Nothing changed');
return;

This is a list of tweaks to make IntelliJ IDEA work better with OpenJDK 8. Refer to System Properties for Java 2D Technology for the details of the options used below.

Note that the performance boost achieved via the OpenGL-based hardware acceleration pipeline is made possible by using the open-source Radeon driver (for AMD graphics cards) included in the latest stable version (10.3.3 as of now) of the Mesa 3D Graphics Library available in the official Fedora 21 stable repository. Therefore, the gained performance boost might vary based on the types of graphics cards and the versions of the drivers used in your system.

  1. Fixing Text Anti-aliasing in Fedora (Ubuntu users may skip this step.)
  2. Fixing text anti-aliasing in IntelliJ IDEA

In $IDEA_HOME/bin/idea64.vmoptions (or $IDEA_HOME/bin/idea.vmoptions on a x86 architecture), change

@kiratheone
kiratheone / gist:37629bf8671cccb4dc42d515e225056c
Created March 17, 2019 15:12 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@kiratheone
kiratheone / LiveData.ext.kt
Created October 29, 2018 14:37 — forked from tinmegali/LiveData.ext.kt
Kotlin extension to allow Unit tests on Android LiveData
package com.tinmegali.daggerwithkotlin.room
import android.arch.lifecycle.LiveData
import android.arch.lifecycle.Observer
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
// Extension to allow unit tests on LiveData
// discussion on: https://stackoverflow.com/questions/44270688/unit-testing-room-and-livedata
@kiratheone
kiratheone / 00_etc-hosts.md
Created October 22, 2018 16:25 — forked from mul14/00_etc-hosts.md
/etc/hosts for Vimeo, Netflix, Reddit, and Imgur.

Unblock Vimeo, Netflix, Reddit, dan Imgur

Linux / BSD / macOS

Tambahkan list di bawah ke /etc/hosts.

Windows

Tambahkan list di bawah ke %System32%\Drivers\etc\hosts

@kiratheone
kiratheone / ApiResponse.java
Created September 5, 2018 04:25 — forked from AkshayChordiya/ApiResponse.java
LiveData adapter for Retrofit
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.util.ArrayMap;
import java.io.IOException;
import java.util.Collections;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@kiratheone
kiratheone / RealPathUtil.kt
Created August 16, 2018 02:17 — forked from micer/RealPathUtil.kt
Utility class to get real path from URI object - all API versions
import android.content.ContentUris
import android.content.Context
import android.database.Cursor
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.DocumentsContract
import android.provider.MediaStore
import android.support.v4.content.CursorLoader
import android.text.TextUtils