Skip to content

Instantly share code, notes, and snippets.

View savioserra's full-sized avatar
🏠
Remote Work

Sávio Serra savioserra

🏠
Remote Work
View GitHub Profile
import { useState } from 'react';
export type RetryCallback<T> = (...args: any[]) => void | T | Promise<T>;
function useRetry<T, E = any>(callback: RetryCallback<T>) {
const [error, setError] = useState<E>();
const [retryCount, setRetryCount] = useState(0);
function watchRetry(callback: RetryCallback<T>) {
return async function (...args: any[]) {
@savioserra
savioserra / main.dart
Created March 10, 2021 05:34
Mouse Pointer
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
@savioserra
savioserra / machine.js
Created February 12, 2021 02:29
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
import { ObjectType, DeepPartial, EntityManager, Connection, FindConditions } from 'typeorm';
import { Injectable, Scope } from '@nestjs/common';
import { InjectConnection } from '@nestjs/typeorm';
import DataLoader from 'dataloader';
@Injectable({ scope: Scope.REQUEST })
export abstract class BaseService<M extends { id: string }> {
abstract get type(): ObjectType<M>;
protected loader: DataLoader<string, M>;
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@savioserra
savioserra / controller.dart
Created February 13, 2020 21:56
ObservableFuture
import 'package:mobx/mobx.dart';
part 'mainpage.controller.g.dart';
class ExampleModel {
final String observacao;
ExampleModel(this.observacao);
}
class MainPageController = _MainPageControllerBase with _$MainPageController;
abstract class Test {
final String value;
Test(this.value);
}
abstract class Test2 {
final String value;
Test2(String i) : value = i;
abstract class Test<T> {
Test(String a) {}
}
class Store {}
class AppController = _AppControllerBase with Store;
void main() {
var a = B(inject());
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
import 'package:flutter/material.dart';
import 'dart:math' as Math;
enum MarkerType { cross, circle, none }
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {