Skip to content

Instantly share code, notes, and snippets.

View dariush-fathie's full-sized avatar
😙
I may be slow to respond.

dariush-fathie

😙
I may be slow to respond.
View GitHub Profile
@dariush-fathie
dariush-fathie / DispatcherProvider.kt
Last active August 26, 2021 12:47
Testable viewModel
interface DispatcherProvider {
val mainImmediate: CoroutineDispatcher
val io: CoroutineDispatcher
val default: CoroutineDispatcher
val unconfined: CoroutineDispatcher
}
@dariush-fathie
dariush-fathie / MainViewModel.kt
Last active August 25, 2021 17:05
ViewModelScope Extensions
class MainViewModel : ViewModel() {
private fun doIoOperation() = onIO {
// do your IO work here
}
private fun heavyCalculation() = onDefault {
// do your calculation here
}
// Implementation details omitted. Check out full sample
class DrawingCanvas: View(context) {
// When the user pinches the view, zoom in, when they reverse pinch the view, zoom out
private val scaleGestureDetector = ScaleGestureDetector(context, object :
ScaleGestureDetector.SimpleOnScaleGestureListener() {
override fun onScale(detector: ScaleGestureDetector?): Boolean {
detector?.let {
scaleX *= detector.scaleFactor
scaleY *= detector.scaleFactor
@dariush-fathie
dariush-fathie / LICENSE
Created April 11, 2020 13:32 — forked from rkirsling/LICENSE
Directed Graph Editor
Copyright (c) 2013 Ross Kirsling
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
@dariush-fathie
dariush-fathie / README.md
Created April 5, 2020 21:51 — forked from cjrd/README.md
Interactive tool for creating directed graphs using d3.js.

directed-graph-creator

Interactive tool for creating directed graphs, created using d3.js.

Demo: http://bl.ocks.org/cjrd/6863459

Operation:

  • drag/scroll to translate/zoom the graph
@dariush-fathie
dariush-fathie / D3JS Tree Editor.md
Created April 4, 2020 21:49 — forked from adamfeuer/ D3JS Tree Editor.md
d3js tree editor with node create, delete, and rename
We couldn’t find that file to show.
@dariush-fathie
dariush-fathie / SignatureCheck.java
Created April 2, 2020 21:18 — forked from scottyab/SignatureCheck.java
Simple Android signature check. It's not bullet proof but does increase the difficulty of backdooring the app
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.Signature;
public class TamperCheck {
//we store the hash of the signture for a little more protection
private static final String APP_SIGNATURE = "1038C0E34658923C4192E61B16846";
@dariush-fathie
dariush-fathie / Installer
Created April 2, 2020 21:17 — forked from scottyab/Installer
Tamper checks
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
public class InstallerCheck{
private static final String PLAY_STORE_APP_ID = "com.google.android";
public static boolean verifyInstaller(final Context context) {