Skip to content

Instantly share code, notes, and snippets.

View enchf's full-sized avatar

Ernesto enchf

  • Belgrade, Serbia
View GitHub Profile
@enchf
enchf / node-haskell.md
Created March 1, 2017 16:16 — forked from paf31/node-haskell.md
Reimplementing a NodeJS Service in Haskell

Introduction

At DICOM Grid, we recently made the decision to use Haskell for some of our newer projects, mostly small, independent web services. This isn't the first time I've had the opportunity to use Haskell at work - I had previously used Haskell to write tools to automate some processes like generation of documentation for TypeScript code - but this is the first time we will be deploying Haskell code into production.

Over the past few months, I have been working on two Haskell services:

  • A reimplementation of an existing socket.io service, previously written for NodeJS using TypeScript.
  • A new service, which would interact with third-party components using standard data formats from the medical industry.

I will write here mostly about the first project, since it is a self-contained project which provides a good example of the power of Haskell. Moreover, the proces

@enchf
enchf / MergeSort.scala
Created March 15, 2017 10:22 — forked from fancellu/MergeSort.scala
MergeSort in Scala with recursive merge
object MergeSort {
// recursive merge of 2 sorted lists
def merge(left: List[Int], right: List[Int]): List[Int] =
(left, right) match {
case(left, Nil) => left
case(Nil, right) => right
case(leftHead :: leftTail, rightHead :: rightTail) =>
if (leftHead < rightHead) leftHead::merge(leftTail, right)
else rightHead :: merge(left, rightTail)
@enchf
enchf / ruby-gem-cheatsheet.md
Last active July 20, 2018 16:00
Creating a Ruby Gem Cheatsheet

Creating a Ruby Gem Cheatsheet

Here you are the basics to create a Ruby Gem, with some appendix about interesting use cases. This guide tries to cover the minimum requirements to create a Gem using Ruby conventions. For more information, navigate to this link to see what is a Gem.

Step 0 - Have a good README

Most of Ruby Gems have lack of documentation, usage guides and examples. In order to make the usage comfortable would be important to have a robust guide.

@enchf
enchf / flatten.rb
Last active July 31, 2018 22:00
Implementation of a Flatten function in Ruby
# This gist shows two different implementation of a Flatten function in Ruby.
# The workaround is to do something like the Deep-First Search algorithm to 'visit' all items contained in recursive arrays.
# These items are being added to the returning array after visited.
# First implementation: Recursive.
# The function tests if the object passed as argument is an array.
# If it does, it iterates it recursively, otherwise it adds the element to the visited elements array (acc).
def recursive_flatten(obj, acc = [])
obj.is_a?(Array) ? obj.each { |i| recursive_flatten(i, acc) } : acc << obj
acc
@enchf
enchf / README-Template.md
Created August 21, 2018 22:38 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites