Skip to content

Instantly share code, notes, and snippets.

View aitoroses's full-sized avatar

Aitor Oses aitoroses

View GitHub Profile
@aitoroses
aitoroses / kmskeys10.txt
Created November 11, 2017 15:26 — forked from CHEF-KOCH/kmskeys10.txt
Windows 10 KMS Keys
Windows.10.and.Office.2016.gVLK
#####################################################################
# Install/Uninstall keys #
#####################################################################
1.) Uninstall the current product by entering the “uninstall product key” extension:
slmgr.vbs /upk
2.) Install the key that you obtained above for “Windows Srv 2012R2 DataCtr/Std KMS for Windows 10”
@aitoroses
aitoroses / Free.re
Created August 18, 2022 15:01
Free Monads in ReasonML
module type Functor = {
type t('a);
let map: (t('a), 'a => 'b) => t('b);
};
module type Monad = {
type t('a);
let return: 'a => t('a);
let flatMap: (t('a), 'a => t('b)) => t('b);
@aitoroses
aitoroses / di-in-fp.md
Created May 13, 2022 15:14 — forked from gvolpe/di-in-fp.md
Dependency Injection in Functional Programming

Dependency Injection in Functional Programming

There exist several DI frameworks / libraries in the Scala ecosystem. But the more functional code you write the more you'll realize there's no need to use any of them.

A few of the most claimed benefits are the following:

  • Dependency Injection.
  • Life cycle management.
  • Dependency graph rewriting.
@aitoroses
aitoroses / AppM.purs
Created April 12, 2022 08:30
Purescript Example: Application Monad (AppM) with parallelization
type Env
= { hello :: String }
newtype AppM a
= AppM (ReaderT Env Aff a)
runAppM ∷ Env → AppM ~> Aff
runAppM env (AppM m) = runReaderT m env
@aitoroses
aitoroses / background.js
Created April 4, 2022 08:41 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
module Main where
import Prelude
import Control.Monad.Reader (Reader, runReader, ReaderT(..), runReaderT, ask, class MonadAsk)
import Effect (Effect)
import Effect.Class (class MonadEffect, liftEffect)
import Effect.Console (log)
---------------------------------------------------------
@aitoroses
aitoroses / AsyncEx.fs
Created March 14, 2021 20:15 — forked from panesofglass/AsyncEx.fs
Create an Observable from an F# Async.
module AsyncEx
open System
type Async<'a> with
member this.ToObservable() =
{ new IObservable<_> with
member x.Subscribe(o) =
if o = null then nullArg "observer"
let cts = new System.Threading.CancellationTokenSource()
let invoked = ref 0
@aitoroses
aitoroses / ReaderM.fs
Created February 27, 2021 11:56 — forked from CarstenKoenig/ReaderM.fs
Reader monad in F#
namespace ReaderM
type ReaderM<'d,'out> =
'd -> 'out
module Reader =
// basic operations
let run dep (rm : ReaderM<_,_>) =
@aitoroses
aitoroses / JerseyFileUpload.java
Created January 25, 2016 09:42
Jersey Upload & Download Examples
package com.javacodegeeks.enterprise.rest.jersey;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
@aitoroses
aitoroses / GADT.re
Created June 23, 2020 08:46
Using GADT's to parametrize functions
module Arg = {
type arg(_) =
| Arg(argument('a)): arg('a)
and argument('a) =
| Scalar({
name: option(string),
description: option(string),
validator: 'a => bool,
})
and arglist(_, _) =