Skip to content

Instantly share code, notes, and snippets.

Avatar
🦈
Baabyyy Shark tu tu ru tu tu tu

Roman Gonzalez roman

🦈
Baabyyy Shark tu tu ru tu tu tu
View GitHub Profile
@roman
roman / mvar.rs
Created Aug 18, 2019
Fun exercise of implementing Haskell's MVar in Rust
View mvar.rs
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
Heap Implementation in Java [shivers]...
View Heap.java
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 Sep 16, 2011
Experiments with Github + Redis + Haskell
View Github.hs
{-# 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)
View golang_sprintf_luxury.go
package main
import (
// "fmt"
"fmt"
"strings"
"testing"
)
// type Greeter interface {
@roman
roman / core.clj
Created Apr 10, 2015
Hystrix-clj hello world
View core.clj
(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
Proof for keybase to prove my identity on github
View keybase.md

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 Apr 25, 2018
Simplest example of concurrency with Schedulers
View schedulers.clj
(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 Feb 10, 2018
Playing around with Type families and Constraint kinds
View Example.lhs
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 #-}
@roman
roman / lib.hsfiles
Last active Jan 9, 2018
Snapshot of library skeleton for Haskell Projects
View lib.hsfiles
{-# START_FILE README.md #-}
# {{name}}
> Description of what this library does
## Table Of Contents
* [Raison d'etre](#raison-detre)
* [Library Usage](#library-usage)
* [Installation](#installation)
* [Development Notes](#development)
@roman
roman / throttle.hs
Last active Dec 7, 2017
Implementation of throttle in Conduit 0.5.x
View throttle.hs
import Control.Concurrent (forkIO, killThread,
threadDelay, newEmptyMVar,
tryTakeMVar, putMVar)
import Control.Monad (void, forever)
import Control.Concurrent.STM (atomically)
import Control.Monad.Trans (MonadIO(..))
import Control.Monad.Trans.Resource (MonadResource, allocate)
import Data.Conduit (GInfConduit, awaitE)
throttle :: (MonadResource m) => Int -> GInfConduit a m a