Skip to content

Instantly share code, notes, and snippets.

View douglasiacovelli's full-sized avatar

Douglas Iacovelli douglasiacovelli

  • @contratadome
  • Bertioga
View GitHub Profile
@douglasiacovelli
douglasiacovelli / auth_interceptor.dart
Created January 5, 2021 11:40
This is a code for an auth interceptor for Dio, which uses a header to avoid retrying indefinitely to refresh the token.
/// This interceptor is simplified because is doesn't contemplate
/// a refresh token, which you should take care of.
/// I haven't tested this code, but I believe it should work.
/// If you have some feedback, please leave a comment and I'll review it :) Thanks.
class AuthInterceptor extends InterceptorsWrapper {
final Dio loggedDio;
final Dio tokenDio;
interface Repository {
suspend fun getRedditPosts(): ResultWrapper<String>
}
class RepositoryImpl(private val service: RedditService,
private val dispatcher: CoroutineDispatcher = Dispatchers.IO) : Repository {
override suspend fun getRedditPosts(): ResultWrapper<RedditPosts> {
return safeApiCall(dispatcher) { service.getRedditPosts().toRedditPosts() }
}
import java.util.Scanner;
public class Loja{
static double calca = 100.00, camisa = 99.99, blusa = 75.10, sapato = 125.00, bermuda = 85.90, bone = 50.00, camiseta = 73.20;
static int codigoProduto;
static int [] listaCompra = new int [100];
static int posicao = 0;
public static void Lista () {
System.out.println("\n \t menu \n" );
System.out.println("1. Calca = R$ " + calca );
suspend fun <T> safeApiCall(dispatcher: CoroutineDispatcher, apiCall: suspend () -> T): ResultWrapper<T> {
return withContext(dispatcher) {
try {
ResultWrapper.Success(apiCall.invoke())
} catch (throwable: Throwable) {
when (throwable) {
is IOException -> ResultWrapper.NetworkError
is HttpException -> {
val code = throwable.code()
val errorResponse = convertErrorBody(throwable)
platform :ios do
# ... here comes the lanes we've created earlier
desc "deploy"
lane :deploy do
setup_ci
sync_code_signing(
type: "appstore",
app_identifier: 'com.company.example',
readonly: true
team_name "Your company's team name"
team_id "Your company's team id"
itc_team_id "Your company's Appstore connect id"
itc_team_name "Your company's team name"
platform :ios do
desc "Get certificates"
lane :certificates do
sync_code_signing(
type: "development",
app_identifier: ['com.company.example', 'com.company.example.stg'],
force_for_new_devices: true,
readonly: true
)
# These keys must be filled in order to fetch the certificates
# Git basic authorization for match encoded in base64
# This is only needed if the user is not authenticated using ssh on git or if you're running on CI/CD server.
# MATCH_GIT_BASIC_AUTHORIZATION=
# Password used to encrypt/decrypt certificates
MATCH_PASSWORD=
# (Optional) Your local machine password, such as the one you use to login.
@douglasiacovelli
douglasiacovelli / Matchfile
Created March 26, 2021 15:47
Matchfile sample
git_url("git@github.com:<yourcompany>/<repo>.git")
storage_mode("git")
type("development") # The default type, can be: appstore, adhoc, enterprise or development
import 'dart:async';
void main() {
escutarDeepLinks().listen((e) {
print(e);
}, onError: (error) {
print('deu erro vei. $error');
});