Skip to content

Instantly share code, notes, and snippets.

View paulosuzart's full-sized avatar

Paulo Suzart paulosuzart

View GitHub Profile
package com;
import static java.lang.String.valueOf;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
@paulosuzart
paulosuzart / Application.java
Created November 11, 2021 10:34
first repeated char
public class Application {
static String solve(String word) {
Objects.requireNonNull(word);
Map<String, Integer> chars = new LinkedHashMap<String, Integer>();
for (int i = 0; i < word.length(); i++) {
var w = word.charAt(i);
chars.compute(String.valueOf(w), (k, v) -> {
if (v != null) {
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
@paulosuzart
paulosuzart / ReduxFetcher.js
Last active January 6, 2021 05:52
a simple abstraction for fetching, updating and filtering objects with correspondending state.
import {
XPTOService
} from '../services'
import { loginFailed } from './index.js'
const initial = {
filtering: {
data: []
},
listing: {}
@paulosuzart
paulosuzart / post.js
Last active July 17, 2020 13:02
post.js
import React, { useEffect } from "react";
import { connect, styled } from "frontity";
import Link from "./link";
import List from "./list";
import Item from "./list/list-item";
import FeaturedMedia from "./featured-media";
const Post = ({ state, actions, libraries }) => {
// Get information about the current URL.
const promiseWithTimeout = (timeoutMs, promise, failureMessage) => {
var timeoutHandle;
const timeoutPromise = new Promise((resolve, reject) => {
timeoutHandle = setTimeout(() => reject(new Error(failureMessage)), timeoutMs);
});
return Promise.race([
promise,
timeoutPromise,
]).then((result) => {
#lang racket
(require net/http-client)
(require net/url)
(require json)
(require net/uri-codec)
(require racket/cmdline)
(define lg (make-logger 'currency-logger))
(current-logger lg)
package example.controller
import arrow.fx.reactor.FluxK
import arrow.fx.reactor.extensions.fluxk.async.effect
import arrow.fx.reactor.value
import example.ParserService
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import reactor.core.publisher.Flux
@paulosuzart
paulosuzart / guess.rs
Last active June 13, 2019 14:13
book guess game modified a bit for fun
use std::cmp::Ordering;
use std::io;
use rand::Rng;
fn main() {
println!("Guess the number!");
let secret_number = rand::thread_rng().gen_range(1, 101);
let mut attempts : Vec<u32> = Vec::new();
package io.github.pauljamescleary.petstore.domain.destination
import scala.language.higherKinds
trait DestinationRepositoryAlgebra[F[_]] {
def destinations(departureId: Long): F[List[Long]]
}