Skip to content

Instantly share code, notes, and snippets.

View roman's full-sized avatar

Roman Gonzalez roman

View GitHub Profile
@roman
roman / quickfix_ghc.vim
Created June 4, 2011 22:18
Code to use QuickFix with GHC + Cabal
" let mapleader='\'
" When using \b on normal mode, it will compile the
" project
nmap <LEADER>b :<C-u>make<CR>
" Close the QuickFix window just with the q
au FileType qf nnoremap <buffer> q :<C-u>cclose<CR>
" After compiling, open the QuickFix window if there
@roman
roman / ArbitraryInstances.hs
Created September 29, 2011 22:12
QuickCheck generator for Canonicalized and Normal URI generation
module Test.Util.ArbitraryInstances where
import Data.List (intercalate)
import Control.Applicative ((<$>), (<*>), pure)
import Network.URI (URI(..), URIAuth(..), uriToString)
import Test.QuickCheck
newtype URIPair
= URIPair { fromPair :: (String, String) }
deriving (Show)
@roman
roman / mvar.rs
Created August 18, 2019 21:46
Fun exercise of implementing Haskell's MVar in Rust
use std::sync::{Condvar, Mutex};
pub struct MVar<T> {
locked_value: Mutex<Option<T>>,
empty_cond: Condvar,
full_cond: Condvar,
}
// Methods of MVar that need the Clone type constraint
impl<T> MVar<T>
@roman
roman / Heap.java
Created May 22, 2012 19:49
Heap Implementation in Java [shivers]...
import java.util.ArrayList;
// This is a min heap
public class Heap {
protected int[] data = new int[1000];
public Heap() {
this.data[0] = 0;
}
@roman
roman / Github.hs
Created September 16, 2011 18:11
Experiments with Github + Redis + Haskell
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Control.Failure (Failure(..))
import Control.Monad.Trans (MonadIO, liftIO, lift)
import Control.Monad.IO.Control (MonadControlIO)
package main
import (
// "fmt"
"fmt"
"strings"
"testing"
)
// type Greeter interface {
@roman
roman / core.clj
Created April 10, 2015 18:03
Hystrix-clj hello world
(ns hystrix-hello-world.core
(:require
;; hystrix
[com.netflix.hystrix.core :as hystrix]
[hystrix-event-stream-clj.core :as hystrix-event]
;; http
[aleph.http :refer [start-http-server wrap-ring-handler]]
[clj-http.client :as http])
(:import [com.netflix.hystrix
@roman
roman / keybase.md
Last active May 13, 2018 14:54
Proof for keybase to prove my identity on github

Keybase proof

I hereby claim:

  • I am roman on github.
  • I am romanandreg (https://keybase.io/romanandreg) on keybase.
  • I have a public key ASAvDKNxvV3MbARSw0PrDLl-EggvvoUXWuOeXOm1igAWbQo

To claim this, I am signing this object:

@roman
roman / schedulers.clj
Last active April 25, 2018 15:47
Simplest example of concurrency with Schedulers
(ns rx.example.schedulers
(:require
[monads.core :refer [Monad] :as monad]
[clojure.core.match :refer [match]]
[disposables.core :as disposable]
[com.unbounce.treajure.io :as tio]
[rx.lang.clojure.core :as rx]
[clj-http.client :as http])
(:import
[java.util.concurrent Executors]
@roman
roman / Example.lhs
Last active February 10, 2018 23:15
Playing around with Type families and Constraint kinds
In this example we are using both *TypeFamilies* and *ConstraintKinds* to create a monadic
interface that keeps track of valid state transitions.
This is an evolution from @pittma experiments from the #haskell channel on the Functional Programming slack
> {-# LANGUAGE GADTs #-}
> {-# LANGUAGE DataKinds #-}
> {-# LANGUAGE StandaloneDeriving #-}
> {-# LANGUAGE MultiParamTypeClasses #-}
> {-# LANGUAGE RankNTypes #-}