Skip to content

Instantly share code, notes, and snippets.

View maxcruz's full-sized avatar

Max Cruz maxcruz

  • Barcelona, Spain
View GitHub Profile
@maxcruz
maxcruz / Composition.kt
Created May 19, 2020 06:41
Either suspend composition
package com.mytaxi.arrowplayground
import arrow.core.Either
import arrow.core.EitherOf
import arrow.core.fix
import arrow.fx.IO
import arrow.fx.extensions.io.async.effectMap
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlin.random.Random
package com.example.poc
import arrow.core.Either
import arrow.core.flatMap
import com.mytaxi.driver.core.presentation.AbstractPresenter
import com.mytaxi.driver.core.presentation.PresenterView
import com.mytaxi.driver.threading.APPLICATION_MAIN
import kotlinx.coroutines.withContext
import okhttp3.Interceptor
import okhttp3.OkHttpClient
@maxcruz
maxcruz / parallel_map.kt
Last active February 9, 2020 08:59
Run a map execution in parallel
suspend fun <I, O> Iterable<I>.parallelMap(function: suspend (I) -> O): List<O> =
coroutineScope {
map { async { function(it) } }.awaitAll()
}
@maxcruz
maxcruz / authentication_with_bcrypt_in_rails_4.md
Created October 18, 2018 07:47 — forked from thebucknerlife/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

package com.mercadoni.user.android.faq
import android.content.Context
import android.graphics.PointF
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.LinearSmoothScroller
import android.support.v7.widget.RecyclerView
import android.util.DisplayMetrics
/**
@maxcruz
maxcruz / 50-synaptics.conf
Created June 3, 2017 23:08
Thinkpad Touchpad
# Example xorg.conf.d snippet that assigns the touchpad driver
# to all touchpads. See xorg.conf.d(5) for more information on
# InputClass.
# DO NOT EDIT THIS FILE, your distribution will likely overwrite
# it when updating. Copy (and rename) this file into
# /etc/X11/xorg.conf.d first.
# Additional options may be added in the form of
# Option "OptionName" "value"
#
Section "InputClass"
@maxcruz
maxcruz / activity_book_detail.xml
Created January 24, 2017 13:17
Layout with nested scroll and collapsible image
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainContent"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
#!/usr/bin/env python
#*-* encoding: utf-8 *-*
# Algoritmo de la amistad - Sheldon Cooper (The Big Bang Theory)
import random #Modulo para generar numeros de forma aleatoria
class algoritmoAmistad(object):
def __init__(self):