Skip to content

Instantly share code, notes, and snippets.

View ehbc221's full-sized avatar
🏠
Working from home

El Hadj Babacar Cissé ehbc221

🏠
Working from home
  • Sonatel SA
  • Dakar, Sénégal
  • X @ehbc221
View GitHub Profile
@ehbc221
ehbc221 / jwt.interceptor.dart
Last active June 8, 2023 16:54
An interceptor for JWTs in Flutter, using dio and shared_preferences libraries. Handles retrieving the JWT in shared_preferences (when exists) and adding it to the request
import 'package:dio/dio.dart';
import 'package:expenza/config/injectable.dart';
import 'package:expenza/domain/user_preferences.dart';
import 'package:expenza/utils/log.utils.dart';
const String _tag = 'JwtInterceptor';
/// Jwt Interceptor.
///
/// This class provides the Jwt from the user's session to the request's header
@ehbc221
ehbc221 / base.repository.dart
Last active June 8, 2023 16:54
A wrapper for all your repositories in Flutter. Used to parse responses from your datasources (remote; ie: API / local; ie: SqfLite) with a unified Resource class, making it easy to have the same logic throughout your application UIs.
import 'dart:async';
import 'package:expenza/constants/global.constants.dart';
import 'package:expenza/domain/resource.dart';
import 'package:expenza/utils/log.utils.dart';
const String _tag = 'BaseRepository';
/// Base Repository that wraps all the app's repositories.
///
@ehbc221
ehbc221 / base.datasource.dart
Last active June 8, 2023 16:54
A wrapper around all your datasources (ie: API) in Flutter with the dio package. Responsible for calling the APIs and handling the response / errors parsing, and avoid redundancy.
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:expenza/constants/global.constants.dart';
import 'package:expenza/domain/resource.dart';
import 'package:expenza/network/dto/base.dto.dart';
import 'package:expenza/utils/log.utils.dart';
import 'package:expenza/utils/pagination.utils.dart';
import 'package:retrofit/dio.dart';
@ehbc221
ehbc221 / resource.dart
Last active June 8, 2023 16:55
A wrapper class for uniform data requesting (API / local database) for Flutter. Handles loading, success, and error data mapping.
import 'package:expenza/domain/models/type/json_map.type.dart';
import 'package:expenza/network/dto/pagintor.dto.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';
part 'resource.g.dart';
/// The types of status used for the api/database calls responses.
///
/// - author - @ehbc221
@ehbc221
ehbc221 / app.config.dart
Last active June 8, 2023 16:55
A configuration file for your Flutter environments
import 'dart:io';
import 'package:expenza/config/injectable.dart';
import 'package:expenza/config/my_http_overrides.dart';
import 'package:expenza/constants/api.constants.dart';
const String baseUrlKey = 'baseUrl';
const String environmentKey = 'ENVIRONMENT';
/// The application's environments.
@ehbc221
ehbc221 / criteria.mixin.dart
Last active June 8, 2023 16:53
A mixin for handling filtering criteria in Flutter
/// Wrapper for all the criterias.
///
/// - author - @ehbc221
/// - version - 1.0.0
/// - last updated - June 8th, 2023
mixin Criteria {
Criteria copy();
/// The search page.
abstract final int? page;
@ehbc221
ehbc221 / create-and-publish-npm-package.MD
Created October 27, 2022 17:21
Create and publish a npm package

Create and publish a npm package

How to create and configure your own npm repository

Let's take example as our new project name:

  1. Create and open the directory

    mkdir example
    

cd example

@ehbc221
ehbc221 / iterm2-solarized.md
Created September 22, 2022 15:54 — forked from kevin-smets/iterm2-solarized.md
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@ehbc221
ehbc221 / jhipster-json-folder-to-dot-notation.py
Last active June 23, 2022 09:22
Convert Jhipster translations to dot annotation (for Wieldy React Admin Template)
from getopt import getopt, GetoptError
from json import load, loads, dumps
from os import listdir, SEEK_END
from os.path import isfile, isdir, join
from sys import argv, exit, stdout
# Query Yes or No to the user
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via raw_input() and return their answer.
@ehbc221
ehbc221 / switch-docker-daemon.sh
Created May 24, 2021 19:04
Switch Docker Daemon
cd C:\Program Files\Docker\Docker
DockerCli.exe -SwitchDaemon