Skip to content

Instantly share code, notes, and snippets.

View zakayothuku's full-sized avatar
👨‍💻
Opportunities don't respect sleep

Zakayo Thuku zakayothuku

👨‍💻
Opportunities don't respect sleep
View GitHub Profile
@zakayothuku
zakayothuku / pagination.js
Last active May 8, 2019 09:46 — forked from proudlygeek/pagination.js
Pagination Helper Kata
// http://www.codewars.com/kata/515bb423de843ea99400000a/train/javascript
// TODO: complete this object/class
// The constructor takes in an array of items and a integer indicating how many
// items fit within a single page
function PaginationHelper(collection, itemsPerPage){
this.collection = collection;
this.itemsPerPage = itemsPerPage;
}
@zakayothuku
zakayothuku / XposedUtils.java
Created November 8, 2019 11:30 — forked from jaredrummler/XposedUtils.java
Utility methods for checking if the Xposed framework is installed.
/*
* Copyright (C) 2016 Jared Rummler <[email protected]>
*
* 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
@zakayothuku
zakayothuku / OnThrottleClickListener.kt
Created June 8, 2020 20:58 — forked from matpag/OnThrottleClickListener.kt
ThrottleClickListener prevent double click using OnClickListener
import android.os.SystemClock
import android.view.View
/**
* This is a custom clicklistener to prevent multiple click events to happens at the same time.
*
* Each click on a button is added in the internal event handler queue, there is no way to remove
* them from there so the only thing we can do is adding a filter to prevent them to run too
* frequently
*
package com.geekorum.geekdroid.navigation
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import androidx.core.content.res.use
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
package com.geekorum.geekdroid.navigation
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import androidx.core.content.res.use
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
@zakayothuku
zakayothuku / ReceiverRegistrar.java
Created June 11, 2020 18:15 — forked from curioustechizen/ReceiverRegistrar.java
Tiny utility class that helps avoid book-keeping code when dealing with registering and unregistering BroadcastReceivers. Hopefully, this will help you get rid of "Activity has leaked IntentReceiver that was originally registered here" messages without resorting to using boolean flags to keep track of your BroadcastReceivers.
package com.github.curioustechizen.safereg;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.util.ArrayMap;
/**
* Helper class to keep track of what {@code BroadcastReceiver}s have been
# Assume we are in your home directory
cd ~/
# Clone the repo from GitLab using the `--mirror` option
$ git clone --mirror [email protected]:mario/my-repo.git
# Change into newly created repo directory
$ cd ~/my-repo.git
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
@zakayothuku
zakayothuku / git-tag-delete-local-and-remote.sh
Created June 19, 2020 09:14 — forked from mobilemind/git-tag-delete-local-and-remote.sh
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@zakayothuku
zakayothuku / circleci
Created June 22, 2020 21:25 — forked from ajaysaini-sgvu/circleci
config.yml
version: 2
references:
## Cache
cache_key: &cache_key
key: cache-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "mobile/build.gradle" }}
restore_cache: &restore_cache
restore_cache:

Using Tinder's Finite State Machine Library to wrap Android's MediaPlayer

When developing software, it's sometimes very easy to get overwhelmed by complexity due to the number of interacting pieces.

This is a problem that's prevalent in all software development from Server-Side development, Front-End development and all the way to Android development.

In a bid to tame complexity software engineers building complex software have looked up to tools that help reduce this burden. One such tool is design using Finite State Machines.

In this tutorial we'll be using Tinder's State Machine to model an Entity and handle complexity of dealing with the many possible states it can be in a manner that makes it almost effortless.