Skip to content

Instantly share code, notes, and snippets.


Ivan Terekhin JEuler

View GitHub Profile
JEuler / mime_to_extension.dart
Created Feb 9, 2020
MIME type to extension (dart) (media)
View mime_to_extension.dart
String mimeToExtension(String mime) {
switch (mime.toLowerCase()) {
case 'image/apng':
return 'apng';
case 'image/bmp':
return 'bmp';
case 'image/gif':
return 'gif';
case 'image/x-icon':
return 'ico';
View storage_service_example_impl.dart
/// Implementation of StorageService using Hive Key-Value DB
class StorageServiceImpl implements StorageService {
Future saveUser(User user) async {
final userToSave = DBUser(,,
final usersBox = await Hive.openBox('user');
View storage_service_example.dart
abstract class StorageService {
/// Save user to D
void saveUser(User user);
/// Get user from DB
Future<DBUser> getUser();
/// Stop all operations
void stop();
JEuler / some_kind_of_store.dart
Last active Dec 10, 2019
MobX Store example
View some_kind_of_store.dart
part 'some_kind_of_store.g.dart';
/// User Resources Store
class SomeKindOfStore = SomeKindOfStoreBase with _$SomeKindOfStore;
/// User Resources Store
abstract class SomeKindOfStoreBase with Store {
final WebService _webService;
final StorageService _storageService;
JEuler / flutter_app.dart
Last active Dec 10, 2019
View flutter_app.dart
class FlutterApp extends StatelessWidget {
final WebService _webService;
final StorageService _storageService;
FlutterApp(this._webService, this._storageService);
Widget build(BuildContext context) {
var localizationDelegate = LocalizedApp.of(context).delegate;
JEuler / reg_comments.txt
Created Sep 4, 2019
Regular to match comments.
View reg_comments.txt
View BaseActivityRx.kt
protected fun <T> subscribe(observable: Observable<T>?, observer: Observer<T>?, bind: Boolean = true) {
if (observable != null && observer != null) {
if (bind) {
.observeOn(AndroidSchedulers.mainThread(), true)
} else {
protected <T> void autoResubscribe(Observable<T> observable, ResubscriptionObserver<T> resubscriptionObserver) {
if (getObservableGroup() != null && observable != null) {
.compose(getObservableGroup().<T>transform((String) resubscriptionObserver.resubscriptionTag()))
JEuler / SendDataJob.kt
Created Feb 25, 2019
Priority queue job example
View SendDataJob.kt
class SendDataJob(private val dataInput: SomeDataClass) :
Job(Params(1).requireNetwork().persist().groupBy(“tag”)), KoinComponent {
// job is queued, need to update local storage
override fun onAdded() {
override fun onRun() {
val sendService: SendService? by inject()
JEuler / SendDataWorker.kt
Created Feb 25, 2019
SendData Worker example
View SendDataWorker.kt
class SendDataWorker(context: Context, params: WorkerParameters) : Worker(context, params), KoinComponent {
override fun doWork(): Result {
val sendService: SendService? by inject()
val data = inputData.getString("data")
val dataInput = getGsonForJoda()?.fromJson(data,
return try {
val query = sendService?.sendData(dataInput)
You can’t perform that action at this time.