Skip to content

Instantly share code, notes, and snippets.


Svetlozar Kostadinov sevar83

View GitHub Profile
wajahatkarim3 / ActivitiesLaunchingWay.kt
Last active Jun 24, 2021
Kotlin Extensions for simpler, easier and funw way of launching of Activities
View ActivitiesLaunchingWay.kt
* Kotlin Extensions for simpler, easier and funw way
* of launching of Activities
inline fun <reified T : Any> Activity.launchActivity (
requestCode: Int = -1,
options: Bundle? = null,
noinline init: Intent.() -> Unit = {})
davidwhitman / ViewOnceData.kt
Last active Oct 3, 2018
A class that encapsulates data, adding ability to know when the data has already been viewed. Useful for putting one-shot events, like "display dialog", into a State object that can be reapplied to a view.
View ViewOnceData.kt
import java.util.concurrent.atomic.AtomicBoolean
* Wraps some data that should track when it has been viewed and allow future viewers to avoid a second showing.
* Useful for showing messages in the app that auto-hide because this class can exist in the app's state.
data class ViewOnceData<T>(private val data: T) {
val wasViewed = AtomicBoolean(false)
internetmosquito / gist:b1c1f00ac99d9aa1f79cfdc21be36b5b
Last active Jun 11, 2018
How to encode images for Google Cloud Vision
View gist:b1c1f00ac99d9aa1f79cfdc21be36b5b
images_names = list()
for iterator, image_file in enumerate(images):
image_path = os.path.join(folder_name, image_file)
with open(image_path, 'rb') as image:
image_content = base64.b64encode(
image_payload = {}
image_payload['image'] = {}
image_payload['image']['content'] = image_content.decode('UTF-8')
vestrel00 /
Last active Nov 2, 2020
A: 2.11 simple example with support for Singleton, PerActivity, PerFragment, and PerChildFragment scopes
// This is a super simplified example of how to use the new framework
// introduced in Dagger 2.10. For a more complete, in-depth guide to
// read
// For a complete codebase using 2.11-2.17, butterknife 8.7-8.8, and MVP,
// see
// This example works with Dagger 2.11-2.17. Starting with Dagger 2.11,
// @ContributesAndroidInjector was introduced removing the need to define @Subcomponent classes.
yanngx / FragmentArgumentDelegate.kt
Last active Feb 20, 2021
Fragment arguments without hassle !
View FragmentArgumentDelegate.kt
package be.brol
import android.os.Binder
import android.os.Bundle
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created
class FooActivity extends MviActivity<...> {
@Inject FooPresenter
public void onCreate(Bundle bundle){
FooComponent component = DaggerFooComponent.builder()
.fooModule(new FooModule(bundle))
iago-suarez /
Last active Sep 14, 2020
Setting Up OpenCL for OpenCV on Android, the full story

Setting Up OpenCL for OpenCV on Android, the full story

The tutorial Use OpenCL in Android camera preview based CV application show us how we can use the Transparent API to dramatically increase the performance of some expensive operations.

The first step in order to be able to execute the tutorial example is to re-compile opencv with the correct flags:

# Export your NDK, it will be looked for OpenCV to compile your project. In my case
export ANDROID_NDK=~/graffter/libs/android-ndk-r10d/

# Download the necessary code
andymatuschak /
Last active Jun 24, 2021
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

View android_material_design_colours.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- google's material design colours from -->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>