This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Fancy ID generator that creates 20-character string identifiers with the following properties: | |
* | |
* 1. They're based on timestamp so that they sort *after* any existing ids. | |
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs. | |
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly). | |
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the | |
* latter ones will sort after the former ones. We do this by using the previous random bits | |
* but "incrementing" them by 1 (only in the case of a timestamp collision). | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mypackage.myapp.prefs | |
import android.content.Context | |
import com.mypackage.myapp.appCtx | |
object MyPreferences : Preferences(name = "MyPrefsFileName") { | |
var userWantsFancyUi by BoolPref(Keys.FANCY_UI, false) | |
var isFcmTokenSent by BoolPref(Keys.FCM_TOKEN_SENT_TO_SERVER, false) | |
var eggTapsCount by LongPref(Keys.EGG_TAPS_COUNT, 0L) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.database.Cursor; | |
import android.support.annotation.Nullable; | |
import android.support.v7.util.DiffUtil; | |
/** | |
* Created by Nikola on 9/29/2016. | |
*/ | |
public abstract class CursorCallback<C extends Cursor> extends DiffUtil.Callback { | |
private final C newCursor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@file:Suppress("NOTHING_TO_INLINE") | |
import kotlin.experimental.and // Used for Byte | |
import kotlin.experimental.inv // Used for Byte | |
import kotlin.experimental.or // Used for Byte | |
inline fun Int.hasFlag(flag: Int) = flag and this == flag | |
inline fun Int.withFlag(flag: Int) = this or flag | |
inline fun Int.minusFlag(flag: Int) = this and flag.inv() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.annotation.SuppressLint | |
import android.content.ContentResolver | |
import android.database.Cursor | |
import android.net.Uri | |
/** | |
* @see ContentResolver.query | |
*/ | |
@SuppressLint("Recycle") | |
@Suppress("NOTHING_TO_INLINE") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2017. Louis Cognault Ayeva Derman | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.AlarmManager | |
import android.app.AlarmManager.ELAPSED_REALTIME_WAKEUP | |
import android.app.PendingIntent | |
import android.content.Context | |
import android.os.SystemClock | |
import android.support.annotation.IntRange | |
import com.google.firebase.provider.FirebaseInitProvider | |
import org.jetbrains.anko.alarmManager | |
import timber.log.Timber |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.android.gms.gcm.GcmTaskService | |
import com.google.android.gms.gcm.TaskParams | |
import com.example.androidapp.jobs.Jobs | |
import com.example.androidapp.jobs.tagsOfScheduledJobs | |
import timber.log.Timber | |
/** | |
* See [this issue](https://github.com/firebase/firebase-jobdispatcher-android/issues/6). | |
*/ | |
class JobDispatcherReschedulerWorkaroundService : GcmTaskService() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.text.Editable | |
import android.widget.EditText | |
import splitties.collections.forEachByIndex | |
import android.text.TextWatcher as AndroidTextWatcher | |
interface TextWatcher : AndroidTextWatcher { | |
override fun afterTextChanged(s: Editable) = Unit | |
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = Unit | |
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = Unit | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import re | |
import dns.resolver # Requires dnspython | |
email_host_regex = re.compile(".*@(.*)$") | |
gmail_servers_regex = re.compile("(.google.com.|.googlemail.com.)$", re.IGNORECASE) | |
def is_gmail(email): | |
""" Returns True if the supplied Email address is a @gmail.com Email or is a Google Apps for your domain - hosted Gmail address | |
Checks are performed by checking the DNS MX records """ |