Skip to content

Instantly share code, notes, and snippets.

View reu's full-sized avatar

Rodrigo Navarro reu

View GitHub Profile
module Grammar where
import Prelude
import Control.Applicative.Free (FreeAp, liftFreeAp, foldFreeAp)
import Control.Alt (class Alt, (<|>))
import Control.Alternative (class Alternative)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (log, CONSOLE)
import Control.Plus (class Plus, empty)
@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <[email protected]>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!

Why not both?

With the recent announcement of cats-effect, a relevant question from the past resurfaces: why does IO, which is otherwise quite Task-like, not define both or race? To be clear, the type signatures of these functions would be as follows:

object IO {
  def both[A, B](ioa: IO[A], iob: IO[B])(implicit EC: ExecutionContext): IO[(A, B)] = ???
  def race[A, B](ioa: IO[A], iob: IO[B])(implicit EC: ExecutionContext): IO[Either[A, B]] = ???
}
@mrkgnao
mrkgnao / Liege.hs
Last active August 27, 2019 18:11
Servant handled using free monads of coproducts of functors :)
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE ConstrainedClassMethods #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE IncoherentInstances #-}
{-# LANGUAGE InstanceSigs #-}
@staltz
staltz / comment.md
Created March 15, 2017 15:27
Nested Pick<T, K> in TypeScript 2.2

TypeScript supports Pick to allow you to get a "subset" object type of a given type, but there is no built-in Pick for deeper nested fields.

If you have a function that takes a large object as argument, but you don't use all of its fields, you can use Pick, Pick2, Pick3, etc to narrow down the input type to be only just what you need. This will make it easier to test your function, because when mocking the input object, you don't need to pass all fields of the "large" object.

@erickzanardo
erickzanardo / star-command.sh
Last active February 16, 2017 20:09
star-command
#!/bin/bash
function star-command {
if [ "$1" == "" ] || [ "$1" == "-h" ]; then
echo "star-command \"command to store on your favorites\""
echo "star-command -l \"list your favorites\""
elif [ "$1" == "-l" ]; then
cat ~/.star-commands
else
echo "$1" >> ~/.star-commands
@guimello
guimello / desafio_tagview_2016.md
Created October 13, 2016 20:46
Desafio Tagview 2016

Desafio Tagview 2016

Neste desafio você terá que desenvolver uma aplicação web ou mobile (iOS ou android).

Desta vez, você pode optar por diferentes tipos de aplicações. Abaixo está uma relação de APIs que você pode escolher:

  • Star Wars - personagens, planetas, espaçonaves, etc
  • Pokémon - informações diversas sobre eles
  • Marvel - personagens, séries, quadrinhos, etc
  • Blizzard Battle.net - estatísticas, chars, quests, bosses. Muitas informações sobre Diablo 3 e WoW
@pchiusano
pchiusano / fs2-0.9-release-announcement.markdown
Last active September 20, 2016 12:46
FS2: Functional Streams for Scala 0.9 Official Release Announcement

Hi all!

After a very lengthy period of development and testing, FS2 (formerly scalaz-stream) version 0.9 is finally out! Here's how to get it.

For this release, the library has undergone a major redesign. Check out the migration guide for more info, and also the shiny new user guide. Going forward, we expect the API of the library will be quite stable and hope it becomes one of the bedrock libraries of the Scala ecosystem. The 0.9 series has already seen production use as well as a huge amount of testing during the development process; we feel very good about recommending people upgrade.

@keeth
keeth / api.tf
Last active January 13, 2021 14:34
Apex + Terraform + AWS Lambda + API Gateway + JSON Encoded Errors + CORS
resource "aws_api_gateway_rest_api" "myApi" {
name = "myApi-${var.env}"
description = "My awesome API (${var.env} environment)"
}
resource "aws_api_gateway_deployment" "myApi" {
depends_on = [
"aws_api_gateway_integration.myApi_myEndpoint_post",
"aws_api_gateway_integration_response.myApi_myEndpoint_post",
"aws_api_gateway_integration_response.myApi_myEndpoint_post_400",
@dypsilon
dypsilon / reader.js
Last active April 28, 2024 08:50
Example usage of the reader monad.
/**
* This short program will encrypt the user password
* and insert a new record into a mock database.
*/
const Reader = require('fantasy-readers');
const R = require('ramda');
const crypto = require('crypto');
// our mock database
const database = [